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
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -14,7 +14,6 @@ impl TestDataGetter {
|
||||
.get_pokemon(index[0], index[1])
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.read()
|
||||
.current_health()
|
||||
.to_string(),
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use super::test_step::TestStep;
|
||||
use parking_lot::RwLock;
|
||||
use pkmn_lib::defines::LevelInt;
|
||||
use pkmn_lib::dynamic_data::libraries::dynamic_library::DynamicLibrary;
|
||||
use pkmn_lib::dynamic_data::models::battle::Battle;
|
||||
@@ -47,7 +46,7 @@ impl TestCase {
|
||||
let pokemon = party
|
||||
.pokemon
|
||||
.iter()
|
||||
.map(|a| Some(Arc::new(RwLock::new(a.to_pokemon(library)))))
|
||||
.map(|a| Some(Arc::new(a.to_pokemon(library))))
|
||||
.collect();
|
||||
let indices = party.indices.iter().map(|a| (a[0], a[1])).collect();
|
||||
parties.push((Arc::new(PokemonParty::new_from_vec(pokemon)), indices));
|
||||
|
||||
@@ -42,24 +42,22 @@ impl TestStep {
|
||||
use_move,
|
||||
target,
|
||||
} => {
|
||||
let p = battle.sides()[for_pokemon[0] as usize].pokemon()[for_pokemon[1] as usize]
|
||||
let pokemon = battle.sides()[for_pokemon[0] as usize].pokemon()[for_pokemon[1] as usize]
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone();
|
||||
let mut used_move = None;
|
||||
let pokemon_guard = p.read();
|
||||
for learned_move in pokemon_guard.learned_moves().iter().flatten() {
|
||||
for learned_move in pokemon.learned_moves().read().iter().flatten() {
|
||||
if learned_move.move_data().name() == &StringKey::new(use_move) {
|
||||
used_move = Some(learned_move.clone());
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert!(used_move.is_some());
|
||||
drop(pokemon_guard);
|
||||
|
||||
assert!(battle
|
||||
.try_set_choice(TurnChoice::Move(MoveChoice::new(
|
||||
p,
|
||||
pokemon,
|
||||
used_move.unwrap(),
|
||||
target[0],
|
||||
target[1],
|
||||
|
||||
Reference in New Issue
Block a user