Feature/683 damage dialog options (#735)

* Temp solution for specific weapon feature

* Add Serrated & Self-Correcting

* Remove comments
This commit is contained in:
Dapoulp 2025-08-10 01:20:24 +02:00 committed by GitHub
parent 1c000c7cfe
commit 585601c134
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 177 additions and 118 deletions

View file

@ -172,6 +172,26 @@ Roll.replaceFormulaData = function (formula, data = {}, { missing, warn = false
return nativeReplaceFormulaData(formula, data, { missing, warn });
};
foundry.dice.terms.Die.MODIFIERS.sc = "selfCorrecting";
/**
* Return the configured value as result if 1 is rolled
* Example: 6d6sc6 Roll 6d6, each result of 1 will be changed into 6
* @param {string} modifier The matched modifier query
*/
foundry.dice.terms.Die.prototype.selfCorrecting = function(modifier) {
const rgx = /(?:sc)([0-9]+)/i;
const match = modifier.match(rgx);
if ( !match ) return false;
let [target] = match.slice(1);
target = parseInt(target);
for ( const r of this.results ) {
if ( r.result === 1 ) {
r.result = target;
}
}
}
export const getDamageKey = damage => {
return ['none', 'minor', 'major', 'severe'][damage];
};