Example #1
0
        public static List <string> getTamagotchiInformation(Tamagotchi tamagotchi)
        {
            if (tamagotchi == null)
            {
                return(null);
            }
            else
            {
                List <string> returnStrings = new List <string>();

                returnStrings.Add("Name:    " + tamagotchi.name);
                returnStrings.Add("Hunger:  " + tamagotchi.hunger);
                returnStrings.Add("Sleep:   " + tamagotchi.sleep);
                returnStrings.Add("Boredom: " + tamagotchi.boredom);
                returnStrings.Add("Health:  " + (100 - tamagotchi.health) + "%");
                if (tamagotchi.status.getBezig() == true)
                {
                    returnStrings.Add(tamagotchi.name + " is momenteel zeer actief bezig.");
                }
                else
                {
                    returnStrings.Add(tamagotchi.name + " is momenteel aan het uitrusten.");
                }

                return(returnStrings);
            }
        }
Example #2
0
        public void Tamagotchi_Dead_DoNothing()
        {
            var rules = new Rule[]
            {
                new AthleticRule(),
                new BordedomRule(),
                new CrazinessRule(),
                new FatigueRule(),
                new HungerRule(),
                new IsolationRule(),
                new MuchiesRule(),
                new SleepDeprivationRule(),
                new StarvationRule()
            };

            rules = rules.OrderBy(r => r.Order).ToArray();

            Tamagotchi t1 = new Tamagotchi("test", rules);

            t1.HasDied = true;

            var now = DateTime.UtcNow + TimeSpan.FromHours(2);

            Assert.IsFalse(t1.EatAction(now));
            Assert.IsFalse(t1.RefreshRules(now));

            Assert.AreNotEqual(t1.LastAllRulesPassedUtc, now);
        }
Example #3
0
        public void Tamagotchi_StatusDead()
        {
            Tamagotchi t1 = new Tamagotchi(90, 100, 70, 100, DateTime.UtcNow, TimeSpan.Zero);
            t1.HasDied = true;

            Assert.AreEqual("Dead", t1.Status);
        }
Example #4
0
        public void Tamagotchi_Rule_TwentyFiveHours()
        {
            var rules = new Rule[]
            {
                new AthleticRule(),
                new BordedomRule(),
                new CrazinessRule(),
                new FatigueRule(),
                new HungerRule(),
                new IsolationRule(),
                new MuchiesRule(),
                new SleepDeprivationRule(),
                new StarvationRule()
            };

            rules = rules.OrderBy(r => r.Order).ToArray();

            var now = DateTime.UtcNow;
            Tamagotchi t1 = new Tamagotchi("test", rules);

            var inTheFuture = now + TimeSpan.FromHours(25);
            t1.RefreshRules(inTheFuture);

            Assert.AreEqual(100, t1.Sleep);
            Assert.AreEqual(100, t1.Boredom);
            Assert.AreEqual(100, t1.Health);
            Assert.AreEqual(100, t1.Hunger);

            Assert.IsTrue(t1.HasDied);

            Assert.AreEqual(t1.LastAllRulesPassedUtc, inTheFuture);
        }
Example #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Tamagotchi tamagotchi = _tamagotchiRepository.Get(id);

            _tamagotchiRepository.Delete(tamagotchi);
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteLife(int id)
        {
            Tamagotchi.ClearLife(id);
            List <Tamagotchi> allTamagotchis = Tamagotchi.GetAll();

            return(View("Delete", allTamagotchis));
        }
Example #7
0
        public void BeLessFullnessWhenWeMakePoop()
        {
            var tamagotchi = new Tamagotchi();

            var needs = tamagotchi.MakeAPoop();

            needs.Fullness.Should().BeLessThan(10);
        }
Example #8
0
        public void BeLessTiredWhenWePuttingInBed()
        {
            var tamagotchi = new Tamagotchi();

            var needs = tamagotchi.Sleep();

            needs.Tiredness.Should().BeLessThan(10);
        }
Example #9
0
 public string UpdateCurrentStatus(Tamagotchi tamagotchi)
 {
     if (tamagotchi?.Statuses?.Count > 0)
     {
         return($"{tamagotchi.Name} is currently:\r\n{string.Join("\r\n", tamagotchi.Statuses)}");
     }
     return(string.Empty);
 }
