A lot more documentation, some initial work on the script resolver.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,20 +1,29 @@
|
||||
use crate::dynamic_data::models::pokemon::Pokemon;
|
||||
use crate::dynamic_data::models::pokemon_party::PokemonParty;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::dynamic_data::models::pokemon::Pokemon;
|
||||
use crate::dynamic_data::models::pokemon_party::PokemonParty;
|
||||
|
||||
/// A battle party is a wrapper around a party, with the indices for which the party is responsible
|
||||
/// on the field attached.
|
||||
#[derive(Debug)]
|
||||
pub struct BattleParty<'own, 'library> {
|
||||
/// The party the BattleParty is holding.
|
||||
party: Arc<PokemonParty<'own, 'library>>,
|
||||
/// The indices for which the party is responsible, in the format (side, index)
|
||||
responsible_indices: Vec<(u8, u8)>,
|
||||
}
|
||||
|
||||
impl<'own, 'library> BattleParty<'own, 'library> {
|
||||
/// Initializes a battle party with the underlying party, and the indices the party is responsible
|
||||
/// for.
|
||||
pub fn new(party: Arc<PokemonParty<'own, 'library>>, responsible_indices: Vec<(u8, u8)>) -> Self {
|
||||
Self {
|
||||
party,
|
||||
responsible_indices,
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks whether the party is responsible for the given index.
|
||||
pub fn is_responsible_for_index(&self, side: u8, index: u8) -> bool {
|
||||
for responsible_index in &self.responsible_indices {
|
||||
if responsible_index.0 == side && responsible_index.1 == index {
|
||||
@@ -24,6 +33,7 @@ impl<'own, 'library> BattleParty<'own, 'library> {
|
||||
false
|
||||
}
|
||||
|
||||
/// Whether or not the party has non fainted Pokemon that could be thrown out into the field.
|
||||
pub fn has_pokemon_not_in_field(&self) -> bool {
|
||||
for pokemon in self.party.pokemon().iter().flatten() {
|
||||
if pokemon.is_usable() && !pokemon.is_on_battlefield() {
|
||||
@@ -33,6 +43,7 @@ impl<'own, 'library> BattleParty<'own, 'library> {
|
||||
false
|
||||
}
|
||||
|
||||
/// Gets a Pokemon at an index.
|
||||
pub fn get_pokemon(&self, index: usize) -> &Option<Arc<Pokemon<'own, 'library>>> {
|
||||
self.party.at(index)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user