public override void LoadFromResponse( string apiname, dynamic data ) {

			switch ( apiname ) {
				case "api_req_combined_battle/goback_port":
					foreach ( int index in KCDatabase.Instance.Battle.Result.EscapingShipIndex ) {
						Fleets[( index - 1 ) < 6 ? 1 : 2].Escape( ( index - 1 ) % 6 );
					}
					break;

				case "api_get_member/ndock":
					foreach ( var fleet in Fleets.Values ) {
						fleet.LoadFromResponse( apiname, data );
					}
					break;

				case "api_req_hensei/preset_select": {
						int id = (int)data.api_id;

						if ( !Fleets.ContainsKey( id ) ) {
							var a = new FleetData();
							a.LoadFromResponse( apiname, data );
							Fleets.Add( a );

						} else {
							Fleets[id].LoadFromResponse( apiname, data );
						}

					} break;

				default:
					base.LoadFromResponse( apiname, (object)data );

					//api_port/port, api_get_member/deck
					foreach ( var elem in data ) {

						int id = (int)elem.api_id;

						if ( !Fleets.ContainsKey( id ) ) {
							var a = new FleetData();
							a.LoadFromResponse( apiname, elem );
							Fleets.Add( a );

						} else {
							Fleets[id].LoadFromResponse( apiname, elem );
						}
					}
					break;
			}


			// 泊地修理の処理
			if ( apiname == "api_port/port" ) {

				if ( ( DateTime.Now - AnchorageRepairingTimer ).TotalMinutes >= 20 )
					StartAnchorageRepairingTimer();

			}
		}
Example #2
0
        /// <summary>
        /// 輸送作戦成功時の輸送量(減少TP)を求めます。
        /// (S勝利時のもの。A勝利時は int( value * 0.7 ) )
        /// </summary>
        /// <param name="fleet">対象の艦隊。</param>
        /// <returns>減少TP。</returns>
        public static int GetTPDamage( FleetData fleet )
        {
            int tp = 0;

            foreach ( var ship in fleet.MembersWithoutEscaped.Where( s => s != null && s.HPRate > 0.25 ) ) {

                // 装備ボーナス
                foreach ( var eq in ship.AllSlotInstanceMaster.Where( q => q != null ) ) {

                    switch ( eq.CategoryType ) {

                        case 24:	// 上陸用舟艇
                            tp += 8;
                            break;
                        case 30:	// 簡易輸送部材
                            tp += 5;
                            break;
                        case 43:	// 戦闘糧食
                            tp += 1;
                            break;
                        case 46:	// 特型内火艇
                            tp += 2;
                            break;
                    }
                }

                // 艦種ボーナス
                switch ( ship.MasterShip.ShipType ) {

                    case 2:		// 駆逐艦
                        tp += 5;
                        break;
                    case 3:		// 軽巡洋艦
                        tp += 2;
                        break;
                    case 5:		// 重巡洋艦
                        tp += 0;
                        break;
                    case 6:		// 航空巡洋艦
                        tp += 4;
                        break;
                    case 10:	// 航空戦艦
                        tp += 7;
                        break;
                    case 16:	// 水上機母艦
                        tp += 9;
                        break;
                    case 17:	// 揚陸艦
                        tp += 12;
                        break;
                    case 20:	// 潜水母艦
                        tp += 7;
                        break;
                    case 21:	// 練習巡洋艦
                        tp += 6;
                        break;
                    case 22:	// 補給艦
                        tp += 15;
                        break;
                }
            }

            return tp;
        }
Example #3
0
        /// <summary>
        /// 索敵能力を求めます。「判定式(33)」です。
        /// </summary>
        /// <param name="fleet">対象の艦隊。</param>
        public static double GetSearchingAbility_33( FleetData fleet )
        {
            double ret = 0.0;

            foreach ( var ship in fleet.MembersWithoutEscaped ) {
                if ( ship == null ) continue;

                //equipments
                foreach ( var slot in ship.SlotInstance ) {

                    if ( slot == null )
                        continue;

                    switch ( slot.MasterEquipment.CategoryType ) {

                        case 8:		//艦上攻撃機
                            ret += 0.8 * slot.MasterEquipment.LOS;
                            break;

                        case 9:		//艦上偵察機
                        case 94:	//艦上偵察機(II) 存在しないが念のため
                            ret += 1.0 * slot.MasterEquipment.LOS;
                            break;

                        case 10:	//水上偵察機
                            ret += 1.2 * ( slot.MasterEquipment.LOS + 1.2 * Math.Sqrt( slot.Level ) );
                            break;

                        case 11:	//水上爆撃機
                            ret += 1.1 * slot.MasterEquipment.LOS;
                            break;

                        case 12:	//小型電探
                        case 13:	//大型電探
                            ret += 0.6 * ( slot.MasterEquipment.LOS + 1.25 * Math.Sqrt( slot.Level ) );
                            break;

                        default:
                            ret += 0.6 * slot.MasterEquipment.LOS;
                            break;
                    }
                }

                ret += Math.Sqrt( ship.LOSBase );

            }

            ret -= Math.Ceiling( 0.4 * KCDatabase.Instance.Admiral.Level );

            ret += 2.0 * ( 6 - fleet.MembersWithoutEscaped.Count( s => s != null ) );

            return ret;
        }
Example #4
0
        /// <summary>
        /// 機体命中率別の触接選択率を求めます。
        /// </summary>
        /// <param name="fleet">対象の艦隊。</param>
        /// <returns>機体の命中をキー, 触接選択率を値とした Dictionary 。</returns>
        public static Dictionary<int, double> GetContactSelectionProbability( FleetData fleet )
        {
            var probs = new Dictionary<int, double>();

            foreach ( var ship in fleet.MembersWithoutEscaped ) {
                if ( ship == null )
                    continue;

                foreach ( var eq in ship.SlotInstanceMaster ) {
                    if ( eq == null )
                        continue;

                    switch ( eq.CategoryType ) {
                        case 8:		// 艦上攻撃機
                        case 9:		// 艦上偵察機
                        case 10:	// 水上偵察機
                        case 41:	// 大型飛行艇
                            if ( !probs.ContainsKey( eq.Accuracy ) )
                                probs.Add( eq.Accuracy, 1.0 );

                            probs[eq.Accuracy] *= 1.0 - ( 0.07 * eq.LOS );
                            break;
                    }
                }
            }

            foreach ( int key in probs.Keys.ToArray() ) {		//列挙中の変更エラーを防ぐため
                probs[key] = 1.0 - probs[key];
            }

            return probs;
        }
Example #5
0
        /// <summary>
        /// 艦隊の触接開始率を求めます。
        /// </summary>
        /// <param name="fleet">対象の艦隊。</param>
        public static double GetContactProbability( FleetData fleet )
        {
            double successProb = 0.0;

            foreach ( var ship in fleet.MembersWithoutEscaped ) {
                if ( ship == null ) continue;

                var eqs = ship.SlotInstanceMaster;

                for ( int i = 0; i < ship.Slot.Count; i++ ) {
                    if ( eqs[i] == null )
                        continue;

                    if ( eqs[i].CategoryType == 9 ||	// 艦上偵察機
                        eqs[i].CategoryType == 10 ||	// 水上偵察機
                        eqs[i].CategoryType == 41 ) {	// 大型飛行艇

                        successProb += 0.04 * eqs[i].LOS * Math.Sqrt( ship.Aircraft[i] );
                    }
                }
            }

            return successProb;
        }
