Example #1
0
        /// <summary>
        /// Join a game
        /// </summary>
        /// <param name="gameID">The id of the game to join</param>
        /// <param name="user">The current user</param>
        /// <param name="passphrase">The passphrase for the game</param>
        /// <param name="playerType">Type of player joining</param>
        /// <returns>The response to a join request</returns>
        public Entities.JoinResponse Execute(Int32 gameID, Entities.User user, String passphrase,
                                             Entities.Enums.GamePlayerType playerType)
        {
            Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select();
            filter.GameID        = gameID;
            filter.DataToSelect |= Entities.Enums.Game.Select.Rounds;
            filter.DataToSelect |= Entities.Enums.Game.Select.GamePlayerCards;

            Entities.Game game = _selectGame.Execute(filter);

            Entities.JoinResponse response = _joinGame.Execute(game, user, passphrase, playerType);

            if (response.Game != null)
            {
                if (response.Game.IsWaiting() &&
                    response.Result.HasFlag(Entities.Enums.Game.JoinResponseCode.SuccessfulAlreadyPlayer) == false)
                {
                    _sendMessage.UpdateWaiting(response.Game, true);
                }
                else if (response.Result.HasFlag(Entities.Enums.Game.JoinResponseCode.NewRoundStart) == true)
                {
                    _sendMessage.UpdateGame(response.Game, true);
                }
                else
                {
                    _sendMessage.UpdateLobby(response.Game, true);
                }
            }

            return(response);
        }
Example #2
0
        /// <summary>
        /// Validate the passhrase policy
        /// </summary>
        /// <param name="gameID">The gameID for the game containing the policy</param>
        /// <param name="passphrase">The user supplied passphrase</param>
        /// <returns>Returns if the passphrase policy was validated</returns>
        public bool Execute(Int32 gameID, String passphrase)
        {
            Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select();
            filter.GameID = gameID;

            Entities.Game game = _selectGame.Execute(filter);

            return(_validatePassphrase.Execute(game, passphrase));
        }
Example #3
0
        /// <summary>
        /// Starts a game if certain requirements are met
        /// </summary>
        /// <param name="gameID">The ID for the game to start</param>
        /// <param name="commander">The commander for the first round</param>
        /// <returns>The started game</returns>
        public Entities.Game Execute(Int32 gameID, Entities.User commander)
        {
            Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select();
            filter.GameID       = gameID;
            filter.DataToSelect = Entities.Enums.Game.Select.GamePlayerCards;

            Entities.Game game = _selectGame.Execute(filter);

            Entities.GamePlayer host = game.Players.First();

            if (game.IsCurrentCommander(commander.UserId))
            {
                Boolean successful = _startRound.Execute(game, commander);

                if (successful)
                {
                    _sendMessage.UpdateGame(game, true);
                }
            }

            return(game);
        }