Changes for Statistic Sets, use a new way for Atomic 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:
@@ -1,5 +1,4 @@
|
||||
use std::fmt::Debug;
|
||||
use std::sync::atomic::AtomicU32;
|
||||
|
||||
use crate::dynamic_data::Pokemon;
|
||||
use crate::static_data::Statistic;
|
||||
@@ -8,11 +7,11 @@ use crate::static_data::StatisticSet;
|
||||
/// A battle stat calculator is used to calculate stats for a Pokemon.
|
||||
pub trait BattleStatCalculator: Debug {
|
||||
/// Calculate all the flat stats of a Pokemon, disregarding stat boosts.
|
||||
fn calculate_flat_stats(&self, pokemon: &Pokemon, stats: &StatisticSet<AtomicU32>);
|
||||
fn calculate_flat_stats(&self, pokemon: &Pokemon, stats: &StatisticSet<u32>);
|
||||
/// Calculate a single flat stat of a Pokemon, disregarding stat boost
|
||||
fn calculate_flat_stat(&self, pokemon: &Pokemon, stat: Statistic) -> u32;
|
||||
/// Calculate all the boosted stats of a Pokemon, including stat boosts.
|
||||
fn calculate_boosted_stats(&self, pokemon: &Pokemon, stats: &StatisticSet<AtomicU32>);
|
||||
fn calculate_boosted_stats(&self, pokemon: &Pokemon, stats: &StatisticSet<u32>);
|
||||
/// Calculate a single boosted stat of a Pokemon, including stat boosts.
|
||||
fn calculate_boosted_stat(&self, pokemon: &Pokemon, stat: Statistic) -> u32;
|
||||
}
|
||||
@@ -64,7 +63,7 @@ impl Gen7BattleStatCalculator {
|
||||
}
|
||||
|
||||
impl BattleStatCalculator for Gen7BattleStatCalculator {
|
||||
fn calculate_flat_stats(&self, pokemon: &Pokemon, stats: &StatisticSet<AtomicU32>) {
|
||||
fn calculate_flat_stats(&self, pokemon: &Pokemon, stats: &StatisticSet<u32>) {
|
||||
stats.set_stat(Statistic::HP, self.calculate_health_stat(pokemon));
|
||||
stats.set_stat(Statistic::Attack, self.calculate_other_stat(pokemon, Statistic::Attack));
|
||||
stats.set_stat(
|
||||
@@ -90,7 +89,7 @@ impl BattleStatCalculator for Gen7BattleStatCalculator {
|
||||
}
|
||||
}
|
||||
|
||||
fn calculate_boosted_stats(&self, pokemon: &Pokemon, stats: &StatisticSet<AtomicU32>) {
|
||||
fn calculate_boosted_stats(&self, pokemon: &Pokemon, stats: &StatisticSet<u32>) {
|
||||
stats.set_stat(Statistic::HP, self.calculate_boosted_stat(pokemon, Statistic::HP));
|
||||
stats.set_stat(
|
||||
Statistic::Attack,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::sync::atomic::{AtomicBool, AtomicI8, AtomicU32, AtomicU8, Ordering};
|
||||
use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU8, Ordering};
|
||||
use std::sync::{Arc, Weak};
|
||||
|
||||
use atomic::Atomic;
|
||||
@@ -67,16 +67,16 @@ where
|
||||
height: Atomic<f32>,
|
||||
|
||||
/// The stats of the Pokemon when disregarding any stat boosts.
|
||||
flat_stats: StatisticSet<AtomicU32>,
|
||||
flat_stats: StatisticSet<u32>,
|
||||
/// The statistics boosts of the Pokemon. Will prevent the value from going above 6, and below
|
||||
/// -6.
|
||||
stat_boost: ClampedStatisticSet<AtomicI8, -6, 6>,
|
||||
stat_boost: ClampedStatisticSet<i8, -6, 6>,
|
||||
/// The stats of the Pokemon including the stat boosts
|
||||
boosted_stats: StatisticSet<AtomicU32>,
|
||||
boosted_stats: StatisticSet<u32>,
|
||||
/// The [individual values](https://bulbapedia.bulbagarden.net/wiki/Individual_values) of the Pokemon.
|
||||
individual_values: ClampedStatisticSet<AtomicU8, 0, 31>,
|
||||
individual_values: ClampedStatisticSet<u8, 0, 31>,
|
||||
/// The [effort values](https://bulbapedia.bulbagarden.net/wiki/Effort_values) of the Pokemon.
|
||||
effort_values: ClampedStatisticSet<AtomicU8, 0, 252>,
|
||||
effort_values: ClampedStatisticSet<u8, 0, 252>,
|
||||
/// The [nature](https://bulbapedia.bulbagarden.net/wiki/Nature) of the Pokemon.
|
||||
nature: &'own Nature,
|
||||
|
||||
@@ -304,11 +304,11 @@ impl<'own, 'library> Pokemon<'own, 'library> {
|
||||
}
|
||||
|
||||
/// The stats of the Pokemon when disregarding any stat boosts.
|
||||
pub fn flat_stats(&self) -> &StatisticSet<AtomicU32> {
|
||||
pub fn flat_stats(&self) -> &StatisticSet<u32> {
|
||||
&self.flat_stats
|
||||
}
|
||||
/// The stats of the Pokemon including the stat boosts
|
||||
pub fn boosted_stats(&self) -> &StatisticSet<AtomicU32> {
|
||||
pub fn boosted_stats(&self) -> &StatisticSet<u32> {
|
||||
&self.boosted_stats
|
||||
}
|
||||
/// Get the stat boosts for a specific stat.
|
||||
@@ -365,11 +365,11 @@ impl<'own, 'library> Pokemon<'own, 'library> {
|
||||
}
|
||||
|
||||
/// The [individual values](https://bulbapedia.bulbagarden.net/wiki/Individual_values) of the Pokemon.
|
||||
pub fn individual_values(&self) -> &ClampedStatisticSet<AtomicU8, 0, 31> {
|
||||
pub fn individual_values(&self) -> &ClampedStatisticSet<u8, 0, 31> {
|
||||
&self.individual_values
|
||||
}
|
||||
/// The [effort values](https://bulbapedia.bulbagarden.net/wiki/Effort_values) of the Pokemon.
|
||||
pub fn effort_values(&self) -> &ClampedStatisticSet<AtomicU8, 0, 252> {
|
||||
pub fn effort_values(&self) -> &ClampedStatisticSet<u8, 0, 252> {
|
||||
&self.effort_values
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user