private void OnSelectCounter(GameServerPacket packet)
        {
            packet.ReadByte();             // player
            int type     = packet.ReadInt16();
            int quantity = packet.ReadByte();

            IList <ClientCard> cards    = new List <ClientCard>();
            IList <int>        counters = new List <int>();
            int count = packet.ReadByte();

            for (int i = 0; i < count; ++i)
            {
                packet.ReadInt32();                 // card id
                int          player = GetLocalPlayer(packet.ReadByte());
                CardLocation loc    = (CardLocation)packet.ReadByte();
                int          seq    = packet.ReadByte();
                int          num    = packet.ReadByte();
                cards.Add(_duel.GetCard(player, loc, seq));
                counters.Add(num);
            }

            IList <int> used = _ai.OnSelectCounter(type, quantity, cards, counters);

            byte[] result = new byte[used.Count];
            for (int i = 0; i < quantity; ++i)
            {
                result[i] = (byte)used[i];
            }
            GameClientPacket reply = new GameClientPacket(CtosMessage.Response);

            reply.Write(result);
            Connection.Send(reply);
        }
Exemple #2
0
        private void OnSelectCounter(BinaryReader packet)
        {
            packet.ReadByte(); // player
            int type     = packet.ReadInt16();
            int quantity = packet.ReadInt16();

            IList <ClientCard> cards    = new List <ClientCard>();
            IList <int>        counters = new List <int>();
            int count = packet.ReadByte();

            for (int i = 0; i < count; ++i)
            {
                packet.ReadInt32(); // card id
                int          player = GetLocalPlayer(packet.ReadByte());
                CardLocation loc    = (CardLocation)packet.ReadByte();
                int          seq    = packet.ReadByte();
                int          num    = packet.ReadInt16();
                cards.Add(_duel.GetCard(player, loc, seq));
                counters.Add(num);
            }

            IList <int> used = _ai.OnSelectCounter(type, quantity, cards, counters);

            byte[] result = new byte[used.Count * 2];
            for (int i = 0; i < used.Count; ++i)
            {
                result[i * 2]     = (byte)(used[i] & 0xff);
                result[i * 2 + 1] = (byte)(used[i] >> 8);
            }
            BinaryWriter reply = GamePacketFactory.Create(CtosMessage.Response);

            reply.Write(result);
            Connection.Send(reply);
        }