use crate::dynamic_data::{LearnedMove, MoveLearnMethod}; use crate::ffi::ffi_handle::{FFIHandle, FromFFIHandle}; use crate::ffi::FFIResult; use crate::static_data::MoveData; use std::sync::Arc; /// Instantiate a new learned move. #[no_mangle] extern "C" fn learned_move_new( move_data: FFIHandle>, learn_method: MoveLearnMethod, ) -> FFIHandle> { FFIHandle::get_handle(Arc::new(LearnedMove::new(move_data.from_ffi_handle().clone(), learn_method)).into()) } /// The immutable move information of the move. #[no_mangle] extern "C" fn learned_move_move_data(learned_move: FFIHandle>) -> FFIHandle> { FFIHandle::get_handle(learned_move.from_ffi_handle().move_data().clone().into()) } /// The maximal power points for this move. #[no_mangle] extern "C" fn learned_move_max_pp(learned_move: FFIHandle>) -> u8 { learned_move.from_ffi_handle().max_pp() } /// The amount of remaining power points. If this is 0, we can not use the move anymore. #[no_mangle] extern "C" fn learned_move_remaining_pp(learned_move: FFIHandle>) -> u8 { learned_move.from_ffi_handle().remaining_pp() } /// The way the move was learned. #[no_mangle] extern "C" fn learned_move_learn_method(learned_move: FFIHandle>) -> MoveLearnMethod { learned_move.from_ffi_handle().learn_method() } /// Try and reduce the PP by a certain amount. If the amount is higher than the current uses, /// return 0. Otherwise, reduce the PP, and return 1. #[no_mangle] extern "C" fn learned_move_try_use(learned_move: FFIHandle>, amount: u8) -> u8 { u8::from(learned_move.from_ffi_handle().try_use(amount)) } /// Set the remaining PP to the max amount of PP. #[no_mangle] extern "C" fn learned_move_restore_all_uses(learned_move: FFIHandle>) { learned_move.from_ffi_handle().restore_all_uses(); } /// Restore the remaining PP by a certain amount. Will prevent it from going above max PP. #[no_mangle] extern "C" fn learned_move_restore_uses(learned_move: FFIHandle>, amount: u8) -> FFIResult<()> { learned_move.from_ffi_handle().restore_uses(amount); FFIResult::ok(()) }