Exemplo n.º 1
0
        public IActionResult Feed()
        {
            DojoDachi editDachi = GetDachi();

            if (editDachi.Meals > 0)
            {
                editDachi.Meals--;
                if (rand.Next(0, 4) > 0)
                {
                    editDachi.Fullness += rand.Next(5, 11);
                    ViewBag.Reaction    = ":)";
                    ViewBag.Message     = "Your Dachi Enjoyed that meal!";
                }
                else
                {
                    ViewBag.Reaction = ":(";
                    ViewBag.Message  = "Your Dachi didn't like that meal very much...";
                }
            }
            else
            {
                ViewBag.Reaction = ":(";
                ViewBag.Message  = "You Don't have any food for your Dachi.";
            }
            SetDachi(editDachi);
            return(View("Index"));
        }
Exemplo n.º 2
0
        public IActionResult Play()
        {
            DojoDachi editDachi = GetDachi();

            if (editDachi.Energy > 4)
            {
                editDachi.Energy--;
                if (rand.Next(0, 4) > 0)
                {
                    editDachi.Happiness += rand.Next(5, 11);
                    ViewBag.Reaction     = ":)";
                    ViewBag.Message      = "Your Dachi had fun playing!";
                }
                else
                {
                    ViewBag.Reaction = ":(";
                    ViewBag.Message  = "Your Dachi didn't want to play...";
                }
            }
            else
            {
                ViewBag.Reaction = ":(";
                ViewBag.Message  = "You Don't have enough energy.";
            }
            SetDachi(editDachi);
            return(View("Index"));
        }
Exemplo n.º 3
0
 public void SetDachi(DojoDachi dachi)
 {
     HttpContext.Session.SetObjectAsJson("DojoDachi", dachi);
     ViewBag.DojoDachi = dachi;
     ViewBag.Status    = "running";
     CheckForDeath(dachi);
 }
Exemplo n.º 4
0
        public IActionResult Sleep()
        {
            DojoDachi d = HttpContext.Session.GetObjectFromJson <DojoDachi>("Dojodachi");

            d.Sleep();
            HttpContext.Session.SetObjectAsJson("Dojodachi", d);
            return(Redirect("/"));
        }
Exemplo n.º 5
0
        public IActionResult DojoDachiAction()
        {
            DojoDachi.EndGameConditions();
            var myDachi = new dojoDachi_Instance();

            //myDachi.initial = false;
            return(View(myDachi));
        }
Exemplo n.º 6
0
        public DojoDachi GetDachi()
        {
            if (HttpContext.Session.GetObjectFromJson <DojoDachi>("DojoDachi") == null)
            {
                SetDachi(new DojoDachi());
            }
            DojoDachi editDachi = HttpContext.Session.GetObjectFromJson <DojoDachi>("DojoDachi");

            return(editDachi);
        }
Exemplo n.º 7
0
        public IActionResult Sleep()
        {
            DojoDachi editDachi = GetDachi();

            editDachi.Energy    += 15;
            editDachi.Fullness  -= 5;
            editDachi.Happiness -= 5;
            ViewBag.Reaction     = ":)";
            ViewBag.Message      = "Your Dachi seems well rested";
            SetDachi(editDachi);
            return(View("Index"));
        }
Exemplo n.º 8
0
 public void CheckForDeath(DojoDachi editDachi)
 {
     if (editDachi.Fullness < 1 || editDachi.Happiness < 1)
     {
         ViewBag.Reaction = "X(";
         ViewBag.Message  = "Oh no! Your Dachi has Died...";
         ViewBag.Status   = "over";
     }
     else if (editDachi.Fullness > 99 && editDachi.Happiness > 99)
     {
         ViewBag.Reaction = ":D";
         ViewBag.Message  = "Congratulations! You Win!";
         ViewBag.Status   = "over";
     }
 }
Exemplo n.º 9
0
        public IActionResult Index()
        {
            if (HttpContext.Session.GetObjectFromJson <DojoDachi>("Dojodachi") == null)
            {
                DojoDachi newDachi = new DojoDachi();
                HttpContext.Session.SetObjectAsJson("Dojodachi", newDachi);
            }

            DojoDachi d = HttpContext.Session.GetObjectFromJson <DojoDachi>("Dojodachi");

            if (!d.Continue())
            {
                d.winOrLose();
            }

            return(View("Index", d));
        }
