예제 #1
0
        public JsonResult Work()
        {
            Dachi dachi = HttpContext.Session.GetObjectFromJson <Dachi>("Dachi");

            dachi.work();
            HttpContext.Session.SetObjectAsJson("Dachi", dachi);
            return(Json(dachi));
        }
예제 #2
0
        public IActionResult Work()
        {
            List <Dachi> ret   = HttpContext.Session.GetObjectFromJson <List <Dachi> >("dachi");
            Dachi        dachi = (Dachi)ret[0];

            TempData["response"] = dachi.work();
            List <object> dachilist = new List <object>();

            dachilist.Add(dachi);
            HttpContext.Session.SetObjectAsJson("dachi", dachilist);
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public IActionResult Work()
        {
            Dachi CurrDachiData = HttpContext.Session.GetObjectFromJson <Dachi>("DachiData");

            if (CurrDachiData.energy > 0)
            {
                CurrDachiData.work();
            }
            else
            {
                CurrDachiData.status = "No Energy... your Dachi cannot work.";
            }
            HttpContext.Session.SetObjectAsJson("DachiData", CurrDachiData);
            return(RedirectToAction("Index"));
        }
예제 #4
0
        public IActionResult Work()
        {
            Dachi DachiInfo = HttpContext.Session.GetObjectFromJson <Dachi>("DachiInfo");

            if (DachiInfo.energy >= 5)
            {
                DachiInfo.work();
            }
            else
            {
                DachiInfo.status = "Your dachi is too tired to work. It must sleep to gain energy.";
            }
            HttpContext.Session.SetObjectAsJson("DachiInfo", DachiInfo);
            return(RedirectToAction("Index"));
        }
예제 #5
0
파일: dojo.cs 프로젝트: rycaylor/dotNET
        public IActionResult dachi(string button)
        {
            Dachi meep = HttpContext.Session.GetObjectFromJson <Dachi>("dachi");

            if (button == "Feed")
            {
                meep.feed(meep);
                List <string> check = meep.status(meep);
                if (check.Contains("fine"))
                {
                    HttpContext.Session.SetObjectAsJson("dachi", meep);
                    return(RedirectToAction("page"));
                }
                else if (check.Contains("win"))
                {
                    return(View("win"));
                }
                else if (check.Contains("dead"))
                {
                    return(View("dead"));
                }
            }
            else if (button == "Play")
            {
                meep.play(meep);
                List <string> check = meep.status(meep);
                if (check.Contains("fine"))
                {
                    HttpContext.Session.SetObjectAsJson("dachi", meep);
                    return(RedirectToAction("page"));
                }
                else if (check.Contains("win"))
                {
                    return(View("win"));
                }
                else if (check.Contains("dead"))
                {
                    return(View("dead"));
                }
            }
            else if (button == "Work")
            {
                meep.work(meep);
                List <string> check = meep.status(meep);
                if (check.Contains("fine"))
                {
                    HttpContext.Session.SetObjectAsJson("dachi", meep);
                    return(RedirectToAction("page"));
                }
                else if (check.Contains("win"))
                {
                    return(View("win"));
                }
                else if (check.Contains("dead"))
                {
                    return(View("dead"));
                }
            }
            else if (button == "Sleep")
            {
                meep.sleep(meep);
                List <string> check = meep.status(meep);
                if (check.Contains("fine"))
                {
                    HttpContext.Session.SetObjectAsJson("dachi", meep);
                    return(RedirectToAction("page"));
                }
                else if (check.Contains("win"))
                {
                    return(View("win"));
                }
                else if (check.Contains("dead"))
                {
                    return(View("dead"));
                }
            }

            return(View("index"));
        }