Skip to content

Commit

Permalink
Merge remote-tracking branch 'Grabacr07/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuubari committed Jul 6, 2016
2 parents 1a50665 + 8158dd5 commit e17fc74
Show file tree
Hide file tree
Showing 30 changed files with 339 additions and 275 deletions.
36 changes: 18 additions & 18 deletions source/Grabacr07.KanColleViewer/KanColleViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -85,8 +86,8 @@
<HintPath>..\packages\Nekoxy.1.5.2.20\lib\net45\Nekoxy.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="StatefulModel, Version=0.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\StatefulModel.0.5.0\lib\portable-net45+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10\StatefulModel.dll</HintPath>
<Reference Include="StatefulModel">
<HintPath>..\packages\StatefulModel.0.6.0\lib\portable-net45+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10\StatefulModel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down Expand Up @@ -617,6 +618,21 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="readme.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\LICENSE.txt">
<Visible>False</Visible>
<Link>license.txt</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\licenses\*.*">
<Visible>False</Visible>
<Link>Licenses\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<COMReference Include="MSHTML">
<Guid>{3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}</Guid>
Expand All @@ -637,22 +653,6 @@
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<None Include="readme.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\LICENSE.txt">
<Visible>False</Visible>
<Link>license.txt</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\licenses\*.*">
<Visible>False</Visible>
<Link>Licenses\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
2 changes: 1 addition & 1 deletion source/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly)]

