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

@@ -35,29 +35,30 @@ public static class ItemTargetTypeHelpers
/// <summary>
/// Determines if the given target is valid based on the ItemTargetType.
/// </summary>
public static bool IsValidTarget(this ItemTargetType targetType, IBattle battle, IPokemon user, IPokemon target)
public static bool IsValidTarget(this ItemTargetType targetType, IBattle battle, IBattlePokemon user,
IBattlePokemon target)
{
if (targetType == ItemTargetType.None)
return true;
if (targetType.HasFlag(ItemTargetType.OwnPokemon))
{
var userParty = battle.Parties.FirstOrDefault(x => x.Party.Contains(user));
var targetParty = battle.Parties.FirstOrDefault(x => x.Party.Contains(target));
var userParty = battle.Parties.FirstOrDefault(x => x.BattlePokemon.Contains(user));
var targetParty = battle.Parties.FirstOrDefault(x => x.BattlePokemon.Contains(target));
if (userParty is not null && targetParty is not null && userParty == targetParty)
return true;
}
if (targetType.HasFlag(ItemTargetType.AllyPokemon))
{
if (user.BattleData?.BattleSide == target.BattleData?.BattleSide)
if (user.BattleSide == target.BattleSide)
return true;
}
if (targetType.HasFlag(ItemTargetType.FoePokemon))
{
var userParty = battle.Parties.FirstOrDefault(x => x.Party.Contains(user));
var targetParty = battle.Parties.FirstOrDefault(x => x.Party.Contains(target));
var userParty = battle.Parties.FirstOrDefault(x => x.BattlePokemon.Contains(user));
var targetParty = battle.Parties.FirstOrDefault(x => x.BattlePokemon.Contains(target));
if (userParty is not null && targetParty is not null && userParty != targetParty)
return true;
}