Example #6
0
		/// <summary>
		/// 艦隊の状態の情報をラベルに適用します。
		/// </summary>
		/// <param name="fleet">艦隊データ。</param>
		/// <param name="label">適用するラベル。</param>
		/// <param name="tooltip">適用するツールチップ。</param>
		/// <param name="prevstate">前回の状態。</param>
		/// <param name="timer">日時。</param>
		/// <returns>艦隊の状態を表す定数。</returns>
		public static FleetStates UpdateFleetState( FleetData fleet, ImageLabel label, ToolTip tooltip, FleetStates prevstate, ref DateTime timer ) {

			KCDatabase db = KCDatabase.Instance;


			//初期化
			tooltip.SetToolTip( label, null );
			label.BackColor = Color.Transparent;



			//所属艦なし
			if ( fleet == null || fleet.Members.Count( id => id != -1 ) == 0 ) {
				label.Text = FleetRes.NoShips;
				label.ImageIndex = (int)ResourceManager.IconContent.FleetNoShip;

				return FleetStates.NoShip;
			}

			{	//入渠中
				long ntime = db.Docks.Values.Max(
						dock => {
							if ( dock.State == 1 && fleet.Members.Count( ( id => id == dock.ShipID ) ) > 0 )
								return dock.CompletionTime.Ticks;
							else return 0;
						}
						);

				if ( ntime > 0 ) {	//入渠中

					timer = new DateTime( ntime );
					label.Text = FleetRes.Docking + DateTimeHelper.ToTimeRemainString( timer );
					label.ImageIndex = (int)ResourceManager.IconContent.FleetDocking;

					tooltip.SetToolTip( label, FleetRes.CompletionTime + DateTimeHelper.TimeToCSVString( timer ) );

					return FleetStates.Docking;
				}

			}


			if ( fleet.IsInSortie ) {

				//大破出撃中
				if ( fleet.MembersInstance.Count( s =>
						( s != null && !fleet.EscapedShipList.Contains( s.MasterID ) && (double)s.HPCurrent / s.HPMax <= 0.25 )
					 ) > 0 ) {

					label.Text = FleetRes.CriticalDamageAdvance;
					label.ImageIndex = (int)ResourceManager.IconContent.FleetSortieDamaged;

					return FleetStates.SortieDamaged;

				} else {	//出撃中

					label.Text = FleetRes.OnSortie;
					label.ImageIndex = (int)ResourceManager.IconContent.FleetSortie;

					return FleetStates.Sortie;
				}

			}


			//遠征中
			if ( fleet.ExpeditionState != 0 ) {

				timer = fleet.ExpeditionTime;
				label.Text = FleetRes.OnExped + DateTimeHelper.ToTimeRemainString( timer );
				label.ImageIndex = (int)ResourceManager.IconContent.FleetExpedition;

				tooltip.SetToolTip( label, string.Format( "{0} : {1}\r\n" + FleetRes.CompletionTime + " {2}",
					KCDatabase.Instance.Mission[fleet.ExpeditionDestination].ID,
					KCDatabase.Instance.Mission[fleet.ExpeditionDestination].Name,
					DateTimeHelper.TimeToCSVString( timer ) ) );

				return FleetStates.Expedition;
			}

			//大破艦あり
			if ( fleet.MembersInstance.Count( s =>
				( s != null && !fleet.EscapedShipList.Contains( s.MasterID ) && (double)s.HPCurrent / s.HPMax <= 0.25 )
			 ) > 0 ) {

				label.Text = FleetRes.CriticallyDamagedShip;
				label.ImageIndex = (int)ResourceManager.IconContent.FleetDamaged;
				//label.BackColor = Color.LightCoral;

				return FleetStates.Damaged;
			}

			//泊地修理中
			{
				if ( fleet.CanAnchorageRepairing &&
					fleet.MembersInstance.Take( 2 + KCDatabase.Instance.Ships[fleet[0]].SlotInstanceMaster.Count( eq => eq != null && eq.CategoryType == 31 ) )
					.Any( s => s != null && s.HPRate < 1.0 && s.HPRate > 0.5 && s.RepairingDockID == -1 ) ) {

					label.Text = FleetRes.AnchorageRepairing + DateTimeHelper.ToTimeElapsedString( KCDatabase.Instance.Fleet.AnchorageRepairingTimer );
					label.ImageIndex = (int)ResourceManager.IconContent.FleetAnchorageRepairing;

					StringBuilder sb = new StringBuilder();
					sb.AppendFormat( FleetRes.StartTime,
						DateTimeHelper.TimeToCSVString( KCDatabase.Instance.Fleet.AnchorageRepairingTimer ) );

					for ( int i = 0; i < fleet.Members.Count; i++ ) {
						var ship = fleet.MembersInstance[i];
						if ( ship != null && ship.HPRate < 1.0 ) {
							var totaltime = DateTimeHelper.FromAPITimeSpan( ship.RepairTime );
							var unittime = Calculator.CalculateDockingUnitTime( ship );
							sb.AppendFormat( "#{0} : {1:00}:{2:00}:{3:00} @ {4:00}:{5:00}:{6:00} x -{7} HP\r\n",
								i + 1,
								(int)totaltime.TotalHours,
								totaltime.Minutes,
								totaltime.Seconds,
								(int)unittime.TotalHours,
								unittime.Minutes,
								unittime.Seconds,
								ship.HPMax - ship.HPCurrent
								);
						} else {
							sb.Append( "#" ).Append( i + 1 ).Append( " : ----\r\n" );
						}
					}

					tooltip.SetToolTip( label, sb.ToString() );

					return FleetStates.AnchorageRepairing;
				}
			}

			//未補給
			{
				int fuel = fleet.MembersInstance.Sum( ship => ship == null ? 0 : (int)( ( ship.FuelMax - ship.Fuel ) * ( ship.IsMarried ? 0.85 : 1.00 ) ) );
				int ammo = fleet.MembersInstance.Sum( ship => ship == null ? 0 : (int)( ( ship.AmmoMax - ship.Ammo ) * ( ship.IsMarried ? 0.85 : 1.00 ) ) );
				int aircraft = fleet.MembersInstance.Sum(
					ship => {
						if ( ship == null ) return 0;
						else {
							int c = 0;
							for ( int i = 0; i < ship.Slot.Count; i++ ) {
								c += ship.MasterShip.Aircraft[i] - ship.Aircraft[i];
							}
							return c;
						}
					} );
				int bauxite = aircraft * 5;

				if ( fuel > 0 || ammo > 0 || bauxite > 0 ) {

					label.Text = FleetRes.SupplyNeeded;
					label.ImageIndex = (int)ResourceManager.IconContent.FleetNotReplenished;

					tooltip.SetToolTip( label, string.Format( FleetRes.ResupplyTooltip, fuel, ammo, bauxite, aircraft ) );

					return FleetStates.NotReplenished;
				}
			}

			//疲労
			{
				int cond = fleet.MembersInstance.Min( s => s == null ? 100 : s.Condition );

				if ( cond < Configuration.Config.Control.ConditionBorder && fleet.ConditionTime != null ) {

					timer = (DateTime)fleet.ConditionTime;


					label.Text = FleetRes.Fatigued + DateTimeHelper.ToTimeRemainString( timer );

					if ( cond < 20 )
						label.ImageIndex = (int)ResourceManager.IconContent.ConditionVeryTired;
					else if ( cond < 30 )
						label.ImageIndex = (int)ResourceManager.IconContent.ConditionTired;
					else
						label.ImageIndex = (int)ResourceManager.IconContent.ConditionLittleTired;


					tooltip.SetToolTip( label, string.Format( FleetRes.EstimatedRecoveryTime + ": {0}", DateTimeHelper.TimeToCSVString( timer ) ) );

					return FleetStates.Tired;


				} else if ( cond >= 50 ) {		//戦意高揚

					label.Text = FleetRes.FightingSpiritHigh;
					label.ImageIndex = (int)ResourceManager.IconContent.ConditionSparkle;
					tooltip.SetToolTip( label, string.Format( FleetRes.SparkledTooltip, cond, Math.Ceiling( ( cond - 49 ) / 3.0 ) ) );
					return FleetStates.Sparkled;

				}

			}

			//出撃可能!
			{
				label.Text = FleetRes.ReadyToSortie;
				label.ImageIndex = (int)ResourceManager.IconContent.FleetReady;

				return FleetStates.Ready;
			}

		}
