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

@@ -13,7 +13,7 @@ public interface IFleeChoice : ITurnChoice
public class FleeTurnChoice : TurnChoice, IFleeChoice
{
/// <inheritdoc />
public FleeTurnChoice(IPokemon user) : base(user)
public FleeTurnChoice(IBattlePokemon user) : base(user)
{
}

View File

@@ -16,15 +16,15 @@ public interface IItemChoice : ITurnChoice
/// <summary>
/// The target Pokémon of the item, if any.
/// </summary>
IPokemon? GetTargetPokemon(IBattle battle);
IBattlePokemon? GetTargetPokemon(IBattle battle);
}
/// <inheritdoc cref="IItemChoice"/>
public class ItemChoice : TurnChoice, IItemChoice
{
/// <inheritdoc cref="ItemChoice"/>
private ItemChoice(IPokemon user, IItem item, byte? targetSide, byte? targetPosition, IPokemon? targetPokemon) :
base(user)
private ItemChoice(IBattlePokemon user, IItem item, byte? targetSide, byte? targetPosition,
IBattlePokemon? targetPokemon) : base(user)
{
Item = item;
TargetSide = targetSide;
@@ -32,13 +32,13 @@ public class ItemChoice : TurnChoice, IItemChoice
TargetPokemon = targetPokemon;
}
public static ItemChoice CreateWithoutTarget(IPokemon user, IItem item) =>
public static ItemChoice CreateWithoutTarget(IBattlePokemon user, IItem item) =>
new(user, item, null, null, null);
public static ItemChoice CreateForOpponent(IPokemon user, IItem item, byte targetSide, byte targetPosition) =>
public static ItemChoice CreateForOpponent(IBattlePokemon user, IItem item, byte targetSide, byte targetPosition) =>
new(user, item, targetSide, targetPosition, null);
public static ItemChoice CreateForPartyMember(IPokemon user, IItem item, IPokemon targetPokemon) =>
public static ItemChoice CreateForPartyMember(IBattlePokemon user, IItem item, IBattlePokemon targetPokemon) =>
new(user, item, null, null, targetPokemon);
/// <summary>
@@ -47,7 +47,7 @@ public class ItemChoice : TurnChoice, IItemChoice
public IItem Item { get; }
/// <inheritdoc />
public IPokemon? GetTargetPokemon(IBattle battle)
public IBattlePokemon? GetTargetPokemon(IBattle battle)
{
if (TargetPokemon != null)
return TargetPokemon;
@@ -71,7 +71,7 @@ public class ItemChoice : TurnChoice, IItemChoice
/// <summary>
/// The target Pokémon of the item, if any. This is used for party members.
/// </summary>
private IPokemon? TargetPokemon { get; }
private IBattlePokemon? TargetPokemon { get; }
/// <inheritdoc />
public override int ScriptCount => User.ScriptCount;

View File

@@ -51,7 +51,7 @@ public interface IMoveChoice : ITurnChoice
public class MoveChoice : TurnChoice, IMoveChoice
{
/// <inheritdoc cref="MoveChoice"/>
public MoveChoice(IPokemon user, ILearnedMove usedMove, byte targetSide, byte targetPosition) : base(user)
public MoveChoice(IBattlePokemon user, ILearnedMove usedMove, byte targetSide, byte targetPosition) : base(user)
{
ChosenMove = usedMove;
TargetSide = targetSide;

View File

@@ -13,7 +13,7 @@ public interface IPassChoice : ITurnChoice
public class PassChoice : TurnChoice, IPassChoice
{
/// <inheritdoc cref="PassChoice"/>
public PassChoice(IPokemon user) : base(user)
public PassChoice(IBattlePokemon user) : base(user)
{
}

View File

@@ -10,20 +10,20 @@ public interface ISwitchChoice : ITurnChoice
/// <summary>
/// The Pokémon to switch to.
/// </summary>
IPokemon SwitchTo { get; }
IBattlePokemon SwitchTo { get; }
}
/// <inheritdoc cref="ISwitchChoice"/>
public class SwitchChoice : TurnChoice, ISwitchChoice
{
/// <inheritdoc cref="SwitchChoice"/>
public SwitchChoice(IPokemon user, IPokemon switchTo) : base(user)
public SwitchChoice(IBattlePokemon user, IBattlePokemon switchTo) : base(user)
{
SwitchTo = switchTo;
}
/// <inheritdoc />
public IPokemon SwitchTo { get; }
public IBattlePokemon SwitchTo { get; }
/// <inheritdoc />
public override int ScriptCount => User.ScriptCount;

View File

@@ -11,7 +11,7 @@ public interface ITurnChoice : IScriptSource, IDeepCloneable
/// <summary>
/// The user of the turn choice
/// </summary>
IPokemon User { get; }
IBattlePokemon User { get; }
/// <summary>
/// The speed of the user at the beginning of the turn.
@@ -34,7 +34,7 @@ public interface ITurnChoice : IScriptSource, IDeepCloneable
/// Fails the choice. This will prevent it from executing and run a specific fail handling during
/// execution. Note that this can not be undone.
/// </summary>
public void Fail();
void Fail();
}
/// <summary>
@@ -43,7 +43,7 @@ public interface ITurnChoice : IScriptSource, IDeepCloneable
public abstract class TurnChoice : ScriptSource, ITurnChoice
{
/// <inheritdoc cref="TurnChoice"/>
protected TurnChoice(IPokemon user)
protected TurnChoice(IBattlePokemon user)
{
User = user;
}
@@ -51,7 +51,7 @@ public abstract class TurnChoice : ScriptSource, ITurnChoice
/// <summary>
/// The Pokemon for which the choice is made.
/// </summary>
public IPokemon User { get; }
public IBattlePokemon User { get; }
/// <summary>
/// The speed of the user at the beginning of the turn.