Exemplo n.º 1
0
        public ActionResult Stage2()
        {
            if (GetGameStage() != GameStage.FirstDone)
            {
                return(RedirectToAction("Stage1"));
            }

            var playerId          = Request.Cookies.Get("PlayerId").Value;
            var playerGuid        = new Guid(playerId);
            var einsteinsPuzzleId = db.Players.First(x => x.UniqueId == playerGuid).EinsteinsPuzzleId;
            var einsteins         = db.EinteinsPuzzles.First(x => x.Id == einsteinsPuzzleId);
            var puzzleSet         = db.EinteinsPuzzles.Where(x => x.PuzzleId == einsteins.PuzzleId).ToList();

            var stage = new Stage2Model()
            {
                UserId   = new Guid(playerId),
                TaskText = GetTaskTwoText(puzzleSet),
            };

            return(View(stage));
        }
Exemplo n.º 2
0
        public ActionResult Stage2([Bind(Include = "Answer")] Stage2Model stage)
        {
            //This done nothing
            if (stage == null)
            {
                return(View(stage));
            }
            var playerId   = Request.Cookies.Get("PlayerId").Value;
            var playerGuid = new Guid(playerId);
            var player     = db.Players.First(x => x.UniqueId == playerGuid);

            if (player.EinteinsAnswer.ToString() == stage.Answer)
            {
                player.GameStage = GameStage.SecondDone;
            }
            else
            {
                player.GameStage = GameStage.Lost;
            }
            db.SaveChanges();

            return(RedirectToAction("Stage3"));
        }