Skip to content

Commit

Permalink
add accuracy to exp check
Browse files Browse the repository at this point in the history
  • Loading branch information
myangelkamikaze committed Oct 18, 2023
1 parent edc8d53 commit e83014e
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,7 @@ Please return to the home port page.</value>
<data name="Modernization" xml:space="preserve">
<value>Modernization</value>
</data>
<data name="Accuracy" xml:space="preserve">
<value>Accuracy</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,7 @@
<data name="Modernization" xml:space="preserve">
<value>現在改修</value>
</data>
<data name="Accuracy" xml:space="preserve">
<value>命中項</value>
</data>
</root>
3 changes: 2 additions & 1 deletion ElectronicObserver/Window/Tools/ExpChecker/DataGridItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public class DataGridItem
public string EquipmentList { get; init; }
public string ToolTip { get; init; }
public bool IsRemodelLevel { get; init; }
}
public double ShipAccuracy { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding ShipAccuracy, StringFormat={}{0:0.##}}" Header="{Binding DataContext.ExpChecker.Accuracy, Source={StaticResource Proxy}}" />
</DataGrid.Columns>
</DataGrid>
</GroupBox>
Expand Down
15 changes: 1 addition & 14 deletions ElectronicObserverCoreTests/LoSTests.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using ElectronicObserver.Utility.Data;
using ElectronicObserverTypes;
using ElectronicObserverTypes.Mocks;
using Xunit;

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
{
private DatabaseFixture Db { get; }

private int AdmiralLevel => 120;

private ReadOnlyCollection<IEquipmentData> NoEquip => new(new List<IEquipmentData>());

public LoSTests(DatabaseFixture db)
{
Db = db;
Expand Down
10 changes: 8 additions & 2 deletions ElectronicObserverTypes/Extensions/ShipDataExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ public static IShipDataMaster BaseShip(this IShipDataMaster ship)
/// </summary>
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);
/// <summary>
/// Calculates the ship accuracy.
/// </summary>
/// <param name="ship">Ship.</param>
/// <param name="level">Custom level override, ship.Level will be used by default.</param>
/// <returns>Ship accuracy.</returns>
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)
{
Expand Down
12 changes: 12 additions & 0 deletions ElectronicObserverTypes/NumberExtensions.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit e83014e

Please sign in to comment.