/* (During the first turn of a scenario, the ship has additional energy tokens * equal to the number of batteries on the ship, representing power stored in the batteries. ) */ public void Initialize(ShipSpecification spec) { ShipInternals = new ShipInternals(spec); foreach (var shipStateAvailableBattery in ShipInternals.AvailableBatteries) { shipStateAvailableBattery.IsCharged = true; } }
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); }
public void EnactRepairs(int componentId) { var component = ShipInternals.GetComponent(componentId); component.Damaged = false; if (component is WeaponComponent weaponComponent) { ShipInternals.DamageControl.RepairPointsPool -= 4; } else if (component is EnergyComponent energyComponent) { ShipInternals.DamageControl.RepairPointsPool -= 3; } else if (component is SystemComponent controlSystemComponent) { ShipInternals.DamageControl.RepairPointsPool -= 2; } else { ShipInternals.DamageControl.RepairPointsPool -= 1; } }