Merged with main

This commit is contained in:
WBHarry 2025-07-25 01:14:41 +02:00
commit f0a809266d
70 changed files with 1245 additions and 881 deletions

View file

@ -1,4 +1,5 @@
import D20RollDialog from '../applications/dialogs/d20RollDialog.mjs';
import { getDiceSoNicePresets } from '../config/generalConfig.mjs';
import DHRoll from './dhRoll.mjs';
export default class D20Roll extends DHRoll {
@ -156,6 +157,14 @@ export default class D20Roll extends DHRoll {
dice: roll.dAdvantage?.denomination,
value: roll.dAdvantage?.total
};
data.dice = data.dice.map(dice => ({
...dice,
results: dice.results.filter(x => !x.rerolled),
rerolled: {
any: dice.results.some(x => x.rerolled),
rerolls: dice.results.filter(x => x.rerolled)
}
}));
data.isCritical = roll.isCritical;
data.extra = roll.dice
.filter(d => !roll.baseTerms.includes(d))
@ -188,6 +197,26 @@ export default class D20Roll extends DHRoll {
await game.dice3d.showForRoll(parsedRoll, game.user, true);
}
return { newRoll, parsedRoll };
const rerolled = {
any: true,
rerolls: [
...(message.system.roll.dice[0].rerolled?.rerolls?.length > 0
? [message.system.roll.dice[0].rerolled?.rerolls]
: []),
rollString.terms[0].results
]
};
return {
newRoll: {
...newRoll,
dice: [
{
...newRoll.dice[0],
rerolled: rerolled
}
]
},
parsedRoll
};
}
}

View file

@ -12,6 +12,7 @@ export default class DamageRoll extends DHRoll {
static async buildEvaluate(roll, config = {}, message = {}) {
if (config.evaluate !== false) {
if (config.dialog.configure === false) roll.constructFormula(config);
for (const roll of config.roll) await roll.roll.evaluate();
}
roll._evaluated = true;

View file

@ -56,13 +56,13 @@ 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 (config.source?.message) {
if (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 (game.modules.get('dice-so-nice')?.active) await game.dice3d.showForRoll(roll, game.user, true);
} else config.message = await this.toMessage(roll, config);
}
@ -193,6 +193,11 @@ export const registerRollDiceHooks = () => {
if (config.roll.isCritical) updates.push({ key: 'stress', value: -1 });
if (config.roll.result.duality === -1) updates.push({ key: 'fear', value: 1 });
if (config.rerolledRoll.isCritical || config.rerolledRoll.result.duality === 1)
updates.push({ key: 'hope', value: -1 });
if (config.rerolledRoll.isCritical) updates.push({ key: 'stress', value: 1 });
if (config.rerolledRoll.result.duality === -1) updates.push({ key: 'fear', value: -1 });
if (updates.length) {
const target = actor.system.partner ?? actor;
if (!['dead', 'unconcious'].some(x => actor.statuses.has(x))) {

View file

@ -171,11 +171,19 @@ export default class DualityRoll extends D20Roll {
data.hope = {
dice: roll.dHope.denomination,
value: roll.dHope.total
value: roll.dHope.total,
rerolled: {
any: roll.dHope.results.some(x => x.rerolled),
rerolls: roll.dHope.results.filter(x => x.rerolled)
}
};
data.fear = {
dice: roll.dFear.denomination,
value: roll.dFear.total
value: roll.dFear.total,
rerolled: {
any: roll.dFear.results.some(x => x.rerolled),
rerolls: roll.dFear.results.filter(x => x.rerolled)
}
};
data.rally = {
dice: roll.dRally?.denomination,
@ -232,6 +240,13 @@ export default class DualityRoll extends D20Roll {
});
newRoll.extra = newRoll.extra.slice(2);
Hooks.call(`${CONFIG.DH.id}.postRollDuality`, {
source: { actor: message.system.source.actor ?? '' },
targets: message.system.targets,
roll: newRoll,
rerolledRoll:
newRoll.result.duality !== message.system.roll.result.duality ? message.system.roll : undefined
});
return { newRoll, parsedRoll };
}
}