v11.2.0 - Les Terres médianes d'Akarlikarlikar #683

Merged
uberwald merged 7 commits from VincentVk/foundryvtt-reve-de-dragon:v11 into v11 2023-11-20 07:04:11 +01:00
Showing only changes of commit c1a5bd6eb3 - Show all commits

View File

@ -164,7 +164,7 @@ export class RdDDice {
if (options.showDice == HIDE_DICE || !game.modules.get("dice-so-nice")?.active || !game.dice3d) { if (options.showDice == HIDE_DICE || !game.modules.get("dice-so-nice")?.active || !game.dice3d) {
return; return;
} }
let { whisper, blind } = RdDDice._getWhisperBlind(options); let { whisper, blind } = RdDDice._getWhisperBlind(options);
if (options.forceDiceResult?.total) { if (options.forceDiceResult?.total) {
let terms = await RdDDice._getForcedTerms(options); let terms = await RdDDice._getForcedTerms(options);
@ -197,48 +197,25 @@ export class RdDDice {
function terms1d100(total) { function terms1d100(total) {
const unites = total % 10; const unites = total % 10;
const dizaines = Math.floor(total / 10); const dizaines = Math.floor(total / 10);
return [{ return [
resultLabel: dizaines * 10, { type: "d100", result: dizaines, resultLabel: dizaines * 10, vectors: [], options: {}, d100Result: total },
d100Result: total, { type: "d10", result: unites, resultLabel: unites, vectors: [], options: {}, d100Result: total }
result: dizaines, ];
type: "d100",
vectors: [],
options: {}
},
{
resultLabel: unites,
d100Result: total,
result: unites,
type: "d10",
vectors: [],
options: {}
}];
} }
async function terms2d10(total) { async function terms2d10(total) {
if (total>20 || total<2) { return undefined } if (total > 20 || total < 2) { return undefined }
let first = await RdDDice.d10(); const first = await RdDDice.fakeD10(Math.min(10, total - 1));
let second = Math.min(total-first, 10); const second = total - first;
first = Math.max(first, total-second); return [
return [{ { type: "d10", result: first, resultLabel: first, vectors: [], options: {} },
resultLabel:first, { type: "d10", result: second, resultLabel: second, vectors: [], options: {} }
result: first, ];
type: "d10",
vectors: [],
options: {}
},
{
resultLabel: second,
result: second,
type: "d10",
vectors: [],
options: {}
}];
} }
} }
static async d10() { static async fakeD10(faces) {
let roll = new Roll('1d10'); let roll = new Roll(`1d${faces}`);
await roll.evaluate({ async: true }); await roll.evaluate({ async: true });
return roll.total; return roll.total;
} }