First chunk of battling is now fully working, along with integration tests! 🎉
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2022-06-17 19:53:33 +02:00
parent 59cc150643
commit b6ddd1ee13
34 changed files with 1934 additions and 1293 deletions

View File

@@ -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;
}
}