PkmnLib_rs/src/dynamic_data/models/learned_move.rs

49 lines
1.0 KiB
Rust
Raw Normal View History

use crate::static_data::MoveData;
2022-06-03 14:35:18 +00:00
#[derive(Debug)]
pub struct LearnedMove<'library> {
move_data: &'library MoveData,
max_pp: u8,
remaining_pp: u8,
learn_method: MoveLearnMethod,
}
#[derive(Copy, Clone, Debug)]
pub enum MoveLearnMethod {
Unknown = 0,
Level = 1,
}
impl<'a> LearnedMove<'a> {
pub fn new(move_data: &'a MoveData, learn_method: MoveLearnMethod) -> Self {
Self {
move_data,
max_pp: move_data.base_usages(),
remaining_pp: move_data.base_usages(),
learn_method,
}
}
pub fn move_data(&self) -> &MoveData {
self.move_data
}
pub fn max_pp(&self) -> u8 {
self.max_pp
}
pub fn remaining_pp(&self) -> u8 {
self.remaining_pp
}
pub fn learn_method(&self) -> MoveLearnMethod {
self.learn_method
}
pub fn try_use(&mut self, amount: u8) -> bool {
if amount > self.remaining_pp {
return false;
}
self.remaining_pp -= amount;
return true;
}
}