using PkmnLib.Static.Utils; namespace PkmnLib.Dynamic.Models; /// /// A battle party is a wrapper around a Pokemon party that provides additional functionality for battles. /// It indicates for which side and position the party is responsible. /// public interface IBattleParty : IDeepCloneable { /// /// The backing Pokemon party. /// IPokemonParty Party { get; } /// /// Whether the party is responsible for the specified side and position. /// bool IsResponsibleForIndex(ResponsibleIndex index); /// /// Whether the party has a living Pokemon left that is not in the field. /// bool HasPokemonNotInField(); } /// /// A position on the battlefield that a party is responsible for. /// Contains the index of the side and the position on that side. /// public record struct ResponsibleIndex(byte Side, byte Position); /// public class BattlePartyImpl : IBattleParty { private readonly ResponsibleIndex[] _responsibleIndices; /// public BattlePartyImpl(IPokemonParty party, ResponsibleIndex[] responsibleIndices) { Party = party; _responsibleIndices = responsibleIndices; } /// public IPokemonParty Party { get; } /// public bool IsResponsibleForIndex(ResponsibleIndex index) => _responsibleIndices.Contains(index); /// public bool HasPokemonNotInField() => Party.Any(x => x is { IsUsable: true, BattleData.IsOnBattlefield: false }); }