More work on using interior mutability instead of exterior mutability for dynamic types (Battle, Pokemon, etc).
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-06-18 15:52:39 +02:00
parent c45c7538bf
commit 5576bc8b80
21 changed files with 324 additions and 385 deletions

View File

@@ -1,6 +1,5 @@
use crate::dynamic_data::models::pokemon::Pokemon;
use crate::dynamic_data::models::pokemon_party::PokemonParty;
use parking_lot::RwLock;
use std::sync::Arc;
#[derive(Debug)]
@@ -27,7 +26,6 @@ impl<'own, 'library> BattleParty<'own, 'library> {
pub fn has_pokemon_not_in_field(&self) -> bool {
for pokemon in self.party.pokemon().iter().flatten() {
let pokemon = pokemon.read();
if pokemon.is_usable() && !pokemon.is_on_battlefield() {
return true;
}
@@ -35,7 +33,7 @@ impl<'own, 'library> BattleParty<'own, 'library> {
false
}
pub fn get_pokemon(&self, index: usize) -> &Option<Arc<RwLock<Pokemon<'own, 'library>>>> {
pub fn get_pokemon(&self, index: usize) -> &Option<Arc<Pokemon<'own, 'library>>> {
self.party.at(index)
}
}