Skip to content

Commit

Permalink
2015秋イベ対応
Browse files Browse the repository at this point in the history
輸送力表示暫定対応
  • Loading branch information
veigr committed Nov 23, 2015
1 parent 25d8cfb commit 8259b4e
Show file tree
Hide file tree
Showing 13 changed files with 354 additions and 54 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
46 changes: 28 additions & 18 deletions EventMapHpViewer/EventMapHpViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,40 +46,48 @@
<HintPath>..\packages\KanColleViewer.PluginAnalyzer.1.0.1.0\lib\net45\KanColleViewer.PluginAnalyzer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="KanColleWrapper, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\KanColleWrapper.1.2.0.0\lib\net45\KanColleWrapper.dll</HintPath>
<Reference Include="KanColleWrapper, Version=1.2.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\KanColleWrapper.1.2.7.0\lib\net45\KanColleWrapper.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Livet">
<HintPath>..\packages\LivetCask.1.1.0.0\lib\net45\Livet.dll</HintPath>
<Private>False</Private>
<Reference Include="Livet, Version=1.3.0.0, Culture=neutral, PublicKeyToken=b0b1d3f711ef38cb, processorArchitecture=MSIL">
<HintPath>..\packages\LivetCask.1.3.1.0\lib\net45\Livet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MetroRadiance, Version=1.1.0.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MetroRadiance.1.1.0.2\lib\net45\MetroRadiance.dll</HintPath>
<Reference Include="MetroRadiance, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MetroRadiance.1.1.0.0\lib\net45\MetroRadiance.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MetroRadiance.Chrome, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MetroRadiance.Chrome.1.1.0.0\lib\net45\MetroRadiance.Chrome.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MetroRadiance.Core, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MetroRadiance.Core.1.1.0.0\lib\net45\MetroRadiance.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MetroRadiance.Chrome, Version=1.1.0.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MetroRadiance.Chrome.1.1.0.2\lib\net45\MetroRadiance.Chrome.dll</HintPath>
<Reference Include="MetroTrilithon, Version=0.1.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\KanColleViewer.Internal\source\packages\MetroTrilithon.0.1.1.0\lib\portable-net45+dnxcore50+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10\MetroTrilithon.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MetroRadiance.Core, Version=1.1.0.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MetroRadiance.Core.1.1.0.2\lib\net45\MetroRadiance.Core.dll</HintPath>
<Reference Include="MetroTrilithon.Desktop, Version=0.1.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\KanColleViewer.Internal\source\packages\MetroTrilithon.Desktop.0.1.4.0\lib\net45\MetroTrilithon.Desktop.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Expression.Drawing, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\KanColleViewer.Controls.1.2.0.0\lib\net45\Microsoft.Expression.Drawing.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Expression.Interactions, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MetroRadiance.Chrome.1.1.0.2\lib\net45\Microsoft.Expression.Interactions.dll</HintPath>
<HintPath>..\packages\LivetCask.1.3.1.0\lib\net45\Microsoft.Expression.Interactions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nekoxy, Version=1.3.1.16, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nekoxy.1.3.1.16\lib\net45\Nekoxy.dll</HintPath>
<Reference Include="Nekoxy, Version=1.2.0.13, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nekoxy.1.2.0.13\lib\net45\Nekoxy.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
Expand Down Expand Up @@ -111,7 +119,7 @@
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MetroRadiance.Chrome.1.1.0.2\lib\net45\System.Windows.Interactivity.dll</HintPath>
<HintPath>..\packages\LivetCask.1.3.1.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xaml" />
Expand All @@ -121,7 +129,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="TrotiNet, Version=0.8.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nekoxy.1.3.1.16\lib\net45\TrotiNet.dll</HintPath>
<HintPath>..\packages\Nekoxy.1.2.0.13\lib\net45\TrotiNet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WindowsBase" />
Expand All @@ -133,6 +141,7 @@
<Compile Include="Models\MapInfo.cs" />
<Compile Include="Models\Maps.cs" />
<Compile Include="Models\MapInfoProxy.cs" />
<Compile Include="Models\OrganizationExtensions.cs" />
<Compile Include="Models\Raw\Api_Eventmap.cs" />
<Compile Include="Models\Raw\kcsapi_mst_maparea.cs" />
<Compile Include="Models\Raw\kcsapi_mst_mapinfo.cs" />
Expand All @@ -153,10 +162,11 @@
</Page>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<DesignData Include="SampleData\ToolViewModelSampleData.xaml" />
</ItemGroup>
<ItemGroup>
<DesignData Include="SampleData\ToolViewModelSampleData.xaml" />
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\KanColleViewer.PluginAnalyzer.1.0.1.0\analyzers\KanColleViewer.Composition.dll" />
Expand Down
2 changes: 1 addition & 1 deletion EventMapHpViewer/MapHpViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
1 change: 1 addition & 0 deletions EventMapHpViewer/Models/GaugeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace EventMapHpViewer.Models
{
public enum GaugeType
{
Normal = 0,
// 1, 2 は実際には返ってこないので暫定。逆かも。
Event = 1,
Extra = 2,
Expand Down
26 changes: 24 additions & 2 deletions EventMapHpViewer/Models/Maps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public int Current
}
}

