public JsonResult PlayDachi() { Dachi MyDachi = SessionCheck(); MyDachi.Play(); HttpContext.Session.SetObjectAsJson("MyDachi", MyDachi); return(Json(MyDachi)); }
public IActionResult Play() { string LocalVariable = HttpContext.Session.GetString("Dachi.Name"); Dachi newDachi = HttpContext.Session.GetObjectFromJson <Dachi>("Dachi"); int CurrentHap = newDachi.Happiness; newDachi.Play(); int newHap = newDachi.Happiness; if (newHap > CurrentHap) { ViewBag.Result = $"You played with {LocalVariable}! Happiness has gone up by {newHap - CurrentHap} at the cost of 5 Energy"; ViewBag.Emote = 2; } else { ViewBag.Result = $"You played with {LocalVariable}! He just wasn't feeling this half-assed 'play' you still lost 5 Energy"; ViewBag.Emote = 3; } HttpContext.Session.SetObjectAsJson("Dachi", newDachi); ViewBag.Name = LocalVariable; return(View("Dachi", newDachi)); }