From c94ff4a67acaa457a87e32d19516a21874ef8e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Sat, 9 Jan 2021 23:21:57 +0100 Subject: [PATCH] Rudimentary docs. --- src/module/rolls/check-factory.ts | 36 ++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/module/rolls/check-factory.ts b/src/module/rolls/check-factory.ts index a7a718d9..43b06927 100644 --- a/src/module/rolls/check-factory.ts +++ b/src/module/rolls/check-factory.ts @@ -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 { - return { ...this, ...other } as CheckOptions; + mergeWith(other: Partial): 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 = {}, + passedOptions: Partial = {}, ) { this.checkOptions = new DefaultCheckOptions().mergeWith(passedOptions); } - private checkOptions: CheckOptions; + private checkOptions: DS4CheckFactoryOptions; async execute(): Promise { 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): Promise { +/** + * 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} Options changing the behaviour of the roll and message. + */ +export async function createCheckRoll(targetValue: number, options: Partial): Promise { // Ask for additional required data; const gmModifier = await askGmModifier(); @@ -78,16 +89,21 @@ export async function createCheckRoll(targetValue: number, options: Partial} The number by the user. + */ async function askGmModifier(): Promise { // 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";