Example #7
0
        /// <summary>
        /// 索敵能力を求めます。「2-5式」です。
        /// </summary>
        /// <param name="fleet">対象の艦隊。</param>
        public static int GetSearchingAbility_Old( FleetData fleet )
        {
            KCDatabase db = KCDatabase.Instance;

            int los_reconplane = 0;
            int los_radar = 0;
            int los_other = 0;

            foreach ( var ship in fleet.MembersWithoutEscaped ) {

                if ( ship == null )
                    continue;

                los_other += ship.LOSBase;

                var slot = ship.SlotInstanceMaster;

                for ( int j = 0; j < slot.Count; j++ ) {

                    if ( slot[j] == null ) continue;

                    switch ( slot[j].EquipmentType[2] ) {
                        case 9:		//艦偵
                        case 10:	//水偵
                        case 11:	//水爆
                            if ( ship.Aircraft[j] > 0 )
                                los_reconplane += slot[j].LOS * 2;
                            break;

                        case 12:	//小型電探
                        case 13:	//大型電探
                            los_radar += slot[j].LOS;
                            break;

                        default:
                            los_other += slot[j].LOS;
                            break;
                    }
                }
            }

            return (int)Math.Sqrt( los_other ) + los_radar + los_reconplane;
        }
Example #8
0
 /// <summary>
 /// 制空戦力を求めます。
 /// </summary>
 /// <param name="fleet">対象の艦隊。</param>
 public static int GetAirSuperiority( FleetData fleet )
 {
     return fleet.MembersWithoutEscaped.Select( ship => GetAirSuperiority( ship ) ).Sum();
 }
        /// <summary>
        /// 制空戦力を求めます。
        /// </summary>
        /// <param name="fleet">対象の艦隊。</param>
        public static int GetAirSuperiority( FleetData fleet )
        {
            int air = 0;

            foreach ( var ship in fleet.MembersWithoutEscaped ) {
                if ( ship == null ) continue;

                air += GetAirSuperiority( ship );
            }

            return air;
        }
        private string[] GetDamagedShips( FleetData fleet, int[] hps )
        {
            LinkedList<string> list = new LinkedList<string>();

            for ( int i = 0; i < fleet.Members.Count; i++ ) {

                if ( i == 0 && !ContainsFlagship ) continue;

                ShipData s = fleet.MembersInstance[i];

                if ( s != null && !fleet.EscapedShipList.Contains( s.MasterID ) &&
                    IsShipDamaged( s, hps[i] ) ) {

                    list.AddLast( string.Format( "{0} ({1}/{2})", s.NameWithLevel, hps[i], s.HPMax ) );
                }
            }

            return list.ToArray();
        }
Example #11
0
            public void Update( FleetData fleet )
            {
                KCDatabase db = KCDatabase.Instance;

                if ( fleet == null ) return;

                Name.Text = fleet.Name;
                {
                    int levelSum = fleet.MembersInstance.Sum( s => s != null ? s.Level : 0 );

                    int fueltotal = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.FuelMax * ( s.IsMarried ? 0.85 : 1.00 ) ) );
                    int ammototal = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.AmmoMax * ( s.IsMarried ? 0.85 : 1.00 ) ) );

                    int fuelunit = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.MasterShip.Fuel * 0.2 * ( s.IsMarried ? 0.85 : 1.00 ) ) );
                    int ammounit = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.MasterShip.Ammo * 0.2 * ( s.IsMarried ? 0.85 : 1.00 ) ) );

                    int speed = fleet.MembersWithoutEscaped.Min( s => s == null ? 10 : s.MasterShip.Speed );
                    ToolTipInfo.SetToolTip( Name, string.Format(
                        "Lv合計: {0} / 平均: {1:0.00}\r\n{2}艦隊\r\nドラム缶搭載: {3}個 ({4}艦)\r\n大発動艇搭載: {5}個\r\n総積載: 燃 {6} / 弾 {7}\r\n(1戦当たり 燃 {8} / 弾 {9})",
                        levelSum,
                        (double)levelSum / Math.Max( fleet.Members.Count( id => id != -1 ), 1 ),
                        Constants.GetSpeed( speed ),
                        fleet.MembersInstance.Sum( s => s == null ? 0 : s.SlotInstanceMaster.Count( q => q == null ? false : q.CategoryType == 30 ) ),
                        fleet.MembersInstance.Count( s => s == null ? false : s.SlotInstanceMaster.Count( q => q == null ? false : q.CategoryType == 30 ) > 0 ),
                        fleet.MembersInstance.Sum( s => s == null ? 0 : s.SlotInstanceMaster.Count( q => q == null ? false : q.CategoryType == 24 ) ),
                        fueltotal,
                        ammototal,
                        fuelunit,
                        ammounit
                        ) );

                }

                State = FleetData.UpdateFleetState( fleet, StateMain, ToolTipInfo, State, ref Timer );

                //制空戦力計算
                {
                    int airSuperiority = fleet.GetAirSuperiority();
                    AirSuperiority.Text = airSuperiority.ToString();
                    ToolTipInfo.SetToolTip( AirSuperiority,
                        string.Format( "確保: {0}\r\n優勢: {1}\r\n均衡: {2}\r\n劣勢: {3}\r\n",
                        (int)( airSuperiority / 3.0 ),
                        (int)( airSuperiority / 1.5 ),
                        (int)( airSuperiority * 1.5 - 1 ),
                        (int)( airSuperiority * 3.0 - 1 ) ) );
                }

                //索敵能力計算
                SearchingAbility.Text = fleet.GetSearchingAbilityString();
                {
                    StringBuilder sb = new StringBuilder();
                    double probStart = fleet.GetContactProbability();
                    var probSelect = fleet.GetContactSelectionProbability();

                    sb.AppendFormat("(旧)2-5式: {0}\r\n2-5式(秋): {1}\r\n2-5新秋簡易式: {2}\r\n\r\n触接開始率: \r\n 確保 {3:p1} / 優勢 {4:p1}\r\n",
                        fleet.GetSearchingAbilityString( 0 ),
                        fleet.GetSearchingAbilityString( 1 ),
                        fleet.GetSearchingAbilityString( 2 ),
                        probStart,
                        probStart * 0.6 );

                    if ( probSelect.Count > 0 ) {
                        sb.AppendLine( "触接選択率: " );

                        foreach ( var p in probSelect.OrderBy( p => p.Key ) ) {
                            sb.AppendFormat( " 命中{0} : {1:p1}\r\n", p.Key, p.Value );
                        }
                    }

                    ToolTipInfo.SetToolTip( SearchingAbility, sb.ToString() );
                }
            }
