Skip to content

Commit

Permalink
chore!: rename TypeId to Type
Browse files Browse the repository at this point in the history
This is actually what it is, a Type. Not an ID.
  • Loading branch information
TrueBrain committed Jul 19, 2024
1 parent 5570f37 commit 59d79b7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions src/calculate/pass_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/calculate/pass_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() => {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/data_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<f64>,
Expand Down
2 changes: 1 addition & 1 deletion src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<data_types::TypeDogmaEffect>;
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;
}
6 changes: 3 additions & 3 deletions src/rust/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ 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,
mass: None,
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),
Expand Down
2 changes: 1 addition & 1 deletion src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 59d79b7

Please sign in to comment.