Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper

This commit is contained in:
2026-08-28 15:20:26 +02:00
parent 942be8eaeb
commit 8a2733a0a9
859 changed files with 4408 additions and 5331 deletions

View File

@@ -9,7 +9,7 @@ public class FastBall : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
var modifier = target.Form.BaseStats.Speed >= 100 ? 4f : 1f;
catchRate = catchRate.MultiplyOrMax(modifier);

View File

@@ -9,12 +9,12 @@ public class FriendBall : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
}
/// <inheritdoc />
public override void OnAfterSuccessfulCapture(IPokemon target)
public override void OnAfterSuccessfulCapture(IBattlePokemon target)
{
target.Happiness = 200;
}

View File

@@ -9,12 +9,12 @@ public class HealBall : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
}
/// <inheritdoc />
public override void OnAfterSuccessfulCapture(IPokemon target)
public override void OnAfterSuccessfulCapture(IBattlePokemon target)
{
target.Heal(target.MaxHealth, true, forceHeal: true);
target.ClearStatus();

View File

@@ -9,7 +9,7 @@ public class HeavyBall : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
var weight = target.WeightInKg;
switch (weight)

View File

@@ -9,12 +9,10 @@ public class LevelBall : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
if (target.BattleData is null)
return;
var opponentSide = target.BattleData.SideIndex == 0 ? 1 : 0;
var opponent = target.BattleData.Battle.Sides[opponentSide].Pokemon.FirstOrDefault(x => x is not null);
var opponentSide = target.SideIndex == 0 ? 1 : 0;
var opponent = target.Battle.Sides[opponentSide].Pokemon.FirstOrDefault(x => x is not null);
if (opponent is null)
return;

View File

@@ -9,12 +9,10 @@ public class LoveBall : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
if (target.BattleData is null)
return;
var opponentSide = target.BattleData.SideIndex == 0 ? 1 : 0;
var opponent = target.BattleData.Battle.Sides[opponentSide].Pokemon.FirstOrDefault(x => x is not null);
var opponentSide = target.SideIndex == 0 ? 1 : 0;
var opponent = target.Battle.Sides[opponentSide].Pokemon.FirstOrDefault(x => x is not null);
if (opponent is null)
return;

View File

@@ -11,7 +11,7 @@ public class MoonBall : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
if (target.Species.EvolutionData.Any(x =>
{

View File

@@ -9,7 +9,7 @@ public class NestBall : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
if (target.Level >= 30)
return;

View File

@@ -9,7 +9,7 @@ public class NetBall : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
if (target.Types.Any(x => x.Name == TypeNames.Water || x.Name == TypeNames.Bug))
{

View File

@@ -31,7 +31,7 @@ public class PokeballFlatModifier : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
catchRate = catchRate.MultiplyOrMax(_catchModifier);
}

View File

@@ -9,9 +9,9 @@ public class QuickBall : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData is null)
return;

View File

@@ -11,7 +11,7 @@ public class RepeatBall : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
if (target.Library.CaptureLibrary is Gen7CaptureLibrary captureLibrary &&
captureLibrary.HasPokemonBeenCaughtBefore(target.Species))

View File

@@ -9,9 +9,9 @@ public class TimerBall : PokeballScript
}
/// <inheritdoc />
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData is null)
return;