예제 #1
0
        public ActionResult NightInstruction(NightFormModel model)
        {
            var theGame = Game.GetGame(model.GameId);

            if (theGame.CurrentTurn().NightComplete ||
                theGame.CurrentTurn().Id != model.TurnId)
            {
                return(Content("Turn already complete! Did you use the back button in your browser??"));
            }
            else
            {
                theGame.ProcessNightInstruction(model);
                return(Content(null));
            }
        }
예제 #2
0
        public ActionResult GetActions(string gameId, string pid)
        {
            var theGame = Game.GetGame(gameId);
            var player  = theGame.GetPlayer(pid);

            if (player.IsDead)
            {
                return(Content("You have been staked.  But don't worry, as a ghost, you can observe everything that goes on.... [coming soon]"));
            }

            if (!theGame.CurrentTurn().NightComplete)
            {
                if (player.IsInJail)
                {
                    return(Content("It is night time.  You are in protective custody (i.e. jail).  At least you can't get bitten."));
                }
                else
                {
                    var model = new NightFormModel()
                    {
                        GameId       = gameId,
                        ActorId      = player.Id,
                        OtherPlayers = theGame.MobilePlayers.Exclude(pid).ToSelectList(),
                        IsVampire    = player.IsVampire,
                        TurnId       = theGame.CurrentTurn().Id
                    };
                    return(PartialView("_NightActions", model));
                }
            }
            else if (!theGame.CurrentTurn().DayComplete)
            {
                var model = new DayFormModel()
                {
                    GameId       = gameId,
                    ActorId      = player.Id,
                    OtherPlayers = theGame.MobilePlayers.Exclude(pid).ToSelectList(),
                    AllPlayers   = theGame.MobilePlayers.ToSelectList(),
                    TurnId       = theGame.CurrentTurn().Id
                };

                return(PartialView("_DayActions", model));
            }
            else
            {
                return(Content("Turn already complete. Something has gone wrong."));
            }
        }