void OnCreateGameRequest(ClientToServerMessage message) { CreateGameRequest request = message.CreateGameRequest; if (request == null) { throw new ServerClientException("Invalid game creation request"); } // Defaults to false so lazy/afk players lose the first turn privilege _RequestedFirstTurn = false; InitialiseArmy(request.Army); Faction faction = Server.GetFaction(request.Army.FactionId); CreateGameReply reply = Server.OnCreateGameRequest(this, request, out _Game); QueueMessage(new ServerToClientMessage(reply)); _PlayerState = new PanzerKontrol.PlayerState(Game, faction, PlayerIdentifier.Player1); WaitingForOpponentState(); }
public CreateGameReply OnCreateGameRequest(ServerClient client, CreateGameRequest request, out ServerGame game) { Map map = GetMap(request.GameConfiguration.Map); if (map == null) { throw new ServerClientException("No such map"); } ValidateGameConfiguration(request.GameConfiguration); if (request.IsPrivate) { string privateKey = GeneratePrivateKey(); game = new ServerGame(this, client, true, privateKey, request.GameConfiguration, map); PrivateGames[privateKey] = game; return(new CreateGameReply(privateKey)); } else { game = new ServerGame(this, client, false, null, request.GameConfiguration, map); PublicGames[client.Name] = game; return(new CreateGameReply()); } }
public ClientToServerMessage(CreateGameRequest request) { Type = ClientToServerMessageType.CreateGameRequest; CreateGameRequest = request; }