Ejemplo n.º 1
0
        void OnJoinGameRequest(ClientToServerMessage message)
        {
            JoinGameRequest request = message.JoinGameRequest;

            if (request == null)
            {
                throw new ServerClientException("Invalid join game 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);
            bool    success = Server.OnJoinGameRequest(this, request, out _Game);

            if (success)
            {
                _PlayerState = new PanzerKontrol.PlayerState(Game, faction, PlayerIdentifier.Player2);
                InGameState(PlayerStateType.DeployingUnits, ClientToServerMessageType.InitialDeployment);
            }
            else
            {
                ServerToClientMessage reply = new ServerToClientMessage(ServerToClientMessageType.NoSuchGame);
                QueueMessage(reply);
            }
            Game.OnOpponentFound(this);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 public ClientToServerMessage(JoinGameRequest request)
 {
     Type            = ClientToServerMessageType.JoinGameRequest;
     JoinGameRequest = request;
 }