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