Fix DS4Check for 0.8.x

This commit is contained in:
Johannes Loher 2021-07-01 00:36:41 +02:00
parent 61b757ae8f
commit 8f7f6af359
4 changed files with 21180 additions and 1549 deletions

20082
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -86,11 +86,7 @@ function shouldUseCoupForLastSubCheck(
);
}
interface SubCheckResult extends DieWithSubCheck, DiceTerm.Result {
success?: boolean;
failure?: boolean;
count?: number;
}
interface SubCheckResult extends DieWithSubCheck, DiceTerm.Result {}
function evaluateDiceWithSubChecks(
results: DieWithSubCheck[],

View file

@ -15,11 +15,12 @@ import evaluateCheck, { getRequiredNumberOfDice } from "./check-evaluation";
* - Roll a check with a racial ability that makes `5` a coup and default fumble: `/r dsv19c5`
*/
export class DS4Check extends DiceTerm {
constructor({ modifiers = [], options }: Partial<DiceTerm.TermData> = {}) {
constructor({ modifiers = [], results = [], options }: Partial<DiceTerm.TermData> = {}) {
super({
faces: 20,
modifiers: modifiers,
options: options,
results,
modifiers,
options,
});
// Parse and store check target number
@ -57,6 +58,10 @@ export class DS4Check extends DiceTerm {
if (noFumbleModifier) {
this.canFumble = false;
}
if (this.results.length > 0) {
this.evaluateResults();
}
}
coup: boolean | null = null;
@ -78,8 +83,8 @@ export class DS4Check extends DiceTerm {
}
/** @override */
evaluate({ minimize = false, maximize = false } = {}): this {
super.evaluate({ minimize, maximize });
_evaluateSync({ minimize = false, maximize = false } = {}): this {
super._evaluateSync({ minimize, maximize });
this.evaluateResults();
return this;
}
@ -102,19 +107,6 @@ export class DS4Check extends DiceTerm {
this.fumble = results[0].failure ?? false;
}
/** @override */
static fromResults<T extends DS4Check>(
this: ConstructorOf<T>,
options: Partial<DiceTerm.TermData>,
results: DiceTerm.Result[],
): T {
const term = new this(options);
term.results = results;
term.evaluateResults();
term._evaluated = true;
return term;
}
static readonly DEFAULT_CHECK_TARGET_NUMBER = 10;
static readonly DEFAULT_MAXIMUM_COUP_RESULT = 1;
static readonly DEFAULT_MINIMUM_FUMBLE_RESULT = 20;

2613
yarn.lock

File diff suppressed because it is too large Load diff