diff --git a/system/scripts/main-l5r5e.js b/system/scripts/main-l5r5e.js index b811d99..2a304cd 100644 --- a/system/scripts/main-l5r5e.js +++ b/system/scripts/main-l5r5e.js @@ -10,7 +10,6 @@ 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 @@ -47,7 +46,6 @@ Hooks.once("init", async function () { // Add some helper classes in game game.l5r5e = { DicePickerDialog, - TwentyQuestionsDialog, }; // Register custom system settings diff --git a/system/scripts/sheets/actor-sheet.js b/system/scripts/sheets/actor-sheet.js index 64c1891..44ec24f 100644 --- a/system/scripts/sheets/actor-sheet.js +++ b/system/scripts/sheets/actor-sheet.js @@ -1,3 +1,5 @@ +import { TwentyQuestionsDialog } from "./twenty-questions-dialog.js"; + export class ActorSheetL5r5e extends ActorSheet { static get defaultOptions() { return mergeObject(super.defaultOptions, { @@ -10,6 +12,25 @@ export class ActorSheetL5r5e extends ActorSheet { }); } + /** + * Add the TwentyQuestions button on top of sheet + * @override + */ + _getHeaderButtons() { + let buttons = super._getHeaderButtons(); + + buttons.unshift({ + label: "20Q", // TODO localization + class: "twenty-questions", + icon: "fas fa-graduation-cap", + onclick: async () => { + await new TwentyQuestionsDialog({}, this.actor).render(true); + }, + }); + + return buttons; + } + getData() { const sheetData = super.getData(); @@ -131,8 +152,6 @@ export class ActorSheetL5r5e extends ActorSheet { * @param {string} skillId Unique ID of the skill been clicked. */ async _onSkillClicked(skillId) { - console.log("Clicked on skill " + skillId); - - new game.l5r5e.DicePickerDialog({ skillId: skillId, actor: this.actor }).render(); + new game.l5r5e.DicePickerDialog({ skillId: skillId, actor: this.actor }).render(true); } } diff --git a/system/scripts/sheets/npc-sheet.js b/system/scripts/sheets/npc-sheet.js index b32b264..3d868f4 100644 --- a/system/scripts/sheets/npc-sheet.js +++ b/system/scripts/sheets/npc-sheet.js @@ -134,8 +134,6 @@ export class NpcSheetL5r5e extends ActorSheet { * @param {string} skillId Unique ID of the skill been clicked. */ async _onSkillClicked(skillId) { - console.log("Clicked on skill " + skillId); - - new game.l5r5e.DicePickerDialog({ skillId: skillId, actor: this.actor }).render(); + new game.l5r5e.DicePickerDialog({ skillId: skillId, actor: this.actor }).render(true); } } diff --git a/system/scripts/sheets/twenty-questions-dialog.js b/system/scripts/sheets/twenty-questions-dialog.js index 636b42b..0f608c2 100644 --- a/system/scripts/sheets/twenty-questions-dialog.js +++ b/system/scripts/sheets/twenty-questions-dialog.js @@ -5,6 +5,11 @@ import { L5R5E } from "../l5r5e-config.js"; * @extends {FormApplication} */ export class TwentyQuestionsDialog extends FormApplication { + /** + * Current actor data + */ + actor = null; + /** * Assign the default options * @override @@ -24,8 +29,9 @@ export class TwentyQuestionsDialog extends FormApplication { /** * Create dialog */ - constructor(options = null) { + constructor(options = null, actor = null) { super(options); + this.actor = actor; } /** @@ -38,6 +44,7 @@ export class TwentyQuestionsDialog extends FormApplication { ...super.getData(options), elementsList: this._getElements(), skillsList: this._getSkills(), + actor: this.actor.data.data, }; } @@ -77,14 +84,80 @@ export class TwentyQuestionsDialog extends FormApplication { * @override */ async _updateObject(event, formData) { - // const ring = formData.ring || null; + // this.actor + const actorTmp = this.actor.data.data; //.clone(); + + console.log(actorTmp); + + actorTmp.identity.clan = formData.step1_clan; + actorTmp.social.status = formData.step1_social_status; + actorTmp.identity.family = formData.step2_family; + // actorTmp = formData.step2_wealth; + actorTmp.social.glory = formData.step2_social_glory; + actorTmp.identity.school = formData.step3_school; + actorTmp.identity.roles = formData.step3_roles; + // actorTmp = formData.step3_tech_kata; + // actorTmp = formData.step3_tech_kiho; + // actorTmp = formData.step3_tech_invocations; + // actorTmp = formData.step3_tech_rituals; + // actorTmp = formData.step3_tech_shuji; + // actorTmp = formData.step3_tech_maho; + // actorTmp = formData.step3_tech_ninjutsu; + // actorTmp = formData.step3_feats; + // actorTmp = formData.step3_school_ability; + // actorTmp = formData.step3_equipment; + actorTmp.social.honor = formData.step3_social_honor; + // actorTmp = formData.step4_stand_out; + actorTmp.social.giri = formData.step5_social_giri; + actorTmp.social.ninjo = formData.step6_social_ninjo; + // actorTmp = formData.step7_clan_relations; + // actorTmp = formData.step7_social_add_glory; + // actorTmp = formData.step8_bushido; + // actorTmp = formData.step8_social_add_honor; + // actorTmp = formData.step9_success; + // actorTmp = formData.step9_distinction; + // actorTmp = formData.step10_difficulty; + // actorTmp = formData.step10_adversity; + // actorTmp = formData.step11_calms; + // actorTmp = formData.step11_passion; + // actorTmp = formData.step12_worries; + // actorTmp = formData.step12_failure; + // actorTmp = formData.step13_most_learn; + // actorTmp = formData.step13_disadvantage; + // actorTmp = formData.step13_advantage; + // actorTmp = formData.step14_first_sight; + // actorTmp = formData.step14_special_features; + // actorTmp = formData.step15_stress; + // actorTmp = formData.step16_relations; + // actorTmp = formData.step16_item; + // actorTmp = formData.step17_parents_pov; + // actorTmp = formData.step18_heritage_name; + // actorTmp = formData.step18_heritage_1; + // actorTmp = formData.step18_heritage_2; + actorTmp.name = actorTmp.identity.family + " " + formData.step19_firstname; + // actorTmp = formData.step20_death; + + const rings = this._filterRingOrSkills(formData.rings); + const skills = this._filterRingOrSkills(formData.skills); // TODO - console.log(formData); - return; + console.log(rings, skills, actorTmp, formData); + // return this.close(); } + _filterRingOrSkills(obj) { + return obj + .filter((e) => e !== "none") + .reduce((acc, id) => { + if (!acc.has(id)) { + acc.set(id, 0); + } + acc.set(id, acc.get(id) + 1); + return acc; + }, new Map()); + } + /** * Load elements list (id, label) * @private @@ -114,7 +187,6 @@ export class TwentyQuestionsDialog extends FormApplication { label: game.i18n.localize(`l5r5e.skills.${cat}.${id}`), }); }); - console.log(skills); return skills; } } diff --git a/system/templates/sheets/actor/narrative.html b/system/templates/sheets/actor/narrative.html index fc5c354..9e958ad 100644 --- a/system/templates/sheets/actor/narrative.html +++ b/system/templates/sheets/actor/narrative.html @@ -1,15 +1,15 @@
diff --git a/system/templates/sheets/twenty-questions-dialog.html b/system/templates/sheets/twenty-questions-dialog.html index 8f418fa..6d01e78 100644 --- a/system/templates/sheets/twenty-questions-dialog.html +++ b/system/templates/sheets/twenty-questions-dialog.html @@ -1,7 +1,6 @@
- {{json skillsList}}

Vingt questions

@@ -14,11 +13,11 @@

Partie I: Identité (clan et famille)

1. A quel clan appartient votre personnage ? (p. 41) - +
Augmentation d'Anneau (1) - {{#each elementsList as |obj|}} @@ -28,7 +27,7 @@
Augmentation de compétence (1) - {{#each skillsList as |skills catId|}} @@ -43,17 +42,17 @@
2. A quelle famille appartient votre personnage ? (p. 49) - +
Augmentation d'Anneau (1) - {{#each elementsList as |obj|}} @@ -62,7 +61,7 @@
Augmentation de compétence (2) - {{#each skillsList as |skills catId|}} @@ -72,7 +71,7 @@ {{/each}} - {{#each skillsList as |skills catId|}} @@ -88,13 +87,14 @@
@@ -106,23 +106,23 @@
Augmentations d'Anneau (2) - {{#each elementsList as |obj|}} {{/each}} - {{#each elementsList as |obj|}} @@ -131,7 +131,7 @@
Augmentations de compétence (3-5) - {{#each skillsList as |skills catId|}} @@ -141,7 +141,7 @@ {{/each}} - {{#each skillsList as |skills catId|}} @@ -151,7 +151,7 @@ {{/each}} - {{#each skillsList as |skills catId|}} @@ -161,7 +161,7 @@ {{/each}} - {{#each skillsList as |skills catId|}} @@ -171,7 +171,7 @@ {{/each}} - {{#each skillsList as |skills catId|}} @@ -183,28 +183,29 @@
+ Types de techniques accessibles
@@ -227,16 +228,16 @@
4. De quelle manière votre personnage se démarque-t-il au sein de son école ? (p. 88) - + Augmentation d'Anneau (1) - {{#each elementsList as |obj|}} @@ -249,20 +250,20 @@
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) - {{#each skillsList as |skills catId|}} @@ -277,17 +278,17 @@
8. Que pense votre personnage du bushido ? (p. 91) - +
Augmentation de compétence (1) - {{#each skillsList as |skills catId|}} @@ -302,7 +303,7 @@
@@ -311,39 +312,39 @@

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) - {{#each skillsList as |skills catId|}} @@ -368,19 +369,19 @@

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) @@ -390,10 +391,10 @@

Partie VI: Lignée et Famille

17. Comment les parents de votre personnage le décriraient-ils ? (p. 95) - + Augmentation de compétence (1) - {{#each skillsList as |skills catId|}} @@ -406,27 +407,27 @@
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) - +