Lots more work on implementing battling
This commit is contained in:
@@ -10,13 +10,42 @@ public interface IBattleParty
|
||||
/// The backing Pokemon party.
|
||||
/// </summary>
|
||||
IPokemonParty Party { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the party is responsible for the specified side and position.
|
||||
/// </summary>
|
||||
bool IsResponsibleForIndex(byte side, byte position);
|
||||
|
||||
bool IsResponsibleForIndex(ResponsibleIndex index);
|
||||
|
||||
/// <summary>
|
||||
/// Whether the party has a living Pokemon left that is not in the field.
|
||||
/// </summary>
|
||||
bool HasPokemonNotInField();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A position on the battlefield that a party is responsible for.
|
||||
/// Contains the index of the side and the position on that side.
|
||||
/// </summary>
|
||||
public record struct ResponsibleIndex(byte Side, byte Position);
|
||||
|
||||
/// <inheritdoc />
|
||||
public class BattlePartyImpl : IBattleParty
|
||||
{
|
||||
private readonly ResponsibleIndex[] _responsibleIndices;
|
||||
|
||||
/// <inheritdoc cref="BattlePartyImpl"/>
|
||||
public BattlePartyImpl(IPokemonParty party, ResponsibleIndex[] responsibleIndices)
|
||||
{
|
||||
Party = party;
|
||||
_responsibleIndices = responsibleIndices;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IPokemonParty Party { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsResponsibleForIndex(ResponsibleIndex index) => _responsibleIndices.Contains(index);
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasPokemonNotInField() => Party.Any(x => x is { IsUsable: true, BattleData.IsOnBattlefield: false });
|
||||
}
|
||||
Reference in New Issue
Block a user