const for skills map, and raw 20 questions template

This commit is contained in:
Vlyan
2020-12-14 18:22:49 +01:00
parent 4870ad2302
commit 45ca9d1071
6 changed files with 597 additions and 19 deletions

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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");

View File

@@ -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);
});

View File

@@ -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;
}
}

View File

@@ -0,0 +1,437 @@
<form class="l5r5e dice-picker-dialog" autocomplete="off">
<!--TODO Localization !-->
{{json skillsList}}
<h1>Vingt questions</h1>
<div>
Renseignez vos réponses au jeu des vingt questions sur ce formulaire et notez-y des éléments à utiliser
ultérieurement !
<br><i>Livre de Règles de La Légende des Cinq Anneaux, Chapitre 2 : Création de personnage, p. 41-95</i>
</div>
<h2>Partie I: Identité (clan et famille)</h2>
<div>
1. A quel clan appartient votre personnage ? (p. 41)
<input type="text" name="step1_clan">
<div>
Augmentation d'Anneau (1)
<select name="step1_ring">
<option value="none">En choisir un</option>
{{#each elementsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</select>
</div>
<div>
Augmentation de compétence (1)
<select name="step1_skill">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
</select>
</div>
<div>
<label>
Statut
<input type="number" name="step1_social_status" min="0" max="100" value="0">
</label>
</div>
</div>
<div>
2. A quelle famille appartient votre personnage ? (p. 49)
<input type="text" name="step2_family">
<div>
Augmentation d'Anneau (1)
<select name="step2_ring">
<option value="none">En choisir un</option>
{{#each elementsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</select>
</div>
<div>
Augmentation de compétence (2)
<select name="step2_skill_1">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
</select>
<select name="step2_skill_2">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
</select>
</div>
<div>
<label>
Fortune de départ :
<input type="text" name="step2_wealth">
</label>
</div>
<div>
<label>
Gloire
<input type="number" name="step2_social_glory" min="0" max="100" value="0">
</label>
</div>
</div>
<h2>Partie II: Rôle et École</h2>
<div>
3. Quelle est l'École votre personnage, et quel rôle remplit-elle ? (p. 56)
<label>
École
<input type="text" name="step3_school">
</label>
<label>
Rôles
<input type="text" name="step3_roles">
</label>
<div>
Augmentations d'Anneau (2)
<select name="step3_ring_1">
<option value="none">En choisir un</option>
{{#each elementsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</select>
<select name="step3_ring_2">
<option value="none">En choisir un</option>
{{#each elementsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</select>
</div>
<div>
Augmentations de compétence (3-5)
<select name="step3_skill_1">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
</select>
<select name="step3_skill_2">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
</select>
<select name="step3_skill_3">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
</select>
<select name="step3_skill_4">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
</select>
<select name="step3_skill_5">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
</select>
</div>
Types de techniques accessibles
<div>
<label>
<input type="checkbox" name="step3_kata">Kata
</label>
<label>
<input type="checkbox" name="step3_kiho">Kihō
</label>
<label>
<input type="checkbox" name="step3_invocations">Invocations
</label>
<label>
<input type="checkbox" name="step3_rituals">Rituels
</label>
<label>
<input type="checkbox" name="step3_shui">Shūji
</label>
<label>
<input type="checkbox" name="step3_maho">Mahō
</label>
<label>
<input type="checkbox" name="step3_ninjutsu">Ninjutsu
</label>
</div>
<div>
Techniques de départ (2-5)
<textarea name="step3_feats"></textarea>
<!-- TODO Drag n drop feats-->
</div>
<div>
Capacité d'école
<textarea name="step3_school_ability"></textarea>
</div>
<div>
Équipement de départ
<textarea name="step3_equipment"></textarea>
</div>
</div>
<div>
<label>
Honneur
<input type="number" name="step3_social_honor" min="0" max="100" value="0">
</label>
</div>
<div>
4. De quelle manière votre personnage se démarque-t-il au sein de son école ? (p. 88)
<textarea name="step4_answer"></textarea>
Augmentation d'Anneau (1)
<select name="step4_ring">
<option value="none">En choisir un</option>
{{#each elementsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</select>
</div>
<h2>Partie III: Honneur et Gloire</h2>
<div>
5. Qui est le seigneur de votre personnage et quel est le devoir de votre personnage envers lui ? (p. 88)
Choisissez un giri:
<textarea name="step5_social_giri"></textarea>
</div>
<div>
6. Que désire votre personnage, et en quoi ce désir risque-t-il de lempêcher daccomplir son devoir ? (p. 90)
Choisissez un ninjō:
<textarea name="step6_social_ninjo"></textarea>
</div>
<div>
7. Quelle relation votre personnage entretient-il avec son clan ? (p. 91)
<textarea name="step7_answer"></textarea>
<div>
Augmentation de compétence (1)
<select name="step7_skill">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
</select>
OU
<label>
Augmentation de la gloire (+5)
<input type="number" name="step7_social_glory" value="0">
</label>
</div>
</div>
<div>
8. Que pense votre personnage du bushido ? (p. 91)
<textarea name="step8_answer"></textarea>
<div>
Augmentation de compétence (1)
<select name="step8_skill">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
</select>
OU
<label>
Augmentation de l'honneur
<input type="number" name="step8_social_honor" value="0">
</label>
</div>
</div>
<h3>Partie IV: Forces et Faiblesses</h3>
<div>
9. Quelle est à ce jour la plus belle réussite de votre personnage ? (p. 92)
<textarea name="step9_answer"></textarea>
Aptitude (1)
<textarea name="step9_distinction"></textarea>
</div>
<div>
10. Quel est le frein principal dans la vie de votre personnage ? (p. 92)
<textarea name="step10_answer"></textarea>
Coup du sort (1)
<textarea name="step10_adversity"></textarea>
</div>
<div>
11. Quelle activité apaise le plus votre personnage ? (p. 93)
<textarea name="step11_answer"></textarea>
Passion (1)
<textarea name="step11_passion"></textarea>
</div>
<div>
12. Quelle inquiétude, crainte ou manie tracasse le plus votre personnage ? (p. 93)
<textarea name="step12_answer"></textarea>
Défaillance (1)
<textarea name="step12_failure"></textarea>
</div>
<div>
13. De qui votre personnage a-t-il le plus appris au cours de sa vie ? (p. 93)
<textarea name="step13_answer"></textarea>
<div>
Augmentation de compétence (1)
<select name="step13_skill">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
</select>
Désavantage (1)
<textarea name="step13_disadvantage"></textarea>
</div>
<div>
OU
Avantage (1)
<textarea name="step13_advantage"></textarea>
</div>
</div>
<h3>Partie V: Personnalité et Comportement</h3>
<div>
14. Que remarque-t-on en premier chez votre personnage ? (p. 93)
<textarea name="step14_answer"></textarea>
Particularités
<textarea name="step14_special_features"></textarea>
</div>
<div>
15. Comment votre personnage réagit-il aux situations stressantes ? (p. 94)
<textarea name="step15_answer"></textarea>
</div>
<div>
16. Quelles relations votre personnage entretient-il avec des familles, des organisations, des traditions et des
clans différents ? (p. 94)
<textarea name="step16_answer"></textarea>
Objet (Rareté inférieur ou égale à 7)
<textarea name="step16_item"></textarea>
</div>
<h3>Partie VI: Lignée et Famille</h3>
<div>
17. Comment les parents de votre personnage le décriraient-ils ? (p. 95)
<textarea name="step17_answer"></textarea>
Augmentation de compétence (1)
<select name="step17_skill">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
{{#each skills as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
{{/each}}
</optgroup>
{{/each}}
</select>
</div>
<div>
18. En lhonneur de qui votre personnage a-t-il été prénommé ? (p. 95)
<textarea name="step18_answer"></textarea>
<label>
Résultat du 1er D10
<input type="number" name="step18_heritage_1">
</label>
<label>
Résultat du 2eme D10
<input type="number" name="step18_heritage_2">
</label>
</div>
<div>
19. Quel est le prénom de votre personnage ? (p. 95)
<textarea name="step19_answer"></textarea>
</div>
<h3>Partie VII: Mort</h3>
<div>
20. Comment envisagez-vous la mort de votre personnage ? (p. 95)
<textarea name="step20_answer"></textarea>
</div>
<div class="form-group">
<button name="roll" type="submit">
Générer un nouveau personnage <i class='fas fa-arrow-circle-right'></i>
</button>
</div>
</form>