Fix: jets d'encaissement forcés par le Gardien

Les jets d'encaissement forcés par le gardien ne peuvent plus donner
le deuxième d10 négatif si le MJ force un résultat inférieur à 11
This commit is contained in:
Vincent Vandemeulebrouck 2023-11-20 00:37:43 +01:00
parent bfd3b0d74a
commit c1a5bd6eb3

View File

@ -197,48 +197,25 @@ export class RdDDice {
function terms1d100(total) {
const unites = total % 10;
const dizaines = Math.floor(total / 10);
return [{
resultLabel: dizaines * 10,
d100Result: total,
result: dizaines,
type: "d100",
vectors: [],
options: {}
},
{
resultLabel: unites,
d100Result: total,
result: unites,
type: "d10",
vectors: [],
options: {}
}];
return [
{ type: "d100", result: dizaines, resultLabel: dizaines * 10, vectors: [], options: {}, d100Result: total },
{ type: "d10", result: unites, resultLabel: unites, vectors: [], options: {}, d100Result: total }
];
}
async function terms2d10(total) {
if (total > 20 || total < 2) { return undefined }
let first = await RdDDice.d10();
let second = Math.min(total-first, 10);
first = Math.max(first, total-second);
return [{
resultLabel:first,
result: first,
type: "d10",
vectors: [],
options: {}
},
{
resultLabel: second,
result: second,
type: "d10",
vectors: [],
options: {}
}];
const first = await RdDDice.fakeD10(Math.min(10, total - 1));
const second = total - first;
return [
{ type: "d10", result: first, resultLabel: first, vectors: [], options: {} },
{ type: "d10", result: second, resultLabel: second, vectors: [], options: {} }
];
}
}
static async d10() {
let roll = new Roll('1d10');
static async fakeD10(faces) {
let roll = new Roll(`1d${faces}`);
await roll.evaluate({ async: true });
return roll.total;
}