Trying to fix advancement behavior who sometime left point on old choice.

This commit is contained in:
Vlyan
2022-01-09 14:29:28 +01:00
parent 09bb92ae61
commit a39cc0e326
5 changed files with 23 additions and 11 deletions

View File

@@ -4,5 +4,5 @@
{"_id":"dz61B4h3iJwOC0Ob","name":"Draw 5 Ujik names","type":"script","author":"Rv52pj6itbOX14wX","img":"systems/l5r5e/assets/icons/actors/character.svg","scope":"global","command":"game.l5r5e.HelpersL5r5e.drawManyFromPack(\"l5r5e.core-name-tables\", \"Ujik names\", 5);","folder":null,"sort":0,"permission":{"default":0},"flags":{}}
{"_id":"ed0HRLOWSKm6YTUS","name":"Draw 5 Japanese names (male)","type":"script","author":"Rv52pj6itbOX14wX","img":"systems/l5r5e/assets/icons/actors/traditional-japanese-man.svg","scope":"global","command":"game.l5r5e.HelpersL5r5e.drawManyFromPack(\"l5r5e.core-name-tables\", \"Japanese names (Male)\", 5);","folder":null,"sort":0,"permission":{"default":0},"flags":{}}
{"_id":"fk2naBrDnz8ZAVHR","name":"Draw 5 Japanese names (female)","type":"script","author":"Rv52pj6itbOX14wX","img":"systems/l5r5e/assets/icons/actors/traditional-japanese-woman.svg","scope":"global","command":"game.l5r5e.HelpersL5r5e.drawManyFromPack(\"l5r5e.core-name-tables\", \"Japanese names (Female)\", 5);","folder":null,"sort":0,"permission":{"default":0},"flags":{}}
{"_id":"ggs1eiqkfVWlm5JM","name":"Draw Names Dialog","type":"script","author":"Rv52pj6itbOX14wX","img":"systems/l5r5e/assets/icons/actors/army.svg","scope":"global","command":"const pack = \"l5r5e.core-name-tables\";\nconst comp = await game.packs.get(pack);\nif (!comp) { console.log(`L5R5E | Pack not found[${pack}]`); return; }\nawait comp.getDocuments();\n\nlet radioTablesHtml = \"\";\ncomp.index.forEach(obj => { radioTablesHtml += `<label><input type=\"radio\" id=\"${obj._id}\" name=\"tableName\" value=\"${obj.name}\" ${radioTablesHtml === \"\" ? 'checked' : ''}> ${obj.name}</label>`; });\n\nnew Dialog({\n title: \"L5R5E Draw Names\",\n content: `\n <form class=\"noflex\" autocomplete=\"off\">\n <div class=\"form-group\">\n <label>${game.i18n.localize('ENTITY.RollTable')}:</label>\n <div class=\"form-fields\" style=\"flex-direction: column;align-items: flex-start\">\n ${radioTablesHtml}\n </div>\n </div>\n <hr>\n <div class=\"form-group\">\n <label><i class=\"d6\"></i> ${game.i18n.localize('l5r5e.quantity')}:</label>\n <div class=\"form-fields\">\n <input type=\"number\" name=\"drawNumber\" value=\"5\" min=\"0\" max=\"99\"/>\n </div>\n </div>\n </form>\n `,\n buttons: {\n no: {\n icon: \"<i class='fas fa-times'></i>\",\n label: game.i18n.localize('Cancel')\n },\n yes: {\n icon: \"<i class='fas fa-check'></i>\",\n label: game.i18n.localize('TABLE.Roll'),\n callback: (html) => {\n const tableName = html.find('input[name=\"tableName\"]:checked')[0]?.value || null;\n const drawNumber = html.find('input[name=\"drawNumber\"]')[0]?.value || null;\n if (!tableName || !drawNumber || drawNumber < 1) {return;}\n game.l5r5e.HelpersL5r5e.drawManyFromPack(pack, tableName, drawNumber);\n }\n },\n },\n default: \"no\"\n}).render(true);","folder":null,"sort":0,"permission":{"default":0},"flags":{}}
{"_id":"ggs1eiqkfVWlm5JM","name":"Draw Names Dialog","type":"script","author":"Rv52pj6itbOX14wX","img":"systems/l5r5e/assets/icons/actors/army.svg","scope":"global","command":"const pack = \"l5r5e.core-name-tables\";\nconst comp = await game.packs.get(pack);\nif (!comp) { console.log(`L5R5E | Pack not found[${pack}]`); return; }\nawait comp.getDocuments();\n\nlet radioTablesHtml = \"\";\ncomp.index.forEach(obj => { radioTablesHtml += `<label><input type=\"radio\" id=\"${obj._id}\" name=\"tableName\" value=\"${obj.name}\" ${radioTablesHtml === \"\" ? 'checked' : ''}> ${obj.name}</label>`; });\n\nnew Dialog({\n title: \"L5R5E Draw Names\",\n content: `\n <form class=\"noflex\" autocomplete=\"off\">\n <div class=\"form-group\">\n <label>${game.i18n.localize('DOCUMENT.RollTable')}:</label>\n <div class=\"form-fields\" style=\"flex-direction: column;align-items: flex-start\">\n ${radioTablesHtml}\n </div>\n </div>\n <hr>\n <div class=\"form-group\">\n <label><i class=\"d6\"></i> ${game.i18n.localize('l5r5e.quantity')}:</label>\n <div class=\"form-fields\">\n <input type=\"number\" name=\"drawNumber\" value=\"5\" min=\"0\" max=\"99\"/>\n </div>\n </div>\n </form>\n `,\n buttons: {\n no: {\n icon: \"<i class='fas fa-times'></i>\",\n label: game.i18n.localize('Cancel')\n },\n yes: {\n icon: \"<i class='fas fa-check'></i>\",\n label: game.i18n.localize('TABLE.Roll'),\n callback: (html) => {\n const tableName = html.find('input[name=\"tableName\"]:checked')[0]?.value || null;\n const drawNumber = html.find('input[name=\"drawNumber\"]')[0]?.value || null;\n if (!tableName || !drawNumber || drawNumber < 1) {return;}\n game.l5r5e.HelpersL5r5e.drawManyFromPack(pack, tableName, drawNumber);\n }\n },\n },\n default: \"no\"\n}).render(true);","folder":null,"sort":0,"permission":{"default":0},"flags":{}}
{"_id":"hpfDGUS48dA2pkUB","name":"Open Character Sheet (linked actor)","type":"script","author":"Rv52pj6itbOX14wX","img":"systems/l5r5e/assets/icons/actors/character.svg","scope":"global","command":"game.user.character?.sheet.render(true);","folder":null,"sort":0,"permission":{"default":0},"flags":{}}

