Ejemplo n.º 1
0
        /// <summary>
        /// Put gold to the current trade
        /// </summary>
        /// <param name="player"></param>
        /// <param name="e"></param>
        private static void PutGold(IPlayerEntity player, TradePutGoldEventArgs e)
        {
            Logger.Debug("PutGold");

            if (IsNotTrading(player))
            {
                throw new RhisisSystemException($"No trade target {player.Object.Name}");
            }

            var target = GetEntityFromContextOf(player, player.Trade.TargetId);

            if (IsNotTrading(target))
            {
                CancelTrade(player);
                throw new RhisisSystemException($"Target is not trading {target.Object.Name}");
            }

            if (IsNotTradeState(player, TradeComponent.TradeState.Item) ||
                IsNotTradeState(target, TradeComponent.TradeState.Item))
            {
                throw new RhisisSystemException($"Not the right trade state {player.Object.Name}");
            }

            player.PlayerData.Gold -= e.Gold;
            player.Trade.Gold      += e.Gold;

            WorldPacketFactory.SendTradePutGold(player, player.Id, player.Trade.Gold);
            WorldPacketFactory.SendTradePutGold(target, player.Id, player.Trade.Gold);
        }
Ejemplo n.º 2
0
        public static void OnTradePutGold(WorldClient client, INetPacketStream packet)
        {
            var tradePacket = new TradePutGoldPacket(packet);
            var tradeEvent  = new TradePutGoldEventArgs(tradePacket.Gold);

            client.Player.NotifySystem <TradeSystem>(tradeEvent);
        }