Esempio n. 1
0
        public ActionResult Index(Guesser gb)
        {
            //gb = GameData
            string correctGuess = "";

            //Put the posted guess in a temp var.
            int newGuess = gb.Guess;

            //Load the previous session
            gb       = (Guesser)HttpContext.Session["GameData"];
            gb.Guess = newGuess;

            ViewBag.GameMessage = gb.checkGuess();

            if (gb.isCorrect)
            {
                correctGuess = "Correct; new Roll";
                gb.isCorrect = false;
            }
            else
            {
                gb.Counter++;
            }

            ViewBag.HighScore = Load.HighScore(gb, HttpContext.Session);

            if (Load.newHighScore)
            {
                ViewBag.NewHigh = "New Highscore!!";
            }

            ViewBag.Counter = gb.Counter;
            ViewBag.Score   = gb.Score;

            gb.Log.Add(gb.Guess.ToString() + " : " + correctGuess);

            return(View(gb));
        }