Skip to content

Commit

Permalink
fix MainStatMulti
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenari committed Oct 21, 2024
1 parent 2f94a7a commit c59b689
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 1 deletion.
29 changes: 29 additions & 0 deletions XIVCalc.Tests/JobStatMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Lumina.Excel.GeneratedSheets;
using XIVCalc.Interfaces;

namespace XIVCalc.Tests;

public class JobStatMock : IJobStatBlock
{
public ClassJob Job { get; init; } = new ClassJob();
public int Level { get; init; }
public int WeaponDamage { get;init; }
public int WeaponDelay { get; init;}
public int Vitality { get; init;}
public int Strength { get; init;}
public int Dexterity { get; init;}
public int Intelligence { get; init;}
public int Mind { get; init;}
public int PhysicalDefense { get; init;}
public int MagicalDefense { get; init;}
public int AttackPower { get; init;}
public int AttackMagicPotency { get; init;}
public int HealingMagicPotency { get; init;}
public int DirectHit { get; init;}
public int CriticalHit { get; init;}
public int Determination { get; init;}
public int SkillSpeed { get; init;}
public int SpellSpeed { get; init;}
public int Piety { get; init;}
public int Tenacity { get; init;}
}
42 changes: 42 additions & 0 deletions XIVCalc.Tests/SimpleTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Lumina.Excel.GeneratedSheets;
using XIVCalc.Calculations;

namespace XIVCalc.Tests;

public class SimpleTests
{
private ClassJob WHM = new ClassJob()
{
ModifierStrength = 55,
ModifierDexterity = 105,
ModifierIntelligence = 105,
ModifierMind = 115,
ModifierVitality = 100,
ModifierHitPoints = 105,
PrimaryStat = (byte) StatType.Mind,
};

[SetUp]
public void Setup()
{
}

[Test]
public void MainStatMulti()
{
Assert.Multiple(() =>
{
Assert.That(StatEquations.MainStatMultiplier(440, 100, WHM), Is.EqualTo(1d));
Assert.That(StatEquations.MainStatMultiplier(452, 100, WHM), Is.EqualTo(1.06));
Assert.That(StatEquations.MainStatMultiplier(531, 100, WHM), Is.EqualTo( 1.49));
Assert.That(StatEquations.MainStatMultiplier(555, 100, WHM), Is.EqualTo( 1.61));
Assert.That(StatEquations.MainStatMultiplier(629, 100, WHM), Is.EqualTo( 2.01));
});
}

[Test]
public void TestBasicStats()
{
Assert.Pass();
}
}
29 changes: 29 additions & 0 deletions XIVCalc.Tests/XIVCalc.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
<PackageReference Include="Lumina.Excel" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="NUnit" Version="3.14.0"/>
<PackageReference Include="NUnit.Analyzers" Version="3.9.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
</ItemGroup>

<ItemGroup>
<Using Include="NUnit.Framework"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\XIVCalc\XIVCalc.csproj" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions XIVCalc.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 17.4.33205.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XIVCalc", "XIVCalc\XIVCalc.csproj", "{C4D9F54E-983A-45DD-A6E5-F36BF4E54FBE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XIVCalc.Tests", "XIVCalc.Tests\XIVCalc.Tests.csproj", "{576C4195-146C-4058-B5E4-3A1F1FD04D24}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{C4D9F54E-983A-45DD-A6E5-F36BF4E54FBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4D9F54E-983A-45DD-A6E5-F36BF4E54FBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4D9F54E-983A-45DD-A6E5-F36BF4E54FBE}.Release|Any CPU.Build.0 = Release|Any CPU
{576C4195-146C-4058-B5E4-3A1F1FD04D24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{576C4195-146C-4058-B5E4-3A1F1FD04D24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{576C4195-146C-4058-B5E4-3A1F1FD04D24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{576C4195-146C-4058-B5E4-3A1F1FD04D24}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
16 changes: 15 additions & 1 deletion XIVCalc/Calculations/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ public static double GetHpMultiplier(int level, Job job)
};
}

private static double MainStatPowerMod(int level, ClassJob job) => (job.IsTank(), level) switch
{
(_,< 70) => 100,
(true,< 80) => 105,
(false, < 80) => 125,
(true, < 90) => 115,
(false,< 90) => 165,
(true, < 100) => 156,
(false, < 100) => 195,
(true, _) => 190,
(_,_) => 237,

};

public static double CritDamage(int criticalHit, int level) =>
Floor(1400 + 200 * (criticalHit - LevelTable.SUB(level)) / LevelTable.DIV(level)) / 1000d;

Expand Down Expand Up @@ -293,7 +307,7 @@ public static double WeaponDamageMultiplier(int weaponDamage, int level, ClassJo
/// <param name="job">Active job</param>
/// <returns>Damage Multiplier F(AP)/F(ATK)</returns>
public static double MainStatMultiplier(int mainStat, int level, ClassJob job) =>
Max(Floor(GetAttackModifierM(level, job) * (mainStat - LevelTable.MAIN(level)/LevelTable.MAIN(level)))/100d,0);
Max(0, (Floor(MainStatPowerMod(level,job) * (mainStat - LevelTable.MAIN(level)) / LevelTable.MAIN(level) + 100) / 100f));

/// <summary>
/// Like <see cref="WeaponDamageMultiplier"/>, but for auto-attacks.
Expand Down

0 comments on commit c59b689

Please sign in to comment.