public JsonResult Feed() { Dojodachi NewDojo = HttpContext.Session.GetObjectFromJson <Dojodachi>("Dojodachi"); NewDojo.Feed(); HttpContext.Session.SetObjectAsJson("Dojodachi", NewDojo); return(Json(NewDojo)); }
public IActionResult Feed() { Chikorita.Feed(); if (Chikorita.isWin() == true) { return(View("Index", Chikorita)); } else if (Chikorita.isLost() == true) { return(View("Index", Chikorita)); } return(View("Index", Chikorita)); }
public IActionResult Action(String act) { if (act == "feed") { TempData["msg"] = dojodachi.Feed(); if (TempData["msg"].ToString().EndsWith(":(")) { TempData["img"] = "/imgs/badfood.png"; } else { TempData["img"] = "/imgs/goodfood.png"; } } else if (act == "play") { TempData["msg"] = dojodachi.Play(); if (TempData["msg"].ToString().EndsWith(":(")) { TempData["img"] = "/imgs/badplay.png"; } else { TempData["img"] = "/imgs/goodplay.png"; } } else if (act == "work") { TempData["img"] = "/imgs/work.png"; TempData["msg"] = dojodachi.Work(); } else if (act == "sleep") { TempData["img"] = "/imgs/sleep.png"; TempData["msg"] = dojodachi.Sleep(); } if (dojodachi.energy <= 0) { TempData["img"] = "/imgs/lose.png"; TempData["msg"] = "Your dojodachi died from lack of energy!"; return(RedirectToAction("EndGame")); } else if (dojodachi.happiness <= 0) { TempData["img"] = "/imgs/lose.png"; TempData["msg"] = "Your dojodachi died from unhappiness!"; return(RedirectToAction("EndGame")); } else if (dojodachi.fullness <= 0) { TempData["img"] = "/imgs/lose.png"; TempData["msg"] = "Your dojodachi died from starvation!"; return(RedirectToAction("EndGame")); } else if (dojodachi.happiness > 99 && dojodachi.energy > 99 && dojodachi.fullness > 99) { TempData["img"] = "/imgs/win.png"; TempData["msg"] = "Your dojodachi loves you. You win forever!"; return(RedirectToAction("EndGame")); } return(RedirectToAction("Index")); }