Example #12
0
        /// <summary>
        /// 艦隊の状態の情報をラベルに適用します。
        /// </summary>
        /// <param name="fleet">艦隊データ。</param>
        /// <param name="label">適用するラベル。</param>
        /// <param name="tooltip">適用するツールチップ。</param>
        /// <param name="prevstate">前回の状態。</param>
        /// <param name="timer">日時。</param>
        /// <returns>艦隊の状態を表す定数。</returns>
        public static FleetStates UpdateFleetState( FleetData fleet, ImageLabel label, ToolTip tooltip, FleetStates prevstate, ref DateTime timer )
        {
            KCDatabase db = KCDatabase.Instance;

            //初期化
            tooltip.SetToolTip( label, null );
            label.BackColor = Color.Transparent;

            //所属艦なし
            if ( fleet == null || fleet.Members.Count( id => id != -1 ) == 0 ) {
                label.Text = FleetRes.NoShips;
                label.ImageIndex = (int)ResourceManager.IconContent.FleetNoShip;

                return FleetStates.NoShip;
            }

            {	//入渠中
                long ntime = db.Docks.Values.Max(
                        dock => {
                            if ( dock.State == 1 && fleet.Members.Count( ( id => id == dock.ShipID ) ) > 0 )
                                return dock.CompletionTime.Ticks;
                            else return 0;
                        }
                        );

                if ( ntime > 0 ) {	//入渠中

                    timer = new DateTime( ntime );
                    label.Text = FleetRes.Docking + DateTimeHelper.ToTimeRemainString( timer );
                    label.ImageIndex = (int)ResourceManager.IconContent.FleetDocking;

                    tooltip.SetToolTip( label, FleetRes.CompletionTime + ": " + timer );

                    return FleetStates.Docking;
                }

            }

            if ( fleet.IsInSortie ) {

                //大破出撃中
                if ( fleet.MembersInstance.Count( s =>
                        ( s != null && !fleet.EscapedShipList.Contains( s.MasterID ) && (double)s.HPCurrent / s.HPMax <= 0.25 )
                     ) > 0 ) {

                    label.Text = FleetRes.CriticalDamageAdvance;
                    label.ImageIndex = (int)ResourceManager.IconContent.FleetSortieDamaged;

                    return FleetStates.SortieDamaged;

                } else {	//出撃中

                    label.Text = FleetRes.OnSortie;
                    label.ImageIndex = (int)ResourceManager.IconContent.FleetSortie;

                    return FleetStates.Sortie;
                }

            }

            //遠征中
            if ( fleet.ExpeditionState != 0 ) {

                timer = fleet.ExpeditionTime;
                label.Text = FleetRes.OnExped + DateTimeHelper.ToTimeRemainString( timer );
                label.ImageIndex = (int)ResourceManager.IconContent.FleetExpedition;

                tooltip.SetToolTip( label, string.Format( "{0} : {1}\r\n" + FleetRes.CompletionTime + " : {2}", KCDatabase.Instance.Mission[fleet.ExpeditionDestination].ID, KCDatabase.Instance.Mission[fleet.ExpeditionDestination].Name, timer ) );

                return FleetStates.Expedition;
            }

            //大破艦あり
            if ( fleet.MembersInstance.Count( s =>
                ( s != null && !fleet.EscapedShipList.Contains( s.MasterID ) && (double)s.HPCurrent / s.HPMax <= 0.25 )
             ) > 0 ) {

                label.Text = FleetRes.CriticallyDamagedShip;
                label.ImageIndex = (int)ResourceManager.IconContent.FleetDamaged;
                //label.BackColor = Color.LightCoral;

                return FleetStates.Damaged;
            }

            //泊地修理中
            {
                if ( fleet.IsAnchorageRepairing ) {

                    label.Text = FleetRes.AnchorageRepairing + DateTimeHelper.ToTimeElapsedString( KCDatabase.Instance.Fleet.AnchorageRepairingTimer );
                    label.ImageIndex = (int)ResourceManager.IconContent.FleetAnchorageRepairing;

                    tooltip.SetToolTip( label, string.Format( FleetRes.StartTime + ": {0}", KCDatabase.Instance.Fleet.AnchorageRepairingTimer ) );

                    return FleetStates.AnchorageRepairing;
                }
            }

            //未補給
            {
                int fuel = fleet.MembersInstance.Sum( ship => ship == null ? 0 : (int)( ( ship.MasterShip.Fuel - ship.Fuel ) * ( ship.IsMarried ? 0.85 : 1.00 ) ) );
                int ammo = fleet.MembersInstance.Sum( ship => ship == null ? 0 : (int)( ( ship.MasterShip.Ammo - ship.Ammo ) * ( ship.IsMarried ? 0.85 : 1.00 ) ) );
                int aircraft = fleet.MembersInstance.Sum(
                    ship => {
                        if ( ship == null ) return 0;
                        else {
                            int c = 0;
                            for ( int i = 0; i < ship.Slot.Count; i++ ) {
                                c += ship.MasterShip.Aircraft[i] - ship.Aircraft[i];
                            }
                            return c;
                        }
                    } );
                int bauxite = aircraft * 5;

                if ( fuel > 0 || ammo > 0 || bauxite > 0 ) {

                    label.Text = FleetRes.SupplyNeeded;
                    label.ImageIndex = (int)ResourceManager.IconContent.FleetNotReplenished;

                    tooltip.SetToolTip( label, string.Format( FleetRes.ResupplyTooltip, fuel, ammo, bauxite, aircraft ) );

                    return FleetStates.NotReplenished;
                }
            }

            //疲労
            {
                int cond = fleet.MembersInstance.Min( s => s == null ? 100 : s.Condition );

                if ( cond < Configuration.Config.Control.ConditionBorder && fleet.ConditionTime != null ) {

                    timer = (DateTime)fleet.ConditionTime;

                    label.Text = FleetRes.Fatigued + DateTimeHelper.ToTimeRemainString( timer );

                    if ( cond < 20 )
                        label.ImageIndex = (int)ResourceManager.IconContent.ConditionVeryTired;
                    else if ( cond < 30 )
                        label.ImageIndex = (int)ResourceManager.IconContent.ConditionTired;
                    else
                        label.ImageIndex = (int)ResourceManager.IconContent.ConditionLittleTired;

                    tooltip.SetToolTip( label, string.Format( FleetRes.EstimatedRecoveryTime + ": {0}", timer ) );

                    return FleetStates.Tired;

                } else if ( cond >= 50 ) {		//戦意高揚

                    label.Text = FleetRes.FightingSpiritHigh;
                    label.ImageIndex = (int)ResourceManager.IconContent.ConditionSparkle;
                    tooltip.SetToolTip( label, string.Format( FleetRes.SparkledTooltip, cond, Math.Ceiling( ( cond - 49 ) / 3.0 ) ) );
                    return FleetStates.Sparkled;

                }

            }

            //出撃可能!
            {
                label.Text = FleetRes.ReadyToSortie;
                label.ImageIndex = (int)ResourceManager.IconContent.FleetReady;

                return FleetStates.Ready;
            }
        }
