Removes derive-getters, as it was incredibly annoying in IDEs, and couldn't figure out borrow lifetimes.
This commit is contained in:
@@ -8,10 +8,9 @@ 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 derive_getters::Getters;
|
||||
use std::sync::{Arc, RwLock, Weak};
|
||||
|
||||
#[derive(Getters, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct BattleSide<'a> {
|
||||
index: u8,
|
||||
pokemon_per_side: u8,
|
||||
@@ -48,6 +47,33 @@ impl<'a> BattleSide<'a> {
|
||||
volatile_scripts: Default::default(),
|
||||
}
|
||||
}
|
||||
pub fn index(&self) -> u8 {
|
||||
self.index
|
||||
}
|
||||
pub fn pokemon_per_side(&self) -> u8 {
|
||||
self.pokemon_per_side
|
||||
}
|
||||
pub fn pokemon(&self) -> &Vec<Option<Arc<RwLock<Pokemon<'a>>>>> {
|
||||
&self.pokemon
|
||||
}
|
||||
pub fn choices(&self) -> &Vec<Option<Arc<TurnChoice<'a>>>> {
|
||||
&self.choices
|
||||
}
|
||||
pub fn fillable_slots(&self) -> &Vec<bool> {
|
||||
&self.fillable_slots
|
||||
}
|
||||
pub fn choices_set(&self) -> u8 {
|
||||
self.choices_set
|
||||
}
|
||||
pub fn battle(&self) -> &Weak<RwLock<Battle<'a>>> {
|
||||
&self.battle
|
||||
}
|
||||
pub fn has_fled_battle(&self) -> bool {
|
||||
self.has_fled_battle
|
||||
}
|
||||
pub fn volatile_scripts(&self) -> &Arc<RwLock<ScriptSet>> {
|
||||
&self.volatile_scripts
|
||||
}
|
||||
|
||||
pub fn all_choices_set(&self) -> bool {
|
||||
self.choices_set == self.pokemon_per_side
|
||||
@@ -108,13 +134,13 @@ impl<'a> BattleSide<'a> {
|
||||
let battle = self.battle.upgrade().unwrap();
|
||||
let battle = battle.read().unwrap();
|
||||
for side in battle.sides() {
|
||||
if *side.index() == self.index {
|
||||
if side.index() == self.index {
|
||||
continue;
|
||||
}
|
||||
for opponent in side.pokemon().iter().flatten() {
|
||||
let mut opponent = opponent.write().unwrap();
|
||||
opponent.mark_opponent_as_seen(*pokemon.unique_identifier());
|
||||
pokemon.mark_opponent_as_seen(*opponent.unique_identifier());
|
||||
opponent.mark_opponent_as_seen(pokemon.unique_identifier());
|
||||
pokemon.mark_opponent_as_seen(opponent.unique_identifier());
|
||||
}
|
||||
}
|
||||
battle.event_hook().trigger(Event::Switch {
|
||||
|
||||
Reference in New Issue
Block a user