public ActionResult Update(string letter) { // Use the word that was just created MysteryWord playerWord = MysteryWord.FindRandom(MysteryWord.randomId); bool duplicate = playerWord.AlreadyGuessed(letter); if (duplicate) { Console.WriteLine("Already guessed this letter. Try a different letter."); } else { playerWord.AddLetter(letter); bool isMatch = playerWord.CheckLetter(); if (isMatch) { bool win = playerWord.Win(); } else { playerWord.Score++; } bool lose = playerWord.isGameOver(); if (lose) { Console.WriteLine("You lose"); } } return(View(playerWord)); }
public ActionResult Update(string letter) { // Use the word that was just created MysteryWord playerWord = MysteryWord.Find(1); bool duplicate = playerWord.AlreadyGuessed(letter); if (duplicate) { ViewBag.Message = string.Format("Hello {0}.\\nCurrent Date and Time: {1}", letter, DateTime.Now.ToString()); Console.WriteLine("Already guessed this letter. Try a different letter."); } else { playerWord.AddLetter(letter); bool isMatch = playerWord.CheckLetter(); if (isMatch) { bool win = playerWord.Win(); // For all blanks that are that letter, fill them in } else { playerWord.Score++; } bool lose = playerWord.isGameOver(); if (lose) { Console.WriteLine("You lose"); } } return(View(playerWord)); }