First chunk of battling is now fully working, along with integration tests! 🎉
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::dynamic_data::models::pokemon::Pokemon;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PokemonParty<'pokemon, 'library> {
|
||||
@@ -15,6 +16,10 @@ impl<'own, 'library> PokemonParty<'own, 'library> {
|
||||
Self { pokemon }
|
||||
}
|
||||
|
||||
pub fn new_from_vec(pokemon: Vec<Option<Arc<RwLock<Pokemon<'own, 'library>>>>>) -> Self {
|
||||
Self { pokemon }
|
||||
}
|
||||
|
||||
pub fn at(&self, index: usize) -> &Option<Arc<RwLock<Pokemon<'own, 'library>>>> {
|
||||
let opt = self.pokemon.get(index);
|
||||
if let Some(v) = opt {
|
||||
@@ -43,7 +48,7 @@ impl<'own, 'library> PokemonParty<'own, 'library> {
|
||||
|
||||
pub fn has_usable_pokemon(&self) -> bool {
|
||||
for pokemon in self.pokemon.iter().flatten() {
|
||||
if pokemon.read().unwrap().is_usable() {
|
||||
if pokemon.read().is_usable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user