Example #1
0
        public void OnGameStart(ServerGame game, ServerClient opponent)
        {
            _Opponent = opponent;
            GameStart start = new GameStart(game.GameConfiguration, PlayerState.GetBaseArmy(), Opponent.PlayerState.GetBaseArmy(), Opponent.Name, PlayerState.ReinforcementPoints);

            QueueMessage(new ServerToClientMessage(start));
        }
Example #2
0
        public bool OnJoinGameRequest(ServerClient client, JoinGameRequest request, out ServerGame game)
        {
            if (request.IsPrivate)
            {
                string key = request.PrivateKey;
                if (!PrivateGames.TryGetValue(key, out game))
                {
                    return(false);
                }
                PrivateGames.Remove(key);
            }
            else
            {
                string key = request.Owner;
                if (!PublicGames.TryGetValue(key, out game))
                {
                    return(false);
                }
                PublicGames.Remove(key);
            }

            ActiveGames.Add(game);
            game.StartDeploymentTimer();
            return(true);
        }
Example #3
0
        void CancelGame(ServerClient client)
        {
            ServerGame game = client.Game;

            if (game.IsPrivate)
            {
                PrivateGames.Remove(game.Owner.Name);
            }
            else
            {
                PublicGames.Remove(game.PrivateKey);
            }
        }
Example #4
0
        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());
            }
        }
Example #5
0
 public void OnGameStart(ServerGame game, ServerClient opponent)
 {
     _Opponent = opponent;
     GameStart start = new GameStart(game.GameConfiguration, PlayerState.GetBaseArmy(), Opponent.PlayerState.GetBaseArmy(), Opponent.Name, PlayerState.ReinforcementPoints);
     QueueMessage(new ServerToClientMessage(start));
 }
Example #6
0
        public bool OnJoinGameRequest(ServerClient client, JoinGameRequest request, out ServerGame game)
        {
            if (request.IsPrivate)
            {
                string key = request.PrivateKey;
                if (!PrivateGames.TryGetValue(key, out game))
                    return false;
                PrivateGames.Remove(key);
            }
            else
            {
                string key = request.Owner;
                if (!PublicGames.TryGetValue(key, out game))
                    return false;
                PublicGames.Remove(key);
            }

            ActiveGames.Add(game);
            game.StartDeploymentTimer();
            return true;
        }
Example #7
0
 public void OnGameEnd(ServerGame game, GameOutcomeType outcome, ServerClient winner = null)
 {
     ActiveGames.Remove(game);
     game.EndGame(new GameEndBroadcast(outcome, winner));
 }
Example #8
0
 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();
     }
 }
Example #9
0
 public void OnGameEnd(ServerGame game, GameOutcomeType outcome, ServerClient winner = null)
 {
     ActiveGames.Remove(game);
     game.EndGame(new GameEndBroadcast(outcome, winner));
 }