Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -6,8 +6,8 @@ namespace PkmnLib.Plugin.Gen7.Libraries.Battling;
|
||||
public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDamageCalculator
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public uint GetDamage(IExecutingMove? executingMove, MoveCategory category, IPokemon user, IPokemon target,
|
||||
int targetCount, byte hitNumber, IHitData hitData)
|
||||
public uint GetDamage(IExecutingMove? executingMove, MoveCategory category, IBattlePokemon user,
|
||||
IBattlePokemon target, int targetCount, byte hitNumber, IHitData hitData)
|
||||
{
|
||||
if (category == MoveCategory.Status)
|
||||
return 0;
|
||||
@@ -36,7 +36,7 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
||||
|
||||
if (configuration.DamageCalculatorHasRandomness)
|
||||
{
|
||||
var battle = target.BattleData?.Battle;
|
||||
var battle = target.Battle;
|
||||
if (battle == null)
|
||||
throw new InvalidOperationException("Randomness is enabled, but no battle is set.");
|
||||
var random = battle.Random;
|
||||
@@ -75,7 +75,7 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ushort GetBasePower(IExecutingMove executingMove, IPokemon target, byte hitNumber, IHitData hitData)
|
||||
public ushort GetBasePower(IExecutingMove executingMove, IBattlePokemon target, byte hitNumber, IHitData hitData)
|
||||
{
|
||||
if (executingMove.UseMove.Category == MoveCategory.Status)
|
||||
return 0;
|
||||
@@ -86,7 +86,7 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsCritical(IBattle battle, IExecutingMove executingMove, IPokemon target, byte hitNumber)
|
||||
public bool IsCritical(IBattle battle, IExecutingMove executingMove, IBattlePokemon target, byte hitNumber)
|
||||
{
|
||||
if (executingMove.UseMove.Category == MoveCategory.Status)
|
||||
return false;
|
||||
@@ -104,8 +104,8 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
||||
};
|
||||
}
|
||||
|
||||
private static float GetStatModifier(IExecutingMove? executingMove, MoveCategory category, IPokemon user,
|
||||
IPokemon target, byte hitNumber, IHitData hitData)
|
||||
private static float GetStatModifier(IExecutingMove? executingMove, MoveCategory category, IBattlePokemon user,
|
||||
IBattlePokemon target, byte hitNumber, IHitData hitData)
|
||||
{
|
||||
if (category == MoveCategory.Status)
|
||||
return 1;
|
||||
@@ -168,7 +168,7 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
||||
/// Gets the damage modifier. This is a value that defaults to 1.0, but can be modified by scripts
|
||||
/// to apply a raw modifier to the damage.
|
||||
/// </summary>
|
||||
private static float GetDamageModifier(IExecutingMove executingMove, IPokemon target, byte hitNumber)
|
||||
private static float GetDamageModifier(IExecutingMove executingMove, IBattlePokemon target, byte hitNumber)
|
||||
{
|
||||
var modifier = 1.0f;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user