Пример #1
0
        private DamageAllocationTrack GenerateDamageAllocationTrack(SystemTargeting useTargeting)
        {
            var d6 = Dice.RollD6();
            DamageAllocationTrack dacTrack = null;

            dacTrack = DamageAllocationChart.GetTrack(d6);

            if (useTargeting == SystemTargeting.Weapons)
            {
                if (d6 == 1 || d6 == 2)
                {
                    dacTrack = DamageAllocationChart.Weapons;
                }
            }

            if (useTargeting == SystemTargeting.Power)
            {
                if (d6 == 5 || d6 == 6)
                {
                    dacTrack = DamageAllocationChart.Power;
                }
            }

            return(dacTrack);
        }
Пример #2
0
        private void ApplyDamage(int salvoDamage, Hex damageDirection, SystemTargeting salvoTargeting, Ship ship, DamageType damageType)
        {
            var damageRemainingToApply = salvoDamage;
            var useTargeting           = salvoTargeting;

            var amtPenetrated = 0;



            while (damageRemainingToApply > 0 && ship.ShipInternals.IsFrameIntact)
            {
                var damageInThisBatch = Math.Min(damageRemainingToApply, 10);
                var dacTrack          = GenerateDamageAllocationTrack(useTargeting);

                var applyDamageResult = ship.ApplyDamage(
                    damageInThisBatch,
                    damageDirection,
                    dacTrack,
                    damageType,
                    useTargeting);

                damageRemainingToApply -= damageInThisBatch;
                useTargeting            = SystemTargeting.Indiscriminant;
                damageRemainingToApply += applyDamageResult.DamageToMoveToNextbatch;

                amtPenetrated += applyDamageResult.PenetratedDamage;
            }

            var qualifiesForBurnThrough = salvoDamage >= 10 && amtPenetrated == 0;

            if (qualifiesForBurnThrough)
            {
                ApplyDamage(1, damageDirection, salvoTargeting, ship, DamageType.BurnThrough);
            }
        }
Пример #3
0
        internal ApplyDamageResult ApplyDamage(int dmg, Hex damageDirection, DamageAllocationTrack track, DamageType damageType, SystemTargeting targeting)
        {
            var result = new ApplyDamageResult();

            var remainingDamage = dmg;
            var shield          = this.ShipInternals.GetShield(damageDirection);

            if (damageType == DamageType.WeaponFire)
            {
                var absorbed = Math.Min(shield.Remaining, remainingDamage);
                shield.Remaining        -= absorbed;
                remainingDamage         -= absorbed;
                result.ShieldDamageCount = absorbed;
            }

            //give back the damage to the shield, because the damage actually passed 'through' the shield.
            if (damageType == DamageType.BurnThrough)
            {
                shield.Remaining += dmg;
            }


            result.PenetratedDamage = remainingDamage;

            for (int i = 0; i < 10; i++)
            {
                if (remainingDamage == 0)
                {
                    break;
                }

                var target  = track.Get(i);
                var success = ShipInternals.TryApplyDamageToInternalComponent(target.DamageType);
                if (success)
                {
                    remainingDamage--;
                    continue;
                }

                success = ShipInternals.TryApplyDamageToInternalComponent(target.AltDamageType);
                if (success)
                {
                    remainingDamage--;
                    continue;
                }

                //can't move damage to next batch if you were targeting a specific system.
                if (targeting != SystemTargeting.Indiscriminant)
                {
                    remainingDamage--;
                }
            }

            result.DamageToMoveToNextbatch = remainingDamage;

            return(result);
        }