Ejemplo n.º 1
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;
        }