mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Added remaining options and fixed secure loading of dice models (#413)
This commit is contained in:
parent
dddee78356
commit
bf31ced3df
11 changed files with 167 additions and 100 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import D20RollDialog from '../applications/dialogs/d20RollDialog.mjs';
|
||||
import { getDiceSoNicePresets } from '../config/generalConfig.mjs';
|
||||
import DHRoll from './dhRoll.mjs';
|
||||
|
||||
export default class D20Roll extends DHRoll {
|
||||
|
|
@ -141,8 +140,8 @@ export default class D20Roll extends DHRoll {
|
|||
return modifiers;
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
const data = super.postEvaluate(roll, config);
|
||||
static async postEvaluate(roll, config = {}) {
|
||||
const data = await super.postEvaluate(roll, config);
|
||||
if (config.targets?.length) {
|
||||
config.targets.forEach(target => {
|
||||
const difficulty = config.roll.difficulty ?? target.difficulty ?? target.evasion;
|
||||
|
|
@ -185,7 +184,7 @@ export default class D20Roll extends DHRoll {
|
|||
static async reroll(rollString, _target, message) {
|
||||
let parsedRoll = game.system.api.dice.D20Roll.fromData(rollString);
|
||||
parsedRoll = await parsedRoll.reroll();
|
||||
const newRoll = game.system.api.dice.D20Roll.postEvaluate(parsedRoll, {
|
||||
const newRoll = await game.system.api.dice.D20Roll.postEvaluate(parsedRoll, {
|
||||
targets: message.system.targets,
|
||||
roll: {
|
||||
advantage: message.system.roll.advantage?.type,
|
||||
|
|
|
|||
|
|
@ -16,14 +16,19 @@ export default class DamageRoll extends DHRoll {
|
|||
for (const roll of config.roll) await roll.roll.evaluate();
|
||||
}
|
||||
roll._evaluated = true;
|
||||
const parts = config.roll.map(r => this.postEvaluate(r));
|
||||
const parts = [];
|
||||
for (let r of config.roll) {
|
||||
const part = this.postEvaluate(r);
|
||||
parts.push(part);
|
||||
}
|
||||
|
||||
config.roll = this.unifyDamageRoll(parts);
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
static async postEvaluate(roll, config = {}) {
|
||||
return {
|
||||
...roll,
|
||||
...super.postEvaluate(roll.roll, config),
|
||||
...(await super.postEvaluate(roll.roll, config)),
|
||||
damageTypes: [...(roll.damageTypes ?? [])],
|
||||
roll: roll.roll,
|
||||
type: config.type,
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ export default class DHRoll extends Roll {
|
|||
|
||||
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||
if (config.evaluate !== false) await roll.evaluate();
|
||||
config.roll = this.postEvaluate(roll, config);
|
||||
config.roll = await this.postEvaluate(roll, config);
|
||||
}
|
||||
|
||||
static async buildPost(roll, config, message) {
|
||||
|
|
@ -67,7 +67,7 @@ export default class DHRoll extends Roll {
|
|||
} else config.message = await this.toMessage(roll, config);
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
static async postEvaluate(roll, config = {}) {
|
||||
return {
|
||||
total: roll.total,
|
||||
formula: roll.formula,
|
||||
|
|
|
|||
|
|
@ -166,8 +166,8 @@ export default class DualityRoll extends D20Roll {
|
|||
return modifiers;
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
const data = super.postEvaluate(roll, config);
|
||||
static async postEvaluate(roll, config = {}) {
|
||||
const data = await super.postEvaluate(roll, config);
|
||||
|
||||
data.hope = {
|
||||
dice: roll.dHope.denomination,
|
||||
|
|
@ -198,7 +198,13 @@ export default class DualityRoll extends D20Roll {
|
|||
if (roll._rallyIndex && roll.data?.parent)
|
||||
roll.data.parent.deleteEmbeddedDocuments('ActiveEffect', [roll._rallyIndex]);
|
||||
|
||||
setDiceSoNiceForDualityRoll(roll, data.advantage.type);
|
||||
await setDiceSoNiceForDualityRoll(
|
||||
roll,
|
||||
data.advantage.type,
|
||||
data.hope.dice,
|
||||
data.fear.dice,
|
||||
data.advantage.dice
|
||||
);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
@ -220,10 +226,10 @@ export default class DualityRoll extends D20Roll {
|
|||
options: { appearance: {} }
|
||||
};
|
||||
|
||||
const diceSoNicePresets = getDiceSoNicePresets();
|
||||
const diceSoNicePresets = await getDiceSoNicePresets();
|
||||
const type = target.dataset.type;
|
||||
if (diceSoNicePresets[type]) {
|
||||
diceSoNiceRoll.dice[0].options = { appearance: diceSoNicePresets[type] };
|
||||
diceSoNiceRoll.dice[0].options = diceSoNicePresets[type];
|
||||
}
|
||||
|
||||
await game.dice3d.showForRoll(diceSoNiceRoll, game.user, true);
|
||||
|
|
@ -231,7 +237,7 @@ export default class DualityRoll extends D20Roll {
|
|||
|
||||
await parsedRoll.evaluate();
|
||||
|
||||
const newRoll = game.system.api.dice.DualityRoll.postEvaluate(parsedRoll, {
|
||||
const newRoll = await game.system.api.dice.DualityRoll.postEvaluate(parsedRoll, {
|
||||
targets: message.system.targets,
|
||||
roll: {
|
||||
advantage: message.system.roll.advantage?.type,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue