private static void AddAI(GameServer Server) { string name = null; GameRoom room = RoomManager.CreateOrGetGame(GameConfigBuilder.Build("")); if (room == null && room.Config != null) { name = RoomManager.RandomRoomName(); } else { name = room.Config.Name; } if (AddAI(Server.Config, "" + name)) { Console.WriteLine(">>add ai to " + name); } else { Console.WriteLine(">>add ai fail"); } }
public static void OnJoinGame(GameSession client, GameClientPacket packet) { if (string.IsNullOrEmpty(client.Name) || client.Type != (int)PlayerType.Undefined) { Logger.Debug("join room fail:" + client.Name); return; } int version = packet.ReadInt16(); if (version < Program.Config.ClientVersion) { client.LobbyError(Messages.ERR_LOW_VERSION); return; } else if (version > Program.Config.ClientVersion) { client.ServerMessage(Messages.MSG_HIGH_VERSION); } int gameid = packet.ReadInt32(); //gameid packet.ReadInt16(); string joinCommand = packet.ReadUnicode(60); GameRoom room = null; //IsAuthentified = CheckAuth(); if (!client.IsAuthentified) { client.LobbyError(Messages.ERR_AUTH_FAIL); return; } if (!RoomManager.CheckRoomPassword(joinCommand)) { client.LobbyError(Messages.ERR_PASSWORD); return; } GameConfig config = GameConfigBuilder.Build(joinCommand); room = RoomManager.CreateOrGetGame(config); if (room == null) { client.LobbyError(Messages.MSG_FULL); return; } if (!room.IsOpen) { client.LobbyError(Messages.MSG_GAMEOVER); return; } if (room != null && room.Config != null) { if (room.Config.NoCheckDeck) { client.ServerMessage(Messages.MSG_NOCHECKDECK); } if (room.Config.NoShuffleDeck) { client.ServerMessage(Messages.MSG_NOSHUFFLEDECK); } if (room.Config.EnablePriority) { client.ServerMessage(Messages.MSG_ENABLE_PROIORITY); } } client.Game = room; lock (room.AsyncRoot) { room.AddPlayer(client); } }