diff --git a/Grabacr07.KanColleViewer/App.xaml.cs b/Grabacr07.KanColleViewer/App.xaml.cs index ab504ce31..f6c938028 100644 --- a/Grabacr07.KanColleViewer/App.xaml.cs +++ b/Grabacr07.KanColleViewer/App.xaml.cs @@ -40,6 +40,7 @@ protected override void OnStartup(StartupEventArgs e) PluginHost.Instance.Initialize(); NotifierHost.Instance.Initialize(KanColleClient.Current); Helper.SetRegistryFeatureBrowserEmulation(); + Helper.SetMMCSSTask(); KanColleClient.Current.Proxy.Startup(AppSettings.Default.LocalProxyPort); KanColleClient.Current.Proxy.UpstreamProxySettings = Settings.Current.ProxySettings; diff --git a/Grabacr07.KanColleViewer/Composition/PluginHost.cs b/Grabacr07.KanColleViewer/Composition/PluginHost.cs index 6060954b9..0505f84c4 100644 --- a/Grabacr07.KanColleViewer/Composition/PluginHost.cs +++ b/Grabacr07.KanColleViewer/Composition/PluginHost.cs @@ -28,9 +28,12 @@ public class PluginHost : IDisposable /// のインスタンスを取得します。 /// /// のインスタンス。 - public static PluginHost Instance => instance; + public static PluginHost Instance + { + get { return instance; } + } - #endregion + #endregion private readonly CompositionContainer container; @@ -71,6 +74,11 @@ private PluginHost() this.container = new CompositionContainer(catalog); } + static PluginHost() + { + + } + public void Dispose() { this.container.Dispose(); diff --git a/Grabacr07.KanColleViewer/Models/Helper.cs b/Grabacr07.KanColleViewer/Models/Helper.cs index 86610972b..052efbf90 100644 --- a/Grabacr07.KanColleViewer/Models/Helper.cs +++ b/Grabacr07.KanColleViewer/Models/Helper.cs @@ -31,10 +31,13 @@ static Helper() /// /// デザイナーのコンテキストで実行されているかどうかを取得します。 /// - public static bool IsInDesignMode => DesignerProperties.GetIsInDesignMode(new DependencyObject()); + public static bool IsInDesignMode + { + get { return DesignerProperties.GetIsInDesignMode(new DependencyObject()); } + } - public static string CreateScreenshotFilePath() + public static string CreateScreenshotFilePath() { var filePath = Path.Combine( Settings.Current.ScreenshotFolder, @@ -72,6 +75,12 @@ public static void SetRegistryFeatureBrowserEmulation() } } + public static void SetMMCSSTask() + { + var index = 0u; + NativeMethods.AvSetMmThreadCharacteristics("Games", ref index); + } + /// /// キャッシュを削除します。 diff --git a/Grabacr07.KanColleViewer/Models/NotifierHost.cs b/Grabacr07.KanColleViewer/Models/NotifierHost.cs index f766b42f3..5ff5ed134 100644 --- a/Grabacr07.KanColleViewer/Models/NotifierHost.cs +++ b/Grabacr07.KanColleViewer/Models/NotifierHost.cs @@ -15,9 +15,12 @@ public class NotifierHost : NotificationObject private static readonly NotifierHost instance = new NotifierHost(); - public static NotifierHost Instance => instance; + public static NotifierHost Instance + { + get { return instance; } + } - #endregion + #endregion private NotifierHost() { } @@ -77,8 +80,8 @@ private static void UpdateDockyard(Dockyard dockyard) { if (Settings.Current.NotifyBuildingCompleted) { - var shipName = Settings.Current.CanDisplayBuildingShipName - ? args.Ship.Name + var shipName = Settings.Current.CanDisplayBuildingShipName + ? args.Ship.Name : Resources.Common_ShipGirl; PluginHost.Instance.GetNotifier().Show( diff --git a/Grabacr07.KanColleViewer/Models/ProductInfo.cs b/Grabacr07.KanColleViewer/Models/ProductInfo.cs index 6c08f0774..910efa4f6 100644 --- a/Grabacr07.KanColleViewer/Models/ProductInfo.cs +++ b/Grabacr07.KanColleViewer/Models/ProductInfo.cs @@ -20,34 +20,67 @@ public class ProductInfo private string _VersionString; private IReadOnlyCollection _Libraries; - public string Title => this._Title ?? (this._Title = ((AssemblyTitleAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyTitleAttribute))).Title); + public string Title + { + get { return this._Title ?? (this._Title = ((AssemblyTitleAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyTitleAttribute))).Title); } + } - public string Description => this._Description ?? (this._Description = ((AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyDescriptionAttribute))).Description); + public string Description + { + get { return this._Description ?? (this._Description = ((AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyDescriptionAttribute))).Description); } + } - public string Company => this._Company ?? (this._Company = ((AssemblyCompanyAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyCompanyAttribute))).Company); + public string Company + { + get { return this._Company ?? (this._Company = ((AssemblyCompanyAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyCompanyAttribute))).Company); } + } - public string Product => this._Product ?? (this._Product = ((AssemblyProductAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyProductAttribute))).Product); + public string Product + { + get { return this._Product ?? (this._Product = ((AssemblyProductAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyProductAttribute))).Product); } + } - public string Copyright => this._Copyright ?? (this._Copyright = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyCopyrightAttribute))).Copyright); + public string Copyright + { + get { return this._Copyright ?? (this._Copyright = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyCopyrightAttribute))).Copyright); } + } - public string Trademark => this._Trademark ?? (this._Trademark = ((AssemblyTrademarkAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyTrademarkAttribute))).Trademark); + public string Trademark + { + get { return this._Trademark ?? (this._Trademark = ((AssemblyTrademarkAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyTrademarkAttribute))).Trademark); } + } - public Version Version => this._Version ?? (this._Version = this.assembly.GetName().Version); + public Version Version + { + get { return this._Version ?? (this._Version = this.assembly.GetName().Version); } + } - public string VersionString => this._VersionString ?? (this._VersionString = string.Format("{0}{1}{2}", this.Version.ToString(3), this.IsBetaRelease ? " β" : "", this.Version.Revision == 0 ? "" : " rev." + this.Version.Revision)); + public string VersionString + { + get { return this._VersionString ?? (this._VersionString = string.Format("{0}{1}{2}", this.Version.ToString(3), this.IsBetaRelease ? " β" : "", this.Version.Revision == 0 ? "" : " rev." + this.Version.Revision)); } + } - public bool IsBetaRelease => false; + public bool IsBetaRelease + { + get { return false; } + } - public IReadOnlyCollection Libraries => this._Libraries ?? (this._Libraries = new List + public IReadOnlyCollection Libraries { - new Library("Reactive Extensions", new Uri("http://rx.codeplex.com/")), - new Library("Interactive Extensions", new Uri("http://rx.codeplex.com/")), - new Library("Windows API Code Pack", new Uri("http://archive.msdn.microsoft.com/WindowsAPICodePack")), - new Library("Livet", new Uri("http://ugaya40.net/livet")), - new Library("DynamicJson", new Uri("http://dynamicjson.codeplex.com/")), - new Library("FiddlerCore", new Uri("http://fiddler2.com/fiddlercore")), - }); + get + { + return this._Libraries ?? (this._Libraries = new List + { + new Library("Reactive Extensions", new Uri("http://rx.codeplex.com/")), + new Library("Interactive Extensions", new Uri("http://rx.codeplex.com/")), + new Library("Windows API Code Pack", new Uri("http://archive.msdn.microsoft.com/WindowsAPICodePack")), + new Library("Livet", new Uri("http://ugaya40.net/livet")), + new Library("DynamicJson", new Uri("http://dynamicjson.codeplex.com/")), + new Library("FiddlerCore", new Uri("http://fiddler2.com/fiddlercore")), + }); + } + } } public class Library diff --git a/Grabacr07.KanColleViewer/Models/ResourceService.cs b/Grabacr07.KanColleViewer/Models/ResourceService.cs index 926918d66..98359a9dd 100644 --- a/Grabacr07.KanColleViewer/Models/ResourceService.cs +++ b/Grabacr07.KanColleViewer/Models/ResourceService.cs @@ -17,9 +17,12 @@ public class ResourceService : NotificationObject private static readonly ResourceService current = new ResourceService(); - public static ResourceService Current => current; + public static ResourceService Current + { + get { return current; } + } - #endregion + #endregion /// /// サポートされているカルチャの名前。 @@ -33,22 +36,20 @@ public class ResourceService : NotificationObject "ko-KR", }; - private readonly Resources _Resources = new Resources(); - private readonly IReadOnlyCollection _SupportedCultures; - /// /// 多言語化されたリソースを取得します。 /// - public Resources Resources => this._Resources; + public Resources Resources { get; private set; } - /// + /// /// サポートされているカルチャを取得します。 /// - public IReadOnlyCollection SupportedCultures => this._SupportedCultures; + public IReadOnlyCollection SupportedCultures { get; private set; } - private ResourceService() + private ResourceService() { - this._SupportedCultures = this.supportedCultureNames + this.Resources = new Resources(); + this.SupportedCultures = this.supportedCultureNames .Select(x => { try diff --git a/Grabacr07.KanColleViewer/Models/Settings.cs b/Grabacr07.KanColleViewer/Models/Settings.cs index 5d6793d84..eadcafa70 100644 --- a/Grabacr07.KanColleViewer/Models/Settings.cs +++ b/Grabacr07.KanColleViewer/Models/Settings.cs @@ -6,6 +6,7 @@ using System.Xml.Serialization; using Grabacr07.KanColleViewer.Models.Data.Xml; using Grabacr07.KanColleWrapper; +using Grabacr07.KanColleWrapper.Models; using Livet; namespace Grabacr07.KanColleViewer.Models @@ -413,7 +414,7 @@ public KanColleClientSettings KanColleClientSettings } #endregion - + #region EnableTranslations 変更通知プロパティ diff --git a/Grabacr07.KanColleViewer/Models/StatusService.cs b/Grabacr07.KanColleViewer/Models/StatusService.cs index f47605624..3c844e0cc 100644 --- a/Grabacr07.KanColleViewer/Models/StatusService.cs +++ b/Grabacr07.KanColleViewer/Models/StatusService.cs @@ -17,9 +17,13 @@ public class StatusService : NotificationObject #region static members private static readonly StatusService current = new StatusService(); - public static StatusService Current => current; - #endregion + public static StatusService Current + { + get { return current; } + } + + #endregion private readonly Subject notifier; private string persisitentMessage = ""; diff --git a/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs b/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs index 6cf42ba76..815d22606 100644 --- a/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs +++ b/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs @@ -51,4 +51,4 @@ // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を // 既定値にすることができます: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.5.0.3")] +[assembly: AssemblyVersion("3.6.1.4")] diff --git a/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogSortWorker.cs b/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogSortWorker.cs index e9a8adb33..dd6ff61d5 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogSortWorker.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogSortWorker.cs @@ -15,19 +15,19 @@ public class ShipCatalogSortWorker private readonly NoneColumnViewModel noneColumn = new NoneColumnViewModel(); private SortableColumnViewModel currentSortTarget; - public IdColumnViewModel IdColumn { get; } - public TypeColumnViewModel TypeColumn { get; } - public NameColumnViewModel NameColumn { get; } - public LevelColumnViewModel LevelColumn { get; } - public ConditionColumnViewModel ConditionColumn { get; } - public FirepowerColumnViewModel FirepowerColumn { get; } - public TorpedoColumnViewModel TorpedoColumn { get; } - public AntiAirColumnViewModel AntiAirColumn { get; } - public ArmorColumnViewModel ArmorColumn { get; } - public LuckColumnViewModel LuckColumn { get; } - public ViewRangeColumnViewModel ViewRangeColumn { get; } - public EvasionColumnViewModel EvasionColumn { get; } - public AntiSubColumnViewModel AntiSubColumn { get; } + public IdColumnViewModel IdColumn { get; private set; } + public TypeColumnViewModel TypeColumn { get; private set; } + public NameColumnViewModel NameColumn { get; private set; } + public LevelColumnViewModel LevelColumn { get; private set; } + public ConditionColumnViewModel ConditionColumn { get; private set; } + public FirepowerColumnViewModel FirepowerColumn { get; private set; } + public TorpedoColumnViewModel TorpedoColumn { get; private set; } + public AntiAirColumnViewModel AntiAirColumn { get; private set; } + public ArmorColumnViewModel ArmorColumn { get; private set; } + public LuckColumnViewModel LuckColumn { get; private set; } + public ViewRangeColumnViewModel ViewRangeColumn { get; private set; } + public EvasionColumnViewModel EvasionColumn { get; private set; } + public AntiSubColumnViewModel AntiSubColumn { get; private set; } public ShipCatalogSortWorker() { diff --git a/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogWindowViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogWindowViewModel.cs index 3693aa6b3..1abc3dec9 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogWindowViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogWindowViewModel.cs @@ -18,16 +18,16 @@ public class ShipCatalogWindowViewModel : WindowViewModel private readonly Subject updateSource = new Subject(); private readonly Homeport homeport = KanColleClient.Current.Homeport; - public ShipCatalogSortWorker SortWorker { get; } - public IReadOnlyCollection ShipTypes { get; } - - public ShipLevelFilter ShipLevelFilter { get; } - public ShipLockFilter ShipLockFilter { get; } - public ShipSpeedFilter ShipSpeedFilter { get; } - public ShipModernizeFilter ShipModernizeFilter { get; } - public ShipRemodelingFilter ShipRemodelingFilter { get; } - public ShipExpeditionFilter ShipExpeditionFilter { get; } - public ShipSallyAreaFilter ShipSallyAreaFilter { get; } + public ShipCatalogSortWorker SortWorker { get; private set; } + public IReadOnlyCollection ShipTypes { get; private set; } + + public ShipLevelFilter ShipLevelFilter { get; private set; } + public ShipLockFilter ShipLockFilter { get; private set; } + public ShipSpeedFilter ShipSpeedFilter { get; private set; } + public ShipModernizeFilter ShipModernizeFilter { get; private set; } + public ShipRemodelingFilter ShipRemodelingFilter { get; private set; } + public ShipExpeditionFilter ShipExpeditionFilter { get; private set; } + public ShipSallyAreaFilter ShipSallyAreaFilter { get; private set; } public bool CheckAllShipTypes { diff --git a/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipViewModel.cs index d1ba5d017..22856ec52 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipViewModel.cs @@ -18,7 +18,7 @@ public ShipViewModel(int index, Ship ship) { this.Index = index; this.Ship = ship; - this.SlotItems = ship.SlotItems.Select(i => new SlotItemViewModel(i.Info)).ToList(); + // this.SlotItems = ship.SlotItems.Select(i => new SlotItemViewModel(i.Info)).ToList(); } } } diff --git a/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemCatalogViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemCatalogViewModel.cs index 38dae39ec..306c2a96b 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemCatalogViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemCatalogViewModel.cs @@ -96,7 +96,7 @@ private static Task> UpdateCore() foreach (var ship in ships.Values) { - foreach (var target in ship.SlotItems.Where(x => x != null).Select(item => dic[item.Info.Id])) + foreach (var target in ship.EquippedSlots.Select(slot => dic[slot.Item.Info.Id])) { target.AddShip(ship); } diff --git a/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemViewModel.cs index a83b45f19..726fbe2f9 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemViewModel.cs @@ -13,18 +13,22 @@ namespace Grabacr07.KanColleViewer.ViewModels.Catalogs public class SlotItemViewModel : ViewModel { private int count; - public List Ships { get; } + public List Ships { get; private set; } public class Counter { public Ship Ship { get; set; } public int Count { get; set; } - public string ShipName => this.Ship.Info.Name; - - public string ShipLevel => "Lv." + this.Ship.Level; + public string ShipName + { + get { return this.Ship.Info.Name; } + } - public string CountString => this.Count == 1 ? "" : " x " + this.Count + " "; + public string ShipLevel + { + get { return "Lv." + this.Ship.Level; } + } public string StatsToolTip { @@ -42,6 +46,11 @@ public string StatsToolTip return AddDetail; } } + + public string CountString + { + get { return this.Count == 1 ? "" : " x " + this.Count + " "; } + } } diff --git a/Grabacr07.KanColleViewer/ViewModels/Composition/PluginViewModelBase.cs b/Grabacr07.KanColleViewer/ViewModels/Composition/PluginViewModelBase.cs index 976c469f3..3febf8091 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Composition/PluginViewModelBase.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Composition/PluginViewModelBase.cs @@ -12,19 +12,31 @@ public abstract class PluginViewModelBase : ViewModel where TPlugin : I { protected TPlugin Plugin { get; private set; } - private IPluginMetadata Metadata { get; } + private IPluginMetadata Metadata { get; set; } - public string Title => this.Metadata.Title; + public string Title + { + get { return this.Metadata.Title; } + } - public string Description => this.Metadata.Description; + public string Description + { + get { return this.Metadata.Description; } + } - public string Author => this.Metadata.Author; + public string Author + { + get { return this.Metadata.Author; } + } - public string Version => this.Metadata.Version; + public string Version + { + get { return this.Metadata.Version; } + } - protected PluginViewModelBase(Lazy plugin) + protected PluginViewModelBase(Lazy plugin) { this.Plugin = plugin.Value; this.Metadata = plugin.Metadata; diff --git a/Grabacr07.KanColleViewer/ViewModels/Composition/ToolViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Composition/ToolViewModel.cs index a6de2e145..eb35303d9 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Composition/ToolViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Composition/ToolViewModel.cs @@ -11,11 +11,17 @@ public class ToolViewModel : PluginViewModelBase { public ToolViewModel(Lazy plugin) : base(plugin) { } - public string ToolName => this.Plugin.ToolName; + public string ToolName + { + get { return this.Plugin.ToolName; } + } - public object View => this.Plugin.GetToolView(); + public object View + { + get { return this.Plugin.GetToolView(); } + } - public override string ToString() + public override string ToString() { return this.Title; } diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/AdmiralViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/AdmiralViewModel.cs index 0bdc9c72f..18516972f 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/AdmiralViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/AdmiralViewModel.cs @@ -13,9 +13,12 @@ public class AdmiralViewModel : ViewModel { #region Model 変更通知プロパティ - public Admiral Model => KanColleClient.Current.Homeport.Admiral; + public Admiral Model + { + get { return KanColleClient.Current.Homeport.Admiral; } + } - #endregion + #endregion public AdmiralViewModel() { diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/BuildingDockViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/BuildingDockViewModel.cs index afad0b78d..1031b4298 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/BuildingDockViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/BuildingDockViewModel.cs @@ -12,15 +12,30 @@ public class BuildingDockViewModel : ViewModel { private readonly BuildingDock source; - public int Id => this.source.Id; + public int Id + { + get { return this.source.Id; } + } - public string Ship => this.source.Ship == null ? "----" : this.source.Ship.Name; + public string Ship + { + get { return this.source.Ship == null ? "----" : this.source.Ship.Name; } + } - public string CompleteTime => this.source.CompleteTime.HasValue ? this.source.CompleteTime.Value.LocalDateTime.ToString("MM/dd HH:mm") : "--/-- --:--:--"; + public string CompleteTime + { + get { return this.source.CompleteTime.HasValue ? this.source.CompleteTime.Value.LocalDateTime.ToString("MM/dd HH:mm") : "--/-- --:--:--"; } + } - public string Remaining => this.source.Remaining.HasValue ? this.source.Remaining.Value.ToString(@"hh\:mm\:ss") : "--:--:--"; + public string Remaining + { + get { return this.source.Remaining.HasValue ? this.source.Remaining.Value.ToString(@"hh\:mm\:ss") : "--:--:--"; } + } - public BuildingDockState State => this.source.State; + public BuildingDockState State + { + get { return this.source.State; } + } public BuildingDockViewModel(BuildingDock source) { diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ConditionViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ConditionViewModel.cs index f1202a941..81d38b324 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ConditionViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ConditionViewModel.cs @@ -12,20 +12,35 @@ public class ConditionViewModel : ViewModel { private readonly FleetCondition source; - public string RejuvenateTime => this.source.RejuvenateTime.HasValue - ? this.source.RejuvenateTime.Value.LocalDateTime.ToString("MM/dd HH:mm") - : "--/-- --:--"; + public string RejuvenateTime + { + get + { + return this.source.RejuvenateTime.HasValue + ? this.source.RejuvenateTime.Value.LocalDateTime.ToString("MM/dd HH:mm") + : "--/-- --:--"; + } + } - public string Remaining => this.source.Remaining.HasValue - ? string.Format("{0:D2}:{1}", - (int)this.source.Remaining.Value.TotalHours, - this.source.Remaining.Value.ToString(@"mm\:ss")) - : "--:--:--"; + public string Remaining + { + get + { + return this.source.Remaining.HasValue + ? string.Format("{0:D2}:{1}", + (int)this.source.Remaining.Value.TotalHours, + this.source.Remaining.Value.ToString(@"mm\:ss")) + : "--:--:--"; + } + } - public bool IsRejuvenating => this.source.IsRejuvenating; + public bool IsRejuvenating + { + get { return this.source.IsRejuvenating; } + } - public ConditionViewModel(FleetCondition condition) + public ConditionViewModel(FleetCondition condition) { this.source = condition; this.CompositeDisposable.Add(new PropertyChangedEventListener(condition, (sender, args) => this.RaisePropertyChanged(args.PropertyName))); diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ExpeditionViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ExpeditionViewModel.cs index b192a858c..e528b5e98 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ExpeditionViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ExpeditionViewModel.cs @@ -13,21 +13,39 @@ public class ExpeditionViewModel : ViewModel { private readonly Expedition source; - public Mission Mission => this.source.Mission; + public Mission Mission + { + get { return this.source.Mission; } + } - public bool IsInExecution => this.source.IsInExecution; + public bool IsInExecution + { + get { return this.source.IsInExecution; } + } - public string ReturnTime => this.source.ReturnTime.HasValue - ? this.source.ReturnTime.Value.LocalDateTime.ToString("MM/dd HH:mm") - : "--/-- --:--"; + public string ReturnTime + { + get + { + return this.source.ReturnTime.HasValue + ? this.source.ReturnTime.Value.LocalDateTime.ToString("MM/dd HH:mm") + : "--/-- --:--"; + } + } - public string Remaining => this.source.Remaining.HasValue - ? string.Format("{0:D2}:{1}", - (int)this.source.Remaining.Value.TotalHours, - this.source.Remaining.Value.ToString(@"mm\:ss")) - : "--:--:--"; + public string Remaining + { + get + { + return this.source.Remaining.HasValue + ? string.Format("{0:D2}:{1}", + (int)this.source.Remaining.Value.TotalHours, + this.source.Remaining.Value.ToString(@"mm\:ss")) + : "--:--:--"; + } + } - public ExpeditionViewModel(Expedition expedition) + public ExpeditionViewModel(Expedition expedition) { this.source = expedition; this.CompositeDisposable.Add(new PropertyChangedEventListener(expedition, (sender, args) => this.RaisePropertyChanged(args.PropertyName))); diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs index 1eb85a0f4..0ca84ab3b 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs @@ -17,11 +17,11 @@ public class FleetViewModel : ViewModel { private readonly Fleet source; - public SortieViewModel Sortie { get; } + public SortieViewModel Sortie { get; private set; } - public ExpeditionViewModel Expedition { get; } + public ExpeditionViewModel Expedition { get; private set; } - public HomeportViewModel Homeport { get; } + public HomeportViewModel Homeport { get; private set; } /// /// 艦隊に所属している艦娘のコレクションを取得します。 @@ -76,21 +76,42 @@ public bool IsSelected #region wrapper properties - public int Id => this.source.Id; + public int Id + { + get { return this.source.Id; } + } - public string Name => string.IsNullOrEmpty(this.source.Name.Trim()) ? "(第 " + this.source.Id + " 艦隊)" : this.source.Name; + public string Name + { + get { return string.IsNullOrEmpty(this.source.Name.Trim()) ? "(第 " + this.source.Id + " 艦隊)" : this.source.Name; } + } - public string TotalLevel => this.source.TotalLevel.ToString("####"); + public string TotalLevel + { + get { return this.source.TotalLevel.ToString("####"); } + } - public string AverageLevel => this.source.AverageLevel.ToString("##.##"); + public string AverageLevel + { + get { return this.source.AverageLevel.ToString("##.##"); } + } - public string Speed => this.source.Speed == KanColleWrapper.Models.Speed.Fast ? Resources.Fleets_Speed_Fast : Resources.Fleets_Speed_Slow; + public string Speed + { + get { return this.source.Speed == KanColleWrapper.Models.Speed.Fast ? Resources.Fleets_Speed_Fast : Resources.Fleets_Speed_Slow; } + } - public int AirSuperiorityPotential => this.source.AirSuperiorityPotential; + public int AirSuperiorityPotential + { + get { return this.source.AirSuperiorityPotential; } + } - public string TotalViewRange => this.source.TotalViewRange.ToString("####"); + public string TotalViewRange + { + get { return this.source.TotalViewRange.ToString("###.##"); } + } - #endregion + #endregion public FleetViewModel(Fleet fleet) diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetsViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetsViewModel.cs index 39fcf225e..72387bf7b 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetsViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetsViewModel.cs @@ -60,10 +60,13 @@ public FleetViewModel SelectedFleet #endregion - public bool IsSupportedNotification => Helper.IsWindows8OrGreater; + public bool IsSupportedNotification + { + get { return Helper.IsWindows8OrGreater; } + } - public FleetsViewModel() + public FleetsViewModel() { this.CompositeDisposable.Add(new PropertyChangedEventListener(KanColleClient.Current.Homeport.Organization) { diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/HomeportViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/HomeportViewModel.cs index 98695bf48..d00ce90aa 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/HomeportViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/HomeportViewModel.cs @@ -15,7 +15,7 @@ public class HomeportViewModel : ViewModel { public Fleet Fleet { get; private set; } - public ConditionViewModel Condition { get; } + public ConditionViewModel Condition { get; private set; } public HomeportViewModel(Fleet fleet) { diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/OverviewViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/OverviewViewModel.cs index 83ecfb918..aa74a3cb9 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/OverviewViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/OverviewViewModel.cs @@ -16,7 +16,7 @@ public override string Name protected set { throw new NotImplementedException(); } } - public MainContentViewModel Content { get; } + public MainContentViewModel Content { get; private set; } public OverviewViewModel(MainContentViewModel owner) diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/RepairingDockViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/RepairingDockViewModel.cs index 5d3467712..d65f6764e 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/RepairingDockViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/RepairingDockViewModel.cs @@ -12,21 +12,39 @@ public class RepairingDockViewModel : ViewModel { private readonly RepairingDock source; - public int Id => this.source.Id; + public int Id + { + get { return this.source.Id; } + } - public string Ship => this.source.Ship == null ? "----" : this.source.Ship.Info.Name; + public string Ship + { + get { return this.source.Ship == null ? "----" : this.source.Ship.Info.Name; } + } - public string CompleteTime => this.source.CompleteTime.HasValue ? this.source.CompleteTime.Value.LocalDateTime.ToString("MM/dd HH:mm") : "--/-- --:--:--"; + public string CompleteTime + { + get { return this.source.CompleteTime.HasValue ? this.source.CompleteTime.Value.LocalDateTime.ToString("MM/dd HH:mm") : "--/-- --:--:--"; } + } - public string Remaining => this.source.Remaining.HasValue - ? string.Format("{0:D2}:{1}", - (int)this.source.Remaining.Value.TotalHours, - this.source.Remaining.Value.ToString(@"mm\:ss")) - : "--:--:--"; + public string Remaining + { + get + { + return this.source.Remaining.HasValue + ? string.Format("{0:D2}:{1}", + (int)this.source.Remaining.Value.TotalHours, + this.source.Remaining.Value.ToString(@"mm\:ss")) + : "--:--:--"; + } + } - public RepairingDockState State => this.source.State; + public RepairingDockState State + { + get { return this.source.State; } + } - public RepairingDockViewModel(RepairingDock source) + public RepairingDockViewModel(RepairingDock source) { this.source = source; this.CompositeDisposable.Add(new PropertyChangedEventListener(source, (sender, args) => this.RaisePropertyChanged(args.PropertyName))); diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs index e2cea8c9c..ce18cc560 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs @@ -46,7 +46,7 @@ public string StatsToolTip public ShipViewModel(Ship ship) { this.Ship = ship; - this.SlotItems = ship.SlotItems.Select(i => new SlotItemViewModel(i.Info)).ToList(); + // this.SlotItems = ship.SlotItems.Select(i => new SlotItemViewModel(i.Info)).ToList(); } } } diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipyardViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipyardViewModel.cs index c8fc3d87c..43cefe9f7 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipyardViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipyardViewModel.cs @@ -54,7 +54,7 @@ public BuildingDockViewModel[] BuildingDocks #endregion - public CreatedSlotItemViewModel CreatedSlotItem { get; } + public CreatedSlotItemViewModel CreatedSlotItem { get; private set; } public ShipyardViewModel() diff --git a/Grabacr07.KanColleViewer/ViewModels/MainContentViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/MainContentViewModel.cs index c874139b4..330eea2e8 100644 --- a/Grabacr07.KanColleViewer/ViewModels/MainContentViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/MainContentViewModel.cs @@ -16,10 +16,10 @@ public class MainContentViewModel : ViewModel public ShipsViewModel Ships { get; private set; } public SlotItemsViewModel SlotItems { get; private set; } - public FleetsViewModel Fleets { get; } - public ShipyardViewModel Shipyard { get; } - public QuestsViewModel Quests { get; } - public ExpeditionsViewModel Expeditions { get; } + public FleetsViewModel Fleets { get; private set; } + public ShipyardViewModel Shipyard { get; private set; } + public QuestsViewModel Quests { get; private set; } + public ExpeditionsViewModel Expeditions { get; private set; } public IList TabItems { get; set; } public IList SystemTabItems { get; set; } diff --git a/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs index 1ca9f8957..95a8ab6d2 100644 --- a/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs @@ -58,9 +58,12 @@ public string ScreenshotFolder #region CanOpenScreenshotFolder 変更通知プロパティ - public bool CanOpenScreenshotFolder => Directory.Exists(this.ScreenshotFolder); + public bool CanOpenScreenshotFolder + { + get { return Directory.Exists(this.ScreenshotFolder); } + } - #endregion + #endregion #region ScreenshotImageFormat 変更通知プロパティ @@ -611,40 +614,19 @@ public List ToolPlugins #endregion - #region ViewRangeType1 変更通知プロパティ - - private bool _ViewRangeType1; - - public bool ViewRangeType1 - { - get { return this._ViewRangeType1; } - set - { - if (this._ViewRangeType1 != value) - { - this._ViewRangeType1 = value; - this.RaisePropertyChanged(); - if (value) Settings.Current.KanColleClientSettings.ViewRangeCalcLogic = ViewRangeCalcLogic.Type1; - } - } - } - - #endregion - - #region ViewRangeType2 変更通知プロパティ + #region ViewRangeSettingsCollection 変更通知プロパティ - private bool _ViewRangeType2; + private List _ViewRangeSettingsCollection; - public bool ViewRangeType2 + public List ViewRangeSettingsCollection { - get { return this._ViewRangeType2; } + get { return this._ViewRangeSettingsCollection; } set { - if (this._ViewRangeType2 != value) + if (this._ViewRangeSettingsCollection != value) { - this._ViewRangeType2 = value; + this._ViewRangeSettingsCollection = value; this.RaisePropertyChanged(); - if (value) Settings.Current.KanColleClientSettings.ViewRangeCalcLogic = ViewRangeCalcLogic.Type2; } } } @@ -695,8 +677,9 @@ public SettingsViewModel() (sender, args) => this.RaisePropertyChanged(args.PropertyName), }); - this._ViewRangeType1 = Settings.Current.KanColleClientSettings.ViewRangeCalcLogic == ViewRangeCalcLogic.Type1; - this._ViewRangeType2 = Settings.Current.KanColleClientSettings.ViewRangeCalcLogic == ViewRangeCalcLogic.Type2; + this.ViewRangeSettingsCollection = ViewRangeCalcLogic.Logics + .Select(x => new ViewRangeSettingsViewModel(x)) + .ToList(); this.CheckForUpdates(); this.ReloadPlugins(); @@ -822,5 +805,33 @@ public void ReloadPlugins() this.NotifierPlugins = new List(PluginHost.Instance.Notifiers.Select(x => new NotifierViewModel(x))); this.ToolPlugins = new List(PluginHost.Instance.Tools.Select(x => new ToolViewModel(x))); } + + + public class ViewRangeSettingsViewModel + { + private bool selected; + + public ICalcViewRange Logic { get; set; } + + public bool Selected + { + get { return this.selected; } + set + { + this.selected = value; + if (value) + { + Settings.Current.KanColleClientSettings.ViewRangeCalcType = this.Logic.Id; + foreach (var f in KanColleClient.Current.Homeport.Organization.Fleets) f.Value.Calculate(); + } + } + } + + public ViewRangeSettingsViewModel(ICalcViewRange logic) + { + this.Logic = logic; + this.selected = Settings.Current.KanColleClientSettings.ViewRangeCalcType == logic.Id; + } + } } } diff --git a/Grabacr07.KanColleViewer/ViewModels/StartContentViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/StartContentViewModel.cs index daf7d2f0e..b355017bc 100644 --- a/Grabacr07.KanColleViewer/ViewModels/StartContentViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/StartContentViewModel.cs @@ -11,13 +11,16 @@ namespace Grabacr07.KanColleViewer.ViewModels { public class StartContentViewModel : ViewModel { - #region singleton + #region singleton private static readonly StartContentViewModel instance = new StartContentViewModel(); - public static StartContentViewModel Instance => instance; + public static StartContentViewModel Instance + { + get { return instance; } + } - #endregion + #endregion #region CanDeleteInternetCache 変更通知プロパティ diff --git a/Grabacr07.KanColleViewer/Views/Behaviors/FlickFleetsAction.cs b/Grabacr07.KanColleViewer/Views/Behaviors/FlickFleetsAction.cs index b4b2ddda6..3aa503f2c 100644 --- a/Grabacr07.KanColleViewer/Views/Behaviors/FlickFleetsAction.cs +++ b/Grabacr07.KanColleViewer/Views/Behaviors/FlickFleetsAction.cs @@ -15,16 +15,15 @@ public enum FlickOrientation public class FlickFleetsAction : TargetedTriggerAction { - private FlickOrientation orientation = FlickOrientation.Horizontal; + public FlickOrientation Orientation { get; set; } - public FlickOrientation Orientation + public bool IsCyclic { get; set; } + + public FlickFleetsAction() { - get { return orientation; } - set { orientation = value; } + this.Orientation = FlickOrientation.Horizontal; } - public bool IsCyclic { get; set; } - protected override void Invoke(object parameter) { if (!(parameter is FlickDirection)) return; diff --git a/Grabacr07.KanColleViewer/Views/Catalogs/ShipCatalogWindow.xaml b/Grabacr07.KanColleViewer/Views/Catalogs/ShipCatalogWindow.xaml index 5a59a29a4..5e1b53e1d 100644 --- a/Grabacr07.KanColleViewer/Views/Catalogs/ShipCatalogWindow.xaml +++ b/Grabacr07.KanColleViewer/Views/Catalogs/ShipCatalogWindow.xaml @@ -881,7 +881,7 @@ - + - + - diff --git a/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml b/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml index 8d459b699..de2653e8f 100644 --- a/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml +++ b/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml @@ -55,6 +55,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -93,6 +249,7 @@ SharedSizeGroup="SlotItems" /> + @@ -209,9 +366,9 @@ - - diff --git a/Grabacr07.KanColleViewer/Views/Settings/Operation.xaml b/Grabacr07.KanColleViewer/Views/Settings/Operation.xaml index d0f943183..87c54fc3f 100644 --- a/Grabacr07.KanColleViewer/Views/Settings/Operation.xaml +++ b/Grabacr07.KanColleViewer/Views/Settings/Operation.xaml @@ -72,40 +72,24 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + public static int CalcAirSuperiorityPotential(this Ship ship) { - return ship.SlotItems.Zip(ship.OnSlot, (item, i) => item.CalcAirSuperiorityPotential(i)).Sum(); + return ship.EquippedSlots.Select(x => x.Item.CalcAirSuperiorityPotential(x.Current)).Sum(); } - - - /// - /// 艦隊の索敵値を計算します。 - /// - /// - public static int CalcFleetViewRange(this Fleet fleet, ViewRangeCalcLogic logic) - { - if (fleet == null || fleet.Ships.Length == 0) return 0; - - if (logic == ViewRangeCalcLogic.Type1) - { - return fleet.Ships.Sum(x => x.ViewRange); - } - - if (logic == ViewRangeCalcLogic.Type2) - { - // http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#area5 - // [索敵装備と装備例] によって示されている計算式 - // stype=7 が偵察機 (2 倍する索敵値)、stype=8 が電探 - - var spotter = fleet.Ships.SelectMany( - x => x.SlotItems - .Zip(x.OnSlot, (i, o) => new { Item = i.Info, Slot = o }) - .Where(a => a.Item.RawData.api_type.Get(1) == 7) - .Where(a => a.Slot > 0) - .Select(a => a.Item.RawData.api_saku) - ).Sum(); - - var radar = fleet.Ships.SelectMany( - x => x.SlotItems - .Where(i => i.Info.RawData.api_type.Get(1) == 8) - .Select(i => i.Info.RawData.api_saku) - ).Sum(); - - return (spotter * 2) + radar + (int)Math.Sqrt(fleet.Ships.Sum(x => x.ViewRange) - spotter - radar); - } - - return 0; - } - } - - - /// - /// 索敵値の計算に使用するロジックの種類を示す識別します。 - /// - public enum ViewRangeCalcLogic - { - /// - /// 単純な索敵合計値。 - /// - Type1, - - /// - /// (偵察機 × 2) + (電探) + √(装備込みの艦隊索敵値合計 - 偵察機 - 電探)。 - /// - Type2, } -} +} \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/Homeport.cs b/Grabacr07.KanColleWrapper/Homeport.cs index 3d6f718b5..f031c5a85 100644 --- a/Grabacr07.KanColleWrapper/Homeport.cs +++ b/Grabacr07.KanColleWrapper/Homeport.cs @@ -17,12 +17,12 @@ public class Homeport : NotificationObject /// /// 艦隊の編成状況にアクセスできるようにします。 /// - public Organization Organization { get; } + public Organization Organization { get; private set; } /// /// 資源および資材の保有状況にアクセスできるようにします。 /// - public Materials Materials { get; } + public Materials Materials { get; private set; } /// /// 装備や消費アイテムの保有状況にアクセスできるようにします。 @@ -37,7 +37,7 @@ public class Homeport : NotificationObject /// /// 複数の入渠ドックを持つ工廠を取得します。 /// - public Repairyard Repairyard { get; } + public Repairyard Repairyard { get; private set; } /// /// 任務情報を取得します。 @@ -94,7 +94,7 @@ internal Homeport(KanColleProxy proxy) this.Organization.Update(x.Data.api_ship); this.Repairyard.Update(x.Data.api_ndock); this.Organization.Update(x.Data.api_deck_port); - this.Organization.Combined = x.Data.api_combined_flag == 1; + this.Organization.Combined = x.Data.api_combined_flag != 0; this.Materials.Update(x.Data.api_material); this.UpdateAdmiral(x.Data.api_basic); }); diff --git a/Grabacr07.KanColleWrapper/Itemyard.cs b/Grabacr07.KanColleWrapper/Itemyard.cs index 1bcfc7329..3a09fdf8a 100644 --- a/Grabacr07.KanColleWrapper/Itemyard.cs +++ b/Grabacr07.KanColleWrapper/Itemyard.cs @@ -22,9 +22,12 @@ public class Itemyard : NotificationObject /// /// と、出撃中に入手したものを含んだ装備数を取得します。 /// - public int SlotItemsCount => this.SlotItems.Count + this.droppedItemsCount; + public int SlotItemsCount + { + get { return this.SlotItems.Count + this.droppedItemsCount; } + } - #region SlotItems 変更通知プロパティ + #region SlotItems 変更通知プロパティ private MemberTable _SlotItems; @@ -84,6 +87,8 @@ internal Itemyard(KanColleProxy proxy) // proxy.api_req_sortie_battleresult.TryParse().Subscribe(x => this.DropShip(x.Data)); proxy.api_get_member_useitem.TryParse().Subscribe(x => this.Update(x.Data)); + + proxy.api_req_kousyou_remodel_slot.TryParse().Subscribe(x => this.RemoveFromRemodel(x.Data)); } @@ -109,13 +114,24 @@ internal void AddFromDock(kcsapi_kdock_getship source) internal void RemoveFromShip(Ship ship) { - foreach (var x in ship.SlotItems.Where(x => x != null).ToArray()) + foreach (var x in ship.EquippedSlots.ToArray()) { - this.SlotItems.Remove(x); + this.SlotItems.Remove(x.Item); } this.RaiseSlotItemsChanged(); } + internal void RemoveFromRemodel(kcsapi_remodel_slot source) + { + if (source.api_use_slot_id != null) + { + foreach (var id in source.api_use_slot_id) + { + this.SlotItems.Remove(id); + } + this.RaiseSlotItemsChanged(); + } + } private void CreateItem(kcsapi_createitem source) { @@ -132,7 +148,7 @@ private void DestroyItem(SvData data) try { - foreach (var x in data.Request["api_slotitem_ids"].Split(new[] { ',' }).Select(int.Parse)) + foreach (var x in data.Request["api_slotitem_ids"].Split(',').Select(int.Parse)) { this.SlotItems.Remove(x); } @@ -147,21 +163,21 @@ private void DestroyItem(SvData data) /* No longer available in the API private void DropShip(kcsapi_battleresult source) { - try - { - if (source.api_get_ship == null) return; - - var target = KanColleClient.Current.Master.Ships[source.api_get_ship.api_ship_id]; - if (target == null) return; - - this.droppedItemsCount += target.RawData.api_defeq.Count(x => x != -1); - this.RaisePropertyChanged("SlotItemsCount"); - } - catch (Exception ex) - { - // defeq が消えてるっぽい暫定対応 (雑) - Debug.WriteLine(ex); - } + try + { + if (source.api_get_ship == null) return; + + var target = KanColleClient.Current.Master.Ships[source.api_get_ship.api_ship_id]; + if (target == null) return; + + this.droppedItemsCount += target.RawData.api_defeq.Count(x => x != -1); + this.RaisePropertyChanged("SlotItemsCount"); + } + catch (Exception ex) + { + // defeq が消えてるっぽい暫定対応 (雑) + Debug.WriteLine(ex); + } } */ diff --git a/Grabacr07.KanColleWrapper/KanColleClient.cs b/Grabacr07.KanColleWrapper/KanColleClient.cs index 25b2ac28e..d4769feb3 100644 --- a/Grabacr07.KanColleWrapper/KanColleClient.cs +++ b/Grabacr07.KanColleWrapper/KanColleClient.cs @@ -11,34 +11,39 @@ namespace Grabacr07.KanColleWrapper { - public class KanColleClient : NotificationObject - { - #region singleton + public class KanColleClient : NotificationObject + { + #region singleton - public static KanColleClient Current { get; } = new KanColleClient(); + private static KanColleClient current = new KanColleClient(); - #endregion + public static KanColleClient Current + { + get { return current; } + } - /// - /// 艦これの通信をフックするプロキシを取得します。 - /// - public KanColleProxy Proxy { get; private set; } + #endregion - /// - /// ユーザーに依存しないマスター情報を取得します。 - /// - public Master Master { get; private set; } + /// + /// 艦これの通信をフックするプロキシを取得します。 + /// + public KanColleProxy Proxy { get; private set; } - /// - /// 母港の情報を取得します。 - /// - public Homeport Homeport { get; private set; } + /// + /// ユーザーに依存しないマスター情報を取得します。 + /// + public Master Master { get; private set; } /// /// Application update notifications and downloads. /// public Updater Updater { get; private set; } + /// + /// 母港の情報を取得します。 + /// + public Homeport Homeport { get; private set; } + /// /// Translation engine for ships, equipment, quests, and sorties. /// @@ -46,119 +51,119 @@ public class KanColleClient : NotificationObject #region IsStarted 変更通知プロパティ - private bool _IsStarted; - - /// - /// 艦これが開始されているかどうかを示す値を取得します。 - /// - public bool IsStarted - { - get { return this._IsStarted; } - set - { - if (this._IsStarted != value) - { - this._IsStarted = value; - this.RaisePropertyChanged(); - } - } - } - - #endregion - - #region IsInSortie 変更通知プロパティ - - private bool _IsInSortie; - - /// - /// 艦隊が出撃中かどうかを示す値を取得します。 - /// - public bool IsInSortie - { - get { return this._IsInSortie; } - private set - { - if (this._IsInSortie != value) - { - this._IsInSortie = value; - this.RaisePropertyChanged(); - } - } - } - - #endregion - - #region Settings 変更通知プロパティ - - private KanColleClientSettings _Settings; - - public KanColleClientSettings Settings - { - get { return this._Settings ?? (this._Settings = new KanColleClientSettings()); } - set - { - if (this._Settings != value) - { - this._Settings = value; - this.RaisePropertyChanged(); - } - } - } - - #endregion - - - private KanColleClient() - { - this.Initialieze(); - - var start = this.Proxy.api_req_map_start; - var end = this.Proxy.api_port; - - this.Proxy.ApiSessionSource - .SkipUntil(start.Do(_ => this.IsInSortie = true)) - .TakeUntil(end) - .Finally(() => this.IsInSortie = false) - .Repeat() - .Subscribe(); - } - - - public void Initialieze() - { - var proxy = this.Proxy ?? (this.Proxy = new KanColleProxy()); - var basic = proxy.api_get_member_basic.TryParse().FirstAsync().ToTask(); - var kdock = proxy.api_get_member_kdock.TryParse().FirstAsync().ToTask(); - var sitem = proxy.api_get_member_slot_item.TryParse().FirstAsync().ToTask(); + private bool _IsStarted; + + /// + /// 艦これが開始されているかどうかを示す値を取得します。 + /// + public bool IsStarted + { + get { return this._IsStarted; } + set + { + if (this._IsStarted != value) + { + this._IsStarted = value; + this.RaisePropertyChanged(); + } + } + } + + #endregion + + #region IsInSortie 変更通知プロパティ + + private bool _IsInSortie; + + /// + /// 艦隊が出撃中かどうかを示す値を取得します。 + /// + public bool IsInSortie + { + get { return this._IsInSortie; } + private set + { + if (this._IsInSortie != value) + { + this._IsInSortie = value; + this.RaisePropertyChanged(); + } + } + } + + #endregion + + #region Settings 変更通知プロパティ + + private KanColleClientSettings _Settings; + + public KanColleClientSettings Settings + { + get { return this._Settings ?? (this._Settings = new KanColleClientSettings()); } + set + { + if (this._Settings != value) + { + this._Settings = value; + this.RaisePropertyChanged(); + } + } + } + + #endregion + + + private KanColleClient() + { + this.Initialieze(); + + var start = this.Proxy.api_req_map_start; + var end = this.Proxy.api_port; + + this.Proxy.ApiSessionSource + .SkipUntil(start.Do(_ => this.IsInSortie = true)) + .TakeUntil(end) + .Finally(() => this.IsInSortie = false) + .Repeat() + .Subscribe(); + } + + + public void Initialieze() + { + var proxy = this.Proxy ?? (this.Proxy = new KanColleProxy()); + var basic = proxy.api_get_member_basic.TryParse().FirstAsync().ToTask(); + var kdock = proxy.api_get_member_kdock.TryParse().FirstAsync().ToTask(); + var sitem = proxy.api_get_member_slot_item.TryParse().FirstAsync().ToTask(); this.Updater = new Updater(); this.Translations = new Translations(); - proxy.api_start2.FirstAsync().Subscribe(async session => - { - var timeout = Task.Delay(TimeSpan.FromSeconds(20)); - var canInitialize = await Task.WhenAny(new Task[] { basic, kdock, sitem }.WhenAll(), timeout) != timeout; - - // タイムアウト仕掛けてるのは、今後のアップデートで basic, kdock, slot_item のいずれかが来なくなったときに - // 起動できなくなる (IsStarted を true にできなくなる) のを防ぐため - // ----- - // ま、そんな規模の変更があったらそもそもまともに動作せんだろうがな ☝(◞‸◟)☝ 野良ツールはつらいよ - - SvData svd; - if (!SvData.TryParse(session, out svd)) return; - - this.Master = new Master(svd.Data); - if (this.Homeport == null) this.Homeport = new Homeport(proxy); - - if (canInitialize) - { - this.Homeport.UpdateAdmiral((await basic).Data); - this.Homeport.Itemyard.Update((await sitem).Data); - this.Homeport.Dockyard.Update((await kdock).Data); - } - - this.IsStarted = true; - }); - } - } + proxy.api_start2.FirstAsync().Subscribe(async session => + { + var timeout = Task.Delay(TimeSpan.FromSeconds(20)); + var canInitialize = await Task.WhenAny(new Task[] { basic, kdock, sitem }.WhenAll(), timeout) != timeout; + + // タイムアウト仕掛けてるのは、今後のアップデートで basic, kdock, slot_item のいずれかが来なくなったときに + // 起動できなくなる (IsStarted を true にできなくなる) のを防ぐため + // ----- + // ま、そんな規模の変更があったらそもそもまともに動作せんだろうがな ☝(◞‸◟)☝ 野良ツールはつらいよ + + SvData svd; + if (!SvData.TryParse(session, out svd)) return; + + this.Master = new Master(svd.Data); + if (this.Homeport == null) this.Homeport = new Homeport(proxy); + + if (canInitialize) + { + this.Homeport.UpdateAdmiral((await basic).Data); + this.Homeport.Itemyard.Update((await sitem).Data); + this.Homeport.Dockyard.Update((await kdock).Data); + } + + this.IsStarted = true; + }); + } + } } diff --git a/Grabacr07.KanColleWrapper/KanColleClientSettings.cs b/Grabacr07.KanColleWrapper/KanColleClientSettings.cs index d852828fc..34fd8b2d4 100644 --- a/Grabacr07.KanColleWrapper/KanColleClientSettings.cs +++ b/Grabacr07.KanColleWrapper/KanColleClientSettings.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Grabacr07.KanColleWrapper.Models; using Livet; namespace Grabacr07.KanColleWrapper @@ -73,18 +74,18 @@ public bool EnableLogging #endregion - #region ViewRangeCalcLogic 変更通知プロパティ + #region ViewRangeCalcType 変更通知プロパティ - private ViewRangeCalcLogic _ViewRangeCalcLogic; + private string _ViewRangeCalcType; - public ViewRangeCalcLogic ViewRangeCalcLogic + public string ViewRangeCalcType { - get { return this._ViewRangeCalcLogic; } + get { return this._ViewRangeCalcType ?? (this._ViewRangeCalcType = new ViewRangeType1().Id); } set { - if (this._ViewRangeCalcLogic != value) + if (this._ViewRangeCalcType != value) { - this._ViewRangeCalcLogic = value; + this._ViewRangeCalcType = value; this.RaisePropertyChanged(); } } diff --git a/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs b/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs index 1b2f51dab..5fd5adf10 100644 --- a/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs +++ b/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs @@ -8,13 +8,12 @@ using System.Reactive.Linq; using System.Threading.Tasks; using Fiddler; +// ReSharper disable InconsistentNaming namespace Grabacr07.KanColleWrapper { partial class KanColleProxy { - // ReSharper disable InconsistentNaming - /// /// エンド ポイント "/kcsapi/api_start2" からのセッションを配信します。 /// @@ -199,6 +198,30 @@ public IObservable api_req_kousyou_destroyitem2 get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_kousyou/destroyitem2"); } } + /// + /// エンド ポイント "/kcsapi/api_req_kousyou/remodel_slotlist" からのセッションを配信します。 + /// + public IObservable api_req_kousyou_remodel_slotlist + { + get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_kousyou/remodel_slotlist"); } + } + + /// + /// エンド ポイント "/kcsapi/api_req_kousyou/remodel_slotlist_detail" からのセッションを配信します。 + /// + public IObservable api_req_kousyou_remodel_slotlist_detail + { + get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_kousyou/remodel_slotlist_detail"); } + } + + /// + /// エンド ポイント "/kcsapi/api_req_kousyou/remodel_slot" からのセッションを配信します。 + /// + public IObservable api_req_kousyou_remodel_slot + { + get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_kousyou/remodel_slot"); } + } + /// /// エンド ポイント "/kcsapi/api_req_nyukyo/start" からのセッションを配信します。 /// @@ -295,6 +318,13 @@ public IObservable api_req_combined_battle_battleresult get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_combined_battle/battleresult"); } } - // ReSharper restore InconsistentNaming + /// + /// エンド ポイント "/kcsapi/api_req_combined_battle/goback_port" からのセッションを配信します。 + /// + public IObservable api_req_combined_battle_goback_port + { + get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_combined_battle/goback_port"); } + } + } } diff --git a/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.tt b/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.tt index 052940521..3cd3516db 100644 --- a/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.tt +++ b/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.tt @@ -31,6 +31,9 @@ "/kcsapi/api_req_kousyou/createship_speedchange", "/kcsapi/api_req_kousyou/destroyship", "/kcsapi/api_req_kousyou/destroyitem2", + "/kcsapi/api_req_kousyou/remodel_slotlist", + "/kcsapi/api_req_kousyou/remodel_slotlist_detail", + "/kcsapi/api_req_kousyou/remodel_slot", "/kcsapi/api_req_nyukyo/start", "/kcsapi/api_req_nyukyo/speedchange", "/kcsapi/api_req_map/start", @@ -43,6 +46,7 @@ "/kcsapi/api_req_combined_battle/battle", "/kcsapi/api_req_combined_battle/airbattle", "/kcsapi/api_req_combined_battle/battleresult", + "/kcsapi/api_req_combined_battle/goback_port", }; #> // @@ -55,13 +59,12 @@ using System.Linq; using System.Reactive.Linq; using System.Threading.Tasks; using Fiddler; +// ReSharper disable InconsistentNaming namespace Grabacr07.KanColleWrapper { partial class KanColleProxy { - // ReSharper disable InconsistentNaming - <# foreach (var endpoint in endpoints) { @@ -84,6 +87,5 @@ namespace Grabacr07.KanColleWrapper <# } #> - // ReSharper restore InconsistentNaming } } diff --git a/Grabacr07.KanColleWrapper/KanColleProxy.cs b/Grabacr07.KanColleWrapper/KanColleProxy.cs index ba99270b9..6ffba07a2 100644 --- a/Grabacr07.KanColleWrapper/KanColleProxy.cs +++ b/Grabacr07.KanColleWrapper/KanColleProxy.cs @@ -18,9 +18,15 @@ public partial class KanColleProxy private readonly IConnectableObservable apiSource; private readonly LivetCompositeDisposable compositeDisposable; - public IObservable SessionSource => this.connectableSessionSource.AsObservable(); + public IObservable SessionSource + { + get { return this.connectableSessionSource.AsObservable(); } + } - public IObservable ApiSessionSource => this.apiSource.AsObservable(); + public IObservable ApiSessionSource + { + get { return this.apiSource.AsObservable(); } + } public IProxySettings UpstreamProxySettings { get; set; } diff --git a/Grabacr07.KanColleWrapper/KanColleWrapper.csproj b/Grabacr07.KanColleWrapper/KanColleWrapper.csproj index 5ae8648dd..d385d623c 100644 --- a/Grabacr07.KanColleWrapper/KanColleWrapper.csproj +++ b/Grabacr07.KanColleWrapper/KanColleWrapper.csproj @@ -82,7 +82,6 @@ False ..\packages\Rx-PlatformServices.2.2.4\lib\net45\System.Reactive.PlatformServices.dll - @@ -108,6 +107,7 @@ + @@ -120,6 +120,10 @@ + + + + True @@ -171,7 +175,7 @@ - + diff --git a/Grabacr07.KanColleWrapper/MasterTable.cs b/Grabacr07.KanColleWrapper/MasterTable.cs index aa1df2692..fcec3700f 100644 --- a/Grabacr07.KanColleWrapper/MasterTable.cs +++ b/Grabacr07.KanColleWrapper/MasterTable.cs @@ -18,7 +18,10 @@ public class MasterTable : IReadOnlyDictionary where TValue /// /// テーブルから指定した ID の要素を取得します。ID が存在しない場合は null を返します。 /// - public TValue this[int key] => this.dictionary.ContainsKey(key) ? this.dictionary[key] : null; + public TValue this[int key] + { + get { return this.dictionary.ContainsKey(key) ? this.dictionary[key] : null; } + } public MasterTable() : this(new List()) { } @@ -40,7 +43,10 @@ IEnumerator IEnumerable.GetEnumerator() return this.GetEnumerator(); } - public int Count => this.dictionary.Count; + public int Count + { + get { return this.dictionary.Count; } + } public bool ContainsKey(int key) { @@ -52,9 +58,15 @@ public bool TryGetValue(int key, out TValue value) return this.dictionary.TryGetValue(key, out value); } - public IEnumerable Keys => this.dictionary.Keys; + public IEnumerable Keys + { + get { return this.dictionary.Keys; } + } - public IEnumerable Values => this.dictionary.Values; + public IEnumerable Values + { + get { return this.dictionary.Values; } + } #endregion } diff --git a/Grabacr07.KanColleWrapper/Materials.cs b/Grabacr07.KanColleWrapper/Materials.cs index 1d5267d23..55c6fa6f6 100644 --- a/Grabacr07.KanColleWrapper/Materials.cs +++ b/Grabacr07.KanColleWrapper/Materials.cs @@ -147,9 +147,12 @@ private set /// /// バケツ!!! ぶっかけ!!!! /// - public int Bucket => this.InstantRepairMaterials; + public int Bucket + { + get { return this.InstantRepairMaterials; } + } - #endregion + #endregion #region InstantBuildMaterials 変更通知プロパティ diff --git a/Grabacr07.KanColleWrapper/MemberTable.cs b/Grabacr07.KanColleWrapper/MemberTable.cs index a89e3e2bf..086cb9899 100644 --- a/Grabacr07.KanColleWrapper/MemberTable.cs +++ b/Grabacr07.KanColleWrapper/MemberTable.cs @@ -20,10 +20,13 @@ public class MemberTable : IReadOnlyDictionary where TValue /// /// テーブルから指定した ID の要素を取得します。ID が存在しない場合は null を返します。 /// - public TValue this[int key] => this.dictionary.ContainsKey(key) ? this.dictionary[key] : null; + public TValue this[int key] + { + get { return this.dictionary.ContainsKey(key) ? this.dictionary[key] : null; } + } - public MemberTable() : this(new List()) { } + public MemberTable() : this(new List()) { } public MemberTable(IEnumerable source) { @@ -59,9 +62,12 @@ IEnumerator IEnumerable.GetEnumerator() return this.GetEnumerator(); } - public int Count => this.dictionary.Count; + public int Count + { + get { return this.dictionary.Count; } + } - public bool ContainsKey(int key) + public bool ContainsKey(int key) { return this.dictionary.ContainsKey(key); } @@ -71,10 +77,16 @@ public bool TryGetValue(int key, out TValue value) return this.dictionary.TryGetValue(key, out value); } - public IEnumerable Keys => this.dictionary.Keys; + public IEnumerable Keys + { + get { return this.dictionary.Keys; } + } - public IEnumerable Values => this.dictionary.Values; + public IEnumerable Values + { + get { return this.dictionary.Values; } + } - #endregion + #endregion } } diff --git a/Grabacr07.KanColleWrapper/Models/Admiral.cs b/Grabacr07.KanColleWrapper/Models/Admiral.cs index 881c16462..9a127f691 100644 --- a/Grabacr07.KanColleWrapper/Models/Admiral.cs +++ b/Grabacr07.KanColleWrapper/Models/Admiral.cs @@ -14,9 +14,15 @@ namespace Grabacr07.KanColleWrapper.Models /// public class Admiral : RawDataWrapper { - public string MemberId => this.RawData.api_member_id; + public string MemberId + { + get { return this.RawData.api_member_id; } + } - public string Nickname => this.RawData.api_nickname; + public string Nickname + { + get { return this.RawData.api_nickname; } + } #region Comment 変更通知プロパティ @@ -65,7 +71,10 @@ public int Experience /// /// 次のレベルに上がるために必要な提督経験値を取得します。 /// - public int ExperienceForNexeLevel => Models.Experience.GetAdmiralExpForNextLevel(this.Level, this.Experience); + public int ExperienceForNexeLevel + { + get { return Models.Experience.GetAdmiralExpForNextLevel(this.Level, this.Experience); } + } #region Level 変更通知プロパティ @@ -93,7 +102,10 @@ public int Level /// /// 提督のランク名 (元帥, 大将, 中将, ...) を取得します。 /// - public string Rank => Models.Rank.GetName(this.RawData.api_rank); + public string Rank + { + get { return Models.Rank.GetName(this.RawData.api_rank); } + } #region RankID 変更通知プロパティ @@ -121,12 +133,18 @@ public int RankID /// /// 出撃時の勝利数を取得します。 /// - public int SortieWins => this.RawData.api_st_win; + public int SortieWins + { + get { return this.RawData.api_st_win; } + } /// /// 出撃時の敗北数を取得します。 /// - public int SortieLoses => this.RawData.api_st_lose; + public int SortieLoses + { + get { return this.RawData.api_st_lose; } + } /// /// 出撃時の勝率を取得します。 @@ -144,12 +162,18 @@ public double SortieWinningRate /// /// 司令部に所属できる艦娘の最大値を取得します。 /// - public int MaxShipCount => this.RawData.api_max_chara; + public int MaxShipCount + { + get { return this.RawData.api_max_chara; } + } /// /// 司令部が保有できる装備アイテムの最大値を取得します。 /// - public int MaxSlotItemCount => this.RawData.api_max_slotitem; + public int MaxSlotItemCount + { + get { return this.RawData.api_max_slotitem; } + } public void Update() { diff --git a/Grabacr07.KanColleWrapper/Models/CreatedSlotItem.cs b/Grabacr07.KanColleWrapper/Models/CreatedSlotItem.cs index f1a70b4b0..09128bf51 100644 --- a/Grabacr07.KanColleWrapper/Models/CreatedSlotItem.cs +++ b/Grabacr07.KanColleWrapper/Models/CreatedSlotItem.cs @@ -11,9 +11,12 @@ namespace Grabacr07.KanColleWrapper.Models /// public class CreatedSlotItem : RawDataWrapper { - public bool Succeed => this.RawData.api_create_flag == 1; + public bool Succeed + { + get { return this.RawData.api_create_flag == 1; } + } - public SlotItemInfo SlotItemInfo { get; } + public SlotItemInfo SlotItemInfo { get; private set; } public CreatedSlotItem(kcsapi_createitem rawData) : base(rawData) diff --git a/Grabacr07.KanColleWrapper/Models/Expedition.cs b/Grabacr07.KanColleWrapper/Models/Expedition.cs index c49d9db7b..5c2977ec0 100644 --- a/Grabacr07.KanColleWrapper/Models/Expedition.cs +++ b/Grabacr07.KanColleWrapper/Models/Expedition.cs @@ -79,9 +79,12 @@ private set /// /// 現在遠征を実行中かどうかを示す値を取得します。 /// - public bool IsInExecution => this.ReturnTime.HasValue; + public bool IsInExecution + { + get { return this.ReturnTime.HasValue; } + } - #endregion + #endregion #region Remaining 変更通知プロパティ diff --git a/Grabacr07.KanColleWrapper/Models/Experience.cs b/Grabacr07.KanColleWrapper/Models/Experience.cs index d74f6aa81..82709a663 100644 --- a/Grabacr07.KanColleWrapper/Models/Experience.cs +++ b/Grabacr07.KanColleWrapper/Models/Experience.cs @@ -12,7 +12,7 @@ public class Experience { public int Level { get; private set; } public int Next { get; private set; } - public int Total { get; } + public int Total { get; private set; } private Experience(int level, int next, int total) { diff --git a/Grabacr07.KanColleWrapper/Models/Fleet.cs b/Grabacr07.KanColleWrapper/Models/Fleet.cs index b71c8d8ee..42cf89fac 100644 --- a/Grabacr07.KanColleWrapper/Models/Fleet.cs +++ b/Grabacr07.KanColleWrapper/Models/Fleet.cs @@ -145,12 +145,12 @@ private set #region TotalViewRange 変更通知プロパティ - private int _TotalViewRange; + private double _TotalViewRange; /// /// 各艦娘の装備によるボーナスを含めた、艦隊の索敵合計値を取得します。 /// - public int TotalViewRange + public double TotalViewRange { get { return this._TotalViewRange; } private set @@ -210,12 +210,12 @@ private set /// /// 艦隊に編成されている艦娘のコンディションを取得します。 /// - public FleetCondition Condition { get; } + public FleetCondition Condition { get; private set; } /// /// 艦隊の遠征に関するステータスを取得します。 /// - public Expedition Expedition { get; } + public Expedition Expedition { get; private set; } #region IsReady 変更通知プロパティ @@ -400,12 +400,12 @@ internal void UnsetAll() /// /// 艦隊の平均レベルや制空戦力などの各種数値を再計算します。 /// - internal void Calculate() + public void Calculate() { this.TotalLevel = this.Ships.HasItems() ? this.Ships.Sum(x => x.Level) : 0; this.AverageLevel = this.Ships.HasItems() ? (double)this.TotalLevel / this.Ships.Length : 0.0; this.AirSuperiorityPotential = this.Ships.Sum(s => s.CalcAirSuperiorityPotential()); - this.TotalViewRange = this.CalcFleetViewRange(KanColleClient.Current.Settings.ViewRangeCalcLogic); + this.TotalViewRange = ViewRangeCalcLogic.Get(KanColleClient.Current.Settings.ViewRangeCalcType).Calc(this); this.Speed = this.Ships.All(s => s.Info.Speed == Speed.Fast) ? Speed.Fast : Speed.Low; } diff --git a/Grabacr07.KanColleWrapper/Models/FleetCondition.cs b/Grabacr07.KanColleWrapper/Models/FleetCondition.cs index eef8cd0c3..beadc381b 100644 --- a/Grabacr07.KanColleWrapper/Models/FleetCondition.cs +++ b/Grabacr07.KanColleWrapper/Models/FleetCondition.cs @@ -38,7 +38,10 @@ private set /// /// 艦隊に編成されている艦娘の疲労を自然回復しているかどうかを示す値を取得します。 /// - public bool IsRejuvenating => this.RejuvenateTime.HasValue; + public bool IsRejuvenating + { + get { return this.RejuvenateTime.HasValue; } + } #endregion diff --git a/Grabacr07.KanColleWrapper/Models/LimitedValue.cs b/Grabacr07.KanColleWrapper/Models/LimitedValue.cs index 38efdd24e..2e4e5d67a 100644 --- a/Grabacr07.KanColleWrapper/Models/LimitedValue.cs +++ b/Grabacr07.KanColleWrapper/Models/LimitedValue.cs @@ -19,12 +19,12 @@ public struct LimitedValue /// /// 最大値を取得します。 /// - public int Maximum { get; } + public int Maximum { get; private set; } /// /// 最小値を取得します。 /// - public int Minimum { get; } + public int Minimum { get; private set; } public LimitedValue(int current, int maximum, int minimum) : this() diff --git a/Grabacr07.KanColleWrapper/Models/Mission.cs b/Grabacr07.KanColleWrapper/Models/Mission.cs index 121b55f0f..9e4aa9c75 100644 --- a/Grabacr07.KanColleWrapper/Models/Mission.cs +++ b/Grabacr07.KanColleWrapper/Models/Mission.cs @@ -10,7 +10,7 @@ namespace Grabacr07.KanColleWrapper.Models [DebuggerDisplay("[{Id}] {Title} - {Detail}")] public class Mission : RawDataWrapper, IIdentifiable { - public int Id { get; } + public int Id { get; private set; } public string Title { get; private set; } diff --git a/Grabacr07.KanColleWrapper/Models/ModernizableStatus.cs b/Grabacr07.KanColleWrapper/Models/ModernizableStatus.cs index caa940986..6fa71c36f 100644 --- a/Grabacr07.KanColleWrapper/Models/ModernizableStatus.cs +++ b/Grabacr07.KanColleWrapper/Models/ModernizableStatus.cs @@ -6,66 +6,78 @@ namespace Grabacr07.KanColleWrapper.Models { - /// - /// 近代化改修による数値の上昇が可能なステータスを表します。 - /// - public struct ModernizableStatus - { - /// - /// 艦娘ごとに定義されたステータスの最大値を取得します。 - /// - public int Max { get; internal set; } + /// + /// 近代化改修による数値の上昇が可能なステータスを表します。 + /// + public struct ModernizableStatus + { + /// + /// 艦娘ごとに定義されたステータスの最大値を取得します。 + /// + public int Max { get; internal set; } - /// - /// 艦娘ごとに定義されたステータスの初期値を取得します。 - /// - public int Default { get; internal set; } + /// + /// 艦娘ごとに定義されたステータスの初期値を取得します。 + /// + public int Default { get; internal set; } - /// - /// 近代化改修による現在の上昇値を取得します。 - /// - public int Upgraded { get; internal set; } + /// + /// 近代化改修による現在の上昇値を取得します。 + /// + public int Upgraded { get; internal set; } - /// - /// 近代化改修によって上昇した分を含む現在のステータス値を取得します。 - /// - public int Current => this.Default + this.Upgraded; + /// + /// 近代化改修によって上昇した分を含む現在のステータス値を取得します。 + /// + public int Current + { + get { return this.Default + this.Upgraded; } + } - /// - /// このステータスが上限に達するのに必要な値を取得します。 - /// - public int Shortfall => this.Max - this.Current; + /// + /// このステータスが上限に達するのに必要な値を取得します。 + /// + public int Shortfall + { + get { return this.Max - this.Current; } + } - /// - /// このステータスが上限に達しているかどうかを示す値を取得します。 - /// - public bool IsMax => this.Max <= this.Current; + /// + /// このステータスが上限に達しているかどうかを示す値を取得します。 + /// + public bool IsMax + { + get { return this.Max <= this.Current; } + } - internal ModernizableStatus(int[] status, int upgraded) - : this() - { - if (status.Length == 2) - { - this.Default = status[0]; - this.Max = status[1]; - } + internal ModernizableStatus(int[] status, int upgraded) + : this() + { + if (status.Length == 2) + { + this.Default = status[0]; + this.Max = status[1]; + } - this.Upgraded = upgraded; - } + this.Upgraded = upgraded; + } - public override string ToString() - { - return string.Format("Status = {0}->{1}, Current = {2}{3}", this.Default, this.Max, this.Current, this.IsMax ? "(max)" : ""); - } + public override string ToString() + { + return string.Format("Status = {0}->{1}, Current = {2}{3}", this.Default, this.Max, this.Current, this.IsMax ? "(max)" : ""); + } - #region static members + #region static members - private static readonly ModernizableStatus dummy = new ModernizableStatus(new[] { -1, -1 }, 0); + private static ModernizableStatus dummy = new ModernizableStatus(new[] { -1, -1 }, 0); - public static ModernizableStatus Dummy => dummy; + public static ModernizableStatus Dummy + { + get { return dummy; } + } - #endregion - } + #endregion + } } diff --git a/Grabacr07.KanColleWrapper/Models/Quest.cs b/Grabacr07.KanColleWrapper/Models/Quest.cs index 62bc4a38b..af450072e 100644 --- a/Grabacr07.KanColleWrapper/Models/Quest.cs +++ b/Grabacr07.KanColleWrapper/Models/Quest.cs @@ -9,40 +9,61 @@ namespace Grabacr07.KanColleWrapper.Models { public class Quest : RawDataWrapper, IIdentifiable { - public int Id => this.RawData.api_no; + public int Id + { + get { return this.RawData.api_no; } + } - /// + /// /// 任務のカテゴリ (編成、出撃、演習 など) を取得します。 /// - public QuestCategory Category => (QuestCategory)this.RawData.api_category; + public QuestCategory Category + { + get { return (QuestCategory)this.RawData.api_category; } + } - /// + /// /// 任務の種類 (1 回のみ、デイリー、ウィークリー) を取得します。 /// - public QuestType Type => (QuestType)this.RawData.api_type; + public QuestType Type + { + get { return (QuestType)this.RawData.api_type; } + } - /// + /// /// 任務の状態を取得します。 /// - public QuestState State => (QuestState)this.RawData.api_state; + public QuestState State + { + get { return (QuestState)this.RawData.api_state; } + } - /// + /// /// 任務の進捗状況を取得します。 /// - public QuestProgress Progress => (QuestProgress)this.RawData.api_progress_flag; + public QuestProgress Progress + { + get { return (QuestProgress)this.RawData.api_progress_flag; } + } - /// + /// /// 任務名を取得します。 /// - public string Title => KanColleClient.Current.Translations.GetTranslation(RawData.api_title, TranslationType.QuestTitle, this.RawData, this.RawData.api_no); + public string Title + { + get { return KanColleClient.Current.Translations.GetTranslation(RawData.api_title, TranslationType.QuestTitle, this.RawData, this.RawData.api_no); } + } - /// + /// /// 任務の詳細を取得します。 /// - public string Detail => KanColleClient.Current.Translations.GetTranslation(RawData.api_detail, TranslationType.QuestDetail, this.RawData, this.RawData.api_no); + public string Detail + { + get { return KanColleClient.Current.Translations.GetTranslation(RawData.api_detail, TranslationType.QuestDetail, this.RawData, this.RawData.api_no); } + } - public Quest(kcsapi_quest rawData) : base(rawData) { } + public Quest(kcsapi_quest rawData) : base(rawData) { } public override string ToString() diff --git a/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_combined_battle_battleresult.cs b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_combined_battle_battleresult.cs index 4099340fe..269b3a30c 100644 --- a/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_combined_battle_battleresult.cs +++ b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_combined_battle_battleresult.cs @@ -6,48 +6,55 @@ namespace Grabacr07.KanColleWrapper.Models.Raw { - // ReSharper disable InconsistentNaming - public class kcsapi_combined_battle_battleresult - { - public int[] api_ship_id { get; set; } - public string api_win_rank { get; set; } - public int api_get_exp { get; set; } - public int api_mvp { get; set; } - public int api_mvp_combined { get; set; } - public int api_member_lv { get; set; } - public int api_member_exp { get; set; } - public int api_get_base_exp { get; set; } - public int[] api_get_ship_exp { get; set; } - public int[] api_get_ship_exp_combined { get; set; } - public int[][] api_get_exp_lvup { get; set; } - public int[][] api_get_exp_lvup_combined { get; set; } - public int api_dests { get; set; } - public int api_destsf { get; set; } - public string api_quest_name { get; set; } - public int api_quest_level { get; set; } - public Api_Enemy_Info api_enemy_info { get; set; } - public int api_first_clear { get; set; } - public int[] api_get_flag { get; set; } - public Api_Get_Ship api_get_ship { get; set; } - public int api_get_exmap_rate { get; set; } - public int api_get_exmap_useitem_id { get; set; } - public int api_escape_flag { get; set; } - public object api_escape { get; set; } - } + // ReSharper disable InconsistentNaming + public class kcsapi_combined_battle_battleresult + { + public int[] api_ship_id { get; set; } + public string api_win_rank { get; set; } + public int api_get_exp { get; set; } + public int api_mvp { get; set; } + public int api_mvp_combined { get; set; } + public int api_member_lv { get; set; } + public int api_member_exp { get; set; } + public int api_get_base_exp { get; set; } + public int[] api_get_ship_exp { get; set; } + public int[] api_get_ship_exp_combined { get; set; } + public int[][] api_get_exp_lvup { get; set; } + public int[][] api_get_exp_lvup_combined { get; set; } + public int api_dests { get; set; } + public int api_destsf { get; set; } + public string api_quest_name { get; set; } + public int api_quest_level { get; set; } + public Api_Enemy_Info api_enemy_info { get; set; } + public int api_first_clear { get; set; } + public int[] api_get_flag { get; set; } + public Api_Get_Ship api_get_ship { get; set; } + public int api_get_exmap_rate { get; set; } + public int api_get_exmap_useitem_id { get; set; } + public int api_escape_flag { get; set; } + public Api_Escape api_escape { get; set; } + } - public class Api_Enemy_Info - { - public string api_level { get; set; } - public string api_rank { get; set; } - public string api_deck_name { get; set; } - } + public class Api_Enemy_Info + { + public string api_level { get; set; } + public string api_rank { get; set; } + public string api_deck_name { get; set; } + } - public class Api_Get_Ship - { - public int api_ship_id { get; set; } - public string api_ship_type { get; set; } - public string api_ship_name { get; set; } - public string api_ship_getmes { get; set; } - } - // ReSharper restore InconsistentNaming + public class Api_Get_Ship + { + public int api_ship_id { get; set; } + public string api_ship_type { get; set; } + public string api_ship_name { get; set; } + public string api_ship_getmes { get; set; } + } + + public class Api_Escape + { + public int[] api_escape_idx { get; set; } + public int[] api_tow_idx { get; set; } + } + + // ReSharper restore InconsistentNaming } diff --git a/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slot.cs b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slot.cs new file mode 100644 index 000000000..75eec3304 --- /dev/null +++ b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slot.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +// ReSharper disable InconsistentNaming + +namespace Grabacr07.KanColleWrapper.Models.Raw +{ + public class kcsapi_remodel_slot + { + public int api_remodel_flag { get; set; } + public int[] api_remodel_id { get; set; } + public int[] api_after_material { get; set; } + public string api_voice_id { get; set; } + public Api_After_Slot api_after_slot { get; set; } + public int[] api_use_slot_id { get; set; } + } + + public class Api_After_Slot + { + public int api_id { get; set; } + public int api_slotitem_id { get; set; } + public int api_locked { get; set; } + public int api_level { get; set; } + } +} \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist.cs b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist.cs new file mode 100644 index 000000000..d5b8f114c --- /dev/null +++ b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +// ReSharper disable InconsistentNaming + +namespace Grabacr07.KanColleWrapper.Models.Raw +{ + public class kcsapi_remodel_slotlist + { + public int api_id { get; set; } + public int api_slot_id { get; set; } + public int api_req_fuel { get; set; } + public int api_req_bull { get; set; } + public int api_req_steel { get; set; } + public int api_req_bauxite { get; set; } + public int api_req_buildkit { get; set; } + public int api_req_remodelkit { get; set; } + public int api_req_slot_id { get; set; } + public int api_req_slot_num { get; set; } + } +} \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist_detail.cs b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist_detail.cs new file mode 100644 index 000000000..a39041820 --- /dev/null +++ b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist_detail.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +// ReSharper disable InconsistentNaming + +namespace Grabacr07.KanColleWrapper.Models.Raw +{ + public class kcsapi_remodel_slotlist_detail + { + public int api_req_buildkit { get; set; } + public int api_req_remodelkit { get; set; } + public int api_certain_buildkit { get; set; } + public int api_certain_remodelkit { get; set; } + public int api_req_slot_id { get; set; } + public int api_req_slot_num { get; set; } + public int api_change_flag { get; set; } + } +} \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/Models/Ship.cs b/Grabacr07.KanColleWrapper/Models/Ship.cs index 242ff00bb..d1a9a7c47 100644 --- a/Grabacr07.KanColleWrapper/Models/Ship.cs +++ b/Grabacr07.KanColleWrapper/Models/Ship.cs @@ -7,6 +7,7 @@ using Fiddler; using Grabacr07.KanColleWrapper.Internal; using Grabacr07.KanColleWrapper.Models.Raw; +using Livet; namespace Grabacr07.KanColleWrapper.Models { @@ -29,36 +30,54 @@ public class Ship : RawDataWrapper, IIdentifiable /// /// この艦娘を識別する ID を取得します。 /// - public int Id => this.RawData.api_id; + public int Id + { + get { return this.RawData.api_id; } + } - /// + /// /// 艦娘の種類に基づく情報を取得します。 /// public ShipInfo Info { get; private set; } - public int SortNumber => this.RawData.api_sortno; + public int SortNumber + { + get { return this.RawData.api_sortno; } + } - /// + /// /// 艦娘の現在のレベルを取得します。 /// - public int Level => this.RawData.api_lv; + public int Level + { + get { return this.RawData.api_lv; } + } - /// + /// /// 艦娘がロックされているかどうかを示す値を取得します。 /// - public bool IsLocked => this.RawData.api_locked == 1; + public bool IsLocked + { + get { return this.RawData.api_locked == 1; } + } - /// + /// /// 艦娘の現在の累積経験値を取得します。 /// - public int Exp => this.RawData.api_exp.Get(0) ?? 0; + public int Exp + { + get { return this.RawData.api_exp.Get(0) ?? 0; } + } - /// + /// /// この艦娘が次のレベルに上がるために必要な経験値を取得します。 /// - public int ExpForNextLevel => this.RawData.api_exp.Get(1) ?? 0; + public int ExpForNextLevel + { + get { return this.RawData.api_exp.Get(1) ?? 0; } + } - #region HP 変更通知プロパティ + #region HP 変更通知プロパティ private LimitedValue _HP; @@ -216,7 +235,10 @@ private set /// /// 装備によるボーナスを含めた索敵ステータス値を取得します。 /// - public int ViewRange => this.RawData.api_sakuteki.Get(0) ?? 0; + public int ViewRange + { + get { return this.RawData.api_sakuteki.Get(0) ?? 0; } + } /// /// Anti-Submarine stat with and without equipment. @@ -236,17 +258,26 @@ private set /// /// 火力・雷装・対空・装甲のすべてのステータス値が最大値に達しているかどうかを示す値を取得します。 /// - public bool IsMaxModernized => this.Firepower.IsMax && this.Torpedo.IsMax && this.AA.IsMax && this.Armer.IsMax; + public bool IsMaxModernized + { + get { return this.Firepower.IsMax && this.Torpedo.IsMax && this.AA.IsMax && this.Armer.IsMax; } + } - /// + /// /// 現在のコンディション値を取得します。 /// - public int Condition => this.RawData.api_cond; + public int Condition + { + get { return this.RawData.api_cond; } + } - /// + /// /// コンディションの種類を示す 値を取得します。 /// - public ConditionType ConditionType => ConditionTypeHelper.ToConditionType(this.RawData.api_cond); + public ConditionType ConditionType + { + get { return ConditionTypeHelper.ToConditionType(this.RawData.api_cond); } + } /// /// For visually generated elements. "[Lv.00] Name" @@ -295,7 +326,6 @@ public bool IsDamaged { get { return (this.HP.Maximum - this.HP.Current) > 0; } } - public bool IsLightlyDamaged { get { return this.IsDamaged && (this.HP.Current / (double)this.HP.Maximum) > 0.5; } @@ -306,29 +336,9 @@ public bool IsBadlyDamaged get { return (this.HP.Current / (double)this.HP.Maximum) <= 0.25; } } - public SlotItem[] SlotItems { get; private set; } - - #region OnSlot 変更通知プロパティ + public ShipSlot[] Slots { get; private set; } - private int[] _OnSlot; - - /// - /// 各装備スロットの艦載機数を取得します。 - /// - public int[] OnSlot - { - get { return this._OnSlot; } - private set - { - if (this._OnSlot != value) - { - this._OnSlot = value; - this.RaisePropertyChanged(); - } - } - } - - #endregion + public ShipSlot[] EquippedSlots { get; private set; } #region IsInRepairing 変更通知プロパティ @@ -355,10 +365,13 @@ internal set /// /// この艦が出撃した海域を識別する整数値を取得します。 /// - public int SallyArea => this.RawData.api_sally_area; + public int SallyArea + { + get { return this.RawData.api_sally_area; } + } - internal Ship(Homeport parent, kcsapi_ship2 rawData) + internal Ship(Homeport parent, kcsapi_ship2 rawData) : base(rawData) { this.homeport = parent; @@ -383,10 +396,8 @@ internal void Update(kcsapi_ship2 rawData) this.Luck = new ModernizableStatus(this.Info.RawData.api_luck, this.RawData.api_kyouka[4]); } - this.SlotItems = this.RawData.api_slot.Select(id => this.homeport.Itemyard.SlotItems[id]).Where(x => x != null).ToArray(); - this.OnSlot = this.RawData.api_onslot; - // Minimum removes equipped values. + /* int EqAntiSub = 0, EqEvasion = 0, EqLineOfSight = 0; foreach (SlotItem item in this.SlotItems) @@ -402,6 +413,13 @@ internal void Update(kcsapi_ship2 rawData) this.AntiSub = new LimitedValue(this.RawData.api_taisen[0], this.RawData.api_taisen[1], this.RawData.api_taisen[0] - EqAntiSub); this.Evasion = new LimitedValue(this.RawData.api_kaihi[0], this.RawData.api_kaihi[1], this.RawData.api_kaihi[0] - EqEvasion); this.LineOfSight = new LimitedValue(this.RawData.api_sakuteki[0], this.RawData.api_sakuteki[1], this.RawData.api_sakuteki[0] - EqLineOfSight); + */ + + this.Slots = this.RawData.api_slot + .Select(id => this.homeport.Itemyard.SlotItems[id]) + .Select((t, i) => new ShipSlot(t, this.Info.RawData.api_maxeq.Get(i) ?? 0, this.RawData.api_onslot.Get(i) ?? 0)) + .ToArray(); + this.EquippedSlots = this.Slots.Where(x => x.Equipped).ToArray(); } @@ -409,7 +427,7 @@ internal void Charge(int fuel, int bull, int[] onslot) { this.Fuel = this.Fuel.Update(fuel); this.Bull = this.Bull.Update(bull); - this.OnSlot = onslot; + for (var i = 0; i < this.Slots.Length; i++) this.Slots[i].Current = onslot.Get(i) ?? 0; } internal void Repair() @@ -423,4 +441,43 @@ public override string ToString() return string.Format("ID = {0}, Name = \"{1}\", ShipType = \"{2}\", Level = {3}", this.Id, this.Info.Name, this.Info.ShipType.Name, this.Level); } } + + + public class ShipSlot : NotificationObject + { + public SlotItem Item { get; private set; } + + public int Maximum { get; private set; } + + public bool Equipped + { + get { return this.Item != null; } + } + + #region Current 変更通知プロパティ + + private int _Current; + + public int Current + { + get { return this._Current; } + set + { + if (this._Current != value) + { + this._Current = value; + this.RaisePropertyChanged(); + } + } + } + + #endregion + + public ShipSlot(SlotItem item, int maximum, int current) + { + this.Item = item; + this.Maximum = maximum; + this.Current = current; + } + } } diff --git a/Grabacr07.KanColleWrapper/Models/ShipInfo.cs b/Grabacr07.KanColleWrapper/Models/ShipInfo.cs index c7b2d59bd..10bf531c5 100644 --- a/Grabacr07.KanColleWrapper/Models/ShipInfo.cs +++ b/Grabacr07.KanColleWrapper/Models/ShipInfo.cs @@ -8,111 +8,162 @@ namespace Grabacr07.KanColleWrapper.Models { - /// - /// 艦娘の種類に基づく情報を表します。 - /// - public class ShipInfo : RawDataWrapper, IIdentifiable - { - private ShipType shipType; - - /// - /// 艦を一意に識別する ID を取得します。 - /// - public int Id => this.RawData.api_id; - - public int SortId => this.RawData.api_sortno; - - /// - /// 艦の名称を取得します。 - /// - public string Name => KanColleClient.Current.Translations.GetTranslation(RawData.api_name, TranslationType.Ships, this.RawData); + /// + /// 艦娘の種類に基づく情報を表します。 + /// + public class ShipInfo : RawDataWrapper, IIdentifiable + { + private ShipType shipType; + + /// + /// 艦を一意に識別する ID を取得します。 + /// + public int Id + { + get { return this.RawData.api_id; } + } + + public int SortId + { + get { return this.RawData.api_sortno; } + } + + /// + /// 艦の名称を取得します。 + /// + public string Name + { + get { return KanColleClient.Current.Translations.GetTranslation(RawData.api_name, TranslationType.Ships, this.RawData); } + } /// /// Get the untranslated version of the name. If it is untranslated, return nothing. /// - public string UntranslatedName => this.Name != RawData.api_name ? RawData.api_name : ""; - - /// - /// 艦種を取得します。 - /// - public ShipType ShipType => this.shipType ?? (this.shipType = KanColleClient.Current.Master.ShipTypes[this.RawData.api_stype]) ?? ShipType.Dummy; - - #region 用意したけど使わないっぽい? - - /// - /// 火力の最大値を取得します。 - /// - public int MaxFirepower => this.RawData.api_houg.Get(1) ?? 0; - - /// - /// 装甲の最大値を取得します。 - /// - public int MaxArmer => this.RawData.api_souk.Get(1) ?? 0; - - /// - /// 雷装の最大値を取得します。 - /// - public int MaxTorpedo => this.RawData.api_raig.Get(1) ?? 0; - - /// - /// 対空の最大値を取得します。 - /// - public int MaxAA => this.RawData.api_tyku.Get(1) ?? 0; - - - /// - /// 耐久値を取得します。 - /// - public int HP => this.RawData.api_taik.Get(0) ?? 0; - - /* No longer available in the API - - /// - /// 回避の最大値を取得します。 - /// - public int MaxEvasion => this.RawData.api_kaih.Get(1) ?? 0; - - /// - /// 対潜の最大値を取得します (ASW: Anti-submarine warfare)。 - /// - public int MaxASW => this.RawData.api_tais.Get(1) ?? 0; + public string UntranslatedName { + get { return this.Name != RawData.api_name ? RawData.api_name : ""; } + } - /// - /// 索敵の最大値を取得します。 - /// - public int MaxLOS => this.RawData.api_saku.Get(1) ?? 0; + /// + /// 艦種を取得します。 + /// + public ShipType ShipType + { + get { return this.shipType ?? (this.shipType = KanColleClient.Current.Master.ShipTypes[this.RawData.api_stype]) ?? ShipType.Dummy; } + } + + public int[] Slots + { + get { return this.RawData.api_maxeq; } + } + + #region 用意したけど使わないっぽい? + + /// + /// 火力の最大値を取得します。 + /// + public int MaxFirepower + { + get { return this.RawData.api_houg.Get(1) ?? 0; } + } + + /// + /// 装甲の最大値を取得します。 + /// + public int MaxArmer + { + get { return this.RawData.api_souk.Get(1) ?? 0; } + } + + /// + /// 雷装の最大値を取得します。 + /// + public int MaxTorpedo + { + get { return this.RawData.api_raig.Get(1) ?? 0; } + } + + /// + /// 対空の最大値を取得します。 + /// + public int MaxAA + { + get { return this.RawData.api_tyku.Get(1) ?? 0; } + } + + + /// + /// 耐久値を取得します。 + /// + public int HP + { + get { return this.RawData.api_taik.Get(0) ?? 0; } + } + + /* No longer in the API + /// + /// 回避の最大値を取得します。 + /// + public int MaxEvasion + { + get { return this.RawData.api_kaih.Get(1) ?? 0; } + } + + /// + /// 対潜の最大値を取得します (ASW: Anti-submarine warfare)。 + /// + public int MaxASW + { + get { return this.RawData.api_tais.Get(1) ?? 0; } + } + + /// + /// 索敵の最大値を取得します。 + /// + public int MaxLOS + { + get { return this.RawData.api_saku.Get(1) ?? 0; } + } */ - #endregion + #endregion - /// - /// 速力を取得します。 - /// - public Speed Speed => (Speed)this.RawData.api_soku; + /// + /// 速力を取得します。 + /// + public Speed Speed + { + get { return (Speed)this.RawData.api_soku; } + } - /// - /// 次の改造が実施できるレベルを取得します。 - /// - public int? NextRemodelingLevel => this.RawData.api_afterlv == 0 ? null : (int?)this.RawData.api_afterlv; + /// + /// 次の改造が実施できるレベルを取得します。 + /// + public int? NextRemodelingLevel + { + get { return this.RawData.api_afterlv == 0 ? null : (int?)this.RawData.api_afterlv; } + } - internal ShipInfo(kcsapi_mst_ship rawData) : base(rawData) { } + internal ShipInfo(kcsapi_mst_ship rawData) : base(rawData) { } - public override string ToString() - { - return string.Format("ID = {0}, Name = \"{1}\", ShipType = \"{2}\"", this.Id, this.Name, this.ShipType.Name); - } + public override string ToString() + { + return string.Format("ID = {0}, Name = \"{1}\", ShipType = \"{2}\"", this.Id, this.Name, this.ShipType.Name); + } - #region static members + #region static members - private static readonly ShipInfo dummy = new ShipInfo(new kcsapi_mst_ship - { - api_id = 0, - api_name = "???" - }); + private static ShipInfo dummy = new ShipInfo(new kcsapi_mst_ship + { + api_id = 0, + api_name = "???" + }); - public static ShipInfo Dummy => dummy; + public static ShipInfo Dummy + { + get { return dummy; } + } - #endregion - } + #endregion + } } diff --git a/Grabacr07.KanColleWrapper/Models/ShipType.cs b/Grabacr07.KanColleWrapper/Models/ShipType.cs index 485b15c6d..60208b545 100644 --- a/Grabacr07.KanColleWrapper/Models/ShipType.cs +++ b/Grabacr07.KanColleWrapper/Models/ShipType.cs @@ -14,11 +14,20 @@ namespace Grabacr07.KanColleWrapper.Models /// public class ShipType : RawDataWrapper, IIdentifiable { - public int Id => this.RawData.api_id; + public int Id + { + get { return this.RawData.api_id; } + } - public string Name => KanColleClient.Current.Translations.GetTranslation(RawData.api_name, TranslationType.ShipTypes, this.RawData, this.Id); + public string Name + { + get { return KanColleClient.Current.Translations.GetTranslation(RawData.api_name, TranslationType.ShipTypes, this.RawData, this.Id); } + } - public int SortNumber => this.RawData.api_sortno; + public int SortNumber + { + get { return this.RawData.api_sortno; } + } public double RepairMultiplier { @@ -54,15 +63,18 @@ public override string ToString() #region static members - private static readonly ShipType dummy = new ShipType(new kcsapi_mst_stype + private static ShipType dummy = new ShipType(new kcsapi_mst_stype { api_id = 999, api_sortno = 999, api_name = "不審船", }); - public static ShipType Dummy => dummy; + public static ShipType Dummy + { + get { return dummy; } + } - #endregion + #endregion } } diff --git a/Grabacr07.KanColleWrapper/Models/SlotItem.cs b/Grabacr07.KanColleWrapper/Models/SlotItem.cs index 7b9665a22..c72ad5520 100644 --- a/Grabacr07.KanColleWrapper/Models/SlotItem.cs +++ b/Grabacr07.KanColleWrapper/Models/SlotItem.cs @@ -10,9 +10,12 @@ namespace Grabacr07.KanColleWrapper.Models { public class SlotItem : RawDataWrapper, IIdentifiable { - public int Id => this.RawData.api_id; + public int Id + { + get { return this.RawData.api_id; } + } - public SlotItemInfo Info { get; } + public SlotItemInfo Info { get; private set; } private bool IsLocked { get { return (this.RawData.api_locked > 0); } } private int Level { get { return this.RawData.api_level; } } public string ItemLevel { get { return "+" + Level.ToString(); } } diff --git a/Grabacr07.KanColleWrapper/Models/SlotItemIconType.cs b/Grabacr07.KanColleWrapper/Models/SlotItemIconType.cs new file mode 100644 index 000000000..24ff9a422 --- /dev/null +++ b/Grabacr07.KanColleWrapper/Models/SlotItemIconType.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Grabacr07.KanColleWrapper.Models +{ + public enum SlotItemIconType + { + Unknown = 0, + + /// + /// 小口径主砲。 + /// + MainCanonLight = 1, + + /// + /// 中口径主砲。 + /// + MainCanonMedium = 2, + + /// + /// 大口径主砲。 + /// + MainCanonHeavy = 3, + + /// + /// 副砲。 + /// + SecondaryCanon = 4, + + /// + /// 魚雷。 + /// + Torpedo = 5, + + /// + /// 艦戦。 + /// + Fighter = 6, + + /// + /// 艦爆。 + /// + DiveBomber = 7, + + /// + /// 艦攻。 + /// + TorpedoBomber = 8, + + /// + /// 偵察機。 + /// + ReconPlane = 9, + + /// + /// 水上機。 + /// + ReconSeaplane = 10, + + /// + /// 電探。 + /// + Rader = 11, + + /// + /// 三式弾。 + /// + AAShell = 12, + + /// + /// 徹甲弾。 + /// + APShell = 13, + + /// + /// ダメコン。 + /// + DamageControl = 14, + + /// + /// 機銃。 + /// + AAGun = 15, + + /// + /// 高角砲。 + /// + HighAngleGun = 16, + + /// + /// 爆雷投射機。 + /// + ASW = 17, + + /// + /// ソナー。 + /// + Soner = 18, + + /// + /// 機関部強化。 + /// + EngineImprovement = 19, + + /// + /// 上陸用舟艇。 + /// + LandingCraft = 20, + + /// + /// オートジャイロ。 + /// + Autogyro = 21, + + /// + /// 指揮連絡機。 + /// + ArtillerySpotter = 22, + + /// + /// 増設バルジ。 + /// + AntiTorpedoBulge = 23, + + /// + /// 探照灯。 + /// + Searchlight = 24, + + /// + /// ドラム缶。 + /// + DrumCanister = 25, + + /// + /// 施設。 + /// + Facility = 26, + + /// + /// 照明弾。 + /// + Flare = 27, + + /// + /// 司令部施設。 + /// + FleetCommandFacility = 28, + + /// + /// 航空要員。 + /// + MaintenancePersonnel = 29, + + /// + /// 高射砲。 + /// + AntiAircraftFireDirector = 30, + + /// + /// ロケットランチャー。 + /// + RocketLauncher = 31, + } +} diff --git a/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs b/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs index aa81be489..f63861148 100644 --- a/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs +++ b/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs @@ -9,41 +9,65 @@ namespace Grabacr07.KanColleWrapper.Models { - /// - /// 装備アイテムの種類に基づく情報を表します。 - /// - public class SlotItemInfo : RawDataWrapper, IIdentifiable - { - private SlotItemIconType? iconType; - private int? categoryId; - - public int Id => this.RawData.api_id; - - public string Name => KanColleClient.Current.Translations.GetTranslation(this.RawData.api_name, TranslationType.Equipment, this.RawData); - - public string UntranslatedName => (this.RawData.api_name != this.Name ? this.RawData.api_name : ""); - - public SlotItemIconType IconType => this.iconType ?? (SlotItemIconType)(this.iconType = (SlotItemIconType)(this.RawData.api_type.Get(3) ?? 0)); - - public int CategoryId => this.categoryId ?? (int)(this.categoryId = this.RawData.api_type.Get(2) ?? int.MaxValue); - - /// - /// 対空値を取得します。 - /// - public int AA => this.RawData.api_tyku; - - /// - /// 制空戦に参加できる戦闘機または水上機かどうかを示す値を取得します。 - /// - public bool IsAirSuperiorityFighter + /// + /// 装備アイテムの種類に基づく情報を表します。 + /// + public class SlotItemInfo : RawDataWrapper, IIdentifiable + { + private SlotItemType? type; + private SlotItemIconType? iconType; + private int? categoryId; + + public int Id + { + get { return this.RawData.api_id; } + } + + public string Name + { + get { return KanColleClient.Current.Translations.GetTranslation(this.RawData.api_name, TranslationType.Equipment, this.RawData); } + } + + public string UntranslatedName { - get - { - var type = this.RawData.api_type.Get(2); - return type.HasValue && (type == 6 || type == 7 || type == 8 || type == 11); - } + get { return (this.RawData.api_name != this.Name ? this.RawData.api_name : ""); } } + public SlotItemType Type + { + get { return this.type ?? (SlotItemType)(this.type = (SlotItemType)(this.RawData.api_type.Get(2) ?? 0)); } + } + + public SlotItemIconType IconType + { + get { return this.iconType ?? (SlotItemIconType)(this.iconType = (SlotItemIconType)(this.RawData.api_type.Get(3) ?? 0)); } + } + + public int CategoryId + { + get { return this.categoryId ?? (int)(this.categoryId = this.RawData.api_type.Get(2) ?? int.MaxValue); } + } + + /// + /// 対空値を取得します。 + /// + public int AA + { + get { return this.RawData.api_tyku; } + } + + /// + /// 制空戦に参加できる戦闘機または水上機かどうかを示す値を取得します。 + /// + public bool IsAirSuperiorityFighter + { + get + { + var type = this.RawData.api_type.Get(2); + return type.HasValue && (type == 6 || type == 7 || type == 8 || type == 11); + } + } + public int Firepower { get { return this.RawData.api_houg; } @@ -104,24 +128,35 @@ public int AttackRange get { return this.RawData.api_leng; } } - - internal SlotItemInfo(kcsapi_mst_slotitem rawData) : base(rawData) { } - - public override string ToString() - { - return string.Format("ID = {0}, Name = \"{1}\", Type = {{{2}}}", this.Id, this.Name, this.RawData.api_type.ToString(", ")); - } - - #region static members - - private static readonly SlotItemInfo dummy = new SlotItemInfo(new kcsapi_mst_slotitem() - { - api_id = 0, - api_name = "???", - }); - - public static SlotItemInfo Dummy => dummy; - - #endregion - } + public bool IsNumerable + { + get + { + var type = this.RawData.api_type.Get(2); + return type.HasValue && (type == 6 || type == 7 || type == 8 || type == 11); + } + } + + internal SlotItemInfo(kcsapi_mst_slotitem rawData) : base(rawData) { } + + public override string ToString() + { + return string.Format("ID = {0}, Name = \"{1}\", Type = {{{2}}}", this.Id, this.Name, this.RawData.api_type.ToString(", ")); + } + + #region static members + + private static SlotItemInfo dummy = new SlotItemInfo(new kcsapi_mst_slotitem() + { + api_id = 0, + api_name = "???", + }); + + public static SlotItemInfo Dummy + { + get { return dummy; } + } + + #endregion + } } diff --git a/Grabacr07.KanColleWrapper/Models/SlotItemType.cs b/Grabacr07.KanColleWrapper/Models/SlotItemType.cs index 5a4787d2a..df0cf98a6 100644 --- a/Grabacr07.KanColleWrapper/Models/SlotItemType.cs +++ b/Grabacr07.KanColleWrapper/Models/SlotItemType.cs @@ -6,163 +6,17 @@ namespace Grabacr07.KanColleWrapper.Models { - public enum SlotItemIconType - { - Unknown = 0, - - /// - /// 小口径主砲。 - /// - MainCanonLight = 1, - - /// - /// 中口径主砲。 - /// - MainCanonMedium = 2, - - /// - /// 大口径主砲。 - /// - MainCanonHeavy = 3, - - /// - /// 副砲。 - /// - SecondaryCanon = 4, - - /// - /// 魚雷。 - /// - Torpedo = 5, - - /// - /// 艦戦。 - /// - Fighter = 6, - - /// - /// 艦爆。 - /// - DiveBomber = 7, - - /// - /// 艦攻。 - /// - TorpedoBomber = 8, - - /// - /// 偵察機。 - /// - ReconPlane = 9, - - /// - /// 水上機。 - /// - ReconSeaplane = 10, - - /// - /// 電探。 - /// - Rader = 11, - - /// - /// 三式弾。 - /// - AAShell = 12, - - /// - /// 徹甲弾。 - /// - APShell = 13, - - /// - /// ダメコン。 - /// - DamageControl = 14, - - /// - /// 機銃。 - /// - AAGun = 15, - - /// - /// 高角砲。 - /// - HighAngleGun = 16, - - /// - /// 爆雷投射機。 - /// - ASW = 17, - - /// - /// ソナー。 - /// - Soner = 18, - - /// - /// 機関部強化。 - /// - EngineImprovement = 19, - - /// - /// 上陸用舟艇。 - /// - LandingCraft = 20, - - /// - /// オートジャイロ。 - /// - Autogyro = 21, - - /// - /// 指揮連絡機。 - /// - ArtillerySpotter = 22, - - /// - /// 増設バルジ。 - /// - AntiTorpedoBulge = 23, - - /// - /// 探照灯。 - /// - Searchlight = 24, - - /// - /// ドラム缶。 - /// - DrumCanister = 25, - - /// - /// 施設。 - /// - Facility = 26, - - /// - /// 照明弾。 - /// - Flare = 27, - - /// - /// 司令部施設。 - /// - FleetCommandFacility = 28, - - /// - /// 航空要員。 - /// - MaintenancePersonnel = 29, - - /// - /// 高射砲。 - /// - AntiAircraftFireDirector = 30, - - /// - /// ロケットランチャー。 - /// - RocketLauncher = 31, + public enum SlotItemType + { + 艦上戦闘機 = 6, + 艦上爆撃機 = 7, + 艦上攻撃機 = 8, + 艦上偵察機 = 9, + 水上偵察機 = 10, + 水上爆撃機 = 11, + 小型電探 = 12, + 大型電探 = 13, + + 探照灯 = 29, } } diff --git a/Grabacr07.KanColleWrapper/Models/SvData.cs b/Grabacr07.KanColleWrapper/Models/SvData.cs index 6de9da60c..49c177749 100644 --- a/Grabacr07.KanColleWrapper/Models/SvData.cs +++ b/Grabacr07.KanColleWrapper/Models/SvData.cs @@ -18,11 +18,20 @@ public class SvData : RawDataWrapper> { public NameValueCollection Request { get; private set; } - public bool IsSuccess => this.RawData.api_result == 1; + public bool IsSuccess + { + get { return this.RawData.api_result == 1; } + } - public T Data => this.RawData.api_data; + public T Data + { + get { return this.RawData.api_data; } + } - public kcsapi_deck[] Fleets => this.RawData.api_data_deck; + public kcsapi_deck[] Fleets + { + get { return this.RawData.api_data_deck; } + } public SvData(svdata rawData, string reqBody) : base(rawData) @@ -35,7 +44,10 @@ public class SvData : RawDataWrapper { public NameValueCollection Request { get; private set; } - public bool IsSuccess => this.RawData.api_result == 1; + public bool IsSuccess + { + get { return this.RawData.api_result == 1; } + } public SvData(svdata rawData, string reqBody) : base(rawData) diff --git a/Grabacr07.KanColleWrapper/Models/UseItem.cs b/Grabacr07.KanColleWrapper/Models/UseItem.cs index efc63ad54..68f914e31 100644 --- a/Grabacr07.KanColleWrapper/Models/UseItem.cs +++ b/Grabacr07.KanColleWrapper/Models/UseItem.cs @@ -13,11 +13,20 @@ namespace Grabacr07.KanColleWrapper.Models /// public class UseItem : RawDataWrapper, IIdentifiable { - public int Id => this.RawData.api_id; + public int Id + { + get { return this.RawData.api_id; } + } - public string Name => this.RawData.api_name; + public string Name + { + get { return this.RawData.api_name; } + } - public int Count => this.RawData.api_count; + public int Count + { + get { return this.RawData.api_count; } + } internal UseItem(kcsapi_useitem rawData) : base(rawData) { } diff --git a/Grabacr07.KanColleWrapper/Models/UseItemInfo.cs b/Grabacr07.KanColleWrapper/Models/UseItemInfo.cs index 5c011b69a..97744066c 100644 --- a/Grabacr07.KanColleWrapper/Models/UseItemInfo.cs +++ b/Grabacr07.KanColleWrapper/Models/UseItemInfo.cs @@ -13,9 +13,15 @@ namespace Grabacr07.KanColleWrapper.Models /// public class UseItemInfo : RawDataWrapper, IIdentifiable { - public int Id => this.RawData.api_id; + public int Id + { + get { return this.RawData.api_id; } + } - public string Name => this.RawData.api_name; + public string Name + { + get { return this.RawData.api_name; } + } internal UseItemInfo(kcsapi_mst_useitem rawData) : base(rawData) { } diff --git a/Grabacr07.KanColleWrapper/Models/ViewRange.cs b/Grabacr07.KanColleWrapper/Models/ViewRange.cs new file mode 100644 index 000000000..9c10dc5ff --- /dev/null +++ b/Grabacr07.KanColleWrapper/Models/ViewRange.cs @@ -0,0 +1,222 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Grabacr07.KanColleWrapper.Internal; + +namespace Grabacr07.KanColleWrapper.Models +{ + /// + /// 索敵値計算を提供します。 + /// + public interface ICalcViewRange + { + string Id { get; } + + string Name { get; } + + string Description { get; } + + double Calc(Fleet fleet); + } + + + public abstract class ViewRangeCalcLogic : ICalcViewRange + { + private static readonly Dictionary logics = new Dictionary(); + + public static IEnumerable Logics + { + get { return logics.Values; } + } + + public static ICalcViewRange Get(string key) + { + ICalcViewRange logic; + return logics.TryGetValue(key, out logic) ? logic : new ViewRangeType1(); + } + + static ViewRangeCalcLogic() + { + // ひどぅい設計を見た + // ReSharper disable ObjectCreationAsStatement + new ViewRangeType1(); + new ViewRangeType2(); + new ViewRangeType3(); + // ReSharper restore ObjectCreationAsStatement + } + + public abstract string Id { get; } + public abstract string Name { get; } + public abstract string Description { get; } + public abstract double Calc(Fleet fleet); + + protected ViewRangeCalcLogic() + { + // ReSharper disable once DoNotCallOverridableMethodsInConstructor + var key = this.Id; + if (key != null && !logics.ContainsKey(key)) logics.Add(key, this); + } + } + + + public class ViewRangeType1 : ViewRangeCalcLogic + { + public override sealed string Id + { + get { return "KanColleViewer.Type1"; } + } + + public override string Name + { + get { return "単純計算"; } + } + + public override string Description + { + get { return "艦娘と装備の索敵値の単純な合計値"; } + } + + public override double Calc(Fleet fleet) + { + if (fleet == null || fleet.Ships.Length == 0) return 0; + + return fleet.Ships.Sum(x => x.ViewRange); + } + } + + + public class ViewRangeType2 : ViewRangeCalcLogic + { + public override sealed string Id + { + get { return "KanColleViewer.Type2"; } + } + + public override string Name + { + get { return "2-5 式 (旧)"; } + } + + public override string Description + { + get { return "(偵察機 × 2) + (電探) + √(装備込みの艦隊索敵値合計 - 偵察機 - 電探)"; } + } + + public override double Calc(Fleet fleet) + { + if (fleet == null || fleet.Ships.Length == 0) return 0; + + // http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#area5 + // [索敵装備と装備例] によって示されている計算式 + // stype=7 が偵察機 (2 倍する索敵値)、stype=8 が電探 + + var spotter = fleet.Ships.SelectMany( + x => x.EquippedSlots + .Where(s => s.Item.Info.RawData.api_type.Get(1) == 7) + .Where(s => s.Current > 0) + .Select(s => s.Item.Info.RawData.api_saku) + ).Sum(); + + var radar = fleet.Ships.SelectMany( + x => x.EquippedSlots + .Where(s => s.Item.Info.RawData.api_type.Get(1) == 8) + .Select(s => s.Item.Info.RawData.api_saku) + ).Sum(); + + return (spotter * 2) + radar + (int)Math.Sqrt(fleet.Ships.Sum(x => x.ViewRange) - spotter - radar); + } + } + + + public class ViewRangeType3 : ViewRangeCalcLogic + { + public override sealed string Id + { + get { return "KanColleViewer.Type3"; } + } + + public override string Name + { + get { return "2-5 式 (秋)"; } + } + + public override string Description + { + get + { + return @"(艦上爆撃機 × 1.04) + (艦上攻撃機 × 1.37) + (艦上偵察機 × 1.66) ++ (水上偵察機 × 2.00) + (水上爆撃機 × 1.78) + (探照灯 × 0.91) ++ (小型電探 × 1.00) + (大型電探 × 0.99) + (√各艦毎の素索敵 × 1.69) ++ (司令部レベルを 5 の倍数に切り上げ × -0.61)"; + } + } + + public override double Calc(Fleet fleet) + { + if (fleet == null || fleet.Ships.Length == 0) return 0; + + // http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#search-calc + // > 2-5式では説明出来ない事象を解決するため膨大な検証報告数より導き出した新式。2014年11月に改良され精度があがった。 + // > 索敵スコア + // > = 艦上爆撃機 × (1.04) + // > + 艦上攻撃機 × (1.37) + // > + 艦上偵察機 × (1.66) + // > + 水上偵察機 × (2.00) + // > + 水上爆撃機 × (1.78) + // > + 小型電探 × (1.00) + // > + 大型電探 × (0.99) + // > + 探照灯 × (0.91) + // > + √(各艦毎の素索敵) × (1.69) + // > + (司令部レベルを5の倍数に切り上げ) × (-0.61) + + var itemScore = fleet.Ships + .SelectMany(x => x.EquippedSlots) + .Select(x => x.Item.Info) + .GroupBy( + x => x.Type, + x => x.RawData.api_saku, + (type, scores) => new { type, score = scores.Sum() }) + .Aggregate(.0, (score, item) => score + GetScore(item.type, item.score)); + + var shipScore = fleet.Ships + .Select(x => x.ViewRange - x.EquippedSlots.Sum(s => s.Item.Info.RawData.api_saku)) + .Select(x => Math.Sqrt(x)) + .Sum() * 1.69; + + var level = (((KanColleClient.Current.Homeport.Admiral.Level + 4) / 5) * 5); + var admiralScore = level * -0.61; + + return itemScore + shipScore + admiralScore; + } + + private static double GetScore(SlotItemType type, int score) + { + switch (type) + { + case SlotItemType.艦上爆撃機: + return score * 1.04; + case SlotItemType.艦上攻撃機: + return score * 1.37; + case SlotItemType.艦上偵察機: + return score * 1.66; + + case SlotItemType.水上偵察機: + return score * 2.00; + case SlotItemType.水上爆撃機: + return score * 1.78; + + case SlotItemType.小型電探: + return score * 1.00; + case SlotItemType.大型電探: + return score * 0.99; + + case SlotItemType.探照灯: + return score * 0.91; + } + + return .0; + } + } +} diff --git a/Grabacr07.KanColleWrapper/Organization.cs b/Grabacr07.KanColleWrapper/Organization.cs index f44869eba..d71c45b14 100644 --- a/Grabacr07.KanColleWrapper/Organization.cs +++ b/Grabacr07.KanColleWrapper/Organization.cs @@ -113,7 +113,7 @@ public Organization(Homeport parent, KanColleProxy proxy) proxy.api_req_member_updatedeckname.TryParse().Subscribe(this.UpdateFleetName); proxy.api_req_hensei_combined.TryParse() - .Subscribe(x => this.Combined = x.Data.api_combined == 1); + .Subscribe(x => this.Combined = x.Data.api_combined != 0); proxy.ApiSessionSource .SkipUntil(proxy.api_req_map_start.TryParse().Do(this.Sortie)) diff --git a/Plugins/Counter/KanColleCounter.cs b/Plugins/Counter/KanColleCounter.cs index 6a6106385..ffb6c46c5 100644 --- a/Plugins/Counter/KanColleCounter.cs +++ b/Plugins/Counter/KanColleCounter.cs @@ -26,9 +26,12 @@ public class KanColleCounter : IToolPlugin } }; - public string ToolName => "Counter"; + public string ToolName + { + get { return "Counter"; } + } - public object GetSettingsView() + public object GetSettingsView() { return null; } diff --git a/Plugins/MasterDataViewer/MasterDataViewer.cs b/Plugins/MasterDataViewer/MasterDataViewer.cs index b5ee9bced..a13d28809 100644 --- a/Plugins/MasterDataViewer/MasterDataViewer.cs +++ b/Plugins/MasterDataViewer/MasterDataViewer.cs @@ -18,10 +18,13 @@ public class MasterDataViewer : IToolPlugin { private readonly PortalViewModel portalViewModel = new PortalViewModel(); - public string ToolName => "MasterView"; + public string ToolName + { + get { return "MasterView"; } + } - public object GetSettingsView() + public object GetSettingsView() { return null; } diff --git a/Plugins/WindowsNotifier/Windows8Notifier.cs b/Plugins/WindowsNotifier/Windows8Notifier.cs index 53a4ee591..ea4d642e0 100644 --- a/Plugins/WindowsNotifier/Windows8Notifier.cs +++ b/Plugins/WindowsNotifier/Windows8Notifier.cs @@ -15,9 +15,12 @@ internal class Windows8Notifier : INotifier CustomSound sound = new CustomSound(); #region static members - public static bool IsSupported => Toast.IsSupported; + public static bool IsSupported + { + get { return Toast.IsSupported; } + } - #endregion + #endregion public void Initialize() { @@ -42,12 +45,12 @@ public void Initialize() private static void InstallShortcut(string shortcutPath) { var exePath = Process.GetCurrentProcess().MainModule.FileName; - var newShortcut = (IShellLinkW) new CShellLink(); + var newShortcut = (IShellLinkW)new CShellLink(); ErrorHelper.VerifySucceeded(newShortcut.SetPath(exePath)); ErrorHelper.VerifySucceeded(newShortcut.SetArguments("")); - var newShortcutProperties = (IPropertyStore) newShortcut; + var newShortcutProperties = (IPropertyStore)newShortcut; using (var appId = new PropVariant(Toast.AppId)) { @@ -55,7 +58,7 @@ private static void InstallShortcut(string shortcutPath) ErrorHelper.VerifySucceeded(newShortcutProperties.Commit()); } - var newShortcutSave = (IPersistFile) newShortcut; + var newShortcutSave = (IPersistFile)newShortcut; ErrorHelper.VerifySucceeded(newShortcutSave.Save(shortcutPath, true)); }