/// <summary>
/// 残回数。輸送の場合はA勝利の残回数。
/// </summary>
public int RemainingCount
{
get
Expand All @@ -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();
Expand All @@ -73,6 +80,21 @@ public int RemainingCount
}
}

/// <summary>
/// 輸送ゲージのS勝利時の残回数
/// </summary>
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<int, IReadOnlyDictionary<int, int[]>> EventBossHpDictionary
= new Dictionary<int, IReadOnlyDictionary<int, int[]>>
{
Expand Down
65 changes: 65 additions & 0 deletions EventMapHpViewer/Models/OrganizationExtensions.cs
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
2 changes: 1 addition & 1 deletion EventMapHpViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.1.0")]
[assembly: AssemblyVersion("2.5.0.0")]
40 changes: 32 additions & 8 deletions EventMapHpViewer/SampleData/ToolViewModelSampleData.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<viewModels:ToolViewModel xmlns:local="clr-namespace:EventMapHpViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:viewModels="clr-namespace:EventMapHpViewer.ViewModels"
IsNoMap="False">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:viewModels="clr-namespace:EventMapHpViewer.ViewModels"
IsNoMap="False"
TransportCapacity="100"
TransportCapacityS="145">
<viewModels:ToolViewModel.Maps>
<viewModels:MapViewModel Current="1000"
Max="9999"
Expand All @@ -11,7 +13,8 @@
Name="サーモン海域北方"
IsCleared="False"
IsRankSelected="False"
IsSupported="True">
IsSupported="True"
GaugeType="Event">
<viewModels:MapViewModel.GaugeColor>
<SolidColorBrush Color="#40C820"/>
</viewModels:MapViewModel.GaugeColor>
Expand All @@ -24,7 +27,8 @@
Name="ふつうマップ"
IsCleared="False"
IsRankSelected="True"
IsSupported="True">
IsSupported="True"
GaugeType="Normal">
<viewModels:MapViewModel.GaugeColor>
<SolidColorBrush Color="#FF2020"/>
</viewModels:MapViewModel.GaugeColor>
Expand All @@ -37,7 +41,8 @@
Name="あるフォンシーの方面進出"
IsCleared="False"
IsRankSelected="True"
IsSupported="True">
IsSupported="True"
GaugeType="Extra">
<viewModels:MapViewModel.GaugeColor>
<SolidColorBrush Color="#FF2020"/>
</viewModels:MapViewModel.GaugeColor>
Expand All @@ -52,7 +57,8 @@
Name="未対応海域"
IsCleared="False"
IsRankSelected="True"
IsSupported="True">
IsSupported="True"
GaugeType="Event">
<viewModels:MapViewModel.GaugeColor>
<SolidColorBrush Color="#40C820"/>
</viewModels:MapViewModel.GaugeColor>
Expand All @@ -67,7 +73,25 @@
Name="未対応海域"
IsCleared="False"
IsRankSelected="True"
IsSupported="False">
IsSupported="False"
GaugeType="Event">
<viewModels:MapViewModel.GaugeColor>
<SolidColorBrush Color="#40C820"/>
</viewModels:MapViewModel.GaugeColor>
</viewModels:MapViewModel>
<viewModels:MapViewModel Current="333"
Max="444"
SelectedRank=""
SelectedRankVisibility="Visible"
RemainingCount="7"
RemainingCountTransportS="5"
MapNumber="30-5"
AreaName="イベント海域"
Name="輸送"
IsCleared="False"
IsRankSelected="True"
IsSupported="True"
GaugeType="Transport">
<viewModels:MapViewModel.GaugeColor>
<SolidColorBrush Color="#40C820"/>
</viewModels:MapViewModel.GaugeColor>
Expand Down
Loading

0 comments on commit 8259b4e

Please sign in to comment.