Example #13
0
		/// <summary>
		/// 艦隊の状態の情報をラベルに適用します。
		/// </summary>
		/// <param name="fleet">艦隊データ。</param>
		/// <param name="label">適用するラベル。</param>
		/// <param name="tooltip">適用するツールチップ。</param>
		/// <param name="prevstate">前回の状態。</param>
		/// <param name="timer">日時。</param>
		/// <returns>艦隊の状態を表す定数。</returns>
		public static FleetStates UpdateFleetState( FleetData fleet, ImageLabel label, ToolTip tooltip, FleetStates prevstate, ref DateTime timer ) {

			KCDatabase db = KCDatabase.Instance;


			//初期化
			tooltip.SetToolTip( label, null );
			label.BackColor = Color.Transparent;



			//所属艦なし
			if ( fleet == null || fleet.Members.Count( id => id != -1 ) == 0 ) {
				label.Text = "所属艦なし";
				label.ImageIndex = (int)ResourceManager.IconContent.FleetNoShip;

				return FleetStates.NoShip;
			}

			// その他の状態は設定した順番に判定
			foreach ( var key in Configuration.Config.FormFleetPlus.FleetIconOrder.List ) {
				var result = fleetStateFuncs[(int)key]( fleet, label, tooltip, prevstate );
				if (result != null ) {
					if ( result.Item2 != null ) {
						timer = result.Item2.Value;
					}
					return result.Item1;
				}
			}

			//出撃可能!
			{
				label.Text = "出撃可能!";
				label.ImageIndex = (int)ResourceManager.IconContent.FleetReady;

				return FleetStates.Ready;
			}

		}
        /// <summary>
        /// 艦隊の状態の情報をラベルに適用します。
        /// </summary>
        /// <param name="fleet">艦隊データ。</param>
        /// <param name="label">適用するラベル。</param>
        /// <param name="tooltip">適用するツールチップ。</param>
        /// <param name="prevstate">前回の状態。</param>
        /// <param name="timer">日時。</param>
        /// <returns>艦隊の状態を表す定数。</returns>
        public static FleetStates UpdateFleetState( FleetData fleet, ImageLabel label, ToolTip tooltip, FleetStates prevstate, ref DateTime timer )
        {
            KCDatabase db = KCDatabase.Instance;

            //初期化
            tooltip.SetToolTip( label, null );
            label.BackColor = Color.Transparent;

            //所属艦なし
            if ( fleet == null || fleet.Members.Count( id => id != -1 ) == 0 ) {
                label.Text = "所属艦なし";
                label.ImageIndex = (int)ResourceManager.IconContent.FleetNoShip;

                return FleetStates.NoShip;
            }

            {	//入渠中
                long ntime = db.Docks.Values.Max(
                        dock => {
                            if ( dock.State == 1 && fleet.Members.Count( ( id => id == dock.ShipID ) ) > 0 )
                                return dock.CompletionTime.Ticks;
                            else return 0;
                        }
                        );

                if ( ntime > 0 ) {	//入渠中

                    timer = new DateTime( ntime );
                    label.Text = "入渠中 " + DateTimeHelper.ToTimeRemainString( timer );
                    label.ImageIndex = (int)ResourceManager.IconContent.FleetDocking;

                    tooltip.SetToolTip( label, "完了日時 : " + DateTimeHelper.TimeToCSVString( timer ) );

                    return FleetStates.Docking;
                }

            }

            if ( fleet.IsInSortie ) {

                //大破出撃中
                if ( fleet.MembersInstance.Count( s =>
                        ( s != null && !fleet.EscapedShipList.Contains( s.MasterID ) && (double)s.HPCurrent / s.HPMax <= 0.25 )
                     ) > 0 ) {

                    label.Text = "!!大破進撃中!!";
                    label.ImageIndex = (int)ResourceManager.IconContent.FleetSortieDamaged;

                    return FleetStates.SortieDamaged;

                } else {	//出撃中

                    label.Text = "出撃中";
                    label.ImageIndex = (int)ResourceManager.IconContent.FleetSortie;

                    return FleetStates.Sortie;
                }

            }

            //遠征中
            if ( fleet.ExpeditionState != 0 ) {

                timer = fleet.ExpeditionTime;
                label.Text = "遠征中 " + DateTimeHelper.ToTimeRemainString( timer );
                label.ImageIndex = (int)ResourceManager.IconContent.FleetExpedition;

                tooltip.SetToolTip( label, string.Format( "{0} : {1}\r\n完了日時 : {2}",
                    KCDatabase.Instance.Mission[fleet.ExpeditionDestination].ID,
                    KCDatabase.Instance.Mission[fleet.ExpeditionDestination].Name,
                    DateTimeHelper.TimeToCSVString( timer ) ) );

                return FleetStates.Expedition;
            }

            //大破艦あり
            if ( fleet.MembersInstance.Count( s =>
                ( s != null && !fleet.EscapedShipList.Contains( s.MasterID ) && (double)s.HPCurrent / s.HPMax <= 0.25 )
             ) > 0 ) {

                label.Text = "大破艦あり!";
                label.ImageIndex = (int)ResourceManager.IconContent.FleetDamaged;
                //label.BackColor = Color.LightCoral;

                return FleetStates.Damaged;
            }

            //泊地修理中
            {
                if ( fleet.CanAnchorageRepairing &&
                    fleet.MembersInstance.Take( 2 + KCDatabase.Instance.Ships[fleet[0]].SlotInstanceMaster.Count( eq => eq != null && eq.CategoryType == 31 ) )
                    .Any( s => s != null && s.HPRate < 1.0 && s.HPRate > 0.5 && s.RepairingDockID == -1 ) ) {

                    label.Text = "泊地修理中 " + DateTimeHelper.ToTimeElapsedString( KCDatabase.Instance.Fleet.AnchorageRepairingTimer );
                    label.ImageIndex = (int)ResourceManager.IconContent.FleetAnchorageRepairing;

                    tooltip.SetToolTip( label, string.Format( "開始日時 : {0}",
                        DateTimeHelper.TimeToCSVString( KCDatabase.Instance.Fleet.AnchorageRepairingTimer ) ) );

                    return FleetStates.AnchorageRepairing;
                }
            }

            //未補給
            {
                int fuel = fleet.MembersInstance.Sum( ship => ship == null ? 0 : (int)( ( ship.FuelMax - ship.Fuel ) * ( ship.IsMarried ? 0.85 : 1.00 ) ) );
                int ammo = fleet.MembersInstance.Sum( ship => ship == null ? 0 : (int)( ( ship.AmmoMax - ship.Ammo ) * ( ship.IsMarried ? 0.85 : 1.00 ) ) );
                int aircraft = fleet.MembersInstance.Sum(
                    ship => {
                        if ( ship == null ) return 0;
                        else {
                            int c = 0;
                            for ( int i = 0; i < ship.Slot.Count; i++ ) {
                                c += ship.MasterShip.Aircraft[i] - ship.Aircraft[i];
                            }
                            return c;
                        }
                    } );
                int bauxite = aircraft * 5;

                if ( fuel > 0 || ammo > 0 || bauxite > 0 ) {

                    label.Text = "未補給";
                    label.ImageIndex = (int)ResourceManager.IconContent.FleetNotReplenished;

                    tooltip.SetToolTip( label, string.Format( "燃 : {0}\r\n弾 : {1}\r\nボ : {2} ({3}機)", fuel, ammo, bauxite, aircraft ) );

                    return FleetStates.NotReplenished;
                }
            }

            //疲労
            {
                int cond = fleet.MembersInstance.Min( s => s == null ? 100 : s.Condition );

                if ( cond < Configuration.Config.Control.ConditionBorder && fleet.ConditionTime != null ) {

                    timer = (DateTime)fleet.ConditionTime;

                    label.Text = "疲労 " + DateTimeHelper.ToTimeRemainString( timer );

                    if ( cond < 20 )
                        label.ImageIndex = (int)ResourceManager.IconContent.ConditionVeryTired;
                    else if ( cond < 30 )
                        label.ImageIndex = (int)ResourceManager.IconContent.ConditionTired;
                    else
                        label.ImageIndex = (int)ResourceManager.IconContent.ConditionLittleTired;

                    tooltip.SetToolTip( label, string.Format( "回復目安日時: {0}", DateTimeHelper.TimeToCSVString( timer ) ) );

                    return FleetStates.Tired;

                } else if ( cond >= 50 ) {		//戦意高揚

                    label.Text = "戦意高揚!";
                    label.ImageIndex = (int)ResourceManager.IconContent.ConditionSparkle;
                    tooltip.SetToolTip( label, string.Format( "最低cond: {0}\r\nあと {1} 回遠征可能", cond, Math.Ceiling( ( cond - 49 ) / 3.0 ) ) );
                    return FleetStates.Sparkled;

                }

            }

            //出撃可能!
            {
                label.Text = "出撃可能!";
                label.ImageIndex = (int)ResourceManager.IconContent.FleetReady;

                return FleetStates.Ready;
            }
        }
