From e83014ef7ecbfc42f36f17ccf1e7e45b08597abd Mon Sep 17 00:00:00 2001 From: MyAngelKamikaze Date: Wed, 18 Oct 2023 23:10:38 +0900 Subject: [PATCH] add accuracy to exp check --- .../Window/Dialog/ExpCheckerResources.en.resx | 3 +++ .../Window/Dialog/ExpCheckerResources.resx | 3 +++ .../Window/Tools/ExpChecker/DataGridItem.cs | 3 ++- .../ExpChecker/ExpCheckerTranslationViewModel.cs | 1 + .../Tools/ExpChecker/ExpCheckerViewModel.cs | 5 +++-- .../Window/Tools/ExpChecker/ExpCheckerWindow.xaml | 1 + ElectronicObserverCoreTests/LoSTests.cs | 15 +-------------- .../Extensions/ShipDataExtensions.cs | 10 ++++++++-- ElectronicObserverTypes/NumberExtensions.cs | 12 ++++++++++++ 9 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 ElectronicObserverTypes/NumberExtensions.cs diff --git a/ElectronicObserver/Properties/Window/Dialog/ExpCheckerResources.en.resx b/ElectronicObserver/Properties/Window/Dialog/ExpCheckerResources.en.resx index aadeb3eef..d41262bb0 100644 --- a/ElectronicObserver/Properties/Window/Dialog/ExpCheckerResources.en.resx +++ b/ElectronicObserver/Properties/Window/Dialog/ExpCheckerResources.en.resx @@ -184,4 +184,7 @@ Please return to the home port page. Modernization + + Accuracy + \ No newline at end of file diff --git a/ElectronicObserver/Properties/Window/Dialog/ExpCheckerResources.resx b/ElectronicObserver/Properties/Window/Dialog/ExpCheckerResources.resx index 85bfce73e..5da93a7fb 100644 --- a/ElectronicObserver/Properties/Window/Dialog/ExpCheckerResources.resx +++ b/ElectronicObserver/Properties/Window/Dialog/ExpCheckerResources.resx @@ -165,4 +165,7 @@ 現在改修 + + 命中項 + \ No newline at end of file diff --git a/ElectronicObserver/Window/Tools/ExpChecker/DataGridItem.cs b/ElectronicObserver/Window/Tools/ExpChecker/DataGridItem.cs index f76a31187..a077d7a2f 100644 --- a/ElectronicObserver/Window/Tools/ExpChecker/DataGridItem.cs +++ b/ElectronicObserver/Window/Tools/ExpChecker/DataGridItem.cs @@ -9,4 +9,5 @@ public class DataGridItem public string EquipmentList { get; init; } public string ToolTip { get; init; } public bool IsRemodelLevel { get; init; } -} \ No newline at end of file + public double ShipAccuracy { get; init; } +} diff --git a/ElectronicObserver/Window/Tools/ExpChecker/ExpCheckerTranslationViewModel.cs b/ElectronicObserver/Window/Tools/ExpChecker/ExpCheckerTranslationViewModel.cs index fda790456..3ecacf109 100644 --- a/ElectronicObserver/Window/Tools/ExpChecker/ExpCheckerTranslationViewModel.cs +++ b/ElectronicObserver/Window/Tools/ExpChecker/ExpCheckerTranslationViewModel.cs @@ -26,6 +26,7 @@ public class ExpCheckerTranslationViewModel : TranslationBaseViewModel public string ColumnSortieCount => ExpCheckerResources.ColumnSortieCount; public string ASW => ExpCheckerResources.ASW; public string ColumnEquipment => ExpCheckerResources.ColumnEquipment; + public string Accuracy => ExpCheckerResources.Accuracy; public string AswUnknown => ExpCheckerResources.AswUnknown; public string AswApproximated => ExpCheckerResources.AswApproximated; diff --git a/ElectronicObserver/Window/Tools/ExpChecker/ExpCheckerViewModel.cs b/ElectronicObserver/Window/Tools/ExpChecker/ExpCheckerViewModel.cs index 614dc796f..c13857fff 100644 --- a/ElectronicObserver/Window/Tools/ExpChecker/ExpCheckerViewModel.cs +++ b/ElectronicObserver/Window/Tools/ExpChecker/ExpCheckerViewModel.cs @@ -321,14 +321,15 @@ private void UpdateLevelView() EquipmentList = !aswdata.IsAvailable ? "-" : equipmentPairs switch { null => "-", - _ => string.Join(", ", equipmentPairs) + _ => string.Join(", ", equipmentPairs), }, ToolTip = equipmentPairs switch { null => "-", - _ => string.Join("\n", equipmentPairs) + _ => string.Join("\n", equipmentPairs), }, IsRemodelLevel = remodelLevelTable.Contains(lv), + ShipAccuracy = selectedShip.Accuracy(lv).RoundDown(2), }; rows[lv - minlv] = row; diff --git a/ElectronicObserver/Window/Tools/ExpChecker/ExpCheckerWindow.xaml b/ElectronicObserver/Window/Tools/ExpChecker/ExpCheckerWindow.xaml index d4cd3bb79..a04c4fa25 100644 --- a/ElectronicObserver/Window/Tools/ExpChecker/ExpCheckerWindow.xaml +++ b/ElectronicObserver/Window/Tools/ExpChecker/ExpCheckerWindow.xaml @@ -162,6 +162,7 @@ + diff --git a/ElectronicObserverCoreTests/LoSTests.cs b/ElectronicObserverCoreTests/LoSTests.cs index b5cd795a5..bb08fe24d 100644 --- a/ElectronicObserverCoreTests/LoSTests.cs +++ b/ElectronicObserverCoreTests/LoSTests.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; +using System.Collections.Generic; using ElectronicObserver.Utility.Data; using ElectronicObserverTypes; using ElectronicObserverTypes.Mocks; @@ -8,15 +6,6 @@ namespace ElectronicObserverCoreTests; -public static class NumberExtensions -{ - public static double RoundDown(this double value, int precision = 0) - { - double power = Math.Pow(10, precision); - return Math.Floor(value * power) / power; - } -} - [Collection(DatabaseCollection.Name)] public class LoSTests { @@ -24,8 +13,6 @@ public class LoSTests private int AdmiralLevel => 120; - private ReadOnlyCollection NoEquip => new(new List()); - public LoSTests(DatabaseFixture db) { Db = db; diff --git a/ElectronicObserverTypes/Extensions/ShipDataExtensions.cs b/ElectronicObserverTypes/Extensions/ShipDataExtensions.cs index 234b771f2..c3bfef558 100644 --- a/ElectronicObserverTypes/Extensions/ShipDataExtensions.cs +++ b/ElectronicObserverTypes/Extensions/ShipDataExtensions.cs @@ -24,8 +24,14 @@ public static IShipDataMaster BaseShip(this IShipDataMaster ship) /// public static bool IsAbyssalShip(this IShipDataMaster ship) => ship.ShipID > 1500; - public static double Accuracy(this IShipData ship) => - 2 * Math.Sqrt(ship.Level) + 1.5 * Math.Sqrt(ship.LuckTotal); + /// + /// Calculates the ship accuracy. + /// + /// Ship. + /// Custom level override, ship.Level will be used by default. + /// Ship accuracy. + public static double Accuracy(this IShipData ship, int? level = null) => + 2 * Math.Sqrt(level ?? ship.Level) + 1.5 * Math.Sqrt(ship.LuckTotal); public static int NextAccuracyLevel(this IShipData ship, int? currentAccuracy = null) { diff --git a/ElectronicObserverTypes/NumberExtensions.cs b/ElectronicObserverTypes/NumberExtensions.cs new file mode 100644 index 000000000..b98c3c9b1 --- /dev/null +++ b/ElectronicObserverTypes/NumberExtensions.cs @@ -0,0 +1,12 @@ +using System; + +namespace ElectronicObserverTypes; + +public static class NumberExtensions +{ + public static double RoundDown(this double value, int precision = 0) + { + double power = Math.Pow(10, precision); + return Math.Floor(value * power) / power; + } +}