public static void Serialize(this StoragePremitive p, DSWriter w) { if (p == null) { w.Write(EnumerablesEx.AsEnumerable(TypeIdentifier.Null)); } else { p.SerializeNonNull(w); } }
private ShipHpStatus ProcessBattle(BattleProcess report) { ShipInfo a = OrigInfo; foreach (var aw in EnumerablesEx.AsEnumerable(report.AirWarfare, report.AirWarfare2)) { if (aw == null) { continue; } if (aw.EnemyCarrierShip.Any(x => x == a)) { if (aw.ZwEnemyCarrierShip.Length == 1) { ZwDeliveredDamage += aw.ZwOurShipDamages.Sum(); } else { ZwDeliveredDamage.UpperBound += aw.ZwOurShipDamages.Sum(); } } else if (aw.OurCarrierShip.Any(x => x == a)) { if (aw.ZwOurCarrierShip.Length == 1) { ZwDeliveredDamage += aw.ZwEnemyShipDamages.Sum(); } else { ZwDeliveredDamage.UpperBound += aw.ZwEnemyShipDamages.Sum(); } } } foreach (var aws3report in report.AirWarfare.EnemyStage3Report.SafeConcat( report.AirWarfare?.EscortStage3Report, report.AirWarfare?.OurStage3Report, report.Support?.AttackInfo.EnemyStage3Report, report.AirWarfare2?.EnemyStage3Report, report.AirWarfare2?.EscortStage3Report, report.AirWarfare2?.OurStage3Report)) { if (aws3report.Ship != a) { continue; } HpCurrent -= (int)aws3report.Damage; } foreach (var bmbreport in report.BombardRound1.SafeConcat(report.BombardRound2, report.BombardRound3, report.NightWar?.Bombard)) { foreach (var tgt in bmbreport.AttackInfos) { if (tgt.Key != a) { continue; } HpCurrent -= tgt.Value; } if (bmbreport.From == a) { ZwDeliveredDamage += bmbreport.AttackInfos.Sum(x => x.Value); } } foreach (var tpreport in report.ClosingTorpedoAttack.SafeConcat(report.OpeningTorpedoAttack)) { if (tpreport.To == a) { HpCurrent -= tpreport.Damage; } if (tpreport.From == a) { ZwDeliveredDamage += tpreport.Damage; } } if (HpCurrent < 0) { HpCurrent = 0; } return(this); }