Skip to content

Commit

Permalink
fix(pass-2): apply effects on charges and for OwnerRequiredSkillModif…
Browse files Browse the repository at this point in the history
…ier (#31)

This is not perfect yet, but less wrong.
  • Loading branch information
TrueBrain authored Mar 5, 2024
1 parent 147c55c commit e0c1686
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions src/calculate/pass_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ impl Pass for PassTwo {

for item in &mut ship.items {
item.add_effect(info, effect.target_attribute_id, category_id, &effect);

if let Some(charge) = &mut item.charge {
charge.add_effect(
info,
effect.target_attribute_id,
category_id,
&effect,
);
}
}
}
Modifier::LocationGroupModifier(group_id) => {
Expand All @@ -251,9 +260,23 @@ impl Pass for PassTwo {
if type_id.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);

if type_id.groupID == group_id {
charge.add_effect(
info,
effect.target_attribute_id,
category_id,
&effect,
);
}
}
}
}
Modifier::LocationRequiredSkillModifier(skill_type_id) => {
Modifier::OwnerRequiredSkillModifier(skill_type_id)
| Modifier::LocationRequiredSkillModifier(skill_type_id) => {
for attribute_skill_id in &ATTRIBUTE_SKILLS {
if ship.hull.attributes.contains_key(attribute_skill_id)
&& ship.hull.attributes[attribute_skill_id].base_value
Expand All @@ -279,12 +302,23 @@ impl Pass for PassTwo {
&effect,
);
}

if let Some(charge) = &mut item.charge {
if charge.attributes.contains_key(attribute_skill_id)
&& charge.attributes[attribute_skill_id].base_value
== skill_type_id as f64
{
charge.add_effect(
info,
effect.target_attribute_id,
category_id,
&effect,
);
}
}
}
}
}
Modifier::OwnerRequiredSkillModifier(_skill_type_id) => {
// TODO
}
}
}
}
Expand Down

0 comments on commit e0c1686

Please sign in to comment.