public static double CalcViewRange(this Fleet fleet) { return(ViewRangeCalcLogic.Get(Settings.ViewRangeCalcType.Value).Calc(new[] { fleet })); }
public void Calculate() { var ships = this.source.SelectMany(x => x.Ships).WithoutEvacuated().ToArray(); var firstFleetShips = this.source.FirstOrDefault()?.Ships.WithoutEvacuated().ToArray() ?? new Ship[0]; List <SecondResult> partPercent = new List <SecondResult>(); List <ShipSlot> SecondSlotList = new List <ShipSlot>(this.MakeSecondList(ships)); List <SecondResult> TotalSecond = new List <SecondResult>(MakeSecondResult(SecondSlotList)); List <int> HitList = new List <int>(this.MakeHitList(ships)); for (int i = 0; i < HitList.Count; i++) { partPercent.Add(new SecondResult { Hit = HitList[i], SecondEncounter = TotalSecond.Where(x => x.Hit == HitList[i]).Sum(y => y.SecondEncounter) }); } if (ships.HasItems()) { this.UsedFuel = ships.Sum(x => x.UsedFuel); this.UsedBull = ships.Sum(x => x.UsedBull); this.UsedBauxite = ships.Sum(x => x.Slots.Sum(y => y.Lost * 5) ); } else { this.UsedFuel = this.UsedBull = this.UsedBauxite = 0; } this.TotalLevel = ships.HasItems() ? ships.Sum(x => x.Level) : 0; this.AverageLevel = ships.HasItems() ? (double)this.TotalLevel / ships.Length : 0.0; this.MinAirSuperiorityPotential = firstFleetShips.Sum(x => x.GetAirSuperiorityPotential(AirSuperiorityCalculationOptions.Minimum)); this.MaxAirSuperiorityPotential = firstFleetShips.Sum(x => x.GetAirSuperiorityPotential(AirSuperiorityCalculationOptions.Maximum)); this.EncounterPercent = TotalSecond.Sum(x => x.SecondEncounter); this.PartEncounterPercent = partPercent; this.FirstEncounter = ships.Sum(s => s.CalcFirstEncounterPercent()); { if (ships.All(x => x.Speed == ShipSpeed.SuperFast)) // 최속으로만 구성 { this.Speed = FleetSpeed.SuperFast; } else if (ships.All(x => x.Speed == ShipSpeed.FastPlus)) // 고속+로만 구성 { this.Speed = FleetSpeed.FastPlus; } else if (ships.All(x => x.Speed == ShipSpeed.Fast)) // 고속으로만 구성 { this.Speed = FleetSpeed.Fast; } else if (ships.All(x => x.Speed == ShipSpeed.Slow)) // 저속으로만 구성 { this.Speed = FleetSpeed.Slow; } else if (!ships.Any(x => x.Speed == ShipSpeed.Fast || x.Speed == ShipSpeed.Slow)) // 최속&고속+ 구성 { this.Speed = FleetSpeed.Hybrid_FastPlus; } else if (!ships.Any(x => x.Speed == ShipSpeed.Slow)) // 최속&고속+&고속 구성 { this.Speed = FleetSpeed.Hybrid_Fast; } else { this.Speed = FleetSpeed.Hybrid_Slow; // 저속 포함 구성 } } var logic = ViewRangeCalcLogic.Get(Settings.ViewRangeCalcType.Value); this.ViewRange = logic.Calc(this.source); this.ViewRangeCalcType = logic.Name; this.Calculated?.Invoke(this, new EventArgs()); }