Rework setting while active to be slightly less hacky.
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
@@ -292,7 +292,7 @@ impl<'own, 'library> VolatileScripts<'own> for Battle<'own, 'library> {
|
||||
&self.volatile_scripts
|
||||
}
|
||||
|
||||
fn load_volatile_script(&self, key: &StringKey) -> PkmnResult<Option<Box<dyn Script>>> {
|
||||
fn load_volatile_script(&self, key: &StringKey) -> PkmnResult<Option<Arc<dyn Script>>> {
|
||||
self.library.load_script(ScriptCategory::Battle, key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ impl<'own, 'library> VolatileScripts<'own> for BattleSide<'own, 'library> {
|
||||
&self.volatile_scripts
|
||||
}
|
||||
|
||||
fn load_volatile_script(&self, key: &StringKey) -> PkmnResult<Option<Box<dyn Script>>> {
|
||||
fn load_volatile_script(&self, key: &StringKey) -> PkmnResult<Option<Arc<dyn Script>>> {
|
||||
self.battle().library().load_script(crate::ScriptCategory::Side, key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,15 +395,10 @@ impl<'own, 'library> Pokemon<'own, 'library> {
|
||||
.load_script(ScriptCategory::Ability, self.active_ability().name())
|
||||
.unwrap();
|
||||
if let Some(ability_script) = ability_script {
|
||||
self.ability_script.set(ability_script);
|
||||
// Ensure the ability script gets initialized with the parameters for the ability.
|
||||
self.ability_script()
|
||||
.get()
|
||||
.unwrap()
|
||||
.read()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
self.ability_script
|
||||
.set(ability_script)
|
||||
.as_ref()
|
||||
// Ensure the ability script gets initialized with the parameters for the ability.
|
||||
.on_initialize(self.active_ability().parameters())
|
||||
} else {
|
||||
self.ability_script.clear();
|
||||
@@ -581,7 +576,7 @@ impl<'own, 'library> VolatileScripts<'own> for Pokemon<'own, 'library> {
|
||||
&self.volatile
|
||||
}
|
||||
|
||||
fn load_volatile_script(&self, key: &StringKey) -> PkmnResult<Option<Box<dyn Script>>> {
|
||||
fn load_volatile_script(&self, key: &StringKey) -> PkmnResult<Option<Arc<dyn Script>>> {
|
||||
self.library.load_script(ScriptCategory::Pokemon, key)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user