Moves a bunch of libraries to traits
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -33,12 +33,13 @@ pub enum MoveLearnMethod {
|
||||
|
||||
impl LearnedMove {
|
||||
/// Instantiate a new learned move.
|
||||
pub fn new(move_data: &Arc<dyn MoveData>, learn_method: MoveLearnMethod) -> Self {
|
||||
pub fn new(move_data: Arc<dyn MoveData>, learn_method: MoveLearnMethod) -> Self {
|
||||
let max_pp = move_data.base_usages();
|
||||
Self {
|
||||
identifier: Default::default(),
|
||||
move_data: move_data.clone(),
|
||||
max_pp: move_data.base_usages(),
|
||||
remaining_pp: AtomicU8::new(move_data.base_usages()),
|
||||
move_data,
|
||||
max_pp,
|
||||
remaining_pp: AtomicU8::new(max_pp),
|
||||
learn_method,
|
||||
}
|
||||
}
|
||||
@@ -107,7 +108,7 @@ mod tests {
|
||||
let mut mock = MockMoveData::new();
|
||||
mock.expect_base_usages().return_const(30);
|
||||
let data: Arc<dyn MoveData> = Arc::new(mock);
|
||||
let learned_move = LearnedMove::new(&data, MoveLearnMethod::Level);
|
||||
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