private void OnStart(GameServerPacket packet) { int type = packet.ReadByte(); m_duel.IsFirst = (type & 0xF) == 0; m_duel.LifePoints[GetLocalPlayer(0)] = packet.ReadInt32(); m_duel.LifePoints[GetLocalPlayer(1)] = packet.ReadInt32(); int deck = packet.ReadInt16(); int extra = packet.ReadInt16(); m_duel.Fields[GetLocalPlayer(0)].Init(deck, extra); deck = packet.ReadInt16(); extra = packet.ReadInt16(); m_duel.Fields[GetLocalPlayer(1)].Init(deck, extra); if (!Game.IsCheckmate && m_room.Names[0] != Program.Config.Username && m_room.Names[1] != Program.Config.Username) { Connection.Close(); return; } Logger.WriteLine("Duel started! " + m_room.Names[0] + " versus " + m_room.Names[1] + "."); m_ai.OnStart(); if (Game.IsCheckmate) { Game.CheckmateClient.OnStart(); } }
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); }
private void OnChat(GameServerPacket packet) { packet.ReadInt16(); // player string msg = packet.ReadUnicode(256); // message Console.WriteLine("Message:" + msg); }
private void OnStart(GameServerPacket packet) { int type = packet.ReadByte(); _duel.IsFirst = (type & 0xF) == 0; _duel.LifePoints[GetLocalPlayer(0)] = packet.ReadInt32(); _duel.LifePoints[GetLocalPlayer(1)] = packet.ReadInt32(); int deck = packet.ReadInt16(); int extra = packet.ReadInt16(); _duel.Fields[GetLocalPlayer(0)].Init(deck, extra); deck = packet.ReadInt16(); extra = packet.ReadInt16(); _duel.Fields[GetLocalPlayer(1)].Init(deck, extra); Logger.WriteLine("Duel started: " + _room.Names[0] + " versus " + _room.Names[1]); _ai.OnStart(); }
private void OnChat(GameServerPacket packet) { packet.ReadInt16(); // player packet.ReadUnicode(256); // message }