Example #10
0
        public void Tamagotchi_Sleep_MinMax()
        {
            Tamagotchi t1 = new Tamagotchi(-20, -20, -20, -20, DateTime.UtcNow, TimeSpan.Zero);
            Tamagotchi t2 = new Tamagotchi(120, 120, 120, 120, DateTime.UtcNow, TimeSpan.Zero);

            Assert.AreEqual(0, t1.Sleep);
            Assert.AreEqual(100, t2.Sleep);
        }
        public DetailWindow(String tamagotchiName)
        {
            InitializeComponent();
            prep       = new setupClass();
            tamagotchi = prep.getByName(tamagotchiName);

            this.refresh();
        }
Example #12
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string name = Interaction.InputBox("Tamagotchi", "Geef je Tamagotchi een naam!", "Default", 0, 0);

            tamagotchi = new Tamagotchi(name);
            tamagotchi.LevensstadiumChangedEvent += Tamagotchi_LevensstadiumChangedEvent;;
            LoadForm();
        }
Example #13
0
        public void TamagotchiAction_HugDoNothingInCooldown()
        {
            var dateTime = new DateTime(1994, 1, 5, 10, 10, 10);
            Tamagotchi t = new Tamagotchi(10, 10, 10, 10, dateTime, new TimeSpan(1));

            Assert.IsFalse(t.HugAction(dateTime));
            Assert.AreEqual(10, t.Health);
        }
Example #14
0
        public ActionResult Create()
        {
            Tamagotchi newTamagotchi = new Tamagotchi();

            newTamagotchi.SetName(Request.Form["new-name"]);
            newTamagotchi.Save();
            return(View("Index", newTamagotchi));
        }
        public ActionResult Create()
        {
            Tamagotchi newTamagotchi = new Tamagotchi(Request.Form["new-tamagotchi"]);

            List <Tamagotchi> allTamagotchies = Tamagotchi.GetAll();

            return(View("Index", allTamagotchies));
        }
Example #16
0
 public void Add(Tamagotchi tama)
 {
     tama.Alive  = true;
     tama.Health = 100;
     tama.Money  = 100;
     _tamagotchiEntities.Tamagotchi.Add(tama);
     _tamagotchiEntities.SaveChanges();
 }
Example #17
0
        public void TamagotchiAction_PlayDoNothingInCooldown()
        {
            var dateTime = new DateTime(1994, 1, 5, 10, 10, 10);
            Tamagotchi t = new Tamagotchi(10, 10, 10, 10, dateTime, new TimeSpan(1));

            Assert.IsFalse(t.PlayAction(dateTime));
            Assert.AreEqual(10, t.Boredom);
        }
Example #18
0
 public ActionResult FastForward()
 {
     foreach (Tamagotchi tamagotchi in Tamagotchi.GetAll())
     {
         tamagotchi.PassTime(15);
     }
     return(Redirect("/"));
 }
Example #19
0
        public void TamagotchiAction_SleepValue()
        {
            Tamagotchi t = new Tamagotchi(0, 0, 0, 10, new DateTime(1994, 1, 5, 10, 10, 10), TimeSpan.Zero);

            t.SleepAction(new DateTime(1994, 1, 5, 10, 10, 10));

            Assert.AreEqual(0, t.Sleep);
        }
Example #20
0
        public ActionResult Play(int id)
        {
            Tamagotchi tama = Tamagotchi.GetById(id);

            Console.Write('1');
            tama.PlayTama();
            return(View("Details", tama));
        }
        public ActionResult Time(int id)
        {
            List <Tamagotchi> allToys = Tamagotchi.GetAll();
            int find = id - 1;

            allToys[find].SimTime();
            return(View("ShowID", allToys[find]));
        }
        public ActionResult Create()
        {
            string            name           = Request.Form["name"];
            Tamagotchi        tama           = new Tamagotchi(name);
            List <Tamagotchi> allTamagotchis = Tamagotchi.GetAll();

            return(View("../Home/Index", allTamagotchis));
        }
        public void GetName_ReturnsName_String()
        {
            string     name          = "Daniel";
            Tamagotchi newTamagotchi = new Tamagotchi(name);
            string     result        = newTamagotchi.Name;

            Assert.AreEqual(name, result);
        }
