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:
@@ -5,6 +5,9 @@ pub use target_resolver::*;
|
||||
#[doc(inline)]
|
||||
pub use turn_runner::*;
|
||||
|
||||
/// Data for enqueueing and retrieving choices.
|
||||
mod choice_queue;
|
||||
/// Data for the resolving and validation of targets for moves.
|
||||
mod target_resolver;
|
||||
/// Logic required to run turns.
|
||||
mod turn_runner;
|
||||
|
||||
@@ -61,6 +61,7 @@ impl<'own, 'library> Battle<'own, 'library> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Executes a single choice.
|
||||
fn execute_choice(&self, choice: &TurnChoice<'own, 'library>) -> PkmnResult<()> {
|
||||
// A pass turn choice means the user does not intend to do anything. As such, return.
|
||||
if let TurnChoice::Pass(..) = choice {
|
||||
@@ -89,6 +90,7 @@ impl<'own, 'library> Battle<'own, 'library> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Executes a move choice.
|
||||
fn execute_move_choice<'func>(&'func self, choice: &'func TurnChoice<'own, 'library>) -> PkmnResult<()> {
|
||||
let choice = choice.get_move_turn_data();
|
||||
let used_move = choice.used_move();
|
||||
@@ -145,6 +147,7 @@ impl<'own, 'library> Battle<'own, 'library> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Executes a move turn choice on a single target.
|
||||
fn handle_move_for_target(
|
||||
&self,
|
||||
executing_move: &mut ExecutingMove<'_, 'own, 'library>,
|
||||
|
||||
@@ -9,8 +9,13 @@ pub use misc_library::*;
|
||||
#[doc(inline)]
|
||||
pub use script_resolver::*;
|
||||
|
||||
/// Data regarding the calculation of battle stats.
|
||||
mod battle_stat_calculator;
|
||||
/// Data regarding the calculation of damage.
|
||||
mod damage_library;
|
||||
/// Collection of all libraries.
|
||||
pub(crate) mod dynamic_library;
|
||||
/// Misc data required for battles.
|
||||
mod misc_library;
|
||||
/// Data for dynamically resolving scripts during battles.
|
||||
mod script_resolver;
|
||||
|
||||
@@ -11,9 +11,15 @@ pub use models::*;
|
||||
#[doc(inline)]
|
||||
pub use script_handling::*;
|
||||
|
||||
/// Holds different choices Pokemon can use during battle.
|
||||
mod choices;
|
||||
/// Holds data to callback events from the battle to clients.
|
||||
mod event_hooks;
|
||||
/// Holds logic on how the battle is executed.
|
||||
mod flow;
|
||||
/// Holds information regarding data that is required for battle execution.
|
||||
pub(crate) mod libraries;
|
||||
/// Holds different struct types that are required for functioning.
|
||||
mod models;
|
||||
/// Holds information for dynamic runtime behaviour during battles.
|
||||
mod script_handling;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -11,9 +11,13 @@ pub use script_set::*;
|
||||
#[doc(inline)]
|
||||
pub use volatile_scripts_owner::*;
|
||||
|
||||
/// Scripts that are used for item usage
|
||||
mod item_script;
|
||||
/// Scripts that are used to change how a battle functions.
|
||||
mod script;
|
||||
/// Collections of scripts.
|
||||
mod script_set;
|
||||
/// A trait to add volatile scripts to any object.
|
||||
mod volatile_scripts_owner;
|
||||
|
||||
/// This macro runs a script function on a given ScriptSource, and all its parents. It will ensure
|
||||
@@ -202,7 +206,7 @@ impl ScriptIterator {
|
||||
ScriptWrapper::Set(set) => {
|
||||
let set = set.upgrade().unwrap();
|
||||
let sc = set.at(self.set_index as usize);
|
||||
return Some(sc.clone());
|
||||
return Some(sc);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user