This commit is contained in:
@@ -6,7 +6,7 @@ use hashbrown::HashSet;
|
||||
use crate::dynamic_data::choices::{MoveChoice, TurnChoice};
|
||||
use crate::dynamic_data::Pokemon;
|
||||
use crate::dynamic_data::{LearnedMove, MoveLearnMethod};
|
||||
use crate::static_data::{MoveCategory, MoveData, MoveTarget, SecondaryEffectImpl};
|
||||
use crate::static_data::{MoveCategory, MoveData, MoveDataImpl, MoveTarget, SecondaryEffectImpl};
|
||||
use crate::{StringKey, ValueIdentifiable, ValueIdentifier};
|
||||
|
||||
/// The misc library holds several misc functions required for the battle to run.
|
||||
@@ -31,7 +31,7 @@ pub struct Gen7MiscLibrary {
|
||||
impl Gen7MiscLibrary {
|
||||
/// Instantiates a new MiscLibrary.
|
||||
pub fn new() -> Self {
|
||||
let struggle_data = Arc::new(MoveData::new(
|
||||
let struggle_data: Arc<dyn MoveData> = Arc::new(MoveDataImpl::new(
|
||||
&StringKey::new("struggle"),
|
||||
0.into(),
|
||||
MoveCategory::Physical,
|
||||
|
||||
@@ -101,7 +101,7 @@ pub struct ExecutingMove {
|
||||
/// The move the user has actually chosen to do.
|
||||
chosen_move: Arc<LearnedMove>,
|
||||
/// The move that the user is actually going to do.
|
||||
use_move: Arc<MoveData>,
|
||||
use_move: Arc<dyn MoveData>,
|
||||
/// The script of the move.
|
||||
script: ScriptContainer,
|
||||
/// The targets for this move.
|
||||
@@ -117,7 +117,7 @@ impl ExecutingMove {
|
||||
number_of_hits: u8,
|
||||
user: Arc<Pokemon>,
|
||||
chosen_move: Arc<LearnedMove>,
|
||||
use_move: Arc<MoveData>,
|
||||
use_move: Arc<dyn MoveData>,
|
||||
script: ScriptContainer,
|
||||
) -> Self {
|
||||
let total_hits = number_of_hits as usize * targets.len();
|
||||
@@ -155,7 +155,7 @@ impl ExecutingMove {
|
||||
&self.chosen_move
|
||||
}
|
||||
/// The move that the user is actually going to do.
|
||||
pub fn use_move(&self) -> &Arc<MoveData> {
|
||||
pub fn use_move(&self) -> &Arc<dyn MoveData> {
|
||||
&self.use_move
|
||||
}
|
||||
/// The script of the move.
|
||||
|
||||
@@ -11,7 +11,7 @@ pub struct LearnedMove {
|
||||
/// A unique identifier so we know what value this is.
|
||||
identifier: ValueIdentifier,
|
||||
/// The immutable move information of the move.
|
||||
move_data: Arc<MoveData>,
|
||||
move_data: Arc<dyn MoveData>,
|
||||
/// The maximal power points for this move.
|
||||
max_pp: u8,
|
||||
/// The amount of remaining power points. If this is 0, we can not use the move anymore.
|
||||
@@ -33,7 +33,7 @@ pub enum MoveLearnMethod {
|
||||
|
||||
impl LearnedMove {
|
||||
/// Instantiate a new learned move.
|
||||
pub fn new(move_data: &Arc<MoveData>, learn_method: MoveLearnMethod) -> Self {
|
||||
pub fn new(move_data: &Arc<dyn MoveData>, learn_method: MoveLearnMethod) -> Self {
|
||||
Self {
|
||||
identifier: Default::default(),
|
||||
move_data: move_data.clone(),
|
||||
@@ -44,7 +44,7 @@ impl LearnedMove {
|
||||
}
|
||||
|
||||
/// The immutable move information of the move.
|
||||
pub fn move_data(&self) -> &Arc<MoveData> {
|
||||
pub fn move_data(&self) -> &Arc<dyn MoveData> {
|
||||
&self.move_data
|
||||
}
|
||||
/// The maximal power points for this move.
|
||||
@@ -100,11 +100,11 @@ impl ValueIdentifiable for LearnedMove {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::static_data::{MoveCategory, MoveTarget};
|
||||
use crate::static_data::{MoveCategory, MoveDataImpl, MoveTarget};
|
||||
|
||||
#[test]
|
||||
fn create_learned_move_restore_uses() {
|
||||
let data = Arc::new(MoveData::new(
|
||||
let data: Arc<dyn MoveData> = Arc::new(MoveDataImpl::new(
|
||||
&"foo".into(),
|
||||
0u8.into(),
|
||||
MoveCategory::Special,
|
||||
|
||||
Reference in New Issue
Block a user