From 837ed35b2278c3502c8501965ca185ebc8c8f4dc Mon Sep 17 00:00:00 2001 From: Yuubari Date: Sun, 8 Nov 2015 15:27:18 +0300 Subject: [PATCH] Implement repair timer tool-tips --- .../ViewModels/Contents/ShipViewModel.cs | 9 ++ .../Views/Contents/Fleets.xaml | 3 +- .../Views/Contents/Overview.xaml | 2 +- .../Grabacr07.KanColleWrapper/Models/Ship.cs | 9 ++ .../Models/ShipType.cs | 140 +++++++++++++++++- 5 files changed, 159 insertions(+), 4 deletions(-) diff --git a/source/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs b/source/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs index 1a0dbcd4b..0dd550bc8 100644 --- a/source/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs +++ b/source/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Grabacr07.KanColleViewer.Properties; using Grabacr07.KanColleWrapper.Models; using Livet; @@ -11,6 +12,14 @@ public class ShipViewModel : ViewModel { public Ship Ship { get; } + public string RepairToolTip => + !((this.Ship.HP.Maximum - this.Ship.HP.Current) > 0) ? + "OK" : + string.Format(Resources.Ship_RepairDockToolTip, this.Ship.RepairTimeDock) + + ((((this.Ship.HP.Current / (double)this.Ship.HP.Maximum) > 0.5) && this.Ship.RepairTimeFacility != this.Ship.RepairTimeDock) ? + "\n" + string.Format(Resources.Ship_RepairFacilityToolTip, this.Ship.RepairTimeFacility) : + ""); + public ShipViewModel(Ship ship) { this.Ship = ship; diff --git a/source/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml b/source/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml index 793b2f693..c2063261d 100644 --- a/source/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml +++ b/source/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml @@ -328,7 +328,8 @@ Grid.Column="4" Grid.Row="0" Margin="10,0,10,10" - Grid.RowSpan="2"> + Grid.RowSpan="2" + ToolTip="{Binding RepairToolTip, Mode=OneWay}"> diff --git a/source/Grabacr07.KanColleViewer/Views/Contents/Overview.xaml b/source/Grabacr07.KanColleViewer/Views/Contents/Overview.xaml index 79b469919..80085035e 100644 --- a/source/Grabacr07.KanColleViewer/Views/Contents/Overview.xaml +++ b/source/Grabacr07.KanColleViewer/Views/Contents/Overview.xaml @@ -200,7 +200,7 @@ - + diff --git a/source/Grabacr07.KanColleWrapper/Models/Ship.cs b/source/Grabacr07.KanColleWrapper/Models/Ship.cs index b1fae023d..d109fa829 100644 --- a/source/Grabacr07.KanColleWrapper/Models/Ship.cs +++ b/source/Grabacr07.KanColleWrapper/Models/Ship.cs @@ -61,6 +61,12 @@ public class Ship : RawDataWrapper, IIdentifiable /// public int ExpForLevelMax => Experience.GetShipExpForSpecifiedLevel(this.Exp, 150); + public TimeSpan RepairTimeDock => + TimeSpan.FromSeconds(Math.Floor(BaseRepairTime(this.Level) * (this.HP.Maximum - this.HP.Current) * this.Info.ShipType.RepairMultiplier) + 30); + + public TimeSpan RepairTimeFacility => + (BaseRepairTime() < 1200) ? this.RepairTimeDock : TimeSpan.FromMinutes((this.HP.Maximum - this.HP.Current) * 20); + #region HP 変更通知プロパティ private LimitedValue _HP; @@ -387,6 +393,9 @@ internal void Repair() this.HP = this.HP.Update(max); } + private double BaseRepairTime(double level = 1.0) => + (Math.Min(level, 150) * ((level < 12) ? 10 : 5) + ((level < 12) ? 0 : (Math.Floor(Math.Sqrt(level - 11) * 10 + 50)))); + public override string ToString() { return $"ID = {this.Id}, Name = \"{this.Info.Name}\", ShipType = \"{this.Info.ShipType.Name}\", Level = {this.Level}"; diff --git a/source/Grabacr07.KanColleWrapper/Models/ShipType.cs b/source/Grabacr07.KanColleWrapper/Models/ShipType.cs index 04da4dcc2..806ade7cd 100644 --- a/source/Grabacr07.KanColleWrapper/Models/ShipType.cs +++ b/source/Grabacr07.KanColleWrapper/Models/ShipType.cs @@ -26,15 +26,151 @@ public override string ToString() return $"ID = {this.Id}, Name = \"{this.Name}\""; } + public double RepairMultiplier + { + get + { + switch ((ShipTypeId)this.Id) + { + case ShipTypeId.Submarine: + return 0.5; + case ShipTypeId.HeavyCruiser: + case ShipTypeId.AerialCruiser: + case ShipTypeId.FastBattleship: + case ShipTypeId.LightAircraftCarrier: + case ShipTypeId.SubmarineTender: + return 1.5; + case ShipTypeId.Battleship: + case ShipTypeId.Superdreadnought: + case ShipTypeId.AerialBattleship: + case ShipTypeId.AircraftCarrier: + case ShipTypeId.ArmoredAircraftCarrier: + case ShipTypeId.RepairShip: + return 2; + default: + return 1; + } + } + } + #region static members - public static ShipType Dummy { get; } = new ShipType(new kcsapi_mst_stype + public static ShipType Dummy { get; } = new ShipType(new kcsapi_mst_stype { api_id = 999, api_sortno = 999, api_name = "不審船", }); - #endregion + #endregion + + public enum ShipTypeId + { + Unknown = 0, + + /// + /// 海防艦。 + /// + EscortShip = 1, + + /// + /// 駆逐艦。 + /// + Destroyer = 2, + + /// + /// 軽巡洋艦。 + /// + LightCruiser = 3, + + /// + /// 重雷装巡洋艦。 + /// + TorpedoCruiser = 4, + + /// + /// 重巡洋艦。 + /// + HeavyCruiser = 5, + + /// + /// 航空巡洋艦。 + /// + AerialCruiser = 6, + + /// + /// 軽空母。 + /// + LightAircraftCarrier = 7, + + /// + /// 高速戦艦。 + /// + FastBattleship = 8, + + /// + /// 戦艦。 + /// + Battleship = 9, + + /// + /// 航空戦艦。 + /// + AerialBattleship = 10, + + /// + /// 正規空母。 + /// + AircraftCarrier = 11, + + /// + /// 超弩級戦艦。 + /// + Superdreadnought = 12, + + /// + /// 潜水艦。 + /// + Submarine = 13, + + /// + /// 潜水空母。 + /// + AircraftCarryingSubmarine = 14, + + /// + /// 補給艦。 + /// + ReplenishmentOiler = 15, + + /// + /// 水上機母艦。 + /// + SeaplaneCarrier = 16, + + /// + /// 揚陸艦 + /// + AmphibiousAssault = 17, + + /// + /// 装甲空母 + /// + ArmoredAircraftCarrier = 18, + + /// + /// 工作艦 + /// + RepairShip = 19, + + /// + /// 潜水母艦 + /// + SubmarineTender = 20, + + TrainingCruiser = 21, + + FleetOiler = 22, + } } }