Example #24
0
        public void TamagotchiAction_EatValue()
        {
            Tamagotchi t = new Tamagotchi(0, 0, 10, 0, new DateTime(1994, 1, 5, 10, 10, 10), TimeSpan.Zero);

            t.EatAction(new DateTime(1994, 1, 5, 10, 10, 10));

            Assert.AreEqual(0, t.Hunger);
        }
Example #25
0
        public void TamagotchiAction_PlayValue()
        {
            Tamagotchi t = new Tamagotchi(20, 0, 0, 0, new DateTime(1994, 1, 5, 10, 10, 10), TimeSpan.Zero);

            t.PlayAction(new DateTime(1994, 1, 5, 10, 10, 10));

            Assert.AreEqual(10, t.Boredom);
        }
        public ActionResult DeleteTama(int id)
        {
            Tamagotchi newTama         = Tamagotchi.Find(id);
            string     tamaToBeDeleted = newTama.name;

            Tamagotchi.Delete(newTama);
            return(View("Delete", tamaToBeDeleted));
        }
Example #27
0
 public TamagotchiRule(Tamagotchi tama, Rule rule)
     : this()
 {
     #pragma warning disable RECS0021 // Warns about calls to virtual member functions occuring in the constructor
     Tamagotchi = tama;
     Rule = rule;
     #pragma warning restore RECS0021 // Warns about calls to virtual member functions occuring in the constructor
 }
Example #28
0
        public void Update(Tamagotchi model)
        {
            Tamagotchi tamagotchi = _tamagotchis.Find(t => t.ID == model.ID);

            tamagotchi.Health = model.Health;
            tamagotchi.Name   = model.Name;
            tamagotchi.Level  = model.Level;
        }
Example #29
0
        public void Tamagotchi_StatusDead()
        {
            Tamagotchi t1 = new Tamagotchi(90, 100, 70, 100, DateTime.UtcNow, TimeSpan.Zero);

            t1.HasDied = true;

            Assert.AreEqual("Dead", t1.Status);
        }
Example #30
0
        public void TamagotchiAction_EatValue()
        {
            Tamagotchi t = new Tamagotchi(0, 0, 10, 0, new DateTime(1994, 1, 5, 10, 10, 10), TimeSpan.Zero);

            t.EatAction(new DateTime(1994, 1, 5, 10, 10, 10));

            Assert.AreEqual(0, t.Hunger);
        }
Example #31
0
        public void TamagotchiAction_PlayValue()
        {
            Tamagotchi t = new Tamagotchi(20, 0, 0, 0, new DateTime(1994, 1, 5, 10, 10, 10), TimeSpan.Zero);

            t.PlayAction(new DateTime(1994, 1, 5, 10, 10, 10));

            Assert.AreEqual(10, t.Boredom);
        }
Example #32
0
        public void TamagotchiAction_HugValue()
        {
            Tamagotchi t = new Tamagotchi(0, 20, 0, 0, new DateTime(1994, 1, 5, 10, 10, 10), TimeSpan.Zero);

            t.HugAction(new DateTime(1994, 1, 5, 10, 10, 10));

            Assert.AreEqual(10, t.Health);
        }
Example #33
0
        public void TamagotchiAction_SleepValue()
        {
            Tamagotchi t = new Tamagotchi(0, 0, 0, 10, new DateTime(1994, 1, 5, 10, 10, 10), TimeSpan.Zero);

            t.SleepAction(new DateTime(1994, 1, 5, 10, 10, 10));

            Assert.AreEqual(0, t.Sleep);
        }
Example #34
0
        public ActionResult Create(string newName)
        {
            // Tamagotchi newPet = new Tamagotchi(Request.Form["newName"]);
            // List<Tamagotchi> allTamagotchi = Tamagotchi.GetAll();
            Tamagotchi newPet = new Tamagotchi(newName);

            return(RedirectToAction("TamagotchiList"));
        }
Example #35
0
 public virtual int ExcecuteInstructie(Tamagotchi tamagotchi)
 {
     if (checkCrazy(tamagotchi))
     {
         return(1);
     }
     return(0);
 }
