PkmnLib_rs/src/dynamic_data/models/battle_party.rs

40 lines
1.2 KiB
Rust
Raw Normal View History

use crate::dynamic_data::models::pokemon::Pokemon;
2022-06-06 11:54:59 +00:00
use crate::dynamic_data::models::pokemon_party::PokemonParty;
use std::sync::Arc;
2022-06-06 11:54:59 +00:00
2022-06-03 14:35:18 +00:00
#[derive(Debug)]
pub struct BattleParty<'own, 'library> {
party: Arc<PokemonParty<'own, 'library>>,
2022-06-06 11:54:59 +00:00
responsible_indices: Vec<(u8, u8)>,
}
impl<'own, 'library> BattleParty<'own, 'library> {
pub fn new(party: Arc<PokemonParty<'own, 'library>>, responsible_indices: Vec<(u8, u8)>) -> Self {
Self {
party,
responsible_indices,
}
}
2022-06-06 11:54:59 +00:00
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 {
return true;
}
}
false
}
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() {
return true;
}
}
false
}
pub fn get_pokemon(&self, index: usize) -> &Option<Arc<Pokemon<'own, 'library>>> {
self.party.at(index)
}
2022-06-06 11:54:59 +00:00
}