Fixes all clippy warnings
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:
@@ -9,7 +9,6 @@ use crate::dynamic_data::choices::TurnChoice;
|
||||
use crate::dynamic_data::event_hooks::{Event, EventHook};
|
||||
use crate::dynamic_data::models::battle_party::BattleParty;
|
||||
use crate::dynamic_data::models::battle_random::BattleRandom;
|
||||
use crate::dynamic_data::models::battle_result::BattleResult;
|
||||
use crate::dynamic_data::models::battle_side::BattleSide;
|
||||
use crate::dynamic_data::models::pokemon::Pokemon;
|
||||
use crate::dynamic_data::ChoiceQueue;
|
||||
@@ -350,3 +349,13 @@ impl<'own, 'library> ScriptSource<'own> for Battle<'own, 'library> {
|
||||
self.get_own_scripts(scripts);
|
||||
}
|
||||
}
|
||||
|
||||
/// The result of a battle.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum BattleResult {
|
||||
/// The battle has no winner. Either the battle has not ended, or everyone is dead, or one of
|
||||
/// the parties has ran away.
|
||||
Inconclusive,
|
||||
/// The battle has a winner, with the inner value being the index of the side that has won.
|
||||
Conclusive(u8),
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
/// The result of a battle.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum BattleResult {
|
||||
/// The battle has no winner. Either the battle has not ended, or everyone is dead, or one of
|
||||
/// the parties has ran away.
|
||||
Inconclusive,
|
||||
/// The battle has a winner, with the inner value being the index of the side that has won.
|
||||
Conclusive(u8),
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/// A source of damage. This should be as unique as possible.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum DamageSource {
|
||||
/// The damage is done by a move.
|
||||
MoveDamage = 0,
|
||||
/// The damage is done by something else.
|
||||
Misc = 1,
|
||||
}
|
||||
@@ -5,12 +5,8 @@ pub use battle_party::*;
|
||||
#[doc(inline)]
|
||||
pub use battle_random::*;
|
||||
#[doc(inline)]
|
||||
pub use battle_result::*;
|
||||
#[doc(inline)]
|
||||
pub use battle_side::*;
|
||||
#[doc(inline)]
|
||||
pub use damage_source::*;
|
||||
#[doc(inline)]
|
||||
pub use executing_move::*;
|
||||
#[doc(inline)]
|
||||
pub use learned_move::*;
|
||||
@@ -21,14 +17,21 @@ pub use pokemon_builder::*;
|
||||
#[doc(inline)]
|
||||
pub use pokemon_party::*;
|
||||
|
||||
/// Data regarding the battle itself.
|
||||
mod battle;
|
||||
/// Data regarding parties that are part of a battle.
|
||||
mod battle_party;
|
||||
/// Data regarding the RNG for battles.
|
||||
mod battle_random;
|
||||
mod battle_result;
|
||||
/// Data regarding a single side on the battle.
|
||||
mod battle_side;
|
||||
mod damage_source;
|
||||
/// Data regarding a move that is being executed.
|
||||
mod executing_move;
|
||||
/// Data regarding a move that is learned by a Pokemon.
|
||||
mod learned_move;
|
||||
/// Data for an individual Pokemon.
|
||||
mod pokemon;
|
||||
/// A constructor for Pokemon.
|
||||
mod pokemon_builder;
|
||||
/// Data for a group of Pokemon belonging to a trainer.
|
||||
mod pokemon_party;
|
||||
|
||||
@@ -8,18 +8,17 @@ use parking_lot::RwLock;
|
||||
use crate::defines::{LevelInt, MAX_MOVES};
|
||||
use crate::dynamic_data::event_hooks::Event;
|
||||
use crate::dynamic_data::models::battle::Battle;
|
||||
use crate::dynamic_data::models::damage_source::DamageSource;
|
||||
use crate::dynamic_data::models::learned_move::{LearnedMove, MoveLearnMethod};
|
||||
use crate::dynamic_data::script_handling::{ScriptSource, ScriptSourceData, ScriptWrapper};
|
||||
use crate::dynamic_data::{DynamicLibrary, Script, ScriptCategory, ScriptContainer, ScriptSet, VolatileScriptsOwner};
|
||||
use crate::static_data::DataLibrary;
|
||||
use crate::static_data::Form;
|
||||
use crate::static_data::Gender;
|
||||
use crate::static_data::Item;
|
||||
use crate::static_data::Nature;
|
||||
use crate::static_data::Species;
|
||||
use crate::static_data::TypeIdentifier;
|
||||
use crate::static_data::{Ability, Statistic};
|
||||
use crate::static_data::{AbilityIndex, TypeIdentifier};
|
||||
use crate::static_data::{AbilityIndex, DataLibrary};
|
||||
use crate::static_data::{ClampedStatisticSet, StatisticSet};
|
||||
use crate::utils::Random;
|
||||
use crate::{script_hook, PkmnResult, StringKey};
|
||||
@@ -344,10 +343,14 @@ impl<'own, 'library> Pokemon<'own, 'library> {
|
||||
|
||||
let mut changed = false;
|
||||
let old_value = self.stat_boost.get_stat(stat);
|
||||
if diff_amount > 0 {
|
||||
changed = self.stat_boost.increase_stat(stat, diff_amount);
|
||||
} else if diff_amount < 0 {
|
||||
changed = self.stat_boost.decrease_stat(stat, -diff_amount);
|
||||
match diff_amount.cmp(&0_i8) {
|
||||
std::cmp::Ordering::Less => {
|
||||
changed = self.stat_boost.decrease_stat(stat, -diff_amount);
|
||||
}
|
||||
std::cmp::Ordering::Greater => {
|
||||
changed = self.stat_boost.increase_stat(stat, -diff_amount);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if changed {
|
||||
if let Some(battle) = self.get_battle() {
|
||||
@@ -361,7 +364,7 @@ impl<'own, 'library> Pokemon<'own, 'library> {
|
||||
}
|
||||
self.recalculate_boosted_stats();
|
||||
}
|
||||
return changed;
|
||||
changed
|
||||
}
|
||||
|
||||
/// The [individual values](https://bulbapedia.bulbagarden.net/wiki/Individual_values) of the Pokemon.
|
||||
@@ -740,12 +743,20 @@ impl<'own, 'library> VolatileScriptsOwner<'own> for Pokemon<'own, 'library> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A source of damage. This should be as unique as possible.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum DamageSource {
|
||||
/// The damage is done by a move.
|
||||
MoveDamage = 0,
|
||||
/// The damage is done by something else.
|
||||
Misc = 1,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
use crate::dynamic_data::models::pokemon::Pokemon;
|
||||
use crate::static_data::AbilityIndex;
|
||||
use crate::static_data::DataLibrary;
|
||||
use crate::static_data::Gender;
|
||||
use crate::static_data::{AbilityIndex, DataLibrary};
|
||||
|
||||
#[test]
|
||||
fn construct_pokemon() {
|
||||
|
||||
Reference in New Issue
Block a user