Skip to content

Commit

Permalink
fix: calculate mass/capacity/volume/radius of all items (#29)
Browse files Browse the repository at this point in the history
This is important to calculate how many charges fit in a module.
  • Loading branch information
TrueBrain authored Mar 5, 2024
1 parent daff3f5 commit 147c55c
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/calculate/pass_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,28 @@ impl Item {
for dogma_attribute in info.get_dogma_attributes(self.type_id) {
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 {
self.set_attribute(ATTRIBUTE_MASS_ID, mass);
}
if let Some(capacity) = type_id.capacity {
self.set_attribute(ATTRIBUTE_CAPACITY_ID, capacity);
}
if let Some(volume) = type_id.volume {
self.set_attribute(ATTRIBUTE_VOLUME_ID, volume);
}
if let Some(radius) = type_id.radius {
self.set_attribute(ATTRIBUTE_RADIUS_ID, radius);
}
}
}

impl Pass for PassOne {
fn pass(info: &Info, ship: &mut Ship) {
ship.hull.set_attributes(info);

/* Some attributes of ships come from the TypeID information. */
let type_id = info.get_type_id(info.esi_fit.ship_type_id);
ship.hull
.set_attribute(ATTRIBUTE_MASS_ID, type_id.mass.unwrap());
ship.hull
.set_attribute(ATTRIBUTE_CAPACITY_ID, type_id.capacity.unwrap());
ship.hull
.set_attribute(ATTRIBUTE_VOLUME_ID, type_id.volume.unwrap());
ship.hull
.set_attribute(ATTRIBUTE_RADIUS_ID, type_id.radius.unwrap());

for (skill_id, skill_level) in info.skills {
let mut skill = Item::new_fake(*skill_id);

Expand Down

0 comments on commit 147c55c

Please sign in to comment.