Beispiel #1
0
        private void OnTradeUpdate(TradeUpdatePacket tup)
        {
            var h = TradeUpdate;

            if (TradeUpdate != null)
            {
                EventHandler.RiseSafely(() => h(tup));
            }
        }
        public void Proper_TradeUpdate_Have_Been_Received_And_Rised()
        {
            var client = new APIClient(moq_connection.Object);

            TradeUpdatePacket sentPacket     = new TradeUpdatePacket(new TradeRecord(), TradeAction.Opened);
            TradeUpdatePacket receivedPacket = null;

            client.TradeUpdate += (tu => receivedPacket = tu);

            moq_connection.Raise(con => con.PacketReceived += null, sentPacket);

            Assert.Equal(sentPacket, receivedPacket);
        }
        //TradeUpdatePacket
        private static void HandlePacket(TradeUpdatePacket packet)
        {
            var side = 0;

            if (packet.TraderId != Globals.Me.Id)
            {
                side = 1;
            }

            var slot = packet.Slot;

            if (packet.ItemId == Guid.Empty)
            {
                Globals.Trade[side, slot] = null;
            }
            else
            {
                Globals.Trade[side, slot] = new Item();
                Globals.Trade[side, slot].Load(packet.ItemId, packet.Quantity, packet.BagId, packet.StatBuffs);
            }
        }