Style and Clippy fixes.
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:
@@ -53,15 +53,13 @@ pub fn load_types(path: &String, type_library: &mut TypeLibrary) {
|
||||
.unwrap();
|
||||
let headers = reader.headers().unwrap();
|
||||
for header in headers.iter().skip(1) {
|
||||
type_library.register_type(&StringKey::new(header.into()));
|
||||
type_library.register_type(&header.into());
|
||||
}
|
||||
|
||||
for record in reader.records() {
|
||||
let record = record.unwrap();
|
||||
let offensive_type = record.get(0).unwrap();
|
||||
let offensive_type_id = type_library
|
||||
.get_type_id(&StringKey::new(offensive_type.into()))
|
||||
.unwrap();
|
||||
let offensive_type_id = type_library.get_type_id(&offensive_type.into()).unwrap();
|
||||
|
||||
for (i, v) in record.iter().skip(1).enumerate() {
|
||||
let effectiveness = v.parse::<f32>().unwrap();
|
||||
@@ -78,7 +76,7 @@ pub fn load_natures(path: &String, nature_library: &mut NatureLibrary) {
|
||||
|
||||
for record in reader.records() {
|
||||
let record = record.unwrap();
|
||||
let nature_name = StringKey::new(record.get(0).unwrap().into());
|
||||
let nature_name = record.get(0).unwrap().into();
|
||||
let increased_statistic_str = record.get(1).unwrap();
|
||||
let decreased_statistic_str = record.get(2).unwrap();
|
||||
if increased_statistic_str.is_empty() || decreased_statistic_str.is_empty() {
|
||||
@@ -102,7 +100,7 @@ pub fn load_items(path: &String, lib: &mut ItemLibrary) {
|
||||
let json_array = json.as_array().unwrap();
|
||||
|
||||
for v in json_array {
|
||||
let name = StringKey::new(v.get("name").unwrap().as_str().unwrap().into());
|
||||
let name = v.get("name").unwrap().as_str().unwrap().into();
|
||||
let category = serde_json::from_value(v.get("itemType").unwrap().clone()).unwrap();
|
||||
let mut battle_category = BattleItemCategory::None;
|
||||
if let Some(c) = v.get("battleType") {
|
||||
@@ -113,7 +111,7 @@ pub fn load_items(path: &String, lib: &mut ItemLibrary) {
|
||||
if let Some(f) = v.get("flags") {
|
||||
let a = f.as_array().unwrap();
|
||||
for flag in a {
|
||||
flags.insert(StringKey::new(flag.as_str().unwrap().into()));
|
||||
flags.insert(flag.as_str().unwrap().into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +152,7 @@ pub fn load_abilities(path: &String, ability_library: &mut AbilityLibrary) {
|
||||
let name = StringKey::new(key);
|
||||
let mut effect = StringKey::empty();
|
||||
if let Some(e) = value.get("effect") {
|
||||
effect = StringKey::new(e.as_str().unwrap().into());
|
||||
effect = e.as_str().unwrap().into();
|
||||
}
|
||||
let mut parameters = Vec::new();
|
||||
if let Some(p) = value.get("parameters") {
|
||||
@@ -175,8 +173,8 @@ pub fn load_moves(path: &String, lib: &mut StaticData) {
|
||||
let data = json.as_object().unwrap().get("data").unwrap().as_array().unwrap();
|
||||
for move_data in data {
|
||||
let move_data = move_data.as_object().unwrap();
|
||||
let move_name = StringKey::new(move_data.get("name").unwrap().as_str().unwrap().into());
|
||||
let move_type = StringKey::new(move_data.get("type").unwrap().as_str().unwrap().into());
|
||||
let move_name = move_data.get("name").unwrap().as_str().unwrap().into();
|
||||
let move_type = move_data.get("type").unwrap().as_str().unwrap().into();
|
||||
let move_type_id = lib.types().get_type_id(&move_type).unwrap();
|
||||
let move_category = serde_json::from_value(move_data.get("category").unwrap().clone()).unwrap();
|
||||
let base_power = move_data.get("power").unwrap().as_i64().unwrap() as u8;
|
||||
@@ -199,7 +197,7 @@ pub fn load_moves(path: &String, lib: &mut StaticData) {
|
||||
|
||||
Some(SecondaryEffect::new(
|
||||
chance,
|
||||
StringKey::new(v.get("name").unwrap().as_str().unwrap().into()),
|
||||
v.get("name").unwrap().as_str().unwrap().into(),
|
||||
parameters,
|
||||
))
|
||||
} else {
|
||||
@@ -210,7 +208,7 @@ pub fn load_moves(path: &String, lib: &mut StaticData) {
|
||||
if let Some(f) = move_data.get("flags") {
|
||||
let f = f.as_array().unwrap();
|
||||
for flag in f {
|
||||
flags.insert(StringKey::new(flag.as_str().unwrap().into()));
|
||||
flags.insert(flag.as_str().unwrap().into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +244,7 @@ pub fn load_species(path: &String, library: &mut StaticData) {
|
||||
let name = StringKey::new(key);
|
||||
let id = value.get("id").unwrap().as_i64().unwrap();
|
||||
let gender_rate = value.get("genderRatio").unwrap().as_f64().unwrap();
|
||||
let growth_rate_name = StringKey::new(value.get("growthRate").unwrap().as_str().unwrap().into());
|
||||
let growth_rate_name = value.get("growthRate").unwrap().as_str().unwrap().into();
|
||||
let _base_happiness = value.get("baseHappiness").unwrap().as_i64().unwrap();
|
||||
let catch_rate = value.get("catchRate").unwrap().as_i64().unwrap();
|
||||
let _color = value.get("color").unwrap().as_str().unwrap();
|
||||
@@ -289,13 +287,13 @@ fn load_wasm(path: &String, library: &mut WebAssemblyScriptResolver) {
|
||||
fn parse_form(name: StringKey, value: &Value, library: &mut StaticData) -> Arc<Form> {
|
||||
let mut abilities = Vec::new();
|
||||
for a in value.get("abilities").unwrap().as_array().unwrap() {
|
||||
abilities.push(StringKey::new(a.as_str().unwrap().into()));
|
||||
abilities.push(a.as_str().unwrap().into());
|
||||
}
|
||||
let mut hidden_abilities = Vec::new();
|
||||
for a in value.get("hiddenAbilities").unwrap().as_array().unwrap() {
|
||||
hidden_abilities.push(StringKey::new(a.as_str().unwrap().into()));
|
||||
hidden_abilities.push(a.as_str().unwrap().into());
|
||||
}
|
||||
let base_stats = parse_statistics(&value.get("baseStats").unwrap());
|
||||
let base_stats = parse_statistics(value.get("baseStats").unwrap());
|
||||
// TODO: ev reward
|
||||
let height = value.get("height").unwrap().as_f64().unwrap();
|
||||
let weight = value.get("weight").unwrap().as_f64().unwrap();
|
||||
@@ -306,15 +304,10 @@ fn parse_form(name: StringKey, value: &Value, library: &mut StaticData) -> Arc<F
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|a| {
|
||||
library
|
||||
.types()
|
||||
.get_type_id(&StringKey::new(a.as_str().unwrap().into()))
|
||||
.unwrap()
|
||||
})
|
||||
.map(|a| library.types().get_type_id(&a.as_str().unwrap().into()).unwrap())
|
||||
.collect();
|
||||
|
||||
let moves = parse_moves(&value.get("moves").unwrap(), library.moves());
|
||||
let moves = parse_moves(value.get("moves").unwrap(), library.moves());
|
||||
|
||||
Arc::new(Form::new(
|
||||
&name,
|
||||
@@ -379,7 +372,7 @@ fn parse_moves(value: &Value, move_library: &MoveLibrary) -> LearnableMoves {
|
||||
|
||||
let level_moves = value.get("levelMoves").unwrap().as_array().unwrap();
|
||||
for level_move in level_moves {
|
||||
let name = StringKey::new(level_move.get("name").unwrap().as_str().unwrap().into());
|
||||
let name = level_move.get("name").unwrap().as_str().unwrap().into();
|
||||
let level = level_move.get("level").unwrap().as_u64().unwrap() as LevelInt;
|
||||
assert!(move_library.get(&name).is_some());
|
||||
moves.add_level_move(level, &name);
|
||||
@@ -401,7 +394,7 @@ fn parse_effect_parameter(value: &Value) -> EffectParameter {
|
||||
n.as_i64().unwrap().into()
|
||||
}
|
||||
}
|
||||
Value::String(s) => StringKey::new(s.as_str().into()).into(),
|
||||
Value::String(s) => StringKey::new(s.as_str()).into(),
|
||||
Value::Array(_) => {
|
||||
panic!("Unexpected type")
|
||||
}
|
||||
@@ -421,8 +414,8 @@ fn test_type_library_loaded() {
|
||||
|
||||
assert_eq!(
|
||||
lib.get_effectiveness(
|
||||
lib.get_type_id(&StringKey::new("fire".into())).unwrap(),
|
||||
&[lib.get_type_id(&StringKey::new("grass".into())).unwrap()],
|
||||
lib.get_type_id(&"fire".into()).unwrap(),
|
||||
&[lib.get_type_id(&"grass".into()).unwrap()],
|
||||
),
|
||||
2.0
|
||||
);
|
||||
|
||||
@@ -74,7 +74,7 @@ impl TestCase {
|
||||
|
||||
impl TestPokemon {
|
||||
fn to_pokemon(&self, library: Arc<DynamicLibrary>) -> Pokemon {
|
||||
let mut builder = PokemonBuilder::new(library, StringKey::new(self.species.as_str().into()), self.level);
|
||||
let mut builder = PokemonBuilder::new(library, self.species.as_str().into(), self.level);
|
||||
for move_name in &self.moves {
|
||||
builder = builder.learn_move(StringKey::new(move_name));
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ fn validate_assurance() {
|
||||
let executing_move = ExecutingMove::new(
|
||||
vec![],
|
||||
1,
|
||||
p1.clone(),
|
||||
p1,
|
||||
mv.clone(),
|
||||
mv.move_data().clone(),
|
||||
ScriptContainer::default(),
|
||||
|
||||
Reference in New Issue
Block a user