Exemplo n.º 10
0
        public IActionResult Work()
        {
            DojoDachi editDachi = GetDachi();

            if (editDachi.Energy > 4)
            {
                editDachi.Energy -= 5;
                editDachi.Meals  += rand.Next(1, 4);
                ViewBag.Reaction  = ":)";
                ViewBag.Message   = "You worked hard to feed your Dachi";
            }
            else
            {
                ViewBag.Reaction = ":(";
                ViewBag.Message  = "Not enough energy.";
            }
            SetDachi(editDachi);
            return(View("Index"));
        }
Exemplo n.º 11
0
        public IActionResult Index()
        {
            if (HttpContext.Session.Get("dojodachi") == null)
            {
                DojoDachi a = new DojoDachi();
                HttpContext.Session.Set("dojodachi", ObjectToByteArray(a));
            }
            DojoDachi b = (DojoDachi)ByteArrayToObject(HttpContext.Session.Get("dojodachi"));

            if (b.Fullness <= 0 || b.Happines <= 0)
            {
                b.Alive = false;
                b.History.Add("Dojodachi is depressed!");
            }
            if (b.Fullness > 100 && b.Energy > 100 && b.Happines > 100)
            {
                b.Win = true;
                b.History.Add("Dojodachi is joyful! ");
            }
            return(View(b));
        }
Exemplo n.º 12
0
 public IActionResult SleepMe()
 {
     DojoDachi.Sleep();
     return(RedirectToAction("DojoDachiAction"));
 }
Exemplo n.º 13
0
 public IActionResult WorkeMe()
 {
     DojoDachi.Work();
     return(RedirectToAction("DojoDachiAction"));
 }
Exemplo n.º 14
0
 public IActionResult PlayMe()
 {
     DojoDachi.Play();
     //myDachi.Play();
     return(RedirectToAction("DojoDachiAction"));
 }
Exemplo n.º 15
0
 public IActionResult ResetMe()
 {
     DojoDachi.reset();
     return(RedirectToAction("DojoDachiAction"));
 }
Exemplo n.º 16
0
        public IActionResult Index(string act)
        {
            System.Console.WriteLine("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
            System.Console.WriteLine(act);
            Random    Rand = new Random();
            DojoDachi a    = (DojoDachi)ByteArrayToObject(HttpContext.Session.Get("dojodachi"));

            if (act == "Feed")
            {
                if (a.Meals > 0)
                {
                    a.Meals--;
                    int temp    = Rand.Next(5, 11);
                    int dislike = Rand.Next(1, 5);
                    if (dislike == 4)
                    {
                        a.History.Add($"Dojodachi doesn't like your food");
                    }
                    else
                    {
                        a.Fullness += temp;
                        a.History.Add($"Dojodachi ate 1 meal and gain {temp} fullness");
                    }
                }
                else
                {
                    a.History.Add($"You have no more meal. Go to work and earn some!");
                }
            }
            else if (act == "Play")
            {
                if (a.Energy >= 5)
                {
                    a.Energy -= 5;
                    int temp    = Rand.Next(5, 11);
                    int dislike = Rand.Next(1, 5);
                    if (dislike == 4)
                    {
                        a.History.Add($"Dojodachi doesn't like to play with you");
                    }
                    else
                    {
                        a.Happines += temp;
                        a.History.Add($"Dojodachi played with you and gain {temp} points happiness");
                    }
                }
                else
                {
                    a.History.Add("No More Energy! Eat something or Sleep to retore engery!");
                }
            }
            else if (act == "Work")
            {
                if (a.Energy >= 5)
                {
                    a.Energy -= 5;
                    int temp = Rand.Next(1, 4);
                    a.Meals += temp;
                    a.History.Add($"Dojodachi went to work and earned {temp} meal(s)");
                }
                else
                {
                    a.History.Add("No More Energy! Eat something or Sleep to retore engery!");
                }
            }
            else if (act == "Sleep")
            {
                a.Fullness -= 5;
                a.Happines -= 5;
                a.Energy   += 15;
                a.History.Add("Dojodachi took a nap and restored 15 energy points, lost 5 points in both fullness and happines");
            }
            HttpContext.Session.Set("dojodachi", ObjectToByteArray(a));
            return(Redirect("/dojodachi"));
        }
Exemplo n.º 17
0
 public IActionResult FeedMe()
 {
     DojoDachi.Feed();
     return(RedirectToAction("DojoDachiAction"));
 }