private void OnSelectSum(GamePacketReader packet) { packet.ReadByte(); // mode packet.ReadByte(); // player int sumval = packet.ReadInt32(); int min = packet.ReadByte(); int max = packet.ReadByte(); // TODO mandatory cards int count = packet.ReadByte(); packet.ReadBytes(count * 11); IList<ClientCard> cards = new List<ClientCard>(); count = packet.ReadByte(); for (int i = 0; i < count; ++i) { int cardId = packet.ReadInt32(); int player = GetLocalPlayer(packet.ReadByte()); CardLocation loc = (CardLocation)packet.ReadByte(); int seq = packet.ReadByte(); ClientCard card = _duel.GetCard(player, loc, seq); if (card != null) { if (cardId != 0 && card.Id != cardId) card.SetId(cardId); cards.Add(card); } packet.ReadInt32(); } IList<ClientCard> selected = _ai.OnSelectSum(cards, sumval, min, max); byte[] result = new byte[selected.Count + 1]; result[0] = (byte)selected.Count; for (int i = 0; i < selected.Count; ++i) { int id = 0; for (int j = 0; j < count; ++j) { if (cards[j] == null) continue; if (cards[j].Equals(selected[i])) { id = j; break; } } result[i + 1] = (byte)id; } GamePacketWriter reply = new GamePacketWriter(CtosMessage.Response); reply.Write(result); Connection.Send(reply); }