A lot more work on a bunch of different parts of the system.
This commit is contained in:
@@ -7,7 +7,8 @@ use crate::dynamic_data::script_handling::script::Script;
|
||||
use crate::dynamic_data::script_handling::script_set::ScriptSet;
|
||||
use crate::dynamic_data::script_handling::volatile_scripts::VolatileScripts;
|
||||
use crate::dynamic_data::script_handling::ScriptSource;
|
||||
use crate::{script_hook, PkmnResult};
|
||||
use crate::{script_hook, PkmnResult, StringKey};
|
||||
use std::ops::Deref;
|
||||
use std::sync::{Arc, RwLock, Weak};
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -83,7 +84,7 @@ impl<'a> BattleSide<'a> {
|
||||
/// responsible for them. Returns false if all slots are filled with usable pokemon, or slots are
|
||||
/// empty, but can't be filled by any party anymore.
|
||||
pub fn all_slots_filled(&self) -> bool {
|
||||
for pokemon in &self.pokemon {
|
||||
for (i, pokemon) in self.pokemon.iter().enumerate() {
|
||||
if (!pokemon.is_none() || !pokemon.as_ref().unwrap().read().unwrap().is_usable())
|
||||
&& self
|
||||
.battle
|
||||
@@ -91,7 +92,7 @@ impl<'a> BattleSide<'a> {
|
||||
.unwrap()
|
||||
.read()
|
||||
.unwrap()
|
||||
.can_slot_be_filled()
|
||||
.can_slot_be_filled(self.index, i as u8)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -146,7 +147,7 @@ impl<'a> BattleSide<'a> {
|
||||
battle.event_hook().trigger(Event::Switch {
|
||||
side_index: self.index,
|
||||
index,
|
||||
pokemon: Some(pokemon_mutex.clone()),
|
||||
pokemon: Some(&pokemon),
|
||||
});
|
||||
script_hook!(on_switch_in, pokemon, &pokemon);
|
||||
} else {
|
||||
@@ -169,10 +170,10 @@ impl<'a> BattleSide<'a> {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn mark_slot_as_unfillable(&mut self, pokemon: Arc<Pokemon<'a>>) {
|
||||
pub fn mark_slot_as_unfillable(&mut self, pokemon: &Pokemon<'a>) {
|
||||
for (i, slot) in self.pokemon.iter().enumerate() {
|
||||
if let Some(p) = slot {
|
||||
if p.read().unwrap().unique_identifier() == pokemon.unique_identifier() {
|
||||
if p.read().unwrap().deref() as *const Pokemon == pokemon as *const Pokemon {
|
||||
self.fillable_slots[i] = false;
|
||||
return;
|
||||
}
|
||||
@@ -266,7 +267,7 @@ impl<'a> VolatileScripts<'a> for BattleSide<'a> {
|
||||
&self.volatile_scripts
|
||||
}
|
||||
|
||||
fn load_volatile_script(&self, key: &str) -> PkmnResult<Box<dyn Script>> {
|
||||
fn load_volatile_script(&self, key: &StringKey) -> PkmnResult<Option<Box<dyn Script>>> {
|
||||
self.battle
|
||||
.upgrade()
|
||||
.unwrap()
|
||||
|
||||
Reference in New Issue
Block a user