some work on 20 questions

fix on actor narrative : social_standing -> social
This commit is contained in:
Vlyan
2020-12-14 23:50:35 +01:00
parent 45ca9d1071
commit a86a0f3ab6
6 changed files with 157 additions and 69 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,15 +1,15 @@
<ul class="narrative-content">
<li>
<label class="attribute-label">{{ localize 'l5r5e.socialstanding.ninjo' }}</label>
<input type="text" name="data.social_standing.ninjo" value="{{data.social_standing.ninjo}}"/>
<input type="text" name="data.social_standing.ninjo" value="{{data.social.ninjo}}"/>
</li>
<li>
<label class="attribute-label">{{ localize 'l5r5e.socialstanding.giri' }}</label>
<input type="text" name="data.social_standing.giri" value="{{data.social_standing.giri}}"/>
<input type="text" name="data.social_standing.giri" value="{{data.social.giri}}"/>
</li>
<li>
<label class="attribute-label">{{ localize 'l5r5e.socialstanding.socialtitles' }}</label>
<input type="text" name="data.social_standing.titles" value="{{data.social_standing.titles}}"/>
<input type="text" name="data.social_standing.titles" value="{{data.social.titles}}"/>
</li>
</ul>
<fieldset>

View File

@@ -1,7 +1,6 @@
<form class="l5r5e dice-picker-dialog" autocomplete="off">
<!--TODO Localization !-->
{{json skillsList}}
<h1>Vingt questions</h1>
<div>
@@ -14,11 +13,11 @@
<h2>Partie I: Identité (clan et famille)</h2>
<div>
1. A quel clan appartient votre personnage ? (p. 41)
<input type="text" name="step1_clan">
<input type="text" name="step1_clan" value="{{actor.identity.clan}}">
<div>
Augmentation d'Anneau (1)
<select name="step1_ring">
<select name="rings">
<option value="none">En choisir un</option>
{{#each elementsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
@@ -28,7 +27,7 @@
<div>
Augmentation de compétence (1)
<select name="step1_skill">
<select name="skills">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
@@ -43,17 +42,17 @@
<div>
<label>
Statut
<input type="number" name="step1_social_status" min="0" max="100" value="0">
<input type="number" name="step1_social_status" min="0" max="100" value="{{actor.social.status}}">
</label>
</div>
</div>
<div>
2. A quelle famille appartient votre personnage ? (p. 49)
<input type="text" name="step2_family">
<input type="text" name="step2_family" value="{{actor.identity.family}}">
<div>
Augmentation d'Anneau (1)
<select name="step2_ring">
<select name="rings">
<option value="none">En choisir un</option>
{{#each elementsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
@@ -62,7 +61,7 @@
</div>
<div>
Augmentation de compétence (2)
<select name="step2_skill_1">
<select name="skills">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
@@ -72,7 +71,7 @@
</optgroup>
{{/each}}
</select>
<select name="step2_skill_2">
<select name="skills">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
@@ -88,13 +87,14 @@
<label>
Fortune de départ :
<input type="text" name="step2_wealth">
<!-- TODO add to template.json -->
</label>
</div>
<div>
<label>
Gloire
<input type="number" name="step2_social_glory" min="0" max="100" value="0">
<input type="number" name="step2_social_glory" min="0" max="100" value="{{actor.social.glory}}">
</label>
</div>
</div>
@@ -106,23 +106,23 @@
<label>
École
<input type="text" name="step3_school">
<input type="text" name="step3_school" value="{{actor.identity.school}}">
</label>
<label>
Rôles
<input type="text" name="step3_roles">
<input type="text" name="step3_roles" value="{{actor.identity.roles}}">
</label>
<div>
Augmentations d'Anneau (2)
<select name="step3_ring_1">
<select name="rings">
<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">
<select name="rings">
<option value="none">En choisir un</option>
{{#each elementsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
@@ -131,7 +131,7 @@
</div>
<div>
Augmentations de compétence (3-5)
<select name="step3_skill_1">
<select name="skills">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
@@ -141,7 +141,7 @@
</optgroup>
{{/each}}
</select>
<select name="step3_skill_2">
<select name="skills">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
@@ -151,7 +151,7 @@
</optgroup>
{{/each}}
</select>
<select name="step3_skill_3">
<select name="skills">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
@@ -161,7 +161,7 @@
</optgroup>
{{/each}}
</select>
<select name="step3_skill_4">
<select name="skills">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
@@ -171,7 +171,7 @@
</optgroup>
{{/each}}
</select>
<select name="step3_skill_5">
<select name="skills">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
@@ -183,28 +183,29 @@
</select>
</div>
<!--TODO in feat or props ? -->
Types de techniques accessibles
<div>
<label>
<input type="checkbox" name="step3_kata">Kata
<input type="checkbox" name="step3_tech_kata">Kata
</label>
<label>
<input type="checkbox" name="step3_kiho">Kihō
<input type="checkbox" name="step3_tech_kiho">Kihō
</label>
<label>
<input type="checkbox" name="step3_invocations">Invocations
<input type="checkbox" name="step3_tech_invocations">Invocations
</label>
<label>
<input type="checkbox" name="step3_rituals">Rituels
<input type="checkbox" name="step3_tech_rituals">Rituels
</label>
<label>
<input type="checkbox" name="step3_shui">Shūji
<input type="checkbox" name="step3_tech_shuji">Shūji
</label>
<label>
<input type="checkbox" name="step3_maho">Mahō
<input type="checkbox" name="step3_tech_maho">Mahō
</label>
<label>
<input type="checkbox" name="step3_ninjutsu">Ninjutsu
<input type="checkbox" name="step3_tech_ninjutsu">Ninjutsu
</label>
</div>
@@ -227,16 +228,16 @@
<div>
<label>
Honneur
<input type="number" name="step3_social_honor" min="0" max="100" value="0">
<input type="number" name="step3_social_honor" min="0" max="100" value="{{actor.social.honor}}">
</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>
<textarea name="step4_stand_out"></textarea>
Augmentation d'Anneau (1)
<select name="step4_ring">
<select name="rings">
<option value="none">En choisir un</option>
{{#each elementsList as |obj|}}
<option value="{{obj.id}}">{{obj.label}}</option>
@@ -249,20 +250,20 @@
<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>
<textarea name="step5_social_giri">{{actor.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>
<textarea name="step6_social_ninjo">{{actor.social.ninjo}}</textarea>
</div>
<div>
7. Quelle relation votre personnage entretient-il avec son clan ? (p. 91)
<textarea name="step7_answer"></textarea>
<textarea name="step7_clan_relations"></textarea>
<div>
Augmentation de compétence (1)
<select name="step7_skill">
<select name="skills">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
@@ -277,17 +278,17 @@
<label>
Augmentation de la gloire (+5)
<input type="number" name="step7_social_glory" value="0">
<input type="number" name="step7_social_add_glory" value="0">
</label>
</div>
</div>
<div>
8. Que pense votre personnage du bushido ? (p. 91)
<textarea name="step8_answer"></textarea>
<textarea name="step8_bushido"></textarea>
<div>
Augmentation de compétence (1)
<select name="step8_skill">
<select name="skills">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
@@ -302,7 +303,7 @@
<label>
Augmentation de l'honneur
<input type="number" name="step8_social_honor" value="0">
<input type="number" name="step8_social_add_honor" value="0">
</label>
</div>
</div>
@@ -311,39 +312,39 @@
<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>
<textarea name="step9_success"></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>
<textarea name="step10_difficulty"></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>
<textarea name="step11_calms"></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>
<textarea name="step12_worries"></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>
<textarea name="step13_most_learn"></textarea>
<div>
Augmentation de compétence (1)
<select name="step13_skill">
<select name="skills">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
@@ -368,19 +369,19 @@
<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>
<textarea name="step14_first_sight"></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>
<textarea name="step15_stress"></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>
<textarea name="step16_relations"></textarea>
Objet (Rareté inférieur ou égale à 7)
<textarea name="step16_item"></textarea>
@@ -390,10 +391,10 @@
<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>
<textarea name="step17_parents_pov"></textarea>
Augmentation de compétence (1)
<select name="step17_skill">
<select name="skills">
<option value="none">En choisir une</option>
{{#each skillsList as |skills catId|}}
<optgroup label="{{localizeSkill catId 'title'}}">
@@ -406,27 +407,27 @@
</div>
<div>
18. En lhonneur de qui votre personnage a-t-il été prénommé ? (p. 95)
<textarea name="step18_answer"></textarea>
<textarea name="step18_heritage_name"></textarea>
<label>
Résultat du 1er D10
Résultat du 1er D10 [[/r 1d10]]
<input type="number" name="step18_heritage_1">
</label>
<label>
Résultat du 2eme D10
Résultat du 2eme D10 [[/r 1d10]]
<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>
<textarea name="step19_firstname"></textarea>
</div>
<h3>Partie VII: Mort</h3>
<div>
20. Comment envisagez-vous la mort de votre personnage ? (p. 95)
<textarea name="step20_answer"></textarea>
<textarea name="step20_death"></textarea>
</div>
<div class="form-group">