Skip to content

Commit

Permalink
Merge pull request #52 from lonevvolf/master
Browse files Browse the repository at this point in the history
Proposed fix for CombatSkillModiferIncrement not cumulative #51
  • Loading branch information
cracrayol authored Aug 24, 2024
2 parents 18a8796 + 6e45709 commit 47d0047
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/ts/controller/mechanics/mechanicsEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions src/ts/tests/__tests__/rules.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 47d0047

Please sign in to comment.