Пример #1
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
        }
Пример #2
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            var timeSpan = now - tama.LastAllRulesPassedUtc;

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

            return(false);
        }
Пример #3
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            if (tama.Sleep == SleepThreshold && !tama.IsAthletic)
            {
                tama.HasDied = true;
            }
            else
            {
                tama.HasDied = false;
            }

            return(true);
        }
Пример #4
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            if (tama.Health < HealthThreshold)
            {
                tama.IsAthletic = true;
            }
            else
            {
                tama.IsAthletic = false;
            }

            return(true);
        }
Пример #5
0
        public override bool Execute(Tamagotchi tama, DateTime now)
        {
            if (tama.Boredom > 80)
            {
                tama.HasMunchies = true;
            }
            else
            {
                tama.HasMunchies = false;
            }

            return(true);
        }
Пример #6
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);
        }
Пример #7
0
 public virtual void Deactivate(Tamagotchi tama) /* do nothing */ }
Пример #8
0
 /// <summary>
 /// Apply this Rule to a Tamagotchi
 /// </summary>
 public abstract bool Execute(Tamagotchi tama, DateTime now);
Пример #9
0
 public override void Deactivate(Tamagotchi tama)
 {
     tama.IsAthletic = false;
 }
Пример #10
0
 public override void Deactivate(Tamagotchi tama)
 {
     tama.HasMunchies = false;
 }
Пример #11
0
 public override void Deactivate(Tamagotchi tama)
 {
     tama.IsCrazy = false;
 }