public IActionResult Feed() { // Every time you feed your dojodachi there's a 25% chance that it won't like it. // Meals will still decrease, but happiness won't change. Dachi dachi = this.SessionDachi; // Get Dachi instance from session dachi.Fullness += _rand.Next(5, 11); // Gains random fullness between 5 and 10 int luck = _rand.Next(0, 4); if (luck > 0) { if (dachi.Meals > 0) { dachi.Meals--; // Feeding your Dojodachi costs 1 meal TempData["Message"] = "You fed your Dojodachi. Your Dojodachi is fuller!"; } else if (dachi.Meals <= 0) // you cannot feed your Dojodachi if you do not have meals { TempData["Message"] = "!! You cannot feed your Dojodachi! There are no more meals!!"; } } this.SessionDachi = dachi; // Store modified instance back in session return(RedirectToAction("Index")); }
public JsonResult ResetDachi() { HttpContext.Session.Clear(); Dachi MyDachi = SessionCheck(); return(Json(MyDachi)); }
public IActionResult Process(string Activity) { Dachi curDachi = HttpContext.Session.GetObjectFromJson <Dachi>("dachi"); if (Activity == "Feed") { curDachi.feed(); System.Console.WriteLine("Hello"); } else if (Activity == "Work") { curDachi.work(); } else if (Activity == "Play") { curDachi.play(); } else if (Activity == "Sleep") { curDachi.sleep(); } HttpContext.Session.SetObjectAsJson("dachi", curDachi); // ViewBag.dachi = curDachi; return(RedirectToAction("Index")); }
public JsonResult SleepDachi() { Dachi MyDachi = SessionCheck(); MyDachi.Sleep(); HttpContext.Session.SetObjectAsJson("MyDachi", MyDachi); return(Json(MyDachi)); }
public IActionResult Result(string name) { Dachi pet = new Dachi(name); List <Dachi> Pet = new List <Dachi>(); Pet.Add(pet); HttpContext.Session.SetObjectAsJson("Character", Pet); return(RedirectToAction("Pet")); }
public IActionResult Dachi() { Dachi newDachi = HttpContext.Session.GetObjectFromJson <Dachi>("Dachi"); string LocalVariable = HttpContext.Session.GetString("Dachi.Name"); ViewBag.Name = LocalVariable; ViewBag.Dachi = newDachi; return(View()); }
public IActionResult Feed() { Dachi DachiCurrent = HttpContext.Session.GetObjectFromJson <Dachi>("DachiNew"); if (DachiCurrent.meals > 0) { DachiCurrent.feed(); } HttpContext.Session.SetObjectAsJson("DachiNew", DachiCurrent); return(RedirectToAction("Index")); }
private Dachi SessionCheck() { Dachi MyDachi = HttpContext.Session.GetObjectFromJson <Dachi>("MyDachi"); if (MyDachi == null) { MyDachi = new Dachi(); HttpContext.Session.SetObjectAsJson("MyDachi", MyDachi); } return(MyDachi); }
public IActionResult Work() { Dachi dachi = this.SessionDachi; // Get Dachi instance from session dachi.Energy -= 5; // Working costs 5 energy dachi.Meals += _rand.Next(1, 4); // Earns between 1 and 3 meals this.SessionDachi = dachi; // Store modified instance back in session TempData["Message"] = "Your Dojodachi worked hard and needs some rest!"; return(RedirectToAction("Index")); }
public IActionResult Sleep() { Dachi newDachi = HttpContext.Session.GetObjectFromJson <Dachi>("Dachi"); newDachi.Sleep(); HttpContext.Session.SetObjectAsJson("Dachi", newDachi); string LocalVariable = HttpContext.Session.GetString("Dachi.Name"); ViewBag.Name = LocalVariable; ViewBag.Result = $"Your Diondachi {LocalVariable} is taking a nap"; ViewBag.Emote = 5; return(View("Dachi", newDachi)); }
public IActionResult Sleep() { GameState state = GetGameStatus(); Dachi dachi = this.SessionDachi; // Get Dachi instance from session dachi.Energy += 15; // sleeping earns 15 energy dachi.Fullness -= 5; // decreases fullness by 5 dachi.Happiness -= 5; // decreases happiness by 5 this.SessionDachi = dachi; // Store modified instance back in session TempData["Message"] = "Your Dojodachi caught some zzs and is well rested!"; return(RedirectToAction("Index")); }
public IActionResult Create(string name) { HttpContext.Session.SetString("Dachi.Name", name); string LocalVariable = HttpContext.Session.GetString("Dachi.Name"); Console.WriteLine(LocalVariable); Dachi newDachi = new Dachi(); HttpContext.Session.SetObjectAsJson("Dachi", newDachi); ViewBag.Name = LocalVariable; ViewBag.Dachi = newDachi; return(View("Dachi", newDachi)); }
public IActionResult Work() { Dachi newDachi = HttpContext.Session.GetObjectFromJson <Dachi>("Dachi"); int CurrentMeal = newDachi.Meals; newDachi.Work(); int newMeal = newDachi.Meals; HttpContext.Session.SetObjectAsJson("Dachi", newDachi); string LocalVariable = HttpContext.Session.GetString("Dachi.Name"); ViewBag.Name = LocalVariable; ViewBag.Result = $"Your Diondachi {LocalVariable} goes to work and recieved {newMeal - CurrentMeal} meals."; ViewBag.Emote = 4; return(View("Dachi", newDachi)); }
public IActionResult Index() { Dachi dachi = this.SessionDachi; GameState state = GetGameStatus(); if (state == GameState.Lose) { ViewBag.Message = ":( This is so sad. Your Dojodachi is no more. You Lose!"; } else if (state == GameState.Win) { ViewBag.Message = "Congratulations! You WON!"; } ViewBag.State = state; return(View(dachi)); }
public GameState GetGameStatus() { Dachi dachi = this.SessionDachi; // If fullness or happiness ever drop to 0, you lose, // and a restart button should be displayed. if (dachi.Fullness <= 0 || dachi.Happiness <= 0) { return(GameState.Lose); } // If energy, fullness, and happiness are all raised to over 100, you win! // a restart button should be displayed. else if (dachi.Energy > 100 && dachi.Fullness > 100 && dachi.Happiness > 100) { return(GameState.Win); } return(GameState.Playing); }
public IActionResult Play() { // Every time you play with your dojodachi there's a 25% chance that it won't like it. // Energy will still decrease, but happiness won't change. Dachi dachi = this.SessionDachi; // Get Dachi instance from session dachi.Energy -= 5; // Costs 5 energy int luck = _rand.Next(0, 4); if (luck > 0) // there's a 25% chance that it won't like it and happiness won't change { dachi.Happiness += _rand.Next(5, 11); // Gains random happiness between 5 and 10 } this.SessionDachi = dachi; // Store modified instance back in session TempData["Message"] = "You played with your Dojodachi. Your Dojodachi is happier!"; return(RedirectToAction("Index")); }
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)); }
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)); }
public HomeController() { _dachi = new Dachi("Bobbert"); }
public void CanSeeDachiName() { Dachi bob = _hc._dachi; Assert.True(bob.name == "Bobbert", "The name isnt wright!!!!!!!"); }
public JsonResult RetrieveDachi() { Dachi MyDachi = SessionCheck(); return(Json(MyDachi)); }