Reorganized folder structure

This commit is contained in:
2024-07-28 10:47:00 +02:00
parent 864dda6644
commit 74996d96b0
10 changed files with 5 additions and 5 deletions

View File

@@ -0,0 +1,10 @@
namespace PkmnLib.Plugin.Gen7.Tests;
public class BattleStatCalculatorTests
{
[Test]
public void Test1()
{
Assert.Pass();
}
}

View File

@@ -0,0 +1,62 @@
using PkmnLib.Dynamic.Models;
using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Plugin.Gen7.Libraries;
using PkmnLib.Static;
using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Tests;
public class DamageCalculatorTests
{
/// <summary>
/// Implements the following example from Bulbapedia:
/// </summary>
/// <para>
/// Imagine a level 75 Glaceon that does not suffer a burn and holds no item with an effective Attack stat of 123
/// uses Ice Fang (an Ice-type physical move with a power of 65) against a Garchomp with an effective Defense stat
/// of 163 in Generation VI, and does not land a critical hit. Then, the move will receive STAB, because Glaceon's
/// Ice type matches the move's: STAB = 1.5. Additionally, Garchomp is Dragon/Ground, and therefore has a double
/// weakness to the move's Ice type: Type = 4. All other (non-random) modifiers will be 1.
///
/// That means Ice Fang will do between 168 and 196 HP damage, depending on luck.
/// </para>
[Test]
public void BulbapediaExampleDamageTest()
{
var attacker = new Mock<IPokemon>();
// Imagine a level 75 Glaceon
attacker.Setup(x => x.Level).Returns(75);
// with an effective Attack stat of 123
attacker.Setup(x => x.BoostedStats).Returns(new StatisticSet<uint>(
1, 123, 1, 1, 1, 1));
// We use 10 as the Ice type
attacker.Setup(x => x.Types).Returns([new TypeIdentifier(10)]);
var defender = new Mock<IPokemon>();
// a Garchomp with an effective Defense stat of 163
defender.Setup(x => x.BoostedStats).Returns(new StatisticSet<uint>(
1, 1, 163, 1, 1, 1));
var useMove = new Mock<IMoveData>();
// Ice Fang (an Ice-type physical move with a power of 65)
useMove.Setup(x => x.Category).Returns(MoveCategory.Physical);
var damageCalculator = new Gen7DamageCalculator(false);
var executingMove = new Mock<IExecutingMove>();
executingMove.Setup(x => x.UseMove).Returns(useMove.Object);
executingMove.Setup(x => x.User).Returns(attacker.Object);
executingMove.Setup(x => x.GetScripts()).Returns(new ScriptIterator([]));
var hit = new Mock<IHitData>();
// Ice Fang (an Ice-type physical move with a power of 65)
hit.Setup(x => x.BasePower).Returns(65);
hit.Setup(x => x.Type).Returns(new TypeIdentifier(10));
// has a double weakness to the move's Ice type
hit.Setup(x => x.Effectiveness).Returns(4.0f);
var damage = damageCalculator.GetDamage(executingMove.Object, defender.Object, 0, hit.Object);
// That means Ice Fang will do between 168 and 196 HP damage, depending on luck.
// Note that we are testing deterministic damage, so we expect the maximum damage.
Assert.That(damage, Is.EqualTo(196));
}
}

View File

@@ -0,0 +1,2 @@
global using NUnit.Framework;
global using Moq;

View File

@@ -0,0 +1,26 @@
<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="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="NUnit" Version="3.13.3"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1"/>
<PackageReference Include="NUnit.Analyzers" Version="3.6.1"/>
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\PkmnLib.Dynamic\PkmnLib.Dynamic.csproj" />
<ProjectReference Include="..\PkmnLib.Plugin.Gen7\PkmnLib.Plugin.Gen7.csproj" />
</ItemGroup>
</Project>