Example #15
0
            public void Update( FleetData fleet )
            {
                KCDatabase db = KCDatabase.Instance;

                if ( fleet == null ) return;

                Name.Text = fleet.Name;
                {
                    int levelSum = fleet.MembersInstance.Sum( s => s != null ? s.Level : 0 );

                    int fueltotal = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.FuelMax * ( s.IsMarried ? 0.85 : 1.00 ) ) );
                    int ammototal = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.AmmoMax * ( s.IsMarried ? 0.85 : 1.00 ) ) );

                    int fuelunit = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.MasterShip.Fuel * 0.2 * ( s.IsMarried ? 0.85 : 1.00 ) ) );
                    int ammounit = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.MasterShip.Ammo * 0.2 * ( s.IsMarried ? 0.85 : 1.00 ) ) );

                    int speed = fleet.MembersWithoutEscaped.Min( s => s == null ? 10 : s.MasterShip.Speed );
                    ToolTipInfo.SetToolTip( Name, string.Format(
                        "Lv合計: {0} / 平均: {1:0.00}\r\n{2}艦隊\r\nドラム缶搭載: {3}個 ({4}艦)\r\n大発動艇搭載: {5}個\r\n総積載: 燃 {6} / 弾 {7}\r\n(1戦当たり 燃 {8} / 弾 {9})",
                        levelSum,
                        (double)levelSum / Math.Max( fleet.Members.Count( id => id != -1 ), 1 ),
                        Constants.GetSpeed( speed ),
                        fleet.MembersInstance.Sum( s => s == null ? 0 : s.SlotInstanceMaster.Count( q => q == null ? false : q.CategoryType == 30 ) ),
                        fleet.MembersInstance.Count( s => s == null ? false : s.SlotInstanceMaster.Count( q => q == null ? false : q.CategoryType == 30 ) > 0 ),
                        fleet.MembersInstance.Sum( s => s == null ? 0 : s.SlotInstanceMaster.Count( q => q == null ? false : q.CategoryType == 24 ) ),
                        fueltotal,
                        ammototal,
                        fuelunit,
                        ammounit
                        ) );

                }

                State = FleetData.UpdateFleetState( fleet, StateMain, ToolTipInfo, State, ref Timer );

                //制空戦力計算
                {
                    int airSuperiority = fleet.GetAirSuperiority();
                    AirSuperiority.Text = airSuperiority.ToString();
                    ToolTipInfo.SetToolTip( AirSuperiority,
                        string.Format( "確保: {0}\r\n優勢: {1}\r\n均衡: {2}\r\n劣勢: {3}\r\n",
                        (int)( airSuperiority / 3.0 ),
                        (int)( airSuperiority / 1.5 ),
                        (int)( airSuperiority * 1.5 - 1 ),
                        (int)( airSuperiority * 3.0 - 1 ) ) );
                }

                //索敵能力計算
                SearchingAbility.Text = fleet.GetSearchingAbilityString();
                ToolTipInfo.SetToolTip( SearchingAbility,
                    string.Format( "(旧)2-5式: {0}\r\n2-5式(秋): {1}\r\n2-5新秋簡易式: {2}\r\n",
                    fleet.GetSearchingAbilityString( 0 ),
                    fleet.GetSearchingAbilityString( 1 ),
                    fleet.GetSearchingAbilityString( 2 ) ) );
            }
