Basic implementation of evolutions
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:
@@ -68,6 +68,9 @@ struct PokemonData {
|
||||
/// The height of the Pokemon in meters.
|
||||
height: Atomic<f32>,
|
||||
|
||||
/// The happiness of the Pokemon. Also known as friendship.
|
||||
happiness: AtomicU8,
|
||||
|
||||
/// The stats of the Pokemon when disregarding any stat boosts.
|
||||
flat_stats: Arc<StatisticSet<u32>>,
|
||||
/// The statistics boosts of the Pokemon. Will prevent the value from going above 6, and below
|
||||
@@ -158,6 +161,7 @@ impl Pokemon {
|
||||
.calculate_experience(species.growth_rate(), level)?;
|
||||
let weight = form.weight();
|
||||
let height = form.height();
|
||||
let base_happiness = species.base_happiness();
|
||||
let nature = library
|
||||
.static_data()
|
||||
.natures()
|
||||
@@ -198,6 +202,7 @@ impl Pokemon {
|
||||
status_script: ScriptContainer::default(),
|
||||
volatile: Default::default(),
|
||||
script_source_data: Default::default(),
|
||||
happiness: AtomicU8::new(base_happiness),
|
||||
};
|
||||
|
||||
let pokemon = Self {
|
||||
@@ -326,11 +331,16 @@ impl Pokemon {
|
||||
pub fn set_weight(&self, weight: f32) {
|
||||
self.data.weight.store(weight, Ordering::Relaxed)
|
||||
}
|
||||
|
||||
/// The height of the Pokemon in meters.
|
||||
pub fn height(&self) -> f32 {
|
||||
self.data.height.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
/// The current happiness of the Pokemon. Also known as friendship.
|
||||
pub fn happiness(&self) -> u8 {
|
||||
self.data.happiness.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
/// An optional nickname of the Pokemon.
|
||||
pub fn nickname(&self) -> &Option<String> {
|
||||
&self.data.nickname
|
||||
@@ -921,6 +931,7 @@ impl Pokemon {
|
||||
current_health: AtomicU32::new(value.current_health),
|
||||
weight: Atomic::new(value.weight),
|
||||
height: Atomic::new(value.height),
|
||||
happiness: AtomicU8::new(value.happiness),
|
||||
flat_stats: Arc::new(Default::default()),
|
||||
stat_boost: Arc::new(value.stat_boosts.clone()),
|
||||
boosted_stats: Arc::new(Default::default()),
|
||||
@@ -1163,6 +1174,7 @@ pub mod test {
|
||||
});
|
||||
species.expect_growth_rate().return_const(StringKey::empty());
|
||||
species.expect_name().return_const(StringKey::new("test_species"));
|
||||
species.expect_base_happiness().return_const(100);
|
||||
|
||||
let s: Arc<dyn Species> = Arc::new(species);
|
||||
Some(s)
|
||||
|
||||
Reference in New Issue
Block a user