Rudimentary docs.
This commit is contained in:
parent
27c0ddbca1
commit
c94ff4a67a
1 changed files with 26 additions and 10 deletions
|
@ -1,26 +1,32 @@
|
||||||
// TODO: Rename to something sane.
|
// TODO: Rename to something sane.
|
||||||
|
|
||||||
class DefaultCheckOptions implements CheckOptions {
|
/**
|
||||||
|
* Provides default values for all arguments the `CheckFactory` expects.
|
||||||
|
*/
|
||||||
|
class DefaultCheckOptions implements DS4CheckFactoryOptions {
|
||||||
maxCritSuccess = 1;
|
maxCritSuccess = 1;
|
||||||
minCritFailure = 20;
|
minCritFailure = 20;
|
||||||
useSlayingDice = false;
|
useSlayingDice = false;
|
||||||
rollMode: RollMode = "roll";
|
rollMode: DS4RollMode = "roll";
|
||||||
|
|
||||||
mergeWith(other: Partial<CheckOptions>): CheckOptions {
|
mergeWith(other: Partial<DS4CheckFactoryOptions>): DS4CheckFactoryOptions {
|
||||||
return { ...this, ...other } as CheckOptions;
|
return { ...this, ...other } as DS4CheckFactoryOptions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Most basic class responsible for generating the chat formula and passing it to the chat as roll.
|
||||||
|
*/
|
||||||
class CheckFactory {
|
class CheckFactory {
|
||||||
constructor(
|
constructor(
|
||||||
private checkTargetValue: number,
|
private checkTargetValue: number,
|
||||||
private gmModifier: number,
|
private gmModifier: number,
|
||||||
passedOptions: Partial<CheckOptions> = {},
|
passedOptions: Partial<DS4CheckFactoryOptions> = {},
|
||||||
) {
|
) {
|
||||||
this.checkOptions = new DefaultCheckOptions().mergeWith(passedOptions);
|
this.checkOptions = new DefaultCheckOptions().mergeWith(passedOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkOptions: CheckOptions;
|
private checkOptions: DS4CheckFactoryOptions;
|
||||||
|
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
const rollCls: typeof Roll = CONFIG.Dice.rolls[0];
|
const rollCls: typeof Roll = CONFIG.Dice.rolls[0];
|
||||||
|
@ -65,7 +71,12 @@ class CheckFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Figure out return of roll (void should be Ok, tough?)
|
// TODO: Figure out return of roll (void should be Ok, tough?)
|
||||||
export async function createCheckRoll(targetValue: number, options: Partial<CheckOptions>): Promise<void> {
|
/**
|
||||||
|
* Asks the user for all unknown/necessary information and passes them on to perform a roll.
|
||||||
|
* @param targetValue {number} The Check Target Number ("CTN")
|
||||||
|
* @param options {Partial<DS4CheckFactoryOptions>} Options changing the behaviour of the roll and message.
|
||||||
|
*/
|
||||||
|
export async function createCheckRoll(targetValue: number, options: Partial<DS4CheckFactoryOptions>): Promise<void> {
|
||||||
// Ask for additional required data;
|
// Ask for additional required data;
|
||||||
const gmModifier = await askGmModifier();
|
const gmModifier = await askGmModifier();
|
||||||
|
|
||||||
|
@ -78,16 +89,21 @@ export async function createCheckRoll(targetValue: number, options: Partial<Chec
|
||||||
await cf.execute();
|
await cf.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Responsible for rendering the modal interface asking for the modifier specified by GM.
|
||||||
|
*
|
||||||
|
* @returns {Promise<number>} The number by the user.
|
||||||
|
*/
|
||||||
async function askGmModifier(): Promise<number> {
|
async function askGmModifier(): Promise<number> {
|
||||||
// Render model interface and return value
|
// Render model interface and return value
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CheckOptions {
|
export interface DS4CheckFactoryOptions {
|
||||||
maxCritSuccess: number;
|
maxCritSuccess: number;
|
||||||
minCritFailure: number;
|
minCritFailure: number;
|
||||||
useSlayingDice: boolean;
|
useSlayingDice: boolean;
|
||||||
rollMode: RollMode;
|
rollMode: DS4RollMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
type RollMode = "roll" | "gmroll" | "blindroll" | "selfroll";
|
export type DS4RollMode = "roll" | "gmroll" | "blindroll" | "selfroll";
|
||||||
|
|
Loading…
Reference in a new issue