private IEnumerable <KeyValuePair <BattleProcess.ShipHpStatus, TriState> > CalcMvpStatus(IReadOnlyList <BattleProcess.ShipHpStatus> EndShips)
        {
            if (EndShips == null)
            {
                yield break;
            }

            var mvpRange = EndShips.Aggregate(new FuzzyInt(), (range, ship) => FuzzyInt.UpperRange(range, ship.DeliveredDamage));
            var fuzzy    = EndShips.Select(x => x.DeliveredDamage).Where(x => x.LowerBound != x.UpperBound);

            if (fuzzy.Count() != 0)
            {
                mvpRange.LowerBound = Math.Max(mvpRange.LowerBound, fuzzy.Max(x => x.UpperBound) / fuzzy.Count());
            }

            var inRangeState = EndShips.Count(x => (x.DeliveredDamage >= mvpRange) != TriState.No) == 1 ? TriState.Yes : TriState.DK;

            if (mvpRange.UpperBound == mvpRange.LowerBound)
            {
                inRangeState = TriState.Yes;
            }
            foreach (var ship in EndShips)
            {
                yield return(new KeyValuePair <BattleProcess.ShipHpStatus, TriState>(ship, (ship.DeliveredDamage >= mvpRange) != TriState.No ? inRangeState : TriState.No));

                if (mvpRange.UpperBound == mvpRange.LowerBound && ship.DeliveredDamage.LowerBound == mvpRange.LowerBound)
                {
                    inRangeState = TriState.No;
                }
            }
        }
            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);
            }
 public ShipHpStatus(int oid, BattleProcess parent)
 {
     _parent = parent; ZwOrigShipId = oid; HpCurrent = OrigInfo.CurrentHp; ZwDeliveredDamage = new FuzzyInt();
     ProcessBattle(parent);
 }