Example #36
0
        public void TamagotchiAction_WorkoutValue()
        {
            Tamagotchi t = new Tamagotchi(0, 20, 0, 0, new DateTime(1994, 1, 5, 10, 10, 10), TimeSpan.Zero);

            t.WorkoutAction(new DateTime(1994, 1, 5, 10, 10, 10));

            Assert.AreEqual(15, t.Health);
        }
Example #37
0
        public void Tamagotchi_Sleep_MinMax()
        {
            Tamagotchi t1 = new Tamagotchi(-20, -20, -20, -20, DateTime.UtcNow, TimeSpan.Zero);
            Tamagotchi t2 = new Tamagotchi(120, 120, 120, 120, DateTime.UtcNow, TimeSpan.Zero);

            Assert.AreEqual(0, t1.Sleep);
            Assert.AreEqual(100, t2.Sleep);
        }
Example #38
0
        public void TamagotchiAction_SleepDoNothingInCooldown()
        {
            var        dateTime = new DateTime(1994, 1, 5, 10, 10, 10);
            Tamagotchi t        = new Tamagotchi(10, 10, 10, 10, dateTime, new TimeSpan(1));

            Assert.IsFalse(t.SleepAction(dateTime));
            Assert.AreEqual(10, t.Sleep);
        }
Example #39
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            if (tama.Boredom > 80)
                tama.HasMunchies = true;
            else
                tama.HasMunchies = false;

            return true;
        }
Example #40
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            if (tama.Health < HealthThreshold)
                tama.IsAthletic = true;
            else
                tama.IsAthletic = false;

            return true;
        }
        public void AddOrUpdate(Tamagotchi tamagotchi)
        {
            if (FindById(tamagotchi.Id) != null)
            {
                _tamagotchis.Remove(_tamagotchis.First(t => t.Id == tamagotchi.Id));
            }

            _tamagotchis.Add(tamagotchi);
        }
Example #42
0
 public override int ExcecuteInstructie(Tamagotchi tamagotchi)
 {
     if (base.ExcecuteInstructie(tamagotchi) == 1)
     {
         return(0);
     }
     tamagotchi.hunger = 0;
     return(30);
 }
Example #43
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            if (tama.Health == HealthThreshold)
                tama.IsCrazy = true;
            else
                tama.IsCrazy = false;

            return true;
        }
        public void Tamagotchiadd(object sender, EventArgs e)
        {
            var        UserLogged          = Session["Auth"];
            string     NomeTamagotchi      = nomePet.Text;
            string     PersonagemEscolhido = personagem.Text;
            Tamagotchi t = new Tamagotchi().CreateTamagotchi(UserLogged.ToString(), NomeTamagotchi, PersonagemEscolhido, 0);

            Page_Load(sender, e);
        }
Example #45
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            if (tama.Sleep == SleepThreshold && !tama.IsAthletic)
                tama.HasDied = true;
            else
                tama.HasDied = false;

            return true;
        }
Example #46
0
        public void TamagotchiAction_PlayValue()
        {
            var dateTime = new DateTime(1994, 1, 5, 10, 10, 10);
            Tamagotchi t = new Tamagotchi(20, 0, 0, 0, DateTime.MinValue, TimeSpan.Zero);

            Assert.IsTrue(t.PlayAction(dateTime));

            Assert.AreEqual(dateTime, t.LastAccessedOnUtc);
            Assert.AreEqual(new TimeSpan(0, 0, 30), t.CoolDown);
            Assert.IsTrue(t.IsInCoolDown(dateTime + new TimeSpan(0, 0, 10)));
        }
Example #47
0
        public void Tamagotchi_NoRules_DoNothing()
        {
            Tamagotchi t1 = new Tamagotchi(0,0,0,0, DateTime.UtcNow, TimeSpan.Zero);

            t1.RefreshRules(DateTime.UtcNow);

            Assert.AreEqual(0, t1.Sleep);
            Assert.AreEqual(0, t1.Boredom);
            Assert.AreEqual(0, t1.Health);
            Assert.AreEqual(0, t1.Hunger);
        }
