public IActionResult Play() { // Status logic DojodachiModel dojodachi = HttpContext.Session.GetObjectFromJson <DojodachiModel>("DD"); string playResult = dojodachi.play(); HttpContext.Session.SetObjectAsJson("DD", dojodachi); // Result if (playResult == "noEnergy") { HttpContext.Session.SetString("Result", "Michael has no Energy left to play or code..."); } else if (playResult == "fail") { HttpContext.Session.SetString("Result", "Michael didn't like your code..."); } else { HttpContext.Session.SetString("Result", $"You coded with Michael! +{playResult} Happiness, -5 Energy."); } // win/loss condition if (dojodachi.dead()) { HttpContext.Session.SetString("Result", "Michael has moved along..."); HttpContext.Session.SetString("Status", "Over"); } if (dojodachi.gameWon()) { HttpContext.Session.SetString("Result", "Congratulations! You won and Michael is proud of you."); HttpContext.Session.SetString("Status", "Over"); } return(RedirectToAction("Index")); }
public IActionResult Sleep() { // Status logic DojodachiModel dojodachi = HttpContext.Session.GetObjectFromJson <DojodachiModel>("DD"); string sleepResult = dojodachi.sleep(); HttpContext.Session.SetObjectAsJson("DD", dojodachi); // Result HttpContext.Session.SetString("Result", $"Michael had a good nap! +15 Energy, -5 Fullness, -5 Happiness."); // win/loss condition if (dojodachi.dead()) { HttpContext.Session.SetString("Result", "Michael has moved along..."); HttpContext.Session.SetString("Status", "Over"); } if (dojodachi.gameWon()) { HttpContext.Session.SetString("Result", "Congratulations! You won and Michael is proud of you."); HttpContext.Session.SetString("Status", "Over"); } return(RedirectToAction("Index")); }
public IActionResult Work() { // Status logic DojodachiModel dojodachi = HttpContext.Session.GetObjectFromJson <DojodachiModel>("DD"); string workResult = dojodachi.work(); HttpContext.Session.SetObjectAsJson("DD", dojodachi); // Result if (workResult == "noEnergy") { HttpContext.Session.SetString("Result", "Michael has no Energy left to make more videos..."); } else { HttpContext.Session.SetString("Result", $"Michael made another video! +{workResult} Meals, -5 Energy."); } // win/loss condition if (dojodachi.dead()) { HttpContext.Session.SetString("Result", "Michael has moved along..."); HttpContext.Session.SetString("Status", "Over"); } if (dojodachi.gameWon()) { HttpContext.Session.SetString("Result", "Congratulations! You won and Michael is proud of you."); HttpContext.Session.SetString("Status", "Over"); } return(RedirectToAction("Index")); }
public IActionResult Feed() { // Status logic DojodachiModel dojodachi = HttpContext.Session.GetObjectFromJson <DojodachiModel>("DD"); string feedResult = dojodachi.feed(); HttpContext.Session.SetObjectAsJson("DD", dojodachi); // Result if (feedResult == "noMeals") { HttpContext.Session.SetString("Result", "Michael has no Meals left to be fed..."); } else if (feedResult == "fail") { HttpContext.Session.SetString("Result", "Michael didn't like the meal..."); } else { HttpContext.Session.SetString("Result", $"Michael had a good meal! +{feedResult} Fullness, -1 Meal."); } // win/loss condition if (dojodachi.dead()) { HttpContext.Session.SetString("Result", "Michael has moved along..."); HttpContext.Session.SetString("Status", "Over"); } if (dojodachi.gameWon()) { HttpContext.Session.SetString("Result", "Congratulations! You won and Michael is proud of you."); HttpContext.Session.SetString("Status", "Over"); } return(RedirectToAction("Index")); }