public HomeModule() { Get["/"] = _ => { Game.ChooseWord(); Game.ResetEverything(); Game newGame = new Game(); return(View["index.cshtml", newGame]); }; Post["/"] = _ => { string userGuess = Request.Form["user-guess"]; userGuess = userGuess.ToLower(); if (!Game.GetGameWin() && !Game.GetGameLose()) { if (Game.GetSetWord().Contains(userGuess)) { Game.SetCurrentGuess(userGuess); Game.AddGoodGuess(userGuess); } else { Game.AddBadGuess(userGuess); Game.IncreaseGuess(); } } Game.CheckGuess(); Game.CheckWin(); Game newGame = new Game(); return(View["index.cshtml", newGame]); }; }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Post["/Game"] = _ => { string input = Request.Form["new-answer"]; Game newGame = new Game(input); Game.SetGameList(newGame); return(View["gameScreen.cshtml", newGame]); }; Post["/Guessed"] = _ => { string guess = Request.Form["guess"]; List <Game> gameList = new List <Game>(); gameList = Game.GetGameList(); Game currentGame = gameList[0]; currentGame.LetterChecker(guess); Game.SetGameList(currentGame); return(View["gameScreen.cshtml", currentGame]); }; Post["/Answer"] = _ => { string wordGuess = Request.Form["word-guess"]; List <Game> gameList = new List <Game>(); gameList = Game.GetGameList(); Game currentGame = gameList[0]; if (currentGame.CheckWin(wordGuess)) { return(View["win.cshtml"]); } else { currentGame.SetTries(currentGame.GetTries()); Game.SetGameList(currentGame); return(View["gameScreen.cshtml", currentGame]); } }; }