mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
Added support for d20 rolls
This commit is contained in:
parent
565f0f9e6f
commit
e7c3bcc362
6 changed files with 107 additions and 55 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import D20RollDialog from '../applications/dialogs/d20RollDialog.mjs';
|
||||
import D20Roll from './d20Roll.mjs';
|
||||
import { setDiceSoNiceForDualityRoll } from '../helpers/utils.mjs';
|
||||
import { getDiceSoNicePresets } from '../config/generalConfig.mjs';
|
||||
|
||||
export default class DualityRoll extends D20Roll {
|
||||
_advantageFaces = 6;
|
||||
|
|
@ -193,4 +194,53 @@ export default class DualityRoll extends D20Roll {
|
|||
|
||||
return data;
|
||||
}
|
||||
|
||||
static async reroll(rollString, target, message) {
|
||||
let parsedRoll = game.system.api.dice.DualityRoll.fromData({ ...rollString, evaluated: false });
|
||||
const term = parsedRoll.terms[target.dataset.dieIndex];
|
||||
await term.reroll(`/r1=${term.total}`);
|
||||
if (game.modules.get('dice-so-nice')?.active) {
|
||||
const diceSoNiceRoll = {
|
||||
_evaluated: true,
|
||||
dice: [
|
||||
new foundry.dice.terms.Die({
|
||||
...term,
|
||||
faces: term._faces,
|
||||
results: term.results.filter(x => !x.rerolled)
|
||||
})
|
||||
],
|
||||
options: { appearance: {} }
|
||||
};
|
||||
const diceSoNicePresets = getDiceSoNicePresets();
|
||||
switch (target.dataset.type) {
|
||||
case 'hope':
|
||||
diceSoNiceRoll.dice[0].options = { appearance: diceSoNicePresets.hope };
|
||||
break;
|
||||
case 'fear':
|
||||
diceSoNiceRoll.dice[0].options = { appearance: diceSoNicePresets.fear };
|
||||
break;
|
||||
case 'advantage':
|
||||
diceSoNiceRoll.dice[0].options = { appearance: diceSoNicePresets.advantage };
|
||||
break;
|
||||
case 'disadvantage':
|
||||
diceSoNiceRoll.dice[0].options = { appearance: diceSoNicePresets.disadvantage };
|
||||
break;
|
||||
}
|
||||
|
||||
await game.dice3d.showForRoll(diceSoNiceRoll, game.user, true);
|
||||
}
|
||||
|
||||
await parsedRoll.evaluate();
|
||||
|
||||
const newRoll = game.system.api.dice.DualityRoll.postEvaluate(parsedRoll, {
|
||||
targets: message.system.targets,
|
||||
roll: {
|
||||
advantage: message.system.roll.advantage?.type,
|
||||
difficulty: message.system.roll.difficulty ? Number(message.system.roll.difficulty) : null
|
||||
}
|
||||
});
|
||||
newRoll.extra = newRoll.extra.slice(2);
|
||||
|
||||
return { newRoll, parsedRoll };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue