Inheritance: ICalcViewRange
Exemplo n.º 1
0
        /// <summary>
        /// 艦隊の平均レベルや制空戦力などの各種数値を再計算します。
        /// </summary>
        internal void Calculate()
        {
            var ships = this.source.SelectMany(x => x.Ships).WithoutEvacuated().ToArray();

            this.TotalLevel   = ships.HasItems() ? ships.Sum(x => x.Level) : 0;
            this.AverageLevel = ships.HasItems() ? (double)this.TotalLevel / ships.Length : 0.0;

            this.MinAirSuperiorityPotential = ships.Sum(s => s.GetAirSuperiorityPotential(AirSuperiorityCalculationOptions.Minimum));
            this.MaxAirSuperiorityPotential = ships.Sum(s => s.GetAirSuperiorityPotential(AirSuperiorityCalculationOptions.Maximum));
            this.Speed = ships.All(x => x.Info.Speed == ShipSpeed.Fast)
                                ? FleetSpeed.Fast
                                : ships.All(x => x.Info.Speed == ShipSpeed.Low)
                                        ? FleetSpeed.Low
                                        : FleetSpeed.Hybrid;

            var logic = ViewRangeCalcLogic.Get(KanColleClient.Current.Settings.ViewRangeCalcType);

            this.ViewRange         = logic.Calc(this.source);
            this.ViewRangeCalcType = logic.Name;

            if (this.Calculated != null)
            {
                this.Calculated(this, new EventArgs());
            }
        }
Exemplo n.º 2
0
		/// <summary>
		/// 艦隊の索敵値を計算します。
		/// </summary>
		/// <returns></returns>
		public static int CalcFleetViewRange(this Fleet fleet, ViewRangeCalcLogic logic)
		{
			if (fleet == null || fleet.Ships.Length == 0) return 0;

			if (logic == ViewRangeCalcLogic.Type1)
			{
				return fleet.Ships.Sum(x => x.ViewRange);
			}

			if (logic == ViewRangeCalcLogic.Type2)
			{
				// http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#area5
				// [索敵装備と装備例] によって示されている計算式
				// stype=7 が偵察機 (2 倍する索敵値)、stype=8 が電探

				var spotter = fleet.Ships.SelectMany(
					x => x.SlotItems
						.Zip(x.OnSlot, (i, o) => new { Item = i.Info, Slot = o })
						.Where(a => a.Item.RawData.api_type.Get(1) == 7)
						.Where(a => a.Slot > 0)
						.Select(a => a.Item.RawData.api_saku)
					).Sum();

				var radar = fleet.Ships.SelectMany(
					x => x.SlotItems
						.Where(i => i.Info.RawData.api_type.Get(1) == 8)
						.Select(i => i.Info.RawData.api_saku)
					).Sum();

				return (spotter * 2) + radar + (int)Math.Sqrt(fleet.Ships.Sum(x => x.ViewRange) - spotter - radar);
			}

			return 0;
		}
Exemplo n.º 3
0
 /// <summary>
 /// 艦隊の平均レベルや制空戦力などの各種数値を再計算します。
 /// </summary>
 public void Calculate()
 {
     this.TotalLevel              = this.Ships.HasItems() ? this.Ships.Sum(x => x.Level) : 0;
     this.AverageLevel            = this.Ships.HasItems() ? (double)this.TotalLevel / this.Ships.Length : 0.0;
     this.AirSuperiorityPotential = this.Ships.Sum(s => s.CalcAirSuperiorityPotential());
     this.TotalViewRange          = ViewRangeCalcLogic.Get(KanColleClient.Current.Settings.ViewRangeCalcType).Calc(this);
     this.Speed = this.Ships.All(s => s.Info.Speed == Speed.Fast) ? Speed.Fast : Speed.Low;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 艦隊の平均レベルや制空戦力などの各種数値を再計算します。
        /// </summary>
        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);
            }
            else
            {
                this.UsedFuel = this.UsedBull = 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());
            this.Speed = ships.All(x => x.Info.Speed == ShipSpeed.Fast)
                                ? FleetSpeed.Fast
                                : ships.All(x => x.Info.Speed == ShipSpeed.Low)
                                        ? FleetSpeed.Low
                                        : FleetSpeed.Hybrid;

            var logic = ViewRangeCalcLogic.Get(KanColleClient.Current.Settings.ViewRangeCalcType);

            this.ViewRange         = logic.Calc(this.source);
            this.ViewRangeCalcType = logic.Name;

            this.Calculated?.Invoke(this, new EventArgs());
        }
