Example #1
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View ["create_tamo.cshtml"]);
            };
            Post["/tamo_list"] = _ => {
                // List<Tamagotchi> zombitamo = new List <string,object>();
                Tamagotchi        myownTamo = new Tamagotchi(Request.Form["create"]);
                List <Tamagotchi> TamoList  = Tamagotchi.GetAll();


                // if (myownTamo.Zombigochi()) {
                //   Tamagotchi myownTamo = new Tamagotchi (myownTamo);
                //   zombitamo.Add("ResultingTamo", myownTamo);
                // }
                return(View["tamo_list.cshtml", TamoList]);
            };

            Post["/new_tamo_list"] = _ => {
                Tamagotchi newTamo = new Tamagotchi(Request.Form["John"]);
                newTamo.Feed();
                List <Tamagotchi> TamoList = Tamagotchi.GetAll();
                return(View["tamo_list.cshtml", newTamo]);
            };
        }
        public ActionResult Feed(int id)
        {
            Tamagotchi newTamagotchi = Tamagotchi.Find(id);

            newTamagotchi.Feed();
            return(View("Details", newTamagotchi));
        }
Example #3
0
        public ActionResult Feed(int id)
        {
            Tamagotchi myPet = Tamagotchi.Find(id);

            myPet.Feed(myPet.GetFood() + 1);
            return(View("Show", myPet));
        }
Example #4
0
        public void ExampleOfUse()
        {
            // Dragon is born and it is a baby
            var dragon = new Tamagotchi("Needy dragon");

            var needForFood    = new FoodNeeds();
            var needForPetting = new PettingNeeds();

            dragon.AddNeed(needForFood);
            dragon.AddNeed(needForPetting);

            // TimePassed could be called each hour (or something like that) to age the pet
            dragon.TimePassed();
            dragon.TimePassed();
            dragon.TimePassed();

            // At this point it is 3 years old, very unhappy and hungry
            dragon.Age.ShouldBe(3);
            dragon.Happiness.ShouldBe(-45);
            dragon.Hungriness.ShouldBe(24);

            // Let's feed it first
            dragon.Feed();
            dragon.Feed();
            dragon.Hungriness.ShouldBe(8); // It is less hungy now

            // Let's give it some attention
            dragon.Pet();
            dragon.Pet();
            dragon.Happiness.ShouldBe(-15); // It is less unhappy now

            // At this point we could add a new need. For example the need for a diet (Implemented bellow)
            dragon.AddNeed(new DietNeeds());

            dragon.Weight.ShouldBe(7);

            // 50 years passed
            for (int i = 0; i < 50; i++)
            {
                dragon.TimePassed();
            }

            dragon.Age.ShouldBe(53);
            dragon.Weight.ShouldBe(107);
        }
Example #5
0
        public void BeMoreFullnessAndHaveLessStarvingWhenWeFeedHim()
        {
            var tamagotchi = new Tamagotchi();

            var needs = tamagotchi.Feed();

            needs.Fullness.Should().BeGreaterThan(10);
            needs.Hungriness.Should().BeLessThan(10);
        }