Skip to content

Commit

Permalink
Bugfix: Consume with Target option now apply correctly to the target …
Browse files Browse the repository at this point in the history
…when ailment was reduced during the action (ex. Bleed)

- Also added Reset after Consume on Target to ensure it doesn't affect any other AutoEffects on the target
  • Loading branch information
BeautiDemise committed Sep 11, 2024
1 parent 1535eb0 commit 4bafbfd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ProjectMoonTRPG/ProjectMoonTRPG.html
Original file line number Diff line number Diff line change
Expand Up @@ -17614,6 +17614,11 @@ <h4 data-il18n-placeholder="editor-pw">Edit Mode Password</h4>
return "(" + AutoEffect.join(" ") + ")";
}

function hasOption(AutoEffect, optionName) {
let optionRegex = new RegExp(`(${optionName.replace("#","[0-9]+")})`, "ig");
return AutoEffect.some(option => optionRegex.test(option));
}

/* Whispers an error message to the user detailing an AutoEffect error */
function autoEffectErrorMessage(errorType, errorString, AutoEffect) {
AutoEffect = AutoEffect.join(" ").replace("Unknown: ","");
Expand Down Expand Up @@ -17860,8 +17865,8 @@ <h4 data-il18n-placeholder="editor-pw">Edit Mode Password</h4>

/* When using the target option, on a successful check, run the Consume again for the target to actually deduct the consumed ailment/bar value */
/* Also makes certain the Consume uses no ailment/bar value on the user */
if (returnValues.checkResult != "failure" && AutoEffect.some(option => (/(target)/ig).test(option))) {
returnValues.autoInflict = autoEffectToString(AutoEffect).replace(/(target)/ig,"").replace(/(scaling[0-9]+)/ig,"").replace(/([0-9]+)/ig, effectVal*scaling);
if (returnValues.checkResult != "failure" && hasOption(AutoEffect, "target")) {
returnValues.autoInflict = `(Consume 1 ${effectTarget} Scaling${effectVal*scaling} ${(hasOption(AutoEffect, "silent")) ? "Silent" : ""}) (Reset)` ;
delete returnValues[effectTarget];
delete returnValues.count;
}
Expand Down

0 comments on commit 4bafbfd

Please sign in to comment.