Example #1
0
        public Damage(Being defender, StatSet damages)
        {
            var    statdmg = new List <StatDamage>();
            double total   = 0.0;

            foreach (StatType dmgType in StatTypeStuff.DirectDamageTypeApplicationTypes)
            {
                double dmg = damages.GetStat(dmgType).Value;
                if (dmg != 0)
                {
                    double resist      = defender[dmgType.AsResistance()].Value;
                    double penetration = damages[dmgType.AsPenetration()];
                    double threshold   = defender[dmgType.AsThreshold()].Value;
                    dmg *= (1 - (resist - penetration));
                    if (Math.Abs(dmg) < threshold)
                    {
                        dmg = 0;                                                //don't negate more than absolute damage
                    }
                    else
                    {
                        dmg -= (dmg < 0 ? -1 : 1) * threshold;                      //negate flat amount regardless of negative or positive damage
                    }
                    ConsoleLoggerHandlerOrWhatever.Log(dmg + " " + dmgType);
                    statdmg.Add(new StatDamage(dmg, dmgType));
                    total += dmg;
                }
            }

            Value = (int)(total + 0.5);
        }
Example #2
0
        public void TakeRawDamage(int dmg)
        {
            int preHP = HP;

            HP -= dmg;
            ConsoleLoggerHandlerOrWhatever.Log(dmg + " Damage taken");
            ConsoleLoggerHandlerOrWhatever.Log(preHP + " => " + HP);
        }
Example #3
0
        public void OnTurnStarted(object s, EventArgs e)
        {
            var ge = Skill.Do(this, TargetSelector());

            if (ge != null)
            {
                ge.Apply();
            }
            ConsoleLoggerHandlerOrWhatever.Log(this.ToString() + " cast " + Skill.Name + " and hit nothing.");
            _awaited = 0;               //should just kill self
            if (TurnFinished != null)
            {
                TurnFinished(this, EventArgs.Empty);
            }
            Place = null;
        }
Example #4
0
        private void ForwardTime()
        {
            if (CurrentTurnHaver == null || CurrentTurnHaver.GetTimeToWait() > 0)
            {
                if (Paused)
                {
                    return;
                }
                if (TurnHavers.Any() == false)
                {
                    return;
                }

                CurrentTurnHaver = TurnHavers.Aggregate((t1, t2) => t1.GetTimeToWait() <= t2.GetTimeToWait() ? t1 : t2);
                var dsgfsdf = CurrentTurnHaver.GetTimeToWait();

                enumerating = true;
                foreach (var t in TurnHavers)
                {
                    t.Await(dsgfsdf);
                }
                enumerating = false;
                while (doAfterEnumerating.Count > 0)
                {
                    doAfterEnumerating.Dequeue()();
                }

                ConsoleLoggerHandlerOrWhatever.Log("_____________");
                foreach (var t in TurnHavers)
                {
                    ConsoleLoggerHandlerOrWhatever.Log(t.ToString() + " " + t.Awaited + " + " + t.Speed);
                }

                shouldStartTurn = true;
                if (!looping)
                {
                    loop();                     //this calls StartTurn
                }
            }
        }