Work on FFI, fixes for learned_move::restore_uses
This commit is contained in:
@@ -58,7 +58,7 @@ pub enum Event<'own> {
|
||||
/// The index of the Pokemon that got switched in/out on its side
|
||||
index: u8,
|
||||
/// The new Pokemon that will be on the spot. If none, the spot will now be empty.
|
||||
pokemon: Option<&'own Pokemon>,
|
||||
pokemon: Option<Arc<Pokemon>>,
|
||||
},
|
||||
/// A swap event happens when two Pokemon on a side swap positions. Note that this is rare.
|
||||
Swap {
|
||||
|
||||
@@ -193,7 +193,7 @@ impl BattleSide {
|
||||
battle.event_hook().trigger(Event::Switch {
|
||||
side_index: self.index,
|
||||
index,
|
||||
pokemon: Some(pokemon),
|
||||
pokemon: Some(pokemon.clone()),
|
||||
});
|
||||
script_hook!(on_switch_in, pokemon, pokemon);
|
||||
} else {
|
||||
|
||||
@@ -86,7 +86,7 @@ impl LearnedMove {
|
||||
if x + uses > self.max_pp {
|
||||
uses = self.max_pp - x;
|
||||
}
|
||||
Some(x)
|
||||
Some(x + uses)
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
@@ -97,3 +97,29 @@ impl ValueIdentifiable for LearnedMove {
|
||||
self.identifier
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::static_data::{MoveCategory, MoveTarget};
|
||||
|
||||
#[test]
|
||||
fn create_learned_move_restore_uses() {
|
||||
let data = Arc::new(MoveData::new(
|
||||
&"foo".into(),
|
||||
0u8.into(),
|
||||
MoveCategory::Special,
|
||||
100,
|
||||
20,
|
||||
30,
|
||||
MoveTarget::All,
|
||||
0,
|
||||
None,
|
||||
Default::default(),
|
||||
));
|
||||
let learned_move = LearnedMove::new(&data, MoveLearnMethod::Level);
|
||||
assert!(learned_move.try_use(15));
|
||||
learned_move.restore_uses(5);
|
||||
assert_eq!(20, learned_move.remaining_pp());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user