[assembly: AssemblyVersion("4.2.5.0")]
[assembly: AssemblyVersion("4.2.7.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class ShipCatalogSortWorker : ViewModel
public static readonly SortableColumn LuckColumn = new SortableColumn { Name = "運", KeySelector = x => x.Luck.Current, DefaultIsDescending = true, };
public static readonly SortableColumn HPColumn = new SortableColumn { Name = "耐久", KeySelector = x => x.HP.Maximum, DefaultIsDescending = true, };
public static readonly SortableColumn ViewRangeColumn = new SortableColumn { Name = "索敵", KeySelector = x => x.ViewRange, DefaultIsDescending = true, };
public static readonly SortableColumn ASWColumn = new SortableColumn { Name = "対潜", KeySelector = x => x.ASW, DefaultIsDescending = true, };
public static readonly SortableColumn TimeToRepairColumn = new SortableColumn { Name = "修復時間", KeySelector = x => x.TimeToRepair.Ticks, DefaultIsDescending = true, };

public static SortableColumn[] Columns { get; set; }
Expand All @@ -48,6 +49,7 @@ static ShipCatalogSortWorker()
LuckColumn,
HPColumn,
ViewRangeColumn,
ASWColumn,
TimeToRepairColumn,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static List<SlotItemCounter> UpdateCore()
{
foreach (var target in ship.EquippedItems.Select(slot => new { slot, counter = dic[slot.Item.Info.Id] }))
{
target.counter.AddShip(ship, target.slot.Item.Level, target.slot.Item.Adept);
target.counter.AddShip(ship, target.slot.Item.Level, target.slot.Item.Proficiency);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public SlotItemCounter(SlotItemInfo target, IEnumerable<SlotItem> items)
this.Target = target;

this.itemsByLevel = items
.GroupBy(x => new SlotItemCounterKey(x.Level, x.Adept))
.GroupBy(x => new SlotItemCounterKey(x.Level, x.Proficiency))
.ToDictionary(
x => x.Key,
x => new SlotItemCounterByLevel { CounterKey = x.Key, Count = x.Count(), }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ public class FleetStateViewModel : ViewModel

public string TotalLevel => this.Source.TotalLevel.ToString("###0");

public string AirSuperiorityPotential => this.Source.AirSuperiorityPotential.ToString("##0");

public string MinAirSuperiorityPotential => this.Source.MinAirSuperiorityPotential.ToString("##0");

public string MaxAirSuperiorityPotential => this.Source.MaxAirSuperiorityPotential.ToString("##0");

public string ViewRange => this.Source.ViewRange.ToString("##0.##");
public string ViewRange => (Math.Floor(this.Source.ViewRange * 100) / 100).ToString("##0.##");

public string Speed
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,23 @@
</GridViewColumn.CellTemplate>
</GridViewColumn>

<GridViewColumn Width="45">
<GridViewColumn.Header>
<metro2:SortButton MethodName="Sort"
MethodParameter="{x:Static viewModels:ShipCatalogSortWorker.ASWColumn}">
<TextBlock Text="対潜"
ToolTip="装備によるステータス上昇を含んだ値です" />
</metro2:SortButton>
</GridViewColumn.Header>
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Ship.ASW, Mode=OneWay}"
Foreground="{DynamicResource ActiveForegroundBrushKey}"
Margin="0,3" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>

<GridViewColumn Width="{Binding ShipSallyAreaFilter.ColumnWidth}">
<GridViewColumn.Header>
<TextBlock Text="出撃海域" />
Expand Down
2 changes: 1 addition & 1 deletion source/Grabacr07.KanColleViewer/Views/FleetWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
<Run Text="{Binding Item.Info.Name, Mode=OneWay}" />
<Run Text="{Binding Item.LevelText, Mode=OneWay}"
Foreground="#FF45A9A5" />
<Run Text="{Binding Item.AdeptText, Mode=OneWay}"
<Run Text="{Binding Item.ProficiencyText, Mode=OneWay}"
Foreground="{DynamicResource ForegroundBrushKey}" />
</TextBlock>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion source/Grabacr07.KanColleViewer/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
<package id="Rx-PlatformServices" version="2.2.5" targetFramework="net45" />
<package id="Rx-WPF" version="2.2.5" targetFramework="net45" />
<package id="Rx-XAML" version="2.2.5" targetFramework="net45" />
<package id="StatefulModel" version="0.5.0" targetFramework="net46" />
<package id="StatefulModel" version="0.6.0" targetFramework="net46" />
</packages>
4 changes: 3 additions & 1 deletion source/Grabacr07.KanColleViewer/readme.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
提督業も忙しい! (KanColleViewer)
version 4.2.1 2016/02/12
version 4.2.6 2016/06/20
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━


Expand Down Expand Up @@ -167,6 +167,8 @@ Desktop Toast

■更新履歴

2016/06/20 - version 4.2.6 リリース
(わすれました)
2016/02/12 - version 4.2.1 リリース
2016/02/08 - version 4.2 リリース
2015/11/10 - version 4.1.6 リリース
Expand Down
140 changes: 0 additions & 140 deletions source/Grabacr07.KanColleWrapper/Calculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,146 +8,6 @@ namespace Grabacr07.KanColleWrapper
{
internal static class Calculator
{
#region 制空値計算

/// <summary>
/// 装備と搭載数を指定して、スロット単位の制空能力を計算します。
/// </summary>
/// <param name="slotItem">対空能力を持つ装備。</param>
/// <param name="onslot">搭載数。</param>
/// <returns></returns>
public static int CalcAirSuperiorityPotential(this SlotItem slotItem, int onslot)
{
if (slotItem.Info.IsAirSuperiorityFighter)
{
return (int)(slotItem.Info.AA * Math.Sqrt(onslot));
}

return 0;
}
/// <summary>
/// 指定した艦の制空能力を計算します。
/// </summary>
public static int CalcAirSuperiorityPotential(this Ship ship)
{
return ship.EquippedItems
.Select(x => x.Item.CalcAirSuperiorityPotential(x.Current))
.Sum();
}

/// <summary>
/// 指定した艦の制空能力の最小値を計算します。
/// </summary>
public static int CalcMinAirSuperiorityPotential(this Ship ship)
{
return ship.EquippedItems
.Select(x => (x.Item.Info.Type == SlotItemType.艦上戦闘機
|| x.Item.Info.Type == SlotItemType.水上戦闘機
? x.Item.CalcAirSuperiorityPotential(x.Current)
: 0)
+ x.Item.CalcMinAirecraftAdeptBonus(x.Current))
.Select(x => (int)x)
.Sum();
}

/// <summary>
/// 指定した艦の制空能力の最大値を計算します。
/// </summary>
public static int CalcMaxAirSuperiorityPotential(this Ship ship)
{
return ship.EquippedItems
.Select(x => x.Item.CalcAirSuperiorityPotential(x.Current)
+ x.Item.CalcMaxAirecraftAdeptBonus(x.Current))
.Select(x => (int)x)
.Sum();
}

/// <summary>
/// 熟練度による制空能力ボーナス最小値を計算します。
/// </summary>
/// <param name="slotItem">対空能力を持つ装備。</param>
/// <param name="onslot">搭載数。</param>
/// <returns></returns>
private static double CalcMinAirecraftAdeptBonus(this SlotItem slotItem, int onslot)
{
if(onslot < 1) return 0;
return slotItem.Info.Type == SlotItemType.艦上戦闘機
|| slotItem.Info.Type == SlotItemType.水上戦闘機
? slotItem.CalcAirecraftAdeptBonusOfType() + slotItem.CalcMinInternalAirecraftAdeptBonus()
: 0; // 艦戦・水戦以外は簡単に吹き飛ぶので最小値としては計算に入れない
}

/// <summary>
/// 熟練度による制空能力ボーナス最大値を計算します。
/// </summary>
/// <param name="slotItem">対空能力を持つ装備。</param>
/// <param name="onslot">搭載数。</param>
/// <returns></returns>
private static double CalcMaxAirecraftAdeptBonus(this SlotItem slotItem, int onslot)
=> onslot < 1 ? 0
: slotItem.CalcAirecraftAdeptBonusOfType() + slotItem.CalcMaxInternalAirecraftAdeptBonus();

/// <summary>
/// 各表記熟練度に対応した機種別熟練度ボーナスを計算します。
/// </summary>
/// <param name="slotItem"></param>
/// <returns></returns>
private static int CalcAirecraftAdeptBonusOfType(this SlotItem slotItem)
=> slotItem.Info.Type == SlotItemType.艦上戦闘機
|| slotItem.Info.Type == SlotItemType.水上戦闘機
? slotItem.Adept == 1 ? 0
: slotItem.Adept == 2 ? 2
: slotItem.Adept == 3 ? 5
: slotItem.Adept == 4 ? 9
: slotItem.Adept == 5 ? 14
: slotItem.Adept == 6 ? 14
: slotItem.Adept == 7 ? 22
: 0 // Adept == 0
: slotItem.Info.Type == SlotItemType.水上爆撃機
? slotItem.Adept == 1 ? 0
: slotItem.Adept == 2 ? 1
: slotItem.Adept == 3 ? 1
: slotItem.Adept == 4 ? 1
: slotItem.Adept == 5 ? 3
: slotItem.Adept == 6 ? 3
: slotItem.Adept == 7 ? 6
: 0 // Adept == 0
: 0;

/// <summary>
/// 各表記熟練度に対応した艦載機内部熟練度ボーナスの最小値を計算します。
/// </summary>
/// <param name="slotItem"></param>
/// <returns></returns>
private static double CalcMinInternalAirecraftAdeptBonus(this SlotItem slotItem)
{
return slotItem.Info.IsAirSuperiorityFighter
? Math.Sqrt((slotItem.Adept != 0 ? (slotItem.Adept - 1) * 15 + 10 : 0) / 10d)
: 0;
}

/// <summary>
/// 各表記熟練度に対応した艦載機内部熟練度ボーナスの最大値を計算します。
/// </summary>
/// <param name="slotItem"></param>
/// <returns></returns>
private static double CalcMaxInternalAirecraftAdeptBonus(this SlotItem slotItem)
{
if (!slotItem.Info.IsAirSuperiorityFighter)
return 0;
switch (slotItem.Adept)
{
case 0:
return Math.Sqrt(9d / 10);
case 7:
return Math.Sqrt(120d / 10);
default:
return Math.Sqrt((slotItem.Adept * 15 + 9) / 10d);
}
}

#endregion

public static double CalcViewRange(this Fleet fleet)
{
return ViewRangeCalcLogic.Get(KanColleClient.Current.Settings.ViewRangeCalcType).Calc(new[] { fleet });
Expand Down
50 changes: 27 additions & 23 deletions source/Grabacr07.KanColleWrapper/KanColleClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
using System.Threading.Tasks;
using Grabacr07.KanColleWrapper.Models;
using Grabacr07.KanColleWrapper.Models.Raw;

namespace Grabacr07.KanColleWrapper
Expand Down Expand Up @@ -98,32 +96,38 @@ private KanColleClient()
public void Initialieze()
{
var proxy = this.Proxy ?? (this.Proxy = new KanColleProxy());
var requireInfoSource = proxy.api_get_member_require_info
.TryParse<kcsapi_require_info>()
.FirstAsync()
.ToTask();

proxy.api_start2.FirstAsync().Subscribe(async session =>
{
var timeout = Task.Delay(TimeSpan.FromSeconds(20));
var canInitialize = await Task.WhenAny(requireInfoSource, timeout) != timeout;

SvData<kcsapi_start2> svd;
if (!SvData.TryParse(session, out svd)) return;

this.Master = new Master(svd.Data);
if (this.Homeport == null) this.Homeport = new Homeport(proxy);
var start2Source = proxy.api_start2.TryParse<kcsapi_start2>();
var requireInfoSource = proxy.api_get_member_require_info.TryParse<kcsapi_require_info>();
var firstTime = start2Source
.CombineLatest(requireInfoSource, (start2, requireInfo) => new { start2, requireInfo, })
.FirstAsync();

if (canInitialize)
{
var requireInfo = await requireInfoSource;
this.Homeport.UpdateAdmiral(requireInfo.Data.api_basic);
this.Homeport.Itemyard.Update(requireInfo.Data.api_slot_item);
this.Homeport.Dockyard.Update(requireInfo.Data.api_kdock);
}
// Homeport の初期化と require_info の適用に Master のインスタンスが必要なため、初回のみ足並み揃えて実行
// 2 回目以降は受信したタイミングでそれぞれ更新すればよい

firstTime.Subscribe(x =>
{
this.Master = new Master(x.start2.Data);
this.Homeport = new Homeport(proxy);
this.SetRequireInfo(x.requireInfo.Data);
this.IsStarted = true;
});

start2Source
.SkipUntil(firstTime)
.Subscribe(x => this.Master = new Master(x.Data));

requireInfoSource
.SkipUntil(firstTime)
.Subscribe(x => this.SetRequireInfo(x.Data));
}

private void SetRequireInfo(kcsapi_require_info data)
{
this.Homeport.UpdateAdmiral(data.api_basic);
this.Homeport.Itemyard.Update(data.api_slot_item);
this.Homeport.Dockyard.Update(data.api_kdock);
}
}
}
Loading

0 comments on commit e17fc74

Please sign in to comment.