/// <summary> /// 演習ダメージ適用 /// </summary> /// <param name="fleet">艦隊</param> /// <param name="damages">適用ダメージリスト</param> public static void CalcPracticeDamages(this FleetData fleet, params FleetDamages[] damages) { foreach (var damage in damages) { fleet.Ships.SetValues(damage.ToArray(), (s, d) => s.NowHP -= d); } if (fleet.Ships == null) { return; } foreach (var item in fleet.Ships) { int tempHP = item.NowHP; if (item.NowHP < 0) { tempHP = 0; } fleet.TotalDamaged += (item.BeforeNowHP - tempHP); if (item.NowHP <= 0) { fleet.SinkCount++; } } }
/// <summary> /// ダメージ適用 /// </summary> /// <param name="fleet">艦隊</param> /// <param name="damages">適用ダメージリスト</param> public static void CalcDamages(this FleetData fleet, params FleetDamages[] damages) { foreach (var damage in damages) { fleet.Ships.SetValues(damage.ToArray(), (s, d) => s.NowHP -= d); } if (fleet.Ships != null) { fleet.SinkCount = 0; // Re-calculate foreach (var item in fleet.Ships) { if (!item.Situation.HasFlag(ShipSituation.Evacuation) && !item.Situation.HasFlag(ShipSituation.Tow)) { int tempHP = item.NowHP; if (item.NowHP < 0) { tempHP = 0; } fleet.TotalDamaged += (item.BeforeNowHP - tempHP); } if (item.NowHP <= 0) { fleet.SinkCount++; } } fleet.IsCritical = fleet.Ships .Where(x => x.MaxHP > 0) .Where(x => (x.NowHP / (double)x.MaxHP) <= 0.25) .Any(x => (!x.Situation.HasFlag(ShipSituation.DamageControlled) || Settings.Default.CriticalAlways) && !x.Situation.HasFlag(ShipSituation.Evacuation) && !x.Situation.HasFlag(ShipSituation.Tow) ); } foreach (var damage in damages) { // 다메콘에 의한 회복 처리. 같은 전투에서 두 번 사용되지 않는다는 전제... // 다메콘 우선도: 확장 슬롯 -> 인덱스 순 var dameconState = fleet.Ships.Select(x => new { HasDamecon = x.HasDamecon(), HasMegami = x.HasMegami() }); fleet.Ships.SetValues(dameconState, (s, d) => { if (0 < s.NowHP) { return; } s.IsUsedDamecon = (d.HasDamecon || d.HasMegami); if (d.HasDamecon) { s.NowHP = (int)Math.Floor(s.MaxHP * 0.2); } else if (d.HasMegami) { s.NowHP = s.MaxHP; } }); } InputCritical(fleet); }
internal static void UpdateMaxHPs(this FleetData fleet, IEnumerable <int> maxhps) { fleet.Ships.SetValues(maxhps, (s, v) => s.MaxHP = v); }
internal static void UpdateNowHPs(this FleetData fleet, IEnumerable <int> nowhps) { fleet.Ships.SetValues(nowhps, (s, v) => s.NowHP = v); }
internal static void UpdateHPs(this FleetData fleet, IEnumerable <int> maxhps, IEnumerable <int> nowhps) { fleet.UpdateMaxHPs(maxhps); fleet.UpdateNowHPs(nowhps); }