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); } }
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); }
public void Tamagotchi_StatusDead() { Tamagotchi t1 = new Tamagotchi(90, 100, 70, 100, DateTime.UtcNow, TimeSpan.Zero); t1.HasDied = true; Assert.AreEqual("Dead", t1.Status); }
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); }
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)); }
public void BeLessFullnessWhenWeMakePoop() { var tamagotchi = new Tamagotchi(); var needs = tamagotchi.MakeAPoop(); needs.Fullness.Should().BeLessThan(10); }
public void BeLessTiredWhenWePuttingInBed() { var tamagotchi = new Tamagotchi(); var needs = tamagotchi.Sleep(); needs.Tiredness.Should().BeLessThan(10); }
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); }
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(); }
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(); }
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); }
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)); }
public void Add(Tamagotchi tama) { tama.Alive = true; tama.Health = 100; tama.Money = 100; _tamagotchiEntities.Tamagotchi.Add(tama); _tamagotchiEntities.SaveChanges(); }
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); }
public ActionResult FastForward() { foreach (Tamagotchi tamagotchi in Tamagotchi.GetAll()) { tamagotchi.PassTime(15); } return(Redirect("/")); }
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); }
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); }
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); }
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)); }
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 }
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; }
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); }
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")); }
public virtual int ExcecuteInstructie(Tamagotchi tamagotchi) { if (checkCrazy(tamagotchi)) { return(1); } return(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); }
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); }
public override bool Execute(Tamagotchi tama, DateTime now) { if (tama.Boredom > 80) tama.HasMunchies = true; else tama.HasMunchies = false; return true; }
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); }
public override int ExcecuteInstructie(Tamagotchi tamagotchi) { if (base.ExcecuteInstructie(tamagotchi) == 1) { return(0); } tamagotchi.hunger = 0; return(30); }
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); }
public override bool Execute(Tamagotchi tama, DateTime now) { if (tama.Sleep == SleepThreshold && !tama.IsAthletic) tama.HasDied = true; else tama.HasDied = false; return true; }
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))); }
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); }
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; }
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; }
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]; }; }
/// <summary> /// Apply this Rule to a Tamagotchi /// </summary> public abstract bool Execute(Tamagotchi tama, DateTime now);
public override void Deactivate(Tamagotchi tama) { tama.IsAthletic = false; }
public virtual void Deactivate(Tamagotchi tama) { /* do nothing */ }
public void Tamagotchi_StatusDoubleValue() { Tamagotchi t1 = new Tamagotchi(90, 100, 70, 100, DateTime.UtcNow, TimeSpan.Zero); Assert.AreEqual("Neutral", t1.Status); }
public void Tamagotchi_StatusSleep() { Tamagotchi t1 = new Tamagotchi(90, 80, 70, 100, DateTime.UtcNow, TimeSpan.Zero); Assert.AreEqual(nameof(t1.Sleep), t1.Status); }
public override void Deactivate(Tamagotchi tama) { tama.IsCrazy = false; }
public void Tamagotchi_RequireName() { Tamagotchi t1 = new Tamagotchi(-20, -20, -20, -20, DateTime.UtcNow, TimeSpan.Zero); Assert.IsTrue(!string.IsNullOrEmpty(t1.Name)); }
public override void Deactivate(Tamagotchi tama) { tama.HasMunchies = false; }
public void Tamagotchi_StatusBoredom() { Tamagotchi t1 = new Tamagotchi(100, 90, 80, 70, DateTime.UtcNow, TimeSpan.Zero); Assert.AreEqual(nameof(t1.Boredom), t1.Status); }