Fixes for comments
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2023-07-15 14:22:48 +02:00
parent f6df95a824
commit f23fc43405
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
9 changed files with 31 additions and 23 deletions

View File

@ -1,6 +1,6 @@
/// The type we store a level in. As our implementation is aimed at normal Pokemon behaviour, a u8 /// The type we store a level in. As our implementation is aimed at normal Pokemon behaviour, a u8
/// is probably enough, as we'd go up to 100. For other users this might however not be enough. This /// is probably enough, as we'd go up to 100. If you for some reason want to go higher, you can just
/// allows them to easily change it. /// change this type to hold a higher number.
pub type LevelInt = u8; pub type LevelInt = u8;
/// The amount of moves a Pokemon can have at once. This is set to 4, as that is the default in most /// The amount of moves a Pokemon can have at once. This is set to 4, as that is the default in most

View File

@ -63,7 +63,7 @@ unsafe impl Send for DynamicLibraryImpl {}
unsafe impl Sync for DynamicLibraryImpl {} unsafe impl Sync for DynamicLibraryImpl {}
impl DynamicLibraryImpl { impl DynamicLibraryImpl {
/// Instantiates a new DynamicLibrary with given parameters. /// Instantiates a new DynamicLibrary with given libraries.
pub fn new( pub fn new(
static_data: Arc<dyn StaticData>, static_data: Arc<dyn StaticData>,
stat_calculator: Arc<dyn BattleStatCalculator>, stat_calculator: Arc<dyn BattleStatCalculator>,

View File

@ -415,11 +415,13 @@ impl Pokemon {
Ok(changed) Ok(changed)
} }
/// The [individual values](https://bulbapedia.bulbagarden.net/wiki/Individual_values) of the Pokemon. /// Gets an individual value of the Pokemon.
/// [See also](https://bulbapedia.bulbagarden.net/wiki/Individual_values)
pub fn individual_values(&self) -> &Arc<ClampedStatisticSet<u8, 0, 31>> { pub fn individual_values(&self) -> &Arc<ClampedStatisticSet<u8, 0, 31>> {
&self.data.individual_values &self.data.individual_values
} }
/// The [effort values](https://bulbapedia.bulbagarden.net/wiki/Effort_values) of the Pokemon. /// Gets an effort value of the Pokemon.
/// [See also](https://bulbapedia.bulbagarden.net/wiki/Effort_values)
pub fn effort_values(&self) -> &Arc<ClampedStatisticSet<u8, 0, 252>> { pub fn effort_values(&self) -> &Arc<ClampedStatisticSet<u8, 0, 252>> {
&self.data.effort_values &self.data.effort_values
} }
@ -485,7 +487,8 @@ impl Pokemon {
self.data.allowed_experience self.data.allowed_experience
} }
/// The [nature](https://bulbapedia.bulbagarden.net/wiki/Nature) of the Pokemon. /// The nature of the Pokemon.
/// [See also](https://bulbapedia.bulbagarden.net/wiki/Nature)
pub fn nature(&self) -> &Arc<dyn Nature> { pub fn nature(&self) -> &Arc<dyn Nature> {
&self.data.nature &self.data.nature
} }
@ -961,7 +964,7 @@ impl VolatileScriptsOwner for Pokemon {
} }
} }
/// A source of damage. This should be as unique as possible. /// A source of damage.
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
#[repr(u8)] #[repr(u8)]
pub enum DamageSource { pub enum DamageSource {

View File

@ -102,7 +102,8 @@ extern "C" fn pokemon_gender(handle: FFIHandle<Pokemon>) -> Gender {
handle.from_ffi_handle().gender() handle.from_ffi_handle().gender()
} }
/// The coloring of the Pokemon. /// The coloring of the Pokemon. If this is 1, the Pokemon is shiny, otherwise it is not. This can
/// also be used for other custom coloring schemes.
#[no_mangle] #[no_mangle]
extern "C" fn pokemon_coloring(handle: FFIHandle<Pokemon>) -> u8 { extern "C" fn pokemon_coloring(handle: FFIHandle<Pokemon>) -> u8 {
handle.from_ffi_handle().coloring() handle.from_ffi_handle().coloring()
@ -196,13 +197,13 @@ extern "C" fn pokemon_nickname(handle: FFIHandle<Pokemon>) -> FFIResult<OwnedPtr
} }
} }
/// Whether the actual ability on the form is a hidden ability. /// Whether the actual ability the Pokemon has (so not its potentially overriden ability) is a hidden ability.
#[no_mangle] #[no_mangle]
extern "C" fn pokemon_real_ability_is_hidden(handle: FFIHandle<Pokemon>) -> u8 { extern "C" fn pokemon_real_ability_is_hidden(handle: FFIHandle<Pokemon>) -> u8 {
u8::from(handle.from_ffi_handle().real_ability().hidden) u8::from(handle.from_ffi_handle().real_ability().hidden)
} }
/// The index of the actual ability on the form. /// The index of the actual ability the Pokemon has (so not its potentially overriden ability).
#[no_mangle] #[no_mangle]
extern "C" fn pokemon_real_ability_index(handle: FFIHandle<Pokemon>) -> u8 { extern "C" fn pokemon_real_ability_index(handle: FFIHandle<Pokemon>) -> u8 {
handle.from_ffi_handle().real_ability().index handle.from_ffi_handle().real_ability().index
@ -246,7 +247,7 @@ extern "C" fn pokemon_boosted_stats(handle: FFIHandle<Pokemon>) -> FFIHandle<Arc
FFIHandle::get_handle(handle.from_ffi_handle().boosted_stats().clone().into()) FFIHandle::get_handle(handle.from_ffi_handle().boosted_stats().clone().into())
} }
/// Get the stat boosts for a specific stat. /// Get the stat boosts for a specific stat. This is a value between -6 and 6.
#[no_mangle] #[no_mangle]
extern "C" fn pokemon_get_stat_boost(handle: FFIHandle<Pokemon>, statistic: Statistic) -> i8 { extern "C" fn pokemon_get_stat_boost(handle: FFIHandle<Pokemon>, statistic: Statistic) -> i8 {
handle.from_ffi_handle().stat_boost(statistic) handle.from_ffi_handle().stat_boost(statistic)
@ -269,26 +270,30 @@ extern "C" fn pokemon_change_stat_boost(
} }
} }
/// Gets a [individual value](https://bulbapedia.bulbagarden.net/wiki/Individual_values) of the Pokemon. /// Gets an individual value of the Pokemon.
/// [See also](https://bulbapedia.bulbagarden.net/wiki/Individual_values)
#[no_mangle] #[no_mangle]
extern "C" fn pokemon_get_individual_value(handle: FFIHandle<Pokemon>, stat: Statistic) -> u8 { extern "C" fn pokemon_get_individual_value(handle: FFIHandle<Pokemon>, stat: Statistic) -> u8 {
handle.from_ffi_handle().individual_values().get_stat(stat) handle.from_ffi_handle().individual_values().get_stat(stat)
} }
/// Modifies a [individual value](https://bulbapedia.bulbagarden.net/wiki/Individual_values) of the Pokemon. /// Modifies an individual value of the Pokemon.
/// [See also](https://bulbapedia.bulbagarden.net/wiki/Individual_values)
#[no_mangle] #[no_mangle]
extern "C" fn pokemon_set_individual_value(handle: FFIHandle<Pokemon>, stat: Statistic, value: u8) -> FFIResult<()> { extern "C" fn pokemon_set_individual_value(handle: FFIHandle<Pokemon>, stat: Statistic, value: u8) -> FFIResult<()> {
handle.from_ffi_handle().individual_values().set_stat(stat, value); handle.from_ffi_handle().individual_values().set_stat(stat, value);
handle.from_ffi_handle().recalculate_flat_stats().into() handle.from_ffi_handle().recalculate_flat_stats().into()
} }
/// Gets a [effort value](https://bulbapedia.bulbagarden.net/wiki/Effort_values) of the Pokemon. /// Gets an effort value of the Pokemon.
/// [See also](https://bulbapedia.bulbagarden.net/wiki/Effort_values)
#[no_mangle] #[no_mangle]
extern "C" fn pokemon_get_effort_value(handle: FFIHandle<Pokemon>, stat: Statistic) -> u8 { extern "C" fn pokemon_get_effort_value(handle: FFIHandle<Pokemon>, stat: Statistic) -> u8 {
handle.from_ffi_handle().effort_values().get_stat(stat) handle.from_ffi_handle().effort_values().get_stat(stat)
} }
/// Modifies a [effort value](https://bulbapedia.bulbagarden.net/wiki/Effort_values) of the Pokemon. /// Modifies a effort value of the Pokemon.
/// [See also](https://bulbapedia.bulbagarden.net/wiki/Effort_values)
#[no_mangle] #[no_mangle]
extern "C" fn pokemon_set_effort_value(handle: FFIHandle<Pokemon>, stat: Statistic, value: u8) -> FFIResult<()> { extern "C" fn pokemon_set_effort_value(handle: FFIHandle<Pokemon>, stat: Statistic, value: u8) -> FFIResult<()> {
handle.from_ffi_handle().effort_values().set_stat(stat, value); handle.from_ffi_handle().effort_values().set_stat(stat, value);
@ -341,7 +346,8 @@ extern "C" fn pokemon_allowed_experience_gain(handle: FFIHandle<Pokemon>) -> u8
u8::from(handle.from_ffi_handle().allowed_experience_gain()) u8::from(handle.from_ffi_handle().allowed_experience_gain())
} }
/// The [nature](https://bulbapedia.bulbagarden.net/wiki/Nature) of the Pokemon. /// The nature of the Pokemon.
/// [See also](https://bulbapedia.bulbagarden.net/wiki/Nature)
#[no_mangle] #[no_mangle]
extern "C" fn pokemon_nature(handle: FFIHandle<Pokemon>) -> FFIHandle<Arc<dyn Nature>> { extern "C" fn pokemon_nature(handle: FFIHandle<Pokemon>) -> FFIHandle<Arc<dyn Nature>> {
FFIHandle::get_handle(handle.from_ffi_handle().nature().clone().into()) FFIHandle::get_handle(handle.from_ffi_handle().nature().clone().into())

View File

@ -188,12 +188,12 @@ impl MoveData for MoveDataImpl {
&self.secondary_effect &self.secondary_effect
} }
/// Arbitrary flags that can be applied to the move. /// Checks if the move has a specific flag.
fn has_flag(&self, key: &StringKey) -> bool { fn has_flag(&self, key: &StringKey) -> bool {
self.flags.contains::<StringKey>(key) self.flags.contains::<StringKey>(key)
} }
/// Arbitrary flags that can be applied to the move. /// Checks if the move has a specific flag.
fn has_flag_by_hash(&self, key_hash: u32) -> bool { fn has_flag_by_hash(&self, key_hash: u32) -> bool {
self.flags.contains::<u32>(&key_hash) self.flags.contains::<u32>(&key_hash)
} }

View File

@ -40,7 +40,7 @@ pub struct NatureImpl {
} }
impl NatureImpl { impl NatureImpl {
/// Instantiates a new statistic. /// Instantiates a new nature.
pub fn new( pub fn new(
increase_stat: Statistic, increase_stat: Statistic,
decrease_stat: Statistic, decrease_stat: Statistic,

View File

@ -26,7 +26,7 @@ pub struct LearnableMovesImpl {
} }
impl LearnableMovesImpl { impl LearnableMovesImpl {
/// Instantiates a new Learnable Moves. /// Instantiates a new object to store the moves a Pokemon can learn.
pub fn new(max_level: LevelInt) -> Self { pub fn new(max_level: LevelInt) -> Self {
Self { Self {
learned_by_level: RwLock::new(vec![Vec::new(); (max_level + 1) as usize]), learned_by_level: RwLock::new(vec![Vec::new(); (max_level + 1) as usize]),

View File

@ -152,7 +152,7 @@ impl Species for SpeciesImpl {
.clone()) .clone())
} }
/// Gets a random gender. /// Gets a random gender, returning a value based on the species gender ratio.
fn get_random_gender(&self, rand: &mut Random) -> Gender { fn get_random_gender(&self, rand: &mut Random) -> Gender {
if self.gender_rate < 0.0 { if self.gender_rate < 0.0 {
Gender::Genderless Gender::Genderless

View File

@ -128,13 +128,12 @@ where
} }
/// A collection of statistics that can not be modified after creation. /// A collection of statistics that can not be modified after creation.
///
/// As no modifications happen, this struct does not use atomics.
#[derive(Default, Eq, PartialEq, Clone, Debug)] #[derive(Default, Eq, PartialEq, Clone, Debug)]
pub struct StaticStatisticSet<T> pub struct StaticStatisticSet<T>
where where
T: PrimInt, T: PrimInt,
{ {
// As no modifications happen, this struct does not use atomics.
/// The health point stat value. /// The health point stat value.
hp: T, hp: T,
/// The physical attack stat value. /// The physical attack stat value.