diff --git a/src/ts/controller/mechanics/mechanicsEngine.ts b/src/ts/controller/mechanics/mechanicsEngine.ts index ded95cd7..5db7bcbe 100644 --- a/src/ts/controller/mechanics/mechanicsEngine.ts +++ b/src/ts/controller/mechanics/mechanicsEngine.ts @@ -148,7 +148,7 @@ export const mechanicsEngine = { /** * Run current section rules * @param resetRandomTableIncrements If it's true, any random table link increment will be reset before - * run the rules. Random table increments are stored on the UI, and they are accumulative. So if rules are re-executed + * running the rules. Random table increments are stored on the UI, and they are cumulative. So if rules are re-executed * without refresh the section, it can be needed */ runSectionRules(resetRandomTableIncrements: boolean = false) { @@ -161,6 +161,13 @@ export const mechanicsEngine = { const $sectionMechanics = state.mechanics.getSection(state.sectionStates.currentSection); if ($sectionMechanics !== null) { + // Reset the combatModifiers before rendering the rules + const sectionState = state.sectionStates.getSectionState(); + if (sectionState && sectionState.combats) { + state.sectionStates.getSectionState().combats.forEach((combat) => { + combat.combatModifier = 0; + }); + } mechanicsEngine.runChildRules($sectionMechanics); } @@ -948,7 +955,9 @@ export const mechanicsEngine = { // Check LW combat ABSOLUTE skill modifier for this section: const combatSkillModifier = mechanicsEngine.getIntProperty($rule, "combatSkillModifier", true); - combat.combatModifier = combatSkillModifier !== null ? combatSkillModifier : 0; + if (combatSkillModifier !== null) { + combat.combatModifier = combatSkillModifier; + } // Check LW combat skill modifier INCREMENT const combatSkillModifierIncrement = mechanicsEngine.getIntProperty($rule, "combatSkillModifierIncrement", true); diff --git a/src/ts/tests/__tests__/rules.tests.ts b/src/ts/tests/__tests__/rules.tests.ts index 4503c936..7d1358e2 100644 --- a/src/ts/tests/__tests__/rules.tests.ts +++ b/src/ts/tests/__tests__/rules.tests.ts @@ -126,6 +126,15 @@ describe("combat", () => { await driver.goToSection("sect86"); expect( await driver.getCombatRatio() ).toBe(-10); }); + + test("combatSkillModifierIncrement", async () => { + await driver.setupBookState(11); + await driver.setDisciplines([MgnDiscipline.AnimalControl, MgnDiscipline.Curing, MgnDiscipline.Huntmastery]); + await driver.pick("psychicring"); + await driver.pick("silverhelm"); + await driver.goToSection("sect270"); + expect( await driver.getCombatRatio() ).toBe(-5); + }); }); // setDisciplines -> See setDisciplines.tests.ts