Example #16
0
            public void Update( FleetData fleet )
            {
                KCDatabase db = KCDatabase.Instance;

                if ( fleet == null ) return;

                Name.Text = fleet.Name;
                {
                    int levelSum = fleet.MembersInstance.Sum( s => s != null ? s.Level : 0 );

                    int fueltotal = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.FuelMax * ( s.IsMarried ? 0.85 : 1.00 ) ) );
                    int ammototal = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.AmmoMax * ( s.IsMarried ? 0.85 : 1.00 ) ) );

                    int fuelunit = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.MasterShip.Fuel * 0.2 * ( s.IsMarried ? 0.85 : 1.00 ) ) );
                    int ammounit = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.MasterShip.Ammo * 0.2 * ( s.IsMarried ? 0.85 : 1.00 ) ) );

                    int speed = fleet.MembersWithoutEscaped.Min( s => s == null ? 10 : s.MasterShip.Speed );

                    var slots = fleet.MembersWithoutEscaped
                        .Where( s => s != null )
                        .SelectMany( s => s.SlotInstance )
                        .Where( e => e != null );
                    var daihatsu = slots.Where( e => e.EquipmentID == 68 );
                    var daihatsu_tank = slots.Where( e => e.EquipmentID == 166 );
                    var landattacker = slots.Where( e => e.EquipmentID == 167 );
                    double expeditionBonus = Math.Min( daihatsu.Count() * 0.05 + daihatsu_tank.Count() * 0.02 + landattacker.Count() * 0.01, 0.20 );

                    ToolTipInfo.SetToolTip( Name, string.Format(
                        "Lv合計: {0} / 平均: {1:0.00}\r\n{2}艦隊\r\nドラム缶搭載: {3}個 ({4}艦)\r\n大発動艇搭載: {5}個 ({6}艦, +{7:p1})\r\n総積載: 燃 {8} / 弾 {9}\r\n(1戦当たり 燃 {10} / 弾 {11})",
                        levelSum,
                        (double)levelSum / Math.Max( fleet.Members.Count( id => id != -1 ), 1 ),
                        Constants.GetSpeed( speed ),
                        fleet.MembersInstance.Sum( s => s == null ? 0 : s.SlotInstanceMaster.Count( q => q == null ? false : q.CategoryType == 30 ) ),
                        fleet.MembersInstance.Count( s => s == null ? false : s.SlotInstanceMaster.Any( q => q == null ? false : q.CategoryType == 30 ) ),
                        daihatsu.Count() + daihatsu_tank.Count() + landattacker.Count(),
                        fleet.MembersInstance.Count( s => s == null ? false : s.SlotInstanceMaster.Any( q => q == null ? false : q.CategoryType == 24 || q.CategoryType == 46 ) ),
                        expeditionBonus + 0.01 * expeditionBonus * ( daihatsu.Sum( e => e.Level ) + daihatsu_tank.Sum( e => e.Level ) + landattacker.Sum( e => e.Level ) ) / Math.Max( daihatsu.Count() + daihatsu_tank.Count() + landattacker.Count(), 1 ),
                        fueltotal,
                        ammototal,
                        fuelunit,
                        ammounit
                        ) );

                }

                State = FleetData.UpdateFleetState( fleet, StateMain, ToolTipInfo, State, ref Timer );

                var config = Utility.Configuration.Config.FormFleetPlus.FleetsInfoIcon[FleetID - 1];

                //制空戦力計算
                {
                    int airSuperiority = fleet.GetAirSuperiority();
                    AirSuperiority.Text = airSuperiority.ToString();
                    ToolTipInfo.SetToolTip( AirSuperiority,
                        string.Format( "確保: {0}\r\n優勢: {1}\r\n均衡: {2}\r\n劣勢: {3}\r\n",
                        (int)( airSuperiority / 3.0 ),
                        (int)( airSuperiority / 1.5 ),
                        (int)( airSuperiority * 1.5 - 1 ),
                        (int)( airSuperiority * 3.0 - 1 ) ) );
                    AirSuperiority.Visible = config[0];
                }

                //索敵能力計算
                SearchingAbility.Text = fleet.GetSearchingAbilityString();
                {
                    StringBuilder sb = new StringBuilder();
                    double probStart = fleet.GetContactProbability();
                    var probSelect = fleet.GetContactSelectionProbability();

                    sb.AppendFormat( "(旧)2-5式: {0}\r\n2-5式(秋): {1}\r\n2-5新秋簡易式: {2}\r\n判定式(33): {3}\r\n\r\n触接開始率: \r\n 確保 {4:p1} / 優勢 {5:p1}\r\n",
                        fleet.GetSearchingAbilityString( 0 ),
                        fleet.GetSearchingAbilityString( 1 ),
                        fleet.GetSearchingAbilityString( 2 ),
                        fleet.GetSearchingAbilityString( 3 ),
                        probStart,
                        probStart * 0.6 );

                    if ( probSelect.Count > 0 ) {
                        sb.AppendLine( "触接選択率: " );

                        foreach ( var p in probSelect.OrderBy( p => p.Key ) ) {
                            sb.AppendFormat( " 命中{0} : {1:p1}\r\n", p.Key, p.Value );
                        }
                    }

                    ToolTipInfo.SetToolTip( SearchingAbility, sb.ToString() );
                }
                SearchingAbility.Visible = config[1];

                int drumTotal = fleet.MembersInstance.Sum( s => s?.SlotInstanceMaster.Count( q => q?.CategoryType == 30 ) ?? 0 );
                int drumShipTotal = fleet.MembersInstance.Count( s => s?.SlotInstanceMaster.Any( q => q?.CategoryType == 30 ) ?? false );
                DrumCanister.Text = $"{drumTotal}/{drumShipTotal}";
                DrumCanister.Visible = config[2];

                int landingCraftTotal = fleet.MembersInstance.Sum(s => s?.SlotInstanceMaster.Count(q => q?.CategoryType == 24) ?? 0);
                LandingCraft.Text = $"{landingCraftTotal}";
                LandingCraft.Visible = config[3];

                if ( ConditionSparkle.Visible = config[4] ) {
                    var sparkleShipCount = fleet.MembersInstance.Count(s => s?.Condition > 50);
                    if ( sparkleShipCount == 6 ) {
                        // 全艦キラ
                        var minCond = fleet.MembersInstance.Min(s => s.Condition);
                        ConditionSparkle.Text = $"{Math.Ceiling((minCond - 49.0) / 3.0)}";
                        ConditionSparkle.ForeColor = Color.Black;
                    } else if ( sparkleShipCount >= 4 ) {
                        // 4隻以上キラ
                        var minCond = fleet.MembersInstance.Where(s => s?.Condition > 50).Min(s => s.Condition);
                        ConditionSparkle.Text = $"{Math.Ceiling((minCond - 49.0) / 3.0)}";
                        ConditionSparkle.ForeColor = Color.Red;
                    } else {
                        // キラ3隻以下
                        ConditionSparkle.Text = "0";
                        ConditionSparkle.ForeColor = Color.Red;
                }
                }
            }
Example #17
0
            public void Update( FleetData fleet )
            {
                KCDatabase db = KCDatabase.Instance;

                if ( fleet == null ) return;

                Name.Text = fleet.Name;
                {
                    int levelSum = fleet.MembersInstance.Sum( s => s != null ? s.Level : 0 );
                    int fueltotal = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)( s.MasterShip.Fuel * ( s.IsMarried ? 0.85 : 1.00 ) ) );
                    int ammototal = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)( s.MasterShip.Ammo * ( s.IsMarried ? 0.85 : 1.00 ) ) );
                    int speed = fleet.MembersWithoutEscaped.Min( s => s == null ? 10 : s.MasterShip.Speed );
                    ToolTipInfo.SetToolTip(Name, string.Format(
                        GeneralRes.FleetTooltip,
                        levelSum,
                        (double)levelSum / Math.Max( fleet.Members.Count( id => id != -1 ), 1 ),
                        Constants.GetSpeed( speed ),
                        fleet.MembersInstance.Sum( s => s == null ? 0 : s.SlotInstanceMaster.Count( q => q == null ? false : q.CategoryType == 30 ) ),
                        fleet.MembersInstance.Count( s => s == null ? false : s.SlotInstanceMaster.Count( q => q == null ? false : q.CategoryType == 30 ) > 0 ),
                        fleet.MembersInstance.Sum( s => s == null ? 0 : s.SlotInstanceMaster.Count( q => q == null ? false : q.CategoryType == 24 ) ),
                        fueltotal,
                        ammototal,
                        (int)( fueltotal * 0.2 ),
                        (int)( ammototal * 0.2 )
                        ) );

                }

                State = FleetData.UpdateFleetState( fleet, StateMain, ToolTipInfo, State, ref Timer );

                //制空戦力計算
                {
                    int airSuperiority = fleet.GetAirSuperiority();
                    AirSuperiority.Text = airSuperiority.ToString();
                    ToolTipInfo.SetToolTip( AirSuperiority,
                        string.Format( GeneralRes.ASTooltip,
                        (int)( airSuperiority / 3.0 ),
                        (int)( airSuperiority / 1.5 ),
                        (int)( airSuperiority * 1.5 ),
                        (int)( airSuperiority * 3.0 ) ) );
                }

                //索敵能力計算
                SearchingAbility.Text = fleet.GetSearchingAbilityString();
                ToolTipInfo.SetToolTip( SearchingAbility,
                    string.Format( GeneralRes.LoSTooltip,
                    fleet.GetSearchingAbilityString( 0 ),
                    fleet.GetSearchingAbilityString( 1 ),
                    fleet.GetSearchingAbilityString( 2 ) ) );
            }
Example #18
0
        /// <summary>
        /// 索敵能力を求めます。「2-5式(秋)」です。
        /// </summary>
        /// <param name="fleet">対象の艦隊。</param>
        public static double GetSearchingAbility_Autumn( FleetData fleet )
        {
            double ret = 0.0;

            foreach ( var ship in fleet.MembersWithoutEscaped ) {
                if ( ship == null ) continue;

                ret += Math.Sqrt( ship.LOSBase ) * 1.6841056;

                foreach ( var eq in ship.SlotInstanceMaster ) {
                    if ( eq == null ) continue;

                    switch ( eq.CategoryType ) {

                        case 7:		//艦爆
                            ret += eq.LOS * 1.0376255; break;

                        case 8:		//艦攻
                            ret += eq.LOS * 1.3677954; break;

                        case 9:		//艦偵
                            ret += eq.LOS * 1.6592780; break;

                        case 10:	//水偵
                            ret += eq.LOS * 2.0000000; break;

                        case 11:	//水爆
                            ret += eq.LOS * 1.7787282; break;

                        case 12:	//小型電探
                            ret += eq.LOS * 1.0045358; break;

                        case 13:	//大型電探
                            ret += eq.LOS * 0.9906638; break;

                        case 29:	//探照灯
                            ret += eq.LOS * 0.9067950; break;

                    }
                }
            }

            ret -= Math.Ceiling( KCDatabase.Instance.Admiral.Level / 5.0 ) * 5.0 * 0.6142467;

            return Math.Round( ret, 1 );
        }
