From e0c16868467c88880c20f4067d89b3366545c17d Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Tue, 5 Mar 2024 22:36:54 +0100 Subject: [PATCH] fix(pass-2): apply effects on charges and for OwnerRequiredSkillModifier (#31) This is not perfect yet, but less wrong. --- src/calculate/pass_2.rs | 42 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/calculate/pass_2.rs b/src/calculate/pass_2.rs index 178c700..6d4d222 100644 --- a/src/calculate/pass_2.rs +++ b/src/calculate/pass_2.rs @@ -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) => { @@ -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 @@ -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 - } } } }