diff --git a/src/calculate/pass_1.rs b/src/calculate/pass_1.rs index 0a0d30c..4d34d3d 100644 --- a/src/calculate/pass_1.rs +++ b/src/calculate/pass_1.rs @@ -20,18 +20,18 @@ impl Item { self.set_attribute(dogma_attribute.attributeID, dogma_attribute.value); } - /* Some attributes of items come from the TypeID information. */ - let type_id = info.get_type_id(self.type_id); - if let Some(mass) = type_id.mass { + /* Some attributes of items come from the Type information. */ + let r#type = info.get_type(self.type_id); + if let Some(mass) = r#type.mass { self.set_attribute(ATTRIBUTE_MASS_ID, mass); } - if let Some(capacity) = type_id.capacity { + if let Some(capacity) = r#type.capacity { self.set_attribute(ATTRIBUTE_CAPACITY_ID, capacity); } - if let Some(volume) = type_id.volume { + if let Some(volume) = r#type.volume { self.set_attribute(ATTRIBUTE_VOLUME_ID, volume); } - if let Some(radius) = type_id.radius { + if let Some(radius) = r#type.radius { self.set_attribute(ATTRIBUTE_RADIUS_ID, radius); } } diff --git a/src/calculate/pass_2.rs b/src/calculate/pass_2.rs index 7896323..69c84b6 100644 --- a/src/calculate/pass_2.rs +++ b/src/calculate/pass_2.rs @@ -220,7 +220,7 @@ impl Pass for PassTwo { Object::Structure => continue, // TODO Object::Target => continue, // TODO }; - let category_id = info.get_type_id(source_type_id).categoryID; + let category_id = info.get_type(source_type_id).categoryID; match effect.modifier { Modifier::ItemModifier() => { @@ -254,8 +254,8 @@ impl Pass for PassTwo { } } Modifier::LocationGroupModifier(group_id) => { - let type_id = info.get_type_id(ship.hull.type_id); - if type_id.groupID == group_id { + let r#type = info.get_type(ship.hull.type_id); + if r#type.groupID == group_id { ship.hull.add_effect( info, effect.target_attribute_id, @@ -265,16 +265,16 @@ impl Pass for PassTwo { } for item in &mut ship.items { - let type_id = info.get_type_id(item.type_id); + let r#type = info.get_type(item.type_id); - if type_id.groupID == group_id { + if r#type.groupID == group_id { item.add_effect(info, effect.target_attribute_id, category_id, &effect); } if let Some(charge) = &mut item.charge { - let type_id = info.get_type_id(charge.type_id); + let r#type = info.get_type(charge.type_id); - if type_id.groupID == group_id { + if r#type.groupID == group_id { charge.add_effect( info, effect.target_attribute_id, diff --git a/src/data_types.rs b/src/data_types.rs index 5d2bbfe..ca52043 100644 --- a/src/data_types.rs +++ b/src/data_types.rs @@ -3,7 +3,7 @@ use serde_repr::*; #[allow(non_snake_case)] #[derive(Deserialize, Debug)] -pub struct TypeId { +pub struct Type { pub groupID: i32, pub categoryID: i32, pub capacity: Option, diff --git a/src/info.rs b/src/info.rs index 1da77cd..d0c0daa 100644 --- a/src/info.rs +++ b/src/info.rs @@ -10,5 +10,5 @@ pub trait Info { fn get_dogma_attribute(&self, attribute_id: i32) -> data_types::DogmaAttribute; fn get_dogma_effects(&self, type_id: i32) -> Vec; fn get_dogma_effect(&self, effect_id: i32) -> data_types::DogmaEffect; - fn get_type_id(&self, type_id: i32) -> data_types::TypeId; + fn get_type(&self, type_id: i32) -> data_types::Type; } diff --git a/src/rust/info.rs b/src/rust/info.rs index 9a3800e..de0549d 100644 --- a/src/rust/info.rs +++ b/src/rust/info.rs @@ -117,9 +117,9 @@ impl Info for InfoMain { } } - fn get_type_id(&self, type_id: i32) -> data_types::TypeId { + fn get_type(&self, type_id: i32) -> data_types::Type { match self.types.get(&type_id) { - None => data_types::TypeId { + None => data_types::Type { groupID: 0, categoryID: 0, capacity: None, @@ -127,7 +127,7 @@ impl Info for InfoMain { volume: None, radius: None, }, - Some(type_) => data_types::TypeId { + Some(type_) => data_types::Type { groupID: type_.group_id, categoryID: type_.category_id, capacity: type_.capacity.map(|x| x as f64), diff --git a/src/wasm/mod.rs b/src/wasm/mod.rs index 38c13f1..ae928f4 100644 --- a/src/wasm/mod.rs +++ b/src/wasm/mod.rs @@ -50,7 +50,7 @@ impl Info for InfoWasm { serde_wasm_bindgen::from_value(js).unwrap() } - fn get_type_id(&self, type_id: i32) -> data_types::TypeId { + fn get_type(&self, type_id: i32) -> data_types::Type { let js = get_type_id(type_id); serde_wasm_bindgen::from_value(js).unwrap() }