public IActionResult Process(string dachi_action)
        {
            System.Console.WriteLine("-----------------------------------------------------------------------------------");
            System.Console.WriteLine($"The form submitted was from {dachi_action}!");
            TempData["form_action"] = $"The form submitted was from {dachi_action}!";
            Dachi DachiOne = HttpContext.Session.GetObjectFromJson <Dachi>("Dachi");

            DachiOne.UpdateDachi(dachi_action);

            // If energy, fullness, and happiness are all raised to over 100, you win! a restart button should be displayed.
            if (DachiOne.Happiness > 100 && DachiOne.Fullness > 100 && DachiOne.Energy > 100)
            {
                // we won
                HttpContext.Session.SetString("Result", "True");
            }
            // If fullness or happiness ever drop to 0, you lose, and a restart button should be displayed.
            else if (DachiOne.Fullness < 0 || DachiOne.Fullness < 0)
            {
                // we lost
                HttpContext.Session.SetString("Result", "False");
            }

            HttpContext.Session.SetObjectAsJson("Dachi", DachiOne);
            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public IActionResult Reset()
        {
            Dachi DojoDachi = GetDachiFromSession();

            DojoDachi.Reset();
            HttpContext.Session.SetString("dachi", JsonConvert.SerializeObject(DojoDachi));
            return(View("Index", DojoDachi));
        }
Exemple #3
0
        public IActionResult Index()
        {
            Dachi DojoDachi = new Dachi();

            HttpContext.Session.SetString("dachi", JsonConvert.SerializeObject(DojoDachi));

            return(View(DojoDachi));
        }
        public IActionResult SleepRedirect()
        {
            Dachi dachi = HttpContext.Session.GetObjectFromJson <Dachi>("Dachi");

            ViewBag.msg = dachi.Sleep();
            HttpContext.Session.SetObjectAsJson("Dachi", dachi);
            return(RedirectToAction("Index"));
        }
        public IActionResult FeedRedirect()
        {
            Dachi dachi = HttpContext.Session.GetObjectFromJson <Dachi>("Dachi");

            ViewBag.msg = dachi.Feed();
            Console.WriteLine(ViewBag.msg);
            HttpContext.Session.SetObjectAsJson("Dachi", dachi);
            return(RedirectToAction("Index"));
        }
Exemple #6
0
        private Dachi GetDachiFromSession()
        {
            Dachi DojoDachi = new Dachi();

            if (HttpContext.Session.GetString("dachi") != null)
            {
                string dachiStr = HttpContext.Session.GetString("dachi");
                DojoDachi = JsonConvert.DeserializeObject <Dachi>(dachiStr);
            }
            return(DojoDachi);
        }
Exemple #7
0
        public JsonResult AjaxCall(string cmd)
        {
            Dachi DojoDachi = GetDachiFromSession();

            switch (cmd)
            {
            case "feed":  DojoDachi.Feed();   break;

            case "play":  DojoDachi.Play();   break;

            case "work":  DojoDachi.Work();   break;

            case "sleep":  DojoDachi.Sleep();   break;

            default: DojoDachi.Reset(); break;
            }
            HttpContext.Session.SetString("dachi", JsonConvert.SerializeObject(DojoDachi));
            return(Json(DojoDachi));
        }
Exemple #8
0
        public IActionResult Index()
        {
            int?   ful = HttpContext.Session.GetInt32("Fullness");
            int?   hap = HttpContext.Session.GetInt32("Happiness");
            int?   ene = HttpContext.Session.GetInt32("Energy");
            int?   mea = HttpContext.Session.GetInt32("Meals");
            string mes = HttpContext.Session.GetString("Message");

            if (ful <= 0 || hap <= 0)
            {
                mes = $"Your Dojodachi has passed away.";
                Dachi update = new Dachi((int)ful, (int)hap, (int)ene, (int)mea, mes);
                return(View("Index", update));
            }
            else if (ful >= 100 && hap >= 100 && ene >= 100)
            {
                mes = "Congratulations! You won!";
                Dachi update = new Dachi((int)ful, (int)hap, (int)ene, (int)mea, mes);
                return(View("Index", update));
            }

            else if (ful != null)
            {
                Dachi update = new Dachi((int)ful, (int)hap, (int)ene, (int)mea, mes);
                return(View("Index", update));
            }

            else
            {
                Dachi first = new Dachi();
                HttpContext.Session.SetInt32("Fullness", first.Fullness);
                HttpContext.Session.SetInt32("Happiness", first.Happiness);
                HttpContext.Session.SetInt32("Energy", first.Energy);
                HttpContext.Session.SetInt32("Meals", first.Meals);
                HttpContext.Session.SetString("Message", first.Message);

                return(View("Index", first));
            }
        }
        public IActionResult Index()
        {
            if (HttpContext.Session.GetInt32("Count") == null)
            {
                Dachi Adrien = new Dachi();
                // Adrien.Stats();
                HttpContext.Session.SetInt32("Count", 1);
                HttpContext.Session.SetInt32("Happiness", (int)Adrien.Happiness);
                HttpContext.Session.SetInt32("Fullness", (int)Adrien.Fullness);
                HttpContext.Session.SetInt32("Energy", (int)Adrien.Energy);
                HttpContext.Session.SetInt32("Meals", (int)Adrien.Meals);
                HttpContext.Session.SetString("Standing", "Welcome to DojoDachi!!! Please begin by selecting from the bellow and try not to kill your Dachi... Thanks");
            }
            else
            {
                int?count = HttpContext.Session.GetInt32("Count");
                count++;
                HttpContext.Session.SetInt32("Count", (int)count);
            }
            if (HttpContext.Session.GetInt32("Happiness") <= 0 || HttpContext.Session.GetInt32("Fullness") <= 0)
            {
                HttpContext.Session.SetString("Standing", "Yo Dachi Dead, What did you do?!?!?!");
            }
            else if (HttpContext.Session.GetInt32("Energy") >= 100 || HttpContext.Session.GetInt32("Fullness") >= 100 || HttpContext.Session.GetInt32("Happiness") >= 100)
            {
                HttpContext.Session.SetString("Standing", "YOU WIN!! Could you watch my dog this weekend?");
            }
// els)e if yo Dachi dead what did you do?
//If fullness or happiness ever drop to 0, you lose, and a restart button should be displayed.
// If energy, fullness, and happiness are all raised to over 100, you win! a restart button should be displayed.
            ViewBag.Count     = HttpContext.Session.GetInt32("Count");
            ViewBag.Happiness = HttpContext.Session.GetInt32("Happiness");
            ViewBag.Fullness  = HttpContext.Session.GetInt32("Fullness");
            ViewBag.Energy    = HttpContext.Session.GetInt32("Energy");
            ViewBag.Meals     = HttpContext.Session.GetInt32("Meals");
            ViewBag.Standing  = HttpContext.Session.GetString("Standing");
            return(View());
        }
        public IActionResult Index()
        {
            Dachi DachiOne;

            if (HttpContext.Session.GetObjectFromJson <Dachi>("Dachi") == null)
            {
                // set the dachi in session
                DachiOne = new Dachi();
                HttpContext.Session.SetObjectAsJson("Dachi", DachiOne);
            }
            else
            {
                DachiOne = HttpContext.Session.GetObjectFromJson <Dachi>("Dachi");
            }


            if (TempData["form_action"] != null)
            {
                ViewBag.FormAction = TempData["form_action"];
            }
            string result = HttpContext.Session.GetString("Result");

            // check if we won or lost
            if (result == "True")
            {
                ViewBag.Result = true;
            }
            else if (result == "False")
            {
                ViewBag.Result = false;
            }
            else
            {
                ViewBag.Result = null;
            }
            return(View(DachiOne));
        }