Skip to content

Commit

Permalink
add luck offset to exp view
Browse files Browse the repository at this point in the history
  • Loading branch information
myangelkamikaze committed Oct 18, 2023
1 parent e83014e commit b470777
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,10 @@ Please return to the home port page.</value>
<data name="Accuracy" xml:space="preserve">
<value>Accuracy</value>
</data>
<data name="LuckOffset" xml:space="preserve">
<value>Luck offset</value>
</data>
<data name="LuckOffsetToolTip" xml:space="preserve">
<value>Offset the current luck value by a specified value.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,10 @@
<data name="Accuracy" xml:space="preserve">
<value>命中項</value>
</data>
<data name="LuckOffset" xml:space="preserve">
<value>運改修</value>
</data>
<data name="LuckOffsetToolTip" xml:space="preserve">
<value>運改修値を現在値から変更します。</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class ExpCheckerTranslationViewModel : TranslationBaseViewModel
public string AswOffset => ExpCheckerResources.AswOffset;
public string ASWModernizationToolTip => ExpCheckerResources.ASWModernizationToolTip;

public string LuckOffset => ExpCheckerResources.LuckOffset;
public string LuckOffsetToolTip => ExpCheckerResources.LuckOffsetToolTip;

public string ExpUnitToolTip => ExpCheckerResources.ExpUnitToolTip;
public string GroupExp => ExpCheckerResources.GroupExp;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public class ExpCheckerViewModel : WindowViewModelBase
public int ASWModernization { get; set; }
public bool ShowAllLevel { get; set; }

public int LuckModernization { get; set; }
public int MaxLuckModernization { get; set; }

public string? WarningText { get; set; }

public string? GroupExpText { get; set; }
Expand Down Expand Up @@ -69,6 +72,8 @@ public ExpCheckerViewModel()
if (SelectedShip is null) return;

ASWModernization = SelectedShip.ASWModernized;
LuckModernization = SelectedShip.LuckModernized;
MaxLuckModernization = SelectedShip.MasterShip.LuckMax - SelectedShip.MasterShip.LuckMin;

UpdateLevelView();
};
Expand All @@ -94,6 +99,13 @@ public ExpCheckerViewModel()
UpdateLevelView();
};

PropertyChanged += (sender, args) =>
{
if (args.PropertyName is not nameof(LuckModernization)) return;

UpdateLevelView();
};

UpdateShipList();
}

Expand Down Expand Up @@ -329,7 +341,9 @@ private void UpdateLevelView()
_ => string.Join("\n", equipmentPairs),
},
IsRemodelLevel = remodelLevelTable.Contains(lv),
ShipAccuracy = selectedShip.Accuracy(lv).RoundDown(2),
ShipAccuracy = selectedShip
.Accuracy(lv, selectedShip.MasterShip.LuckMin + LuckModernization)
.RoundDown(2),
};

rows[lv - minlv] = row;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@
Value="{Binding ASWModernization}"
/>

<TextBlock Text="{Binding ExpChecker.LuckOffset}" ToolTip="{Binding ExpChecker.LuckOffsetToolTip}" />
<ui:NumberBox
Maximum="{Binding MaxLuckModernization}"
Minimum="0"
SpinButtonPlacementMode="Inline"
Value="{Binding LuckModernization}"
/>

<TextBlock Text="{Binding ExpChecker.SortieExp}" />
<ui:NumberBox SpinButtonPlacementMode="Inline" Value="{Binding SortieExp}" />
</StackPanel>
Expand Down
5 changes: 3 additions & 2 deletions ElectronicObserverTypes/Extensions/ShipDataExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ public static IShipDataMaster BaseShip(this IShipDataMaster ship)
/// </summary>
/// <param name="ship">Ship.</param>
/// <param name="level">Custom level override, ship.Level will be used by default.</param>
/// <param name="luck">Custom luck override, ship.LuckTotal 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 double Accuracy(this IShipData ship, int? level = null, int? luck = null) =>
2 * Math.Sqrt(level ?? ship.Level) + 1.5 * Math.Sqrt(luck ?? ship.LuckTotal);

public static int NextAccuracyLevel(this IShipData ship, int? currentAccuracy = null)
{
Expand Down

0 comments on commit b470777

Please sign in to comment.