protected override void IncreaseTiltForSucessfulDefence(TiltFighter tiltFighter, decimal defenceRoll, DefenceEventData eventData)
        {
            var tiltAdded = 15;

            tiltAdded += (int)eventData.ForAttack.Damage / 10;

            tiltFighter.Tilt.Add(tiltAdded);
        }
        public bool Apply(EventType type, IEntity sender, object eventData)
        {
            var data = eventData as DefenceEventData;

            if (data.DefenceType != _defenceName)
            {
                // Don't try to apply it
                return(true);
            }

            var attackClass = data.ForAttack.AttackClass;

            if (!ValidAttackClasses.Contains(attackClass))
            {
                return(true);
            }

            var         defender    = data.ForAttack.Defender;
            TiltFighter tiltFighter = defender.Get <TiltFighter>();
            var         isBroken    = tiltFighter.BrokenTicks > 0;

            if (isBroken)
            {
                return(true);
            }

            var defence = _systemContainer.EventSystem.GetStat(defender, _statName);

            defence = ApplyTiltToDefence(tiltFighter, defence);

            var defenceRoll = _systemContainer.Random.Between(1, 20);

            if (defence + defenceRoll > data.ForAttack.AttackRoll)
            {
                IncreaseTiltForSucessfulDefence(tiltFighter, defenceRoll, data);
                return(false);
            }

            return(true);
        }
 protected override void IncreaseTiltForSucessfulDefence(TiltFighter tiltFighter, decimal defenceRoll, DefenceEventData eventData)
 {
     tiltFighter.Tilt.Add((int)defenceRoll);
 }
        protected override decimal ApplyTiltToDefence(TiltFighter tiltFighter, decimal defence)
        {
            var tiltPercent = (decimal)tiltFighter.Tilt.Current / tiltFighter.Tilt.Max;

            return(defence * (1m - 0.5m * tiltPercent));
        }
 protected abstract void IncreaseTiltForSucessfulDefence(TiltFighter tiltFighter, decimal defenceRoll, DefenceEventData eventData);
 protected abstract decimal ApplyTiltToDefence(TiltFighter tiltFighter, decimal defence);