Exemplo n.º 5
0
        /// <summary>
        /// 艦隊の平均レベルや制空戦力などの各種数値を再計算します。
        /// </summary>
        public void Calculate()
        {
            var ships           = this.source.SelectMany(x => x.Ships).WithoutEvacuated().ToArray();
            var firstFleetShips = this.source.FirstOrDefault()?.Ships.WithoutEvacuated().ToArray() ?? new Ship[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.Speed = new FleetSpeed(Array.ConvertAll(ships, x => x.Speed));

            var logic = ViewRangeCalcLogic.Get(KanColleClient.Current.Settings.ViewRangeCalcType);

            this.ViewRange         = logic.Calc(this.source);
            this.ViewRangeCalcType = logic.Name;

            this.Calculated?.Invoke(this, new EventArgs());
        }
Exemplo n.º 6
0
        /// <summary>
        /// 艦隊の平均レベルや制空戦力などの各種数値を再計算します。
        /// </summary>
        public void Calculate()
        {
            var ships           = this.source.SelectMany(x => x.Ships).WithoutEvacuated().ToArray();
            var firstFleetShips = this.source.FirstOrDefault()?.Ships.WithoutEvacuated().ToArray() ?? new Ship[0];

            this.TotalLevel                 = ships.HasItems() ? ships.Sum(x => x.Level) : 0;
            this.AverageLevel               = ships.HasItems() ? (double)this.TotalLevel / ships.Length : 0.0;
            this.AirSuperiorityPotential    = firstFleetShips.Sum(s => s.CalcAirSuperiorityPotential());
            this.MinAirSuperiorityPotential = firstFleetShips.Sum(s => s.CalcMinAirSuperiorityPotential());
            this.MaxAirSuperiorityPotential = firstFleetShips.Sum(s => s.CalcMaxAirSuperiorityPotential());
            this.Speed = ships.All(x => x.Info.Speed == ShipSpeed.Fast)
                                ? FleetSpeed.Fast
                                : ships.All(x => x.Info.Speed == ShipSpeed.Low)
                                        ? FleetSpeed.Low
                                        : FleetSpeed.Hybrid;

            var logic = ViewRangeCalcLogic.Get(KanColleClient.Current.Settings.ViewRangeCalcType);

            this.ViewRange         = logic.Calc(this.source);
            this.ViewRangeCalcType = logic.Name;

            this.Calculated?.Invoke(this, new EventArgs());
        }
Exemplo n.º 7
0
        /// <summary>
        /// 艦隊の平均レベルや制空戦力などの各種数値を再計算します。
        /// </summary>
        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.Fastest)) // 최속으로만 구성
             *              this.Speed = FleetSpeed.Fastest;
             *      else if (ships.All(x => x.Speed == ShipSpeed.Faster)) // 고속+로만 구성
             *              this.Speed = FleetSpeed.Faster;
             *      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.Low;
             *
             *      else if (!ships.Any(x => x.Speed == ShipSpeed.Fast || x.Speed == ShipSpeed.Slow)) // 최속&고속+ 구성
             *              this.Speed = FleetSpeed.Hybrid_Faster;
             *      else if (!ships.Any(x => x.Speed == ShipSpeed.Slow)) // 최속&고속+&고속 구성
             *              this.Speed = FleetSpeed.Hybrid_Fast;
             *      else
             *              this.Speed = FleetSpeed.Hybrid_Low; // 저속 포함 구성
             * }
             * // this.Speed = new FleetSpeed(Array.ConvertAll(ships, x => x.Speed));
             */
            if (ships.Any(x => x.Speed == ShipSpeed.Slow))             // 저속 포함
            {
                this.Speed = FleetSpeed.Low;
            }
            else if (ships.All(x => x.Speed == ShipSpeed.Fast))             // 고속 포함
            {
                this.Speed = FleetSpeed.Fast;
            }
            else if (ships.All(x => x.Speed == ShipSpeed.Faster))             // 고속+ 포함
            {
                this.Speed = FleetSpeed.Faster;
            }
            else             // 최속만
            {
                this.Speed = FleetSpeed.Fastest;
            }

            var logic = ViewRangeCalcLogic.Get(KanColleClient.Current.Settings.ViewRangeCalcType);

            this.ViewRange         = logic.Calc(this.source);
            this.ViewRangeCalcType = logic.Name;

            this.Calculated?.Invoke(this, new EventArgs());
        }