Rudimentary docs.

This commit is contained in:
Oliver Rümpelein 2021-01-09 23:21:57 +01:00
parent 27c0ddbca1
commit c94ff4a67a

View file

@ -1,26 +1,32 @@
// TODO: Rename to something sane.
class DefaultCheckOptions implements CheckOptions {
/**
* Provides default values for all arguments the `CheckFactory` expects.
*/
class DefaultCheckOptions implements DS4CheckFactoryOptions {
maxCritSuccess = 1;
minCritFailure = 20;
useSlayingDice = false;
rollMode: RollMode = "roll";
rollMode: DS4RollMode = "roll";
mergeWith(other: Partial<CheckOptions>): CheckOptions {
return { ...this, ...other } as CheckOptions;
mergeWith(other: Partial<DS4CheckFactoryOptions>): DS4CheckFactoryOptions {
return { ...this, ...other } as DS4CheckFactoryOptions;
}
}
/**
* Most basic class responsible for generating the chat formula and passing it to the chat as roll.
*/
class CheckFactory {
constructor(
private checkTargetValue: number,
private gmModifier: number,
passedOptions: Partial<CheckOptions> = {},
passedOptions: Partial<DS4CheckFactoryOptions> = {},
) {
this.checkOptions = new DefaultCheckOptions().mergeWith(passedOptions);
}
private checkOptions: CheckOptions;
private checkOptions: DS4CheckFactoryOptions;
async execute(): Promise<void> {
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?)
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;
const gmModifier = await askGmModifier();
@ -78,16 +89,21 @@ export async function createCheckRoll(targetValue: number, options: Partial<Chec
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> {
// Render model interface and return value
return 0;
}
interface CheckOptions {
export interface DS4CheckFactoryOptions {
maxCritSuccess: number;
minCritFailure: number;
useSlayingDice: boolean;
rollMode: RollMode;
rollMode: DS4RollMode;
}
type RollMode = "roll" | "gmroll" | "blindroll" | "selfroll";
export type DS4RollMode = "roll" | "gmroll" | "blindroll" | "selfroll";