Small cleanup

This commit is contained in:
Johannes Loher 2021-03-14 14:52:50 +01:00
parent eb0866cfa7
commit 919091a211

View file

@ -61,33 +61,25 @@ export class DS4Check extends DiceTerm {
minimumFumbleResult = DS4Check.DEFAULT_MINIMUM_FUMBLE_RESULT;
maximumCoupResult = DS4Check.DEFAULT_MAXIMUM_COUP_RESULT;
/**
* @override
*/
/** @override */
get expression(): string {
return `ds${this.modifiers.join("")}`;
}
/**
* @override
*/
/** @override */
get total(): number | null {
if (this.fumble) return 0;
return super.total;
}
/**
* @override
*/
/** @override */
evaluate({ minimize = false, maximize = false } = {}): this {
super.evaluate({ minimize, maximize });
this.evaluateResults();
return this;
}
/**
* @override
*/
/** @override */
roll({ minimize = false, maximize = false } = {}): DiceTerm.Result {
// Swap minimize / maximize because in DS4, the best possible roll is a 1 and the worst possible roll is a 20
return super.roll({ minimize: maximize, maximize: minimize });
@ -105,10 +97,12 @@ export class DS4Check extends DiceTerm {
this.fumble = results[0].failure ?? false;
}
/**
* @override
*/
static fromResults(options: Partial<DiceTerm.TermData>, results: DiceTerm.Result[]): DS4Check {
/** @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();