private void OnSelectSum(GameServerPacket packet) { packet.ReadByte(); // mode packet.ReadByte(); // player int sumval = packet.ReadInt32(); int min = packet.ReadByte(); int max = packet.ReadByte(); IList <ClientCard> cards = new List <ClientCard>(); int 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; } GameClientPacket reply = new GameClientPacket(CtosMessage.Response); reply.Write(result); Connection.Send(reply); }
private void OnSelectSum(BinaryReader packet) { bool mode = packet.ReadByte() == 0; packet.ReadByte(); // player int sumval = packet.ReadInt32(); int min = packet.ReadByte(); int max = packet.ReadByte(); IList <ClientCard> mandatoryCards = new List <ClientCard>(); IList <ClientCard> cards = new List <ClientCard>(); for (int j = 0; j < 2; ++j) { int 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 (cardId != 0 && card.Id != cardId) { card.SetId(cardId); } card.SelectSeq = i; int OpParam = packet.ReadInt32(); int OpParam1 = OpParam & 0xffff; int OpParam2 = OpParam >> 16; if (OpParam2 > 0 && OpParam1 > OpParam2) { card.OpParam1 = OpParam2; card.OpParam2 = OpParam1; } else { card.OpParam1 = OpParam1; card.OpParam2 = OpParam2; } if (j == 0) { mandatoryCards.Add(card); } else { cards.Add(card); } } } for (int k = 0; k < mandatoryCards.Count; ++k) { sumval -= mandatoryCards[k].OpParam1; } IList <ClientCard> selected = _ai.OnSelectSum(cards, sumval, min, max, mode); byte[] result = new byte[mandatoryCards.Count + selected.Count + 1]; int index = 0; result[index++] = (byte)(mandatoryCards.Count + selected.Count); while (index <= mandatoryCards.Count) { result[index++] = 0; } for (int i = 0; i < selected.Count; ++i) { result[index++] = (byte)selected[i].SelectSeq; } BinaryWriter reply = GamePacketFactory.Create(CtosMessage.Response); reply.Write(result); Connection.Send(reply); }
private void OnSelectSum(BinaryReader packet) { packet.ReadByte(); // mode packet.ReadByte(); // player int sumval = packet.ReadInt32(); int min = packet.ReadByte(); int max = packet.ReadByte(); IList <ClientCard> mandatoryCards = new List <ClientCard>(); IList <ClientCard> cards = new List <ClientCard>(); for (int j = 0; j < 2; ++j) { int 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); } } if (j == 0) { mandatoryCards.Add(card); } else { cards.Add(card); } packet.ReadInt32(); } } IList <ClientCard> selected = _ai.OnSelectSum(cards, sumval, min, max); byte[] result = new byte[mandatoryCards.Count + selected.Count + 1]; int index = 0; result[index++] = (byte)(mandatoryCards.Count + selected.Count); while (index < mandatoryCards.Count) { result[index++] = 0; } for (int i = 0; i < selected.Count; ++i) { int id = 0; for (int j = 0; j < cards.Count; ++j) { if (cards[j] == null) { continue; } if (cards[j].Equals(selected[i])) { id = j; break; } } result[index++] = (byte)id; } BinaryWriter reply = GamePacketFactory.Create(CtosMessage.Response); reply.Write(result); Connection.Send(reply); }