mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 23:49:02 +01:00
h
This commit is contained in:
parent
b3984a8e5f
commit
7e382d2e08
9 changed files with 52 additions and 61 deletions
|
|
@ -10,10 +10,19 @@ export default class DamageRoll extends DHRoll {
|
|||
|
||||
static DefaultDialog = DamageDialog;
|
||||
|
||||
static async postEvaluate(roll, config = {}) {
|
||||
super.postEvaluate(roll, config);
|
||||
config.roll.type = config.type;
|
||||
config.roll.modifierTotal = this.calculateTotalModifiers(roll);
|
||||
static async buildEvaluate(rolls, config = {}, message = {}) {
|
||||
if ( config.evaluate !== false ) {
|
||||
for ( const roll of config.roll ) await roll.roll.evaluate();
|
||||
}
|
||||
config.roll = config.roll.map(r => this.postEvaluate(r.roll));
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
return {
|
||||
...super.postEvaluate(roll, config),
|
||||
type: config.type,
|
||||
modifierTotal: this.calculateTotalModifiers(roll)
|
||||
}
|
||||
}
|
||||
|
||||
static async buildPost(roll, config, message) {
|
||||
|
|
@ -75,38 +84,4 @@ export default class DamageRoll extends DHRoll {
|
|||
}
|
||||
return (part.roll._formula = this.constructor.getFormula(part.roll.terms));
|
||||
}
|
||||
|
||||
async evaluate({minimize=false, maximize=false, allowStrings=false, allowInteractive=true, ...options}={}) {
|
||||
if ( this._evaluated ) {
|
||||
throw new Error(`The ${this.constructor.name} has already been evaluated and is now immutable`);
|
||||
}
|
||||
this._evaluated = true;
|
||||
if ( CONFIG.debug.dice ) console.debug(`Evaluating roll with formula "${this.formula}"`);
|
||||
|
||||
// Migration path for async rolls
|
||||
if ( "async" in options ) {
|
||||
foundry.utils.logCompatibilityWarning("The async option for Roll#evaluate has been removed. "
|
||||
+ "Use Roll#evaluateSync for synchronous roll evaluation.");
|
||||
}
|
||||
|
||||
this.options.roll.forEach( async part => {
|
||||
await part.roll.evaluate({minimize, maximize, allowStrings, allowInteractive, ...options})
|
||||
})
|
||||
// return this._evaluate({minimize, maximize, allowStrings, allowInteractive});
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
if (!config.roll) config.roll = {};
|
||||
config.roll.total = roll.total;
|
||||
config.roll.formula = roll.formula;
|
||||
config.roll.dice = [];
|
||||
roll.dice.forEach(d => {
|
||||
config.roll.dice.push({
|
||||
dice: d.denomination,
|
||||
total: d.total,
|
||||
formula: d.formula,
|
||||
results: d.results
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ export default class DHRoll extends Roll {
|
|||
|
||||
// Create Chat Message
|
||||
if (config.source?.message) {
|
||||
if(Array.isArray(config.roll)) {
|
||||
const pool = foundry.dice.terms.PoolTerm.fromRolls(config.roll);
|
||||
roll = Roll.fromTerms([pool]);
|
||||
}
|
||||
if (game.modules.get('dice-so-nice')?.active) await game.dice3d.showForRoll(roll, game.user, true);
|
||||
} else {
|
||||
config.message = await this.toMessage(roll, config);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue