2021-01-02 16:12:16 +01:00
|
|
|
export interface RollOptions {
|
2021-01-08 23:18:01 +01:00
|
|
|
maxCritSuccess: number;
|
2021-01-02 16:12:16 +01:00
|
|
|
minCritFail: number;
|
|
|
|
useSlayingDice: boolean;
|
|
|
|
slayingDiceRepetition: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class DefaultRollOptions implements RollOptions {
|
2021-01-08 23:18:01 +01:00
|
|
|
public maxCritSuccess = 1;
|
2021-01-02 16:12:16 +01:00
|
|
|
public minCritFail = 20;
|
|
|
|
public useSlayingDice = false;
|
|
|
|
public slayingDiceRepetition = false;
|
|
|
|
|
|
|
|
mergeWith(other: Partial<RollOptions>): RollOptions {
|
|
|
|
return { ...this, ...other } as RollOptions;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class RollResult {
|
2021-01-06 18:27:22 +01:00
|
|
|
constructor(
|
2021-01-07 02:26:09 +01:00
|
|
|
public result: number,
|
2021-01-06 18:27:22 +01:00
|
|
|
public status: RollResultStatus,
|
|
|
|
public dice: Array<number>,
|
|
|
|
public active: boolean = true,
|
2021-01-06 19:15:56 +01:00
|
|
|
public exploded: boolean = false,
|
2021-01-07 02:26:09 +01:00
|
|
|
) {
|
|
|
|
if (this.status == RollResultStatus.CRITICAL_FAILURE) {
|
|
|
|
this.failure = true;
|
|
|
|
} else if (this.status == RollResultStatus.CRITICAL_SUCCESS) {
|
|
|
|
this.success = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public failure: boolean | void = undefined;
|
|
|
|
public success: boolean | void = undefined;
|
2021-01-02 16:12:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export enum RollResultStatus {
|
2021-01-07 02:33:22 +01:00
|
|
|
FAILURE = "FAILURE",
|
|
|
|
SUCCESS = "SUCCESS",
|
|
|
|
CRITICAL_FAILURE = "CRITICAL_FAILURE",
|
|
|
|
CRITICAL_SUCCESS = "CRITICAL_SUCCESS",
|
2021-01-02 16:12:16 +01:00
|
|
|
}
|