Exemplo n.º 1
0
        /// <summary>
        /// Let the given player join the game with the given name.
        /// </summary>
        /// <param name="name">
        /// The name of the game that the player wishes to join.
        /// </param>
        /// <param name="player">
        /// The player that sent the Join command.
        /// </param>
        /// <returns>
        /// True if he joined the game, false otherwise.
        /// </returns>
        public bool Join(string name, IClient player)
        {
            Player      myPlayer = connector.GetPlayer(player);
            ISearchGame game     = connector.GetGame(name);

            // if the player isn't a part of an existing game and the game allows a player to join
            if (ReferenceEquals(null, connector.GetGame(myPlayer)) && game.CanAPlayerJoin())
            {
                connector.AddClientToGame(myPlayer, name);
                return(game.AddPlayer(myPlayer));
            } /*else if (!ReferenceEquals(null,connector.GetGame(myPlayer))) {
               * player.SendResponse(@"Deleted game named: " + connector.GetGame(myPlayer).Name
               + " to generate game: " + name);
               + connector.DeleteGame(connector.GetGame(myPlayer));
               + connector.AddClientToGame(myPlayer, name);
               + return game.AddPlayer(myPlayer);
               + }*/
            return(false);
        }