Fixes, tests for Aftermath
All checks were successful
Build / Build (push) Successful in 1m53s

This commit is contained in:
2026-01-09 15:17:54 +01:00
parent 123c3773d2
commit 391edd98f1
3 changed files with 429 additions and 16 deletions

View File

@@ -248,6 +248,9 @@ public interface IPokemon : IScriptSource, IDeepCloneable
[MustUseReturnValue]
IItem? RemoveHeldItem();
/// <summary>
/// Whether the held item has been removed for the duration of the battle.
/// </summary>
bool HasItemBeenRemovedForBattle { get; }
/// <summary>
@@ -451,30 +454,45 @@ public interface IPokemon : IScriptSource, IDeepCloneable
/// </summary>
public interface IPokemonBattleData : IDeepCloneable
{
/// <summary>
/// Sets the battle data of the Pokémon.
/// </summary>
void SetBattle(IBattle battle, byte sideIndex, uint switchInTurn);
/// <summary>
/// Sets the position of the Pokémon on the field.
/// </summary>
void SetPosition(byte position);
/// <summary>
/// The battle the Pokémon is in.
/// </summary>
IBattle Battle { get; internal set; }
IBattle Battle { get; }
/// <summary>
/// The index of the side of the Pokémon
/// </summary>
byte SideIndex { get; internal set; }
byte SideIndex { get; }
/// <summary>
/// The index of the position of the Pokémon on the field
/// </summary>
byte Position { get; internal set; }
byte Position { get; }
/// <summary>
/// A list of opponents the Pokémon has seen this battle.
/// </summary>
IReadOnlyList<IPokemon> SeenOpponents { get; }
/// <summary>
/// Sets whether the Pokémon is on the battlefield.
/// </summary>
void SetOnBattlefield(bool onBattleField);
/// <summary>
/// Whether the Pokémon is on the battlefield.
/// </summary>
bool IsOnBattlefield { get; internal set; }
bool IsOnBattlefield { get; }
/// <summary>
/// Adds an opponent to the list of seen opponents.
@@ -494,8 +512,11 @@ public interface IPokemonBattleData : IDeepCloneable
/// <summary>
/// The turn the Pokémon switched in.
/// </summary>
uint SwitchInTurn { get; internal set; }
uint SwitchInTurn { get; }
/// <summary>
/// The number of turns the Pokémon has been on the field.
/// </summary>
uint TurnsOnField { get; }
/// <summary>
@@ -516,7 +537,7 @@ public interface IPokemonBattleData : IDeepCloneable
/// <summary>
/// The last move choice executed by the Pokémon.
/// </summary>
IMoveChoice? LastMoveChoice { get; internal set; }
IMoveChoice? LastMoveChoice { get; set; }
}
/// <inheritdoc cref="IPokemon"/>
@@ -1315,9 +1336,7 @@ public class PokemonImpl : ScriptSource, IPokemon
{
if (BattleData is not null)
{
BattleData.Battle = battle;
BattleData.SideIndex = sideIndex;
BattleData.SwitchInTurn = battle.CurrentTurnNumber;
BattleData.SetBattle(battle, sideIndex, battle.CurrentTurnNumber);
}
else
{
@@ -1340,7 +1359,7 @@ public class PokemonImpl : ScriptSource, IPokemon
{
if (BattleData is not null)
{
BattleData.IsOnBattlefield = onBattleField;
BattleData.SetOnBattlefield(onBattleField);
if (!onBattleField)
{
Volatile.Clear();
@@ -1356,10 +1375,7 @@ public class PokemonImpl : ScriptSource, IPokemon
/// <inheritdoc />
public void SetBattleSidePosition(byte position)
{
if (BattleData is not null)
{
BattleData.Position = position;
}
BattleData?.SetPosition(position);
}
/// <inheritdoc />
@@ -1494,6 +1510,20 @@ public class PokemonBattleDataImpl : IPokemonBattleData
OriginalForm = originalForm;
}
/// <inheritdoc />
public void SetBattle(IBattle battle, byte sideIndex, uint switchInTurn)
{
Battle = battle;
SideIndex = sideIndex;
SwitchInTurn = switchInTurn;
}
/// <inheritdoc />
public void SetPosition(byte position)
{
Position = position;
}
/// <inheritdoc />
public IBattle Battle { get; set; }
@@ -1508,6 +1538,12 @@ public class PokemonBattleDataImpl : IPokemonBattleData
/// <inheritdoc />
public IReadOnlyList<IPokemon> SeenOpponents => _seenOpponents;
/// <inheritdoc />
public void SetOnBattlefield(bool onBattleField)
{
IsOnBattlefield = onBattleField;
}
/// <inheritdoc />
public bool IsOnBattlefield { get; set; }