From 8259b4ea21ffef660fa0d36260b82b30c83ea8e1 Mon Sep 17 00:00:00 2001 From: veigr Date: Mon, 23 Nov 2015 19:02:21 +0900 Subject: [PATCH] =?UTF-8?q?2015=E7=A7=8B=E3=82=A4=E3=83=99=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C=20=E8=BC=B8=E9=80=81=E5=8A=9B=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E6=9A=AB=E5=AE=9A=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 8 ++ EventMapHpViewer/EventMapHpViewer.csproj | 46 +++++---- EventMapHpViewer/MapHpViewer.cs | 2 +- EventMapHpViewer/Models/GaugeType.cs | 1 + EventMapHpViewer/Models/Maps.cs | 26 ++++- .../Models/OrganizationExtensions.cs | 65 +++++++++++++ EventMapHpViewer/Properties/AssemblyInfo.cs | 2 +- .../SampleData/ToolViewModelSampleData.xaml | 40 ++++++-- EventMapHpViewer/ToolView.xaml | 97 +++++++++++++++---- EventMapHpViewer/ViewModels/MapViewModel.cs | 52 ++++++++++ EventMapHpViewer/ViewModels/ToolViewModel.cs | 44 +++++++++ EventMapHpViewer/app.config | 11 +++ EventMapHpViewer/packages.config | 14 +-- 13 files changed, 354 insertions(+), 54 deletions(-) create mode 100644 .editorconfig create mode 100644 EventMapHpViewer/Models/OrganizationExtensions.cs create mode 100644 EventMapHpViewer/app.config diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6c3fb00 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*.{cs,xaml}] +indent_style = space +indent_size = 4 +end_of_line = crlf +insert_final_newline = true +charset = utf-8-bom diff --git a/EventMapHpViewer/EventMapHpViewer.csproj b/EventMapHpViewer/EventMapHpViewer.csproj index 9f5b59e..3ed0772 100644 --- a/EventMapHpViewer/EventMapHpViewer.csproj +++ b/EventMapHpViewer/EventMapHpViewer.csproj @@ -46,28 +46,36 @@ ..\packages\KanColleViewer.PluginAnalyzer.1.0.1.0\lib\net45\KanColleViewer.PluginAnalyzer.dll True - - ..\packages\KanColleWrapper.1.2.0.0\lib\net45\KanColleWrapper.dll + + ..\packages\KanColleWrapper.1.2.7.0\lib\net45\KanColleWrapper.dll True - - ..\packages\LivetCask.1.1.0.0\lib\net45\Livet.dll - False + + ..\packages\LivetCask.1.3.1.0\lib\net45\Livet.dll + True ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll True - - ..\packages\MetroRadiance.1.1.0.2\lib\net45\MetroRadiance.dll + + ..\packages\MetroRadiance.1.1.0.0\lib\net45\MetroRadiance.dll + True + + + ..\packages\MetroRadiance.Chrome.1.1.0.0\lib\net45\MetroRadiance.Chrome.dll + True + + + ..\packages\MetroRadiance.Core.1.1.0.0\lib\net45\MetroRadiance.Core.dll True - - ..\packages\MetroRadiance.Chrome.1.1.0.2\lib\net45\MetroRadiance.Chrome.dll + + ..\..\KanColleViewer.Internal\source\packages\MetroTrilithon.0.1.1.0\lib\portable-net45+dnxcore50+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10\MetroTrilithon.dll True - - ..\packages\MetroRadiance.Core.1.1.0.2\lib\net45\MetroRadiance.Core.dll + + ..\..\KanColleViewer.Internal\source\packages\MetroTrilithon.Desktop.0.1.4.0\lib\net45\MetroTrilithon.Desktop.dll True @@ -75,11 +83,11 @@ True - ..\packages\MetroRadiance.Chrome.1.1.0.2\lib\net45\Microsoft.Expression.Interactions.dll + ..\packages\LivetCask.1.3.1.0\lib\net45\Microsoft.Expression.Interactions.dll True - - ..\packages\Nekoxy.1.3.1.16\lib\net45\Nekoxy.dll + + ..\packages\Nekoxy.1.2.0.13\lib\net45\Nekoxy.dll True @@ -111,7 +119,7 @@ - ..\packages\MetroRadiance.Chrome.1.1.0.2\lib\net45\System.Windows.Interactivity.dll + ..\packages\LivetCask.1.3.1.0\lib\net45\System.Windows.Interactivity.dll True @@ -121,7 +129,7 @@ - ..\packages\Nekoxy.1.3.1.16\lib\net45\TrotiNet.dll + ..\packages\Nekoxy.1.2.0.13\lib\net45\TrotiNet.dll True @@ -133,6 +141,7 @@ + @@ -153,10 +162,11 @@ - + - + + diff --git a/EventMapHpViewer/MapHpViewer.cs b/EventMapHpViewer/MapHpViewer.cs index 6167d3a..72fbdba 100644 --- a/EventMapHpViewer/MapHpViewer.cs +++ b/EventMapHpViewer/MapHpViewer.cs @@ -10,7 +10,7 @@ namespace EventMapHpViewer [ExportMetadata("Guid", "101436F4-9308-4892-A88A-19EFBDF2ED5F")] [ExportMetadata("Title", "MapHPViewer")] [ExportMetadata("Description", "Map HPを表示します。")] - [ExportMetadata("Version", "2.4.1")] + [ExportMetadata("Version", "2.5.0")] [ExportMetadata("Author", "@veigr")] public class MapHpViewer : IPlugin, ITool { diff --git a/EventMapHpViewer/Models/GaugeType.cs b/EventMapHpViewer/Models/GaugeType.cs index 11b1e55..cc4d24f 100644 --- a/EventMapHpViewer/Models/GaugeType.cs +++ b/EventMapHpViewer/Models/GaugeType.cs @@ -8,6 +8,7 @@ namespace EventMapHpViewer.Models { public enum GaugeType { + Normal = 0, // 1, 2 は実際には返ってこないので暫定。逆かも。 Event = 1, Extra = 2, diff --git a/EventMapHpViewer/Models/Maps.cs b/EventMapHpViewer/Models/Maps.cs index 3a31afe..320e892 100644 --- a/EventMapHpViewer/Models/Maps.cs +++ b/EventMapHpViewer/Models/Maps.cs @@ -46,6 +46,9 @@ public int Current } } + /// + /// 残回数。輸送の場合はA勝利の残回数。 + /// public int RemainingCount { get @@ -57,8 +60,12 @@ public int RemainingCount if (this.Eventmap == null) return 1; //ゲージ無し通常海域 - if (this.Eventmap.GaugeType == GaugeType.Transport) return -1; //TPゲージはとりあえず未対応( TODO: 輸送力計算したい) - + if (this.Eventmap.GaugeType == GaugeType.Transport) + { + var capacityA = KanColleClient.Current.Homeport.Organization.TransportationCapacity(); + return (int)Math.Ceiling((double)this.Current / capacityA); + } + try { var lastBossHp = EventBossHpDictionary[this.Eventmap.SelectedRank][this.Id].Last(); @@ -73,6 +80,21 @@ public int RemainingCount } } + /// + /// 輸送ゲージのS勝利時の残回数 + /// + public int RemainingCountTransportS + { + get + { + if (this.Eventmap?.GaugeType != GaugeType.Transport) return -1; + var capacity = KanColleClient.Current.Homeport.Organization.TransportationCapacity(true); + return (int)Math.Ceiling((double)this.Current / capacity); + } + } + + public GaugeType GaugeType => this.Eventmap?.GaugeType ?? GaugeType.Normal; + public static readonly IReadOnlyDictionary> EventBossHpDictionary = new Dictionary> { diff --git a/EventMapHpViewer/Models/OrganizationExtensions.cs b/EventMapHpViewer/Models/OrganizationExtensions.cs new file mode 100644 index 0000000..fa0ab7c --- /dev/null +++ b/EventMapHpViewer/Models/OrganizationExtensions.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Grabacr07.KanColleWrapper; +using Grabacr07.KanColleWrapper.Models; + +namespace EventMapHpViewer.Models +{ + public static class OrganizationExtensions + { + public static int TransportationCapacity(this Organization org, bool isS = false) + { + if (org == null || org.Fleets == null || org.Fleets.Count < 1) + return 0; + var coefficient = isS ? 1.45 : 1; + return (int)Math.Floor(org.BaseTransportationCapacity() * coefficient) + + (int)Math.Floor(org.DrumTransportationCapacity() * coefficient) + + (int)Math.Floor(org.DaihatsuTransportationCapacity() * coefficient) + ; + } + + private static double BaseTransportationCapacity(this Organization org) + { + var ships = org.Combined ? org.CombinedFleet.Fleets.SelectMany(x => x.Ships) : org.Fleets[1].Ships; + return ships.Sum(x => x.Info.ShipType.TransportationCapacity()); + } + + private static double DrumTransportationCapacity(this Organization org) + { + var ships = org.Combined ? org.CombinedFleet.Fleets.SelectMany(x => x.Ships) : org.Fleets[1].Ships; + var countDrum = ships.Sum(x => x.Slots.Count(y => y.Item.Info.Id == 75)); + return countDrum * 3.5; + } + + private static double DaihatsuTransportationCapacity(this Organization org) + { + var ships = org.Combined ? org.CombinedFleet.Fleets.SelectMany(x => x.Ships) : org.Fleets[1].Ships; + var countDaihatsu = ships.Sum(x => x.Slots.Count(y => y.Item.Info.Id == 68)); + return countDaihatsu * 5.5; + } + + private static double TransportationCapacity(this ShipType type) + { + switch (type.Id) + { + case 2: + return 3.5; + case 3: + return 1.2; + case 6: + return 3; + case 16: + return 6.4; + case 17: + return 8.5; + case 22: + return 10.5; + default: + return 0; //わからないのは0 + } + } + } +} diff --git a/EventMapHpViewer/Properties/AssemblyInfo.cs b/EventMapHpViewer/Properties/AssemblyInfo.cs index 8ab5880..5b81d88 100644 --- a/EventMapHpViewer/Properties/AssemblyInfo.cs +++ b/EventMapHpViewer/Properties/AssemblyInfo.cs @@ -43,4 +43,4 @@ // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を // 既定値にすることができます: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.4.1.0")] +[assembly: AssemblyVersion("2.5.0.0")] diff --git a/EventMapHpViewer/SampleData/ToolViewModelSampleData.xaml b/EventMapHpViewer/SampleData/ToolViewModelSampleData.xaml index c024ec6..aa7e825 100644 --- a/EventMapHpViewer/SampleData/ToolViewModelSampleData.xaml +++ b/EventMapHpViewer/SampleData/ToolViewModelSampleData.xaml @@ -1,7 +1,9 @@  + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:viewModels="clr-namespace:EventMapHpViewer.ViewModels" + IsNoMap="False" + TransportCapacity="100" + TransportCapacityS="145"> + IsSupported="True" + GaugeType="Event"> @@ -24,7 +27,8 @@ Name="ふつうマップ" IsCleared="False" IsRankSelected="True" - IsSupported="True"> + IsSupported="True" + GaugeType="Normal"> @@ -37,7 +41,8 @@ Name="あるフォンシーの方面進出" IsCleared="False" IsRankSelected="True" - IsSupported="True"> + IsSupported="True" + GaugeType="Extra"> @@ -52,7 +57,8 @@ Name="未対応海域" IsCleared="False" IsRankSelected="True" - IsSupported="True"> + IsSupported="True" + GaugeType="Event"> @@ -67,7 +73,25 @@ Name="未対応海域" IsCleared="False" IsRankSelected="True" - IsSupported="False"> + IsSupported="False" + GaugeType="Event"> + + + + + diff --git a/EventMapHpViewer/ToolView.xaml b/EventMapHpViewer/ToolView.xaml index 728cfad..cbbe5f3 100644 --- a/EventMapHpViewer/ToolView.xaml +++ b/EventMapHpViewer/ToolView.xaml @@ -5,6 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:viewModels="clr-namespace:EventMapHpViewer.ViewModels" xmlns:l="http://schemas.livet-mvvm.net/2011/wpf" + xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" Background="{DynamicResource ThemeBrushKey}" Foreground="{DynamicResource ActiveForegroundBrushKey}" mc:Ignorable="d" @@ -48,6 +49,13 @@ + + + + + + @@ -56,6 +64,7 @@ + @@ -173,21 +182,55 @@ - - - - - - + + + + + + - + + + + + + + + + + Margin="5,15,5,0"> ※出撃(海域選択)画面を開いた際に更新されます。 ※イベントマップのHPは、ボス旗艦のHPを削ると連動して減少します。 - ※輸送ゲージの残回数表示には未対応です。 diff --git a/EventMapHpViewer/ViewModels/MapViewModel.cs b/EventMapHpViewer/ViewModels/MapViewModel.cs index 3a3cfbe..186c544 100644 --- a/EventMapHpViewer/ViewModels/MapViewModel.cs +++ b/EventMapHpViewer/ViewModels/MapViewModel.cs @@ -2,6 +2,8 @@ using System.Windows.Media; using EventMapHpViewer.Models; using Livet; +using Grabacr07.KanColleWrapper; +using MetroTrilithon.Mvvm; namespace EventMapHpViewer.ViewModels { @@ -135,6 +137,23 @@ public string RemainingCount } #endregion + #region RemainingCountTransportS変更通知プロパティ + private string _RemainingCountTransportS; + + public string RemainingCountTransportS + { + get + { return this._RemainingCountTransportS; } + set + { + if (this._RemainingCountTransportS == value) + return; + this._RemainingCountTransportS = value; + this.RaisePropertyChanged(); + } + } + #endregion + #region IsCleared変更通知プロパティ private bool _IsCleared; @@ -208,8 +227,28 @@ public bool IsSupported #endregion + #region GaugeType変更通知プロパティ + private GaugeType _GaugeType; + + public GaugeType GaugeType + { + get + { return this._GaugeType; } + set + { + if (this._GaugeType == value) + return; + this._GaugeType = value; + this.RaisePropertyChanged(); + } + } + #endregion + + private MapData _source; + public MapViewModel(MapData info) { + this._source = info; this.MapNumber = info.MapNumber; this.Name = info.Name; this.AreaName = info.AreaName; @@ -217,6 +256,7 @@ public MapViewModel(MapData info) this.Max = info.Max; this.SelectedRank = info.Eventmap?.SelectedRankText ?? ""; this.RemainingCount = info.RemainingCount.ToString(); + this.RemainingCountTransportS = info.RemainingCountTransportS.ToString(); this.IsCleared = info.IsCleared == 1; var color = info.RemainingCount < 2 ? new SolidColorBrush(Color.FromRgb(255, 32, 32)) @@ -227,6 +267,18 @@ public MapViewModel(MapData info) || info.Eventmap.SelectedRank != 0 || info.Eventmap.NowMapHp != 9999; this.IsSupported = 0 < info.RemainingCount; + this.GaugeType = info.GaugeType; + } + + public void CalcTransportCapacityChanged() + { + this.RemainingCount = this._source.RemainingCount.ToString(); + this.RemainingCountTransportS = this._source.RemainingCountTransportS.ToString(); + var color = this._source.RemainingCount < 2 + ? new SolidColorBrush(Color.FromRgb(255, 32, 32)) + : new SolidColorBrush(Color.FromRgb(64, 200, 32)); + color.Freeze(); + this.GaugeColor = color; } } } diff --git a/EventMapHpViewer/ViewModels/ToolViewModel.cs b/EventMapHpViewer/ViewModels/ToolViewModel.cs index 1d8e734..f6fa027 100644 --- a/EventMapHpViewer/ViewModels/ToolViewModel.cs +++ b/EventMapHpViewer/ViewModels/ToolViewModel.cs @@ -2,6 +2,10 @@ using EventMapHpViewer.Models; using Livet; using Livet.EventListeners; +using Grabacr07.KanColleWrapper; +using MetroTrilithon.Mvvm; +using System.Collections.Generic; +using Grabacr07.KanColleWrapper.Models; namespace EventMapHpViewer.ViewModels { @@ -26,11 +30,20 @@ public ToolViewModel(MapInfoProxy proxy) .Where(x => !x.IsCleared) .ToArray(); this.IsNoMap = !this.Maps.Any(); + this.FleetsUpdated(); } } }); } + public void Loaded() + { + KanColleClient.Current.Homeport.Organization + .Subscribe(nameof(Organization.Fleets), this.FleetsUpdated) + .Subscribe(nameof(Organization.Combined), this.RaiseTransportCapacityChanged) + .AddTo(this); + } + #region Maps変更通知プロパティ private MapViewModel[] _Maps; @@ -66,5 +79,36 @@ public bool IsNoMap } #endregion + + public int TransportCapacity => KanColleClient.Current.Homeport.Organization.TransportationCapacity(); + + public int TransportCapacityS => KanColleClient.Current.Homeport.Organization.TransportationCapacity(true); + + private HashSet handledShips = new HashSet(); + + private void FleetsUpdated() + { + foreach (var fleet in KanColleClient.Current.Homeport.Organization.Fleets.Values) + { + fleet.Subscribe(nameof(fleet.Ships), this.RaiseTransportCapacityChanged); + foreach (var ship in fleet.Ships) + { + if (handledShips.Contains(ship)) return; + ship.Subscribe(nameof(ship.Slots), this.RaiseTransportCapacityChanged); + handledShips.Add(ship); + } + } + } + + private void RaiseTransportCapacityChanged() + { + this.RaisePropertyChanged(nameof(this.TransportCapacity)); + this.RaisePropertyChanged(nameof(this.TransportCapacityS)); + if (this.Maps == null) return; + foreach (var map in this.Maps) + { + map.CalcTransportCapacityChanged(); + } + } } } diff --git a/EventMapHpViewer/app.config b/EventMapHpViewer/app.config new file mode 100644 index 0000000..5406190 --- /dev/null +++ b/EventMapHpViewer/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/EventMapHpViewer/packages.config b/EventMapHpViewer/packages.config index 38e3a06..1294d1a 100644 --- a/EventMapHpViewer/packages.config +++ b/EventMapHpViewer/packages.config @@ -3,13 +3,15 @@ - - + + - - - - + + + + + +