Пример #1
0
        /// <summary>
        /// Starts a round if certain requirements are met
        /// </summary>
        /// <param name="game">The game to start a new round for</param>
        /// <param name="commander">The new round's commander</param>
        /// <returns>If a round was successfully started</returns>
        public Boolean Execute(Entities.Game game, Entities.User commander)
        {
            Boolean successful = false;

            //Check to make sure game still has required number of players
            if (game.HasRequiredNumberOfPlayers())
            {
                //Check to make sure the game has not been ended.
                if (game.GameOver.HasValue == false && !game.HasWinner())
                {
                    Entities.GameRound round = _insertGameRound.Execute(game.GameID, commander);

                    successful = round.GameRoundID > 0;

                    if (successful)
                    {
                        game.Rounds.Add(round);

                        game.RoundCount++;

                        //Deal Cards
                        _dealCards.Execute(game);
                    }
                }
            }

            return(successful);
        }
Пример #2
0
        public static String Build(Entities.Game game, Int32 currentUserId, Entities.Enums.GamePlayerType playerType)
        {
            String waitingOnPlayers   = "{0} is waiting for {1} more {2}...";
            String commanderStartGame = "{0} can be started. {1}";
            String waitingOnHost      = "{0} waiting on commander to start game...";

            String headerText = String.Empty;

            if (game.HasRequiredNumberOfPlayers() == false)
            {
                Int32 shortNumberOfPlayers = game.NumberOfPlayersNeededToStart();

                headerText = string.Format(waitingOnPlayers,
                                           game.Title,
                                           shortNumberOfPlayers.ToString(),
                                           shortNumberOfPlayers == 1 ? "player" : "players");
            }
            else
            {
                if (game.IsCurrentCommander(currentUserId) && playerType == Entities.Enums.GamePlayerType.Player)
                {
                    TagBuilder startGame = new TagBuilder("a");
                    startGame.AddCssClass("button");
                    startGame.AddCssClass("startGameButton");
                    startGame.InnerHtml = "Start";
                    startGame.Attributes.Add("style", "font-size: .8em; cursor: pointer;");

                    headerText = string.Format(commanderStartGame, game.Title, startGame.ToString());
                }
                else
                {
                    headerText = string.Format(waitingOnHost, game.Title);
                }
            }

            return(headerText);
        }