Example #48
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            var timeSpan = now - tama.LastAllRulesPassedUtc;

            if (timeSpan >= oneHour)
            {
                tama.Sleep += DeltaSleep * (int)timeSpan.TotalHours;
                return true;
            }

            return false;
        }
Example #49
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            var timeSpan = now - tama.LastAllRulesPassedUtc;

            if (timeSpan >= oneHour)
            {
                int delta = DeltaHunger;

                if (tama.HasMunchies)
                    delta *= 2;

                tama.Hunger += delta * (int)timeSpan.TotalHours;

                return true;
            }

            return false;
        }
Example #50
0
        public HomeModule()
        {
            Get["/"]=_=>View["index.cshtml"];
              Get["/create"]=_=>View["create_a_tamagotchi.cshtml"];
              Post["/birth_form"] = _ => {
            Tamagotchi newTamagotchi = new Tamagotchi(Request.Form["new-name"]);
            return View["tamagotchi.cshtml", newTamagotchi];
              };
              Get["{tamagotchiName}passtime"] = parameters => {
            Tamagotchi tamagotchi = Tamagotchi.Find(parameters.tamagotchiName);
            tamagotchi.ActOnTamgagotchi("passtime");
            if(tamagotchi.GetHunger()<=0 || tamagotchi.GetHappiness()<=0 || tamagotchi.GetSleepiness()<=0)
            {
              return View["/dead_tamagotchi.cshtml"];
            }
            else
            {
              return View["/tamagotchi.cshtml", tamagotchi];
            }
              };

              Get["{tamagotchiName}sleep"] = parameters => {
            Tamagotchi tamagotchi = Tamagotchi.Find(parameters.tamagotchiName);
            tamagotchi.ActOnTamgagotchi("sleep");
            return View["/tamagotchi.cshtml", tamagotchi];
              };
              Get["{tamagotchiName}feed"] = parameters => {
            Tamagotchi tamagotchi = Tamagotchi.Find(parameters.tamagotchiName);
            tamagotchi.ActOnTamgagotchi("feed");
            return View["/tamagotchi.cshtml", tamagotchi];
              };
              Get["{tamagotchiName}play"] = parameters => {
            Tamagotchi tamagotchi = Tamagotchi.Find(parameters.tamagotchiName);
            tamagotchi.ActOnTamgagotchi("play");
            return View["/tamagotchi.cshtml", tamagotchi];
              };
        }
Example #51
0
 /// <summary>
 /// Apply this Rule to a Tamagotchi
 /// </summary>
 public abstract bool Execute(Tamagotchi tama, DateTime now);
Example #52
0
 public override void Deactivate(Tamagotchi tama)
 {
     tama.IsAthletic = false;
 }
Example #53
0
 public virtual void Deactivate(Tamagotchi tama)
 {
     /* do nothing */
 }
Example #54
0
        public void Tamagotchi_StatusDoubleValue()
        {
            Tamagotchi t1 = new Tamagotchi(90, 100, 70, 100, DateTime.UtcNow, TimeSpan.Zero);

            Assert.AreEqual("Neutral", t1.Status);
        }
Example #55
0
        public void Tamagotchi_StatusSleep()
        {
            Tamagotchi t1 = new Tamagotchi(90, 80, 70, 100, DateTime.UtcNow, TimeSpan.Zero);

            Assert.AreEqual(nameof(t1.Sleep), t1.Status);
        }
Example #56
0
 public override void Deactivate(Tamagotchi tama)
 {
     tama.IsCrazy = false;
 }
Example #57
0
        public void Tamagotchi_RequireName()
        {
            Tamagotchi t1 = new Tamagotchi(-20, -20, -20, -20, DateTime.UtcNow, TimeSpan.Zero);

            Assert.IsTrue(!string.IsNullOrEmpty(t1.Name));
        }
Example #58
0
 public override void Deactivate(Tamagotchi tama)
 {
     tama.HasMunchies = false;
 }
Example #59
-1
        public void Tamagotchi_StatusBoredom()
        {
            Tamagotchi t1 = new Tamagotchi(100, 90, 80, 70, DateTime.UtcNow, TimeSpan.Zero);

            Assert.AreEqual(nameof(t1.Boredom), t1.Status);
        }