public JsonResult FeedDachi() { Dachi MyDachi = SessionCheck(); MyDachi.Feed(); HttpContext.Session.SetObjectAsJson("MyDachi", MyDachi); return(Json(MyDachi)); }
public IActionResult feed() { Dachi newDachi = HttpContext.Session.GetObjectFromJson <Dachi>("Dachi"); string LocalVariable = HttpContext.Session.GetString("Dachi.Name"); ViewBag.Name = LocalVariable; int CurrentFill = newDachi.Fullness; newDachi.Feed(); int newFill = newDachi.Fullness; if (newFill > CurrentFill) { ViewBag.Result = $"You fed {LocalVariable}! Fullness has gone up by {newFill - CurrentFill} at the cost of 1 meal"; ViewBag.Emote = 0; } else { ViewBag.Result = $"You fed {LocalVariable}! Fullness hasn't gone up at all. {LocalVariable} said he is sick of this diet!"; ViewBag.Emote = 1; } HttpContext.Session.SetObjectAsJson("Dachi", newDachi); return(View("Dachi", newDachi)); }