Adds optional way to set damage randomness on or off on individual integration tests.
All checks were successful
Build / Build (push) Successful in 49s
All checks were successful
Build / Build (push) Successful in 49s
This commit is contained in:
@@ -40,7 +40,10 @@ public class DamageCalculatorTests
|
||||
// Ice Fang (an Ice-type physical move with a power of 65)
|
||||
useMove.Category.Returns(MoveCategory.Physical);
|
||||
|
||||
var damageCalculator = new Gen7DamageCalculator(false);
|
||||
var damageCalculator = new Gen7DamageCalculator(new Gen7PluginConfiguration
|
||||
{
|
||||
DamageCalculatorHasRandomness = false,
|
||||
});
|
||||
var executingMove = Substitute.For<IExecutingMove>();
|
||||
executingMove.UseMove.Returns(useMove);
|
||||
executingMove.User.Returns(attacker);
|
||||
|
||||
@@ -14,12 +14,12 @@ public class Gen7PluginConfiguration : IPluginConfiguration
|
||||
/// This should be set to true for most cases, as it simulates the actual damage calculation in the games. Only
|
||||
/// set to false for testing purposes.
|
||||
/// </summary>
|
||||
public bool DamageCalculatorHasRandomness { get; init; } = true;
|
||||
public bool DamageCalculatorHasRandomness { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The number of times a species has been caught. This is used for critical capture calculations.
|
||||
/// </summary>
|
||||
public Func<ISpecies, int> TimesSpeciesCaught { get; init; } = _ => 0;
|
||||
public Func<ISpecies, int> TimesSpeciesCaught { get; set; } = _ => 0;
|
||||
}
|
||||
|
||||
public class Gen7Plugin : Plugin<Gen7PluginConfiguration>, IResourceProvider
|
||||
@@ -44,7 +44,7 @@ public class Gen7Plugin : Plugin<Gen7PluginConfiguration>, IResourceProvider
|
||||
{
|
||||
registry.RegisterAssemblyScripts(typeof(Gen7Plugin).Assembly);
|
||||
registry.RegisterBattleStatCalculator(new Gen7BattleStatCalculator());
|
||||
registry.RegisterDamageCalculator(new Gen7DamageCalculator(Configuration.DamageCalculatorHasRandomness));
|
||||
registry.RegisterDamageCalculator(new Gen7DamageCalculator(Configuration));
|
||||
registry.RegisterMiscLibrary(new Gen7MiscLibrary());
|
||||
registry.RegisterCaptureLibrary(new Gen7CaptureLibrary(Configuration));
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using PkmnLib.Static.Moves;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Libraries.Battling;
|
||||
|
||||
public class Gen7DamageCalculator(bool hasRandomness) : IDamageCalculator
|
||||
public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDamageCalculator
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public uint GetDamage(IExecutingMove executingMove, IPokemon target, byte hitNumber, IHitData hitData)
|
||||
@@ -34,7 +34,7 @@ public class Gen7DamageCalculator(bool hasRandomness) : IDamageCalculator
|
||||
floatDamage = MathF.Floor(floatDamage * critModifier);
|
||||
}
|
||||
|
||||
if (hasRandomness)
|
||||
if (configuration.DamageCalculatorHasRandomness)
|
||||
{
|
||||
var battle = target.BattleData?.Battle;
|
||||
if (battle == null)
|
||||
|
||||
Reference in New Issue
Block a user