mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
Fix damage & healing roll
This commit is contained in:
parent
57f19c41cd
commit
a25dbb462c
19 changed files with 200 additions and 60 deletions
|
|
@ -6,19 +6,20 @@ export default class DamageRoll extends DHRoll {
|
|||
super(formula, data, options);
|
||||
}
|
||||
|
||||
static messageType = 'damageRoll';
|
||||
static messageType = 'dualityRoll';
|
||||
|
||||
static DefaultDialog = DamageDialog;
|
||||
|
||||
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||
if (config.evaluate !== false) {
|
||||
// if (config.dialog.configure === false) roll.constructFormula(config);
|
||||
console.log(roll,config)
|
||||
if (config.evaluate !== false)
|
||||
for (const roll of config.roll) await roll.roll.evaluate();
|
||||
}
|
||||
|
||||
roll._evaluated = true;
|
||||
const parts = config.roll.map(r => this.postEvaluate(r));
|
||||
|
||||
config.roll = this.unifyDamageRoll(parts);
|
||||
config.damage = this.unifyDamageRoll(parts);
|
||||
config.targetSelection = config.targets?.length
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
|
|
@ -32,14 +33,6 @@ export default class DamageRoll extends DHRoll {
|
|||
};
|
||||
}
|
||||
|
||||
static async buildPost(roll, config, message) {
|
||||
await super.buildPost(roll, config, message);
|
||||
if (config.source?.message) {
|
||||
const chatMessage = ui.chat.collection.get(config.source.message);
|
||||
chatMessage.update({ 'system.damage': config });
|
||||
}
|
||||
}
|
||||
|
||||
static unifyDamageRoll(rolls) {
|
||||
const unified = {};
|
||||
rolls.forEach(r => {
|
||||
|
|
|
|||
|
|
@ -52,8 +52,10 @@ 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);
|
||||
if (config.evaluate !== false) {
|
||||
await roll.evaluate();
|
||||
config.roll = this.postEvaluate(roll, config);
|
||||
}
|
||||
}
|
||||
|
||||
static async buildPost(roll, config, message) {
|
||||
|
|
@ -62,15 +64,24 @@ export default class DHRoll extends Roll {
|
|||
}
|
||||
|
||||
// Create Chat Message
|
||||
if (roll instanceof CONFIG.Dice.daggerheart.DamageRoll && Object.values(config.roll)?.length) {
|
||||
const pool = foundry.dice.terms.PoolTerm.fromRolls(
|
||||
Object.values(config.roll).flatMap(r => r.parts.map(p => p.roll))
|
||||
);
|
||||
roll = Roll.fromTerms([pool]);
|
||||
}
|
||||
// if (roll instanceof CONFIG.Dice.daggerheart.DamageRoll && Object.values(config.roll)?.length) {
|
||||
// const pool = foundry.dice.terms.PoolTerm.fromRolls(
|
||||
// Object.values(config.roll).flatMap(r => r.parts.map(p => p.roll))
|
||||
// );
|
||||
// roll = Roll.fromTerms([pool]);
|
||||
// }
|
||||
if (config.source?.message) {
|
||||
if (game.modules.get('dice-so-nice')?.active) await game.dice3d.showForRoll(roll, game.user, true);
|
||||
} else config.message = await this.toMessage(roll, config);
|
||||
const chatMessage = ui.chat.collection.get(config.source.message);
|
||||
chatMessage.update({ 'system.damage': config.damage });
|
||||
} else {
|
||||
console.log(roll, config)
|
||||
config.message = await this.toMessage(roll, config);
|
||||
// if(roll._evaluated) {
|
||||
// const cls = getDocumentClass('ChatMessage');
|
||||
// await cls.create(config.message, { rollMode: config.selectedRollMode });
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
|
|
@ -97,7 +108,11 @@ export default class DHRoll extends Roll {
|
|||
system: config,
|
||||
rolls: [roll]
|
||||
};
|
||||
return await cls.create(msg, { rollMode: config.selectedRollMode });
|
||||
// msg.applyRollMode(config.selectedRollMode);
|
||||
// return msg;
|
||||
if(roll._evaluated) return await cls.create(msg, { rollMode: config.selectedRollMode });
|
||||
return msg;
|
||||
// return await cls.create(msg);
|
||||
}
|
||||
|
||||
static applyKeybindings(config) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue