Style and Clippy fixes.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-10-14 16:53:30 +02:00
parent 9efe1b4e22
commit 691bf7c12e
56 changed files with 354 additions and 249 deletions

View File

@@ -345,7 +345,7 @@ impl Battle {
.library()
.load_script(self.into(), ScriptCategory::Weather, &weather)
.unwrap()
.expect(format!("Couldn't find weather script by name {}", weather).as_str());
.unwrap_or_else(|| panic!("Couldn't find weather script by name {}", weather));
self.weather.set(script);
} else {
self.weather.clear();

View File

@@ -1,7 +1,6 @@
use std::sync::atomic::{AtomicU8, Ordering};
use std::sync::Arc;
use crate::dynamic_data::Pokemon;
use crate::static_data::MoveData;
use crate::{ValueIdentifiable, ValueIdentifier};

View File

@@ -457,7 +457,8 @@ impl Pokemon {
.calculate_flat_stats(self, &self.flat_stats);
self.recalculate_boosted_stats();
}
/// Calculates the boosted stats on the Pokemon. This should be called when a stat boost changes.
/// Calculates the boosted stats on the Pokemon, _without_ recalculating the flat stats.
/// This should be called when a stat boost changes.
pub fn recalculate_boosted_stats(&self) {
self.library
.stat_calculator()
@@ -516,7 +517,7 @@ impl Pokemon {
let ability_script = self
.library
.load_script((&*self).into(), ScriptCategory::Ability, self.active_ability().name())
.load_script(self.into(), ScriptCategory::Ability, self.active_ability().name())
.unwrap();
if let Some(ability_script) = ability_script {
self.ability_script
@@ -614,7 +615,7 @@ impl Pokemon {
}
}
/// Damages the Pokemon by a certain amount of damage, from a specific damage source.
/// Damages the Pokemon by a certain amount of damage, from a damage source.
pub fn damage(&self, mut damage: u32, source: DamageSource) {
if damage > self.current_health() {
damage = self.current_health();
@@ -820,7 +821,7 @@ pub mod test {
fn construct_pokemon() {
let lib = Arc::new(crate::dynamic_data::libraries::dynamic_library::test::build());
let species = lib.static_data().species().get(&"foo".into()).unwrap().clone();
let form = species.get_form(&"default".into()).unwrap().clone();
let form = species.get_form(&"default".into()).unwrap();
let pokemon = Pokemon::new(
lib,

View File

@@ -47,7 +47,7 @@ impl PokemonBuilder {
};
let species = self.library.static_data().species().get(&self.species).unwrap().clone();
let form = species.get_default_form().clone();
let form = species.get_default_form();
let p = Pokemon::new(
self.library,
species,

View File

@@ -93,11 +93,9 @@ impl PokemonParty {
/// Checks if the party contains a given pokemon.
pub fn has_pokemon(&self, pokemon: &Pokemon) -> bool {
for p in &self.pokemon {
if let Some(p) = p {
if std::ptr::eq(p.as_ref(), pokemon) {
return true;
}
for p in self.pokemon.iter().flatten() {
if std::ptr::eq(p.as_ref(), pokemon) {
return true;
}
}
false