View File

@@ -318,7 +318,7 @@ export class HelpersL5r5e {
if (!types) {
types = game.system.entityTypes.Item;
}
const title = game.i18n.format("ENTITY.Create", { entity: game.i18n.localize("Item") });
const title = game.i18n.format("DOCUMENT.Create", { type: game.i18n.localize("Item") });
// Render the template
const html = await renderTemplate(`${CONFIG.l5r5e.paths.templates}dialogs/choose-item-type-dialog.html`, {

View File

@@ -7,7 +7,7 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
/**
* Sub Types of advancements
*/
static types = ["ring", "skill"]; // others have theirs own xp count
static types = { ring: "l5r5e.rings.title", skill: "l5r5e.skill" }; // others have theirs own xp count
/** @override */
static get defaultOptions() {
@@ -46,19 +46,30 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
const currentSkill = this.object.data.data.skill;
html.find("#advancement_type").on("change", (event) => {
$(event.target).prop("disabled", true);
if ($(event.target).val() === "skill") {
this._updateChoice({ ring: currentRing }, { skill: currentSkill });
this._updateChoice({ ring: currentRing }, { skill: currentSkill }).then(
$(event.target).prop("disabled", false)
);
} else {
this._updateChoice({ skill: currentSkill }, { ring: currentRing });
this._updateChoice({ skill: currentSkill }, { ring: currentRing }).then(
$(event.target).prop("disabled", false)
);
}
});
html.find("#advancement_ring").on("change", (event) => {
this._updateChoice({ ring: currentRing }, { ring: $(event.target).val() });
$(event.target).prop("disabled", true);
this._updateChoice({ ring: currentRing }, { ring: $(event.target).val() }).then(
$(event.target).prop("disabled", false)
);
});
html.find("#advancement_skill").on("change", (event) => {
this._updateChoice({ skill: currentSkill }, { skill: $(event.target).val() });
$(event.target).prop("disabled", true);
this._updateChoice({ skill: currentSkill }, { skill: $(event.target).val() }).then(
$(event.target).prop("disabled", false)
);
});
}

View File

@@ -9,8 +9,8 @@
<article class="attributes" data-group="primary" data-tab="attributes">
<select name="data.advancement_type" id="advancement_type">
{{#select data.data.advancement_type}}
{{#each data.subTypesList as |type|}}
<option value="{{type}}">{{type}}</option>
{{#each data.subTypesList as |label type|}}
<option value="{{type}}">{{localize label}}</option>
{{/each}}
{{/select}}
</select>