Update localization, add docs.
This commit is contained in:
parent
7ada67b7c3
commit
04bfe61f3f
2 changed files with 55 additions and 8 deletions
|
@ -157,5 +157,18 @@
|
|||
"DS4.UnitKilometers": "Kilometer",
|
||||
"DS4.UnitKilometersAbbr": "km",
|
||||
"DS4.UnitCustom": "individuell",
|
||||
"DS4.UnitCustomAbbr": " "
|
||||
"DS4.UnitCustomAbbr": " ",
|
||||
"DS4.RollDialogDefaultTitle": "Probenwerte",
|
||||
"DS4.RollDialogOkButton": "Ok",
|
||||
"DS4.RollDialogCancelButton": "Abbrechen",
|
||||
"DS4.HtmlTypeError": "Typfehler: Erwartet wurde {exType}, tatsächlich erhalten wurde {realType}",
|
||||
"DS4.RollDialogTargetLabel": "Probenwert",
|
||||
"DS4.RollDialogModifierLabel": "SL-Modifikator",
|
||||
"DS4.RollDialogCoupLabel": "Immersieg bis",
|
||||
"DS4.RollDialogFumbleLabel": "Patzer ab",
|
||||
"DS4.RollDialogVisibilityLabel": "Sichtbarkeit",
|
||||
"DS4.ChatVisibilityRoll": "Alle",
|
||||
"DS4.ChatVisibilityGmRoll": "Selbst & SL",
|
||||
"DS4.ChatVisibilityBlindRoll": "Nur SL",
|
||||
"DS4.ChatVisibilitySelfRoll": "Nur selbst"
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@ class DefaultCheckOptions implements DS4CheckFactoryOptions {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton reference for default value extraction.
|
||||
*/
|
||||
const defaultCheckOptions = new DefaultCheckOptions();
|
||||
|
||||
/**
|
||||
|
@ -73,7 +76,6 @@ class CheckFactory {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Figure out return of roll (void should be Ok, tough?)
|
||||
/**
|
||||
* Asks the user for all unknown/necessary information and passes them on to perform a roll.
|
||||
* @param targetValue {number} The Check Target Number ("CTN")
|
||||
|
@ -100,18 +102,18 @@ export async function createCheckRoll(targetValue: number, options: Partial<DS4C
|
|||
}
|
||||
|
||||
/**
|
||||
* Responsible for rendering the modal interface asking for the modifier specified by GM.
|
||||
* Responsible for rendering the modal interface asking for the modifier specified by GM and (currently) additional data.
|
||||
*
|
||||
* @notes
|
||||
* At the moment, this asks for more data than it will do after some iterations.
|
||||
*
|
||||
* @returns {Promise<number>} The number by the user.
|
||||
* @returns {Promise<IntermediateGmModifierData>} The data given by the user.
|
||||
*/
|
||||
async function askGmModifier(
|
||||
targetValue: number,
|
||||
options: Partial<DS4CheckFactoryOptions>,
|
||||
{ template, title }: { template?: string; title?: string } = {},
|
||||
): Promise<GmModifierData> {
|
||||
): Promise<IntermediateGmModifierData> {
|
||||
// Render model interface and return value
|
||||
const usedTemplate = template ?? "systems/ds4/templates/roll/roll-options.hbs";
|
||||
const usedTitle = title ?? game.i18n.localize("DS4.RollDialogDefaultTitle");
|
||||
|
@ -126,7 +128,6 @@ async function askGmModifier(
|
|||
};
|
||||
const renderedHtml = await renderTemplate(usedTemplate, templateData);
|
||||
|
||||
// TODO: Localize
|
||||
const dialogPromise = new Promise<HTMLFormElement>((resolve) => {
|
||||
new Dialog(
|
||||
{
|
||||
|
@ -168,7 +169,12 @@ async function askGmModifier(
|
|||
return parseDialogFormData(dialogForm, targetValue);
|
||||
}
|
||||
|
||||
function parseDialogFormData(formData: HTMLFormElement, targetValue: number): GmModifierData {
|
||||
/**
|
||||
* Extracts Dialog data from the returned DOM element.
|
||||
* @param formData {HTMLFormElement} The filed dialog
|
||||
* @param targetValue {number} The previously known target value (slated for removal once data automation is available)
|
||||
*/
|
||||
function parseDialogFormData(formData: HTMLFormElement, targetValue: number): IntermediateGmModifierData {
|
||||
return {
|
||||
checkTargetValue: parseInt(formData["ctv"]?.value) ?? targetValue,
|
||||
gmModifier: parseInt(formData["gmmod"]?.value) ?? 0,
|
||||
|
@ -179,8 +185,30 @@ function parseDialogFormData(formData: HTMLFormElement, targetValue: number): Gm
|
|||
};
|
||||
}
|
||||
|
||||
// TODO: Remove unnecessary data step by step
|
||||
/**
|
||||
* Contains data that needs retrieval from an interactive Dialog.
|
||||
*/
|
||||
interface GmModifierData {
|
||||
gmModifier: number;
|
||||
rollMode: DS4RollMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains *CURRENTLY* necessary Data for drafting a roll.
|
||||
*
|
||||
* @deprecated
|
||||
* Quite a lot of this information is requested due to a lack of automation:
|
||||
* - maxCritSuccess
|
||||
* - minCritFailure
|
||||
* - useSlayingDice
|
||||
* - checkTargetValue
|
||||
*
|
||||
* They will and should be removed once effects and data retrieval is in place.
|
||||
* If a "raw" roll dialog is necessary, create another pre-porcessing Dialog
|
||||
* class asking for the required information.
|
||||
* This interface should then be replaced with the `GmModifierData`.
|
||||
*/
|
||||
interface IntermediateGmModifierData extends GmModifierData {
|
||||
checkTargetValue: number;
|
||||
gmModifier: number;
|
||||
maxCritSuccess: number;
|
||||
|
@ -190,6 +218,9 @@ interface GmModifierData {
|
|||
rollMode: DS4RollMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* The minimum behavioural options that need to be passed to the factory.
|
||||
*/
|
||||
export interface DS4CheckFactoryOptions {
|
||||
maxCritSuccess: number;
|
||||
minCritFailure: number;
|
||||
|
@ -197,6 +228,9 @@ export interface DS4CheckFactoryOptions {
|
|||
rollMode: DS4RollMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines all possible roll modes, both for iterating and typing.
|
||||
*/
|
||||
const rollModes = ["roll", "gmroll", "blindroll", "selfroll"] as const;
|
||||
type DS4RollModeTuple = typeof rollModes;
|
||||
export type DS4RollMode = DS4RollModeTuple[number];
|
||||
|
|
Loading…
Reference in a new issue