diff --git a/system/scripts/dice/dice-picker-dialog.js b/system/scripts/dice/dice-picker-dialog.js index e8df1c9..8a71dd6 100644 --- a/system/scripts/dice/dice-picker-dialog.js +++ b/system/scripts/dice/dice-picker-dialog.js @@ -2,6 +2,7 @@ * L5R Dice picker dialog * @extends {FormApplication} */ +import { L5R5E } from "../l5r5e-config.js"; import { RollL5r5e } from "./roll.js"; export class DicePickerDialog extends FormApplication { @@ -138,7 +139,7 @@ export class DicePickerDialog extends FormApplication { name: "", }; - const cat = RollL5r5e.getCategoryForSkillId(skillId); + const cat = L5R5E.skills.get(skillId); if (!cat) { return; } diff --git a/system/scripts/dice/roll.js b/system/scripts/dice/roll.js index be70602..db8e936 100644 --- a/system/scripts/dice/roll.js +++ b/system/scripts/dice/roll.js @@ -1,3 +1,4 @@ +import { L5R5E } from "../l5r5e-config.js"; import { L5rBaseDie } from "./dietype/l5r-base-die.js"; /** @@ -197,9 +198,7 @@ export class RollL5r5e extends Roll { } const skillName = - game.i18n.translations.l5r5e.skills?.[RollL5r5e.getCategoryForSkillId(this.l5r5e.skillId)]?.[ - this.l5r5e.skillId - ] || ""; + game.i18n.translations.l5r5e.skills?.[L5R5E.skills.get(this.l5r5e.skillId)]?.[this.l5r5e.skillId] || ""; // Define chat data const chatData = { @@ -275,17 +274,6 @@ export class RollL5r5e extends Roll { return create ? CONFIG.ChatMessage.entityClass.create(messageData, messageOptions) : messageData; } - /** - * Return the categoryId for the skillId - * TODO in proper category helper ? - * @param skillId - */ - static getCategoryForSkillId(skillId) { - return Object.keys(game.i18n.translations.l5r5e.skills).find((e) => { - return !!game.i18n.translations.l5r5e.skills?.[e]?.[skillId]; - }); - } - /** @override */ static fromData(data) { const roll = super.fromData(data); diff --git a/system/scripts/l5r5e-config.js b/system/scripts/l5r5e-config.js index a533425..0f87def 100644 --- a/system/scripts/l5r5e-config.js +++ b/system/scripts/l5r5e-config.js @@ -1,8 +1,39 @@ export const L5R5E = {}; -L5R5E.stances = ["earth", "air", "water", "fire", "void"]; - L5R5E.paths = { assets: `systems/l5r5e/assets/`, templates: `systems/l5r5e/templates/`, }; + +L5R5E.stances = ["earth", "air", "water", "fire", "void"]; + +// Map SkillId - CategoryId +L5R5E.skills = new Map(); +L5R5E.skills.set("aesthetics", "artisan"); +L5R5E.skills.set("composition", "artisan"); +L5R5E.skills.set("design", "artisan"); +L5R5E.skills.set("smithing", "artisan"); + +L5R5E.skills.set("fitness", "martial"); +L5R5E.skills.set("melee", "martial"); +L5R5E.skills.set("ranged", "martial"); +L5R5E.skills.set("unarmed", "martial"); +L5R5E.skills.set("meditation", "martial"); +L5R5E.skills.set("tactics", "martial"); + +L5R5E.skills.set("culture", "scholar"); +L5R5E.skills.set("government", "scholar"); +L5R5E.skills.set("medicine", "scholar"); +L5R5E.skills.set("sentiment", "scholar"); +L5R5E.skills.set("theology", "scholar"); + +L5R5E.skills.set("command", "social"); +L5R5E.skills.set("courtesy", "social"); +L5R5E.skills.set("games", "social"); +L5R5E.skills.set("performance", "social"); + +L5R5E.skills.set("commerce", "trade"); +L5R5E.skills.set("labor", "trade"); +L5R5E.skills.set("seafaring", "trade"); +L5R5E.skills.set("skulduggery", "trade"); +L5R5E.skills.set("survival", "trade"); diff --git a/system/scripts/main-l5r5e.js b/system/scripts/main-l5r5e.js index 4fa80dc..b811d99 100644 --- a/system/scripts/main-l5r5e.js +++ b/system/scripts/main-l5r5e.js @@ -10,6 +10,7 @@ import { ItemL5r5e } from "./items/item.js"; import { ItemSheetL5r5e } from "./items/item-sheet.js"; import { WeaponSheetL5r5e } from "./items/weapon-sheet.js"; import { FeatSheetL5r5e } from "./items/feat-sheet.js"; +import { TwentyQuestionsDialog } from "./sheets/twenty-questions-dialog.js"; // Import Dice Types @@ -46,6 +47,7 @@ Hooks.once("init", async function () { // Add some helper classes in game game.l5r5e = { DicePickerDialog, + TwentyQuestionsDialog, }; // Register custom system settings @@ -88,8 +90,7 @@ Hooks.once("init", async function () { }); Handlebars.registerHelper("localizeSkillId", function (skillName) { - const key = - "l5r5e.skills." + RollL5r5e.getCategoryForSkillId(skillName.toLowerCase()) + "." + skillName.toLowerCase(); + const key = "l5r5e.skills." + L5R5E.skills.get(skillName.toLowerCase()) + "." + skillName.toLowerCase(); return game.i18n.localize(key); }); diff --git a/system/scripts/sheets/twenty-questions-dialog.js b/system/scripts/sheets/twenty-questions-dialog.js new file mode 100644 index 0000000..636b42b --- /dev/null +++ b/system/scripts/sheets/twenty-questions-dialog.js @@ -0,0 +1,120 @@ +import { L5R5E } from "../l5r5e-config.js"; + +/** + * L5R Twenty Questions form + * @extends {FormApplication} + */ +export class TwentyQuestionsDialog extends FormApplication { + /** + * Assign the default options + * @override + */ + static get defaultOptions() { + return mergeObject(super.defaultOptions, { + id: "l5r5e-twenty-questions-dialog", + classes: ["l5r5e", "twenty-questions-dialog"], + template: CONFIG.L5r5e.paths.templates + "sheets/twenty-questions-dialog.html", + title: "L5R Twenty Questions", // TODO Localize + width: 600, + height: 600, + resizable: true, + }); + } + + /** + * Create dialog + */ + constructor(options = null) { + super(options); + } + + /** + * Construct and return the data object used to render the HTML template for this form application. + * @param options + * @return {Object} + */ + getData(options = null) { + return { + ...super.getData(options), + elementsList: this._getElements(), + skillsList: this._getSkills(), + }; + } + + /** + * Render the dialog + * @param force + * @param options + * @returns {Application} + */ + render(force, options) { + options = { + ...options, + }; + + if (force === undefined) { + force = true; + } + + return super.render(force, options); + } + + /** + * Listen to html elements + * @override + */ + activateListeners(html) { + super.activateListeners(html); + + // html.find('input[name="approach"]').on("click", async (event) => {}); + } + + /** + * This method is called upon form submission after form data is validated + * @param event The initial triggering submission event + * @param formData The object of validated form data with which to update the object + * @returns A Promise which resolves once the update operation has completed + * @override + */ + async _updateObject(event, formData) { + // const ring = formData.ring || null; + + // TODO + console.log(formData); + return; + // return this.close(); + } + + /** + * Load elements list (id, label) + * @private + */ + _getElements() { + return CONFIG.L5r5e.stances.map((e) => { + return { + id: e, + label: game.i18n.localize(`l5r5e.rings.${e}`), + }; + }); + } + + /** + * Load Skills list (id, cat, label) + * @private + */ + _getSkills() { + const skills = {}; + Array.from(L5R5E.skills).forEach(([id, cat]) => { + if (!skills[cat]) { + skills[cat] = []; + } + skills[cat].push({ + id: id, + cat: cat, + label: game.i18n.localize(`l5r5e.skills.${cat}.${id}`), + }); + }); + console.log(skills); + return skills; + } +} diff --git a/system/templates/sheets/twenty-questions-dialog.html b/system/templates/sheets/twenty-questions-dialog.html new file mode 100644 index 0000000..8f418fa --- /dev/null +++ b/system/templates/sheets/twenty-questions-dialog.html @@ -0,0 +1,437 @@ +
+ + + {{json skillsList}} + +

Vingt questions

+
+ Renseignez vos réponses au jeu des vingt questions sur ce formulaire et notez-y des éléments à utiliser + ultérieurement ! +
Livre de Règles de La Légende des Cinq Anneaux, Chapitre 2 : Création de personnage, p. 41-95 +
+ + +

Partie I: Identité (clan et famille)

+
+ 1. A quel clan appartient votre personnage ? (p. 41) + + +
+ Augmentation d'Anneau (1) + +
+ +
+ Augmentation de compétence (1) + +
+ +
+ +
+
+
+ 2. A quelle famille appartient votre personnage ? (p. 49) + + +
+ Augmentation d'Anneau (1) + +
+
+ Augmentation de compétence (2) + + +
+ +
+ +
+ +
+ +
+
+ + +

Partie II: Rôle et École

+
+ 3. Quelle est l'École votre personnage, et quel rôle remplit-elle ? (p. 56) + + + + + +
+ Augmentations d'Anneau (2) + + +
+
+ Augmentations de compétence (3-5) + + + + + +
+ + Types de techniques accessibles +
+ + + + + + + +
+ +
+ Techniques de départ (2-5) + + +
+ +
+ Capacité d'école + +
+ +
+ Équipement de départ + +
+
+
+ +
+ +
+ 4. De quelle manière votre personnage se démarque-t-il au sein de son école ? (p. 88) + + + Augmentation d'Anneau (1) + +
+ + +

Partie III: Honneur et Gloire

+
+ 5. Qui est le seigneur de votre personnage et quel est le devoir de votre personnage envers lui ? (p. 88) + Choisissez un giri: + +
+
+ 6. Que désire votre personnage, et en quoi ce désir risque-t-il de l’empêcher d’accomplir son devoir ? (p. 90) + Choisissez un ninjō: + +
+
+ 7. Quelle relation votre personnage entretient-il avec son clan ? (p. 91) + + +
+ Augmentation de compétence (1) + + + OU + + +
+
+
+ 8. Que pense votre personnage du bushido ? (p. 91) + + +
+ Augmentation de compétence (1) + + + OU + + +
+
+ + +

Partie IV: Forces et Faiblesses

+
+ 9. Quelle est à ce jour la plus belle réussite de votre personnage ? (p. 92) + + + Aptitude (1) + +
+
+ 10. Quel est le frein principal dans la vie de votre personnage ? (p. 92) + + + Coup du sort (1) + +
+
+ 11. Quelle activité apaise le plus votre personnage ? (p. 93) + + + Passion (1) + +
+
+ 12. Quelle inquiétude, crainte ou manie tracasse le plus votre personnage ? (p. 93) + + + Défaillance (1) + +
+
+ 13. De qui votre personnage a-t-il le plus appris au cours de sa vie ? (p. 93) + + +
+ Augmentation de compétence (1) + + + Désavantage (1) + +
+
+ OU + Avantage (1) + +
+
+ + +

Partie V: Personnalité et Comportement

+
+ 14. Que remarque-t-on en premier chez votre personnage ? (p. 93) + + + Particularités + +
+
+ 15. Comment votre personnage réagit-il aux situations stressantes ? (p. 94) + +
+
+ 16. Quelles relations votre personnage entretient-il avec des familles, des organisations, des traditions et des + clans différents ? (p. 94) + + + Objet (Rareté inférieur ou égale à 7) + +
+ + +

Partie VI: Lignée et Famille

+
+ 17. Comment les parents de votre personnage le décriraient-ils ? (p. 95) + + + Augmentation de compétence (1) + +
+
+ 18. En l’honneur de qui votre personnage a-t-il été prénommé ? (p. 95) + + + + + +
+
+ 19. Quel est le prénom de votre personnage ? (p. 95) + +
+ +

Partie VII: Mort

+
+ 20. Comment envisagez-vous la mort de votre personnage ? (p. 95) + +
+ +
+ +
+
\ No newline at end of file