Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -3,22 +3,22 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Side, "follow_me")]
|
||||
public class FollowMeEffect : Script, IScriptChangeIncomingTargets, IScriptOnEndTurn, IScriptOnFaint, IScriptOnSwitchOut
|
||||
{
|
||||
private readonly IPokemon _user;
|
||||
private readonly IBattlePokemon _user;
|
||||
|
||||
public FollowMeEffect(IPokemon user)
|
||||
public FollowMeEffect(IBattlePokemon user)
|
||||
{
|
||||
_user = user;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
|
||||
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IBattlePokemon?> targets)
|
||||
{
|
||||
if (targets.Count != 1)
|
||||
return;
|
||||
if (moveChoice.ChosenMove.MoveData.HasFlag(MoveFlags.NoRedirection))
|
||||
return;
|
||||
|
||||
if (moveChoice.User.BattleData?.SideIndex == _user.BattleData?.SideIndex)
|
||||
if (moveChoice.User.SideIndex == _user.SideIndex)
|
||||
return;
|
||||
targets = [_user];
|
||||
}
|
||||
@@ -28,13 +28,13 @@ public class FollowMeEffect : Script, IScriptChangeIncomingTargets, IScriptOnEnd
|
||||
RemoveSelf();
|
||||
}
|
||||
|
||||
public void OnFaint(IPokemon pokemon, DamageSource source)
|
||||
public void OnFaint(IBattlePokemon pokemon, DamageSource source)
|
||||
{
|
||||
if (pokemon == _user)
|
||||
RemoveSelf();
|
||||
}
|
||||
|
||||
public void OnSwitchOut(IPokemon oldPokemon, byte position)
|
||||
public void OnSwitchOut(IBattlePokemon oldPokemon, byte position)
|
||||
{
|
||||
if (oldPokemon == _user)
|
||||
RemoveSelf();
|
||||
|
||||
Reference in New Issue
Block a user