Example #19
0
		public Tuple<int, String> Predict(FleetData f)
		{
			if (f?.MembersInstance?[0] == null // 0隻
				|| f.IsInSortie // 出撃中
				)
			{
				// 現在、遠征に出せない
				return new Tuple<int, string>(-1, "遠征に出せません");
			}
			else if (!Requirements.All(c => c.Predicate(f)))
			{
				// 失敗
				return new Tuple<int, string>(0,
					Requirements
						.Where(c => !(c.Predicate(f)))
						.Select(c => c.Description)
						.Aggregate((s1, s2) => s1 + Environment.NewLine + s2));
			}
			else if (!GreatSuccessRequirements.All(c => c.Predicate(f)))
			{
				// 成功
				return new Tuple<int, string>(1,
					GreatSuccessRequirements
						.Where(c => !(c.Predicate(f)))
						.Select(c => c.Description)
						.Aggregate((s1, s2) => s1 + Environment.NewLine + s2));
			}
			else
			{
				// 大成功
				return new Tuple<int, string>(2, "");
			}
		}
Example #20
0
        /// <summary>
        /// 索敵能力を求めます。「2-5式(秋)簡易式」です。
        /// </summary>
        /// <param name="fleet">対象の艦隊。</param>
        public static double GetSearchingAbility_TinyAutumn( FleetData fleet )
        {
            double ret = 0.0;

            foreach ( var ship in fleet.MembersWithoutEscaped ) {
                if ( ship == null ) continue;

                double cur = Math.Sqrt( ship.LOSBase );

                foreach ( var eq in ship.SlotInstanceMaster ) {
                    if ( eq == null ) continue;

                    switch ( eq.CategoryType ) {

                        case 7:		//艦爆
                            cur += eq.LOS * 0.6; break;

                        case 8:		//艦攻
                            cur += eq.LOS * 0.8; break;

                        case 9:		//艦偵
                            cur += eq.LOS * 1.0; break;

                        case 10:	//水偵
                            cur += eq.LOS * 1.2; break;

                        case 11:	//水爆
                            cur += eq.LOS * 1.0; break;

                        case 12:	//小型電探
                            cur += eq.LOS * 0.6; break;

                        case 13:	//大型電探
                            cur += eq.LOS * 0.6; break;

                        case 29:	//探照灯
                            cur += eq.LOS * 0.5; break;

                        default:	//その他
                            cur += eq.LOS * 0.5; break;
                    }
                }

                ret += Math.Floor( cur );
            }

            ret -= Math.Floor( KCDatabase.Instance.Admiral.Level * 0.4 );

            return Math.Round( ret, 1 );
        }
Example #21
0
			public void Update( FleetData fleet ) {

				KCDatabase db = KCDatabase.Instance;

				if ( fleet == null ) return;



				Name.Text = fleet.Name;
				{
					int levelSum = fleet.MembersInstance.Sum( s => s != null ? s.Level : 0 );

					int fueltotal = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.FuelMax * ( s.IsMarried ? 0.85 : 1.00 ) ) );
					int ammototal = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.AmmoMax * ( s.IsMarried ? 0.85 : 1.00 ) ) );

					int fuelunit = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.MasterShip.Fuel * 0.2 * ( s.IsMarried ? 0.85 : 1.00 ) ) );
					int ammounit = fleet.MembersInstance.Sum( s => s == null ? 0 : (int)Math.Floor( s.MasterShip.Ammo * 0.2 * ( s.IsMarried ? 0.85 : 1.00 ) ) );

					int speed = fleet.MembersWithoutEscaped.Min( s => s == null ? 10 : s.MasterShip.Speed );

					var slots = fleet.MembersWithoutEscaped
						.Where( s => s != null )
						.SelectMany( s => s.SlotInstance )
						.Where( e => e != null );
					var daihatsu = slots.Where( e => e.EquipmentID == 68 );
					var daihatsu_tank = slots.Where( e => e.EquipmentID == 166 );
					var landattacker = slots.Where( e => e.EquipmentID == 167 );
					double expeditionBonus = Math.Min( daihatsu.Count() * 0.05 + daihatsu_tank.Count() * 0.02 + landattacker.Count() * 0.01, 0.20 );

					ToolTipInfo.SetToolTip( Name, string.Format(
						GeneralRes.FleetTooltip,
						levelSum,
						(double)levelSum / Math.Max( fleet.Members.Count( id => id != -1 ), 1 ),
						Constants.GetSpeed( speed ),
						fleet.MembersInstance.Sum( s => s == null ? 0 : s.SlotInstanceMaster.Count( q => q == null ? false : q.CategoryType == 30 ) ),
						fleet.MembersInstance.Count( s => s == null ? false : s.SlotInstanceMaster.Any( q => q == null ? false : q.CategoryType == 30 ) ),
						daihatsu.Count() + daihatsu_tank.Count() + landattacker.Count(),
						fleet.MembersInstance.Count( s => s == null ? false : s.SlotInstanceMaster.Any( q => q == null ? false : q.CategoryType == 24 || q.CategoryType == 46 ) ),
						expeditionBonus + 0.01 * expeditionBonus * ( daihatsu.Sum( e => e.Level ) + daihatsu_tank.Sum( e => e.Level ) + landattacker.Sum( e => e.Level ) ) / Math.Max( daihatsu.Count() + daihatsu_tank.Count() + landattacker.Count(), 1 ),
						fueltotal,
						ammototal,
						fuelunit,
						ammounit
						) );

				}


				State = FleetData.UpdateFleetState( fleet, StateMain, ToolTipInfo, State, ref Timer );


				//制空戦力計算
				{
					int airSuperiority = fleet.GetAirSuperiority();
					AirSuperiority.Text = airSuperiority.ToString();
					ToolTipInfo.SetToolTip( AirSuperiority,
						string.Format( GeneralRes.ASTooltip,
						(int)( airSuperiority / 3.0 ),
						(int)( airSuperiority / 1.5 ),
						(int)( airSuperiority * 1.5 - 1 ),
						(int)( airSuperiority * 3.0 - 1 ) ) );
				}


				//索敵能力計算
				SearchingAbility.Text = fleet.GetSearchingAbilityString();
				{
					StringBuilder sb = new StringBuilder();
					double probStart = fleet.GetContactProbability();
					var probSelect = fleet.GetContactSelectionProbability();

					sb.AppendFormat( GeneralRes.LoSTooltip,
						fleet.GetSearchingAbilityString( 0 ),
						fleet.GetSearchingAbilityString( 1 ),
						fleet.GetSearchingAbilityString( 2 ),
						fleet.GetSearchingAbilityString( 3 ),
						probStart,
						probStart * 0.6 );

					if ( probSelect.Count > 0 ) {
						sb.AppendLine( GeneralRes.SelectionRate );

						foreach ( var p in probSelect.OrderBy( p => p.Key ) ) {
							sb.AppendFormat( "  " + EncycloRes.Accuracy + "+{0} : {1:p1}\r\n", p.Key, p.Value );
						}
					}

					ToolTipInfo.SetToolTip( SearchingAbility, sb.ToString() );
				}
			}