diff --git a/system/lang/en-en.json b/system/lang/en-en.json index fe39b40..4bbe836 100644 --- a/system/lang/en-en.json +++ b/system/lang/en-en.json @@ -219,31 +219,51 @@ "total": "Total", "spent": "Used", "saved": "Saved", - "acquisitions": "Acquisitions" + "advancements": "Advancements" }, "twenty_questions": { "title": "Twenty questions", "bt_abrev": "20Q", "part1": { - "title": "Partie I: Core Identity (Clan and Family)" + "title": "Part I: Core Identity (Clan and Family)", + "q1": "1. What clan does your character belong to? (p. 41)", + "q2": "2. What family does your character belong to? (p. 49)" }, "part2": { - "title": "Partie II: Role and School" + "title": "Part II: Role and School", + "q3": "3. What is your character’s school, and what roles does that school fall into?(p. 56)", + "q4": "4. How does your character stand out within their school?(p. 88)" }, "part3": { - "title": "Partie III: Honor and Glory" + "title": "Part III: Honor and Glory", + "q5": "5. Who is your lord and what is your character’s duty to them? (p. 88)", + "q6": "6. What does your character long for, and how might this impede their duty? (p. 90)", + "q7": "7. What is your character’s relationship with their clan?(p. 91)", + "q8": "8. What does your character think of Bushidō? (p. 91)" }, "part4": { - "title": "Partie IV: Strengths and Weaknesses" + "title": "Part IV: Strengths and Weaknesses", + "q9": "9. What is your character’s greatest accomplishment so far?(p. 92)", + "q10": "10. What holds your character back the most in life?(p. 92)", + "q11": "11. What activity Most makes your character feel at peace? (p. 92)", + "q12": "12. What concern, fear, or foible troubles your character the most? (p. 93)", + "q13": "13. Who has your character learned the most from during their life (p. 93)" }, "part5": { - "title": "Partie V: Personality and Behavior" + "title": "Part V: Personality and Behavior", + "q14": "14. What do people notice first upon encountering your character? (p. 93)", + "q15": "15. How does your character react to stressful situations? (p. 94)", + "q16": "16. What are your character’s preexisting relationships with other clans, families, organizations, and traditions? (p. 94)" }, "part6": { - "title": "Partie VI: Ancestry and Family" + "title": "Part VI: Ancestry and Family", + "q17": "17. How would your character’s parents describe them? (p. 95)", + "q18": "18. Who was your character named to honor? (p. 95)", + "q19": "19. What is your character’s personal name? (p. 95)" }, "part7": { - "title": "Partie VII: Death" + "title": "Part VII: Death", + "q20": "20. How should your character die? (p. 95)" } } } diff --git a/system/lang/es-es.json b/system/lang/es-es.json index 1a8140f..3856e06 100644 --- a/system/lang/es-es.json +++ b/system/lang/es-es.json @@ -218,31 +218,51 @@ "total": "Total", "spent": "Usada", "saved": "Restante", - "acquisitions": "Adquisiciones" + "advancements": "Advancements" }, "twenty_questions": { "title": "Twenty questions", "bt_abrev": "20Q", "part1": { - "title": "Partie I: Core Identity (Clan and Family)" + "title": "Partie I: Core Identity (Clan and Family)", + "q1": "1. What clan does your character belong to? (p. 41)", + "q2": "2. What family does your character belong to? (p. 49)" }, "part2": { - "title": "Partie II: Role and School" + "title": "Partie II: Role and School", + "q3": "3. 3. What is your character’s school, and what roles does that school fall into?(p. 56)", + "q4": "4. How does your character stand out within their school?(p. 88)" }, "part3": { - "title": "Partie III: Honor and Glory" + "title": "Partie III: Honor and Glory", + "q5": "5. Who is your lord and what is your character’s duty to them? (p. 88)", + "q6": "6. What does your character long for, and how might this impede their duty? (p. 90)", + "q7": "7. What is your character’s relationship with their clan?(p. 91)", + "q8": "8. What does your character think of Bushidō? (p. 91)" }, "part4": { - "title": "Partie IV: Strengths and Weaknesses" + "title": "Partie IV: Strengths and Weaknesses", + "q9": "9. What is your character’s greatest accomplishment so far?(p. 92)", + "q10": "10. What holds your character back the most in life?(p. 92)", + "q11": "11. What activity Most makes your character feel at peace? (p. 93)", + "q12": "12. What concern, fear, or foible troubles your character the most? (p. 93)", + "q13": "12. Who has your character learned the most from during their life(p. 93)" }, "part5": { - "title": "Partie V: Personality and Behavior" + "title": "Partie V: Personality and Behavior", + "q14": "14. What do people notice first upon encountering your character? (p. 93)", + "q15": "15. How does your character react to stressful situations? (p. 94)", + "q16": "16. What are your character’s preexisting relationships with other clans, families, organizations, and traditions? (p. 94)" }, "part6": { - "title": "Partie VI: Ancestry and Family" + "title": "Partie VI: Ancestry and Family", + "q17": "17. How would your character’s parents describe them? (p. 95)", + "q18": "18. Who was your character named to honor? (p. 95)", + "q19": "19. What is your character’s personal name? (p. 95)" }, "part7": { - "title": "Partie VII: Death" + "title": "Partie VII: Death", + "q20": "20. How should your character die? (p. 95)" } } } diff --git a/system/lang/fr-fr.json b/system/lang/fr-fr.json index 63549d4..50c07a0 100644 --- a/system/lang/fr-fr.json +++ b/system/lang/fr-fr.json @@ -23,6 +23,11 @@ "spe.chat.pref": "Si renseignée, la chaîne sera préfixée pour tous les messages de chat qui ne sont pas déjà des commandes (comme /emote.)", "l5r5e": { + "global": { + "add": "Ajouter", + "edit": "Modifier", + "delete": "Supprimer" + }, "logo": { "title": "Besoin d'aide ?", "content": "Suivez le guide :", @@ -90,7 +95,6 @@ "physical": "Physique", "supernatural": "Spirituelle" }, - "add": "Ajouter", "items": "Objets", "feats": "Prouesses", "techniques": { @@ -219,31 +223,51 @@ "total": "Totale", "spent": "Dépensée", "saved": "Restante", - "acquisitions": "Acquisitions" + "advancements": "Progressions" }, "twenty_questions": { "title": "Vingt questions", "bt_abrev": "20Q", "part1": { - "title": "Partie I: Identité (clan et famille)" + "title": "Partie I: Identité (clan et famille)", + "q1": "1. A quel clan appartient votre personnage ? (p. 41)", + "q2": "2. A quelle famille appartient votre personnage ? (p. 49)" }, "part2": { - "title": "Partie II: Rôle et École" + "title": "Partie II: Rôle et École", + "q3": "3. Quelle est l'École votre personnage, et quel rôle remplit-elle ? (p. 56)", + "q4": "4. De quelle manière votre personnage se démarque-t-il au sein de son école ? (p. 88)" }, "part3": { - "title": "Partie III: Honneur et Gloire" + "title": "Partie III: Honneur et Gloire", + "q5": "5. Qui est le seigneur de votre personnage et quel est le devoir de votre personnage envers lui ? (p. 88)", + "q6": "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)", + "q7": "7. Quelle relation votre personnage entretient-il avec son clan ? (p. 91)", + "q8": "8. Que pense votre personnage du bushido ? (p. 91)" }, "part4": { - "title": "Partie IV: Forces et Faiblesses" + "title": "Partie IV: Forces et Faiblesses", + "q9": "9. Quelle est à ce jour la plus belle réussite de votre personnage ? (p. 92)", + "q10": "10. Quel est le frein principal dans la vie de votre personnage ? (p. 92)", + "q11": "11. Quelle activité apaise le plus votre personnage ? (p. 93)", + "q12": "12. Quelle inquiétude, crainte ou manie tracasse le plus votre personnage ? (p. 93)", + "q13": "13. De qui votre personnage a-t-il le plus appris au cours de sa vie ? (p. 93)" }, "part5": { - "title": "Partie V: Personnalité et Comportement" + "title": "Partie V: Personnalité et Comportement", + "q14": "14. Que remarque-t-on en premier chez votre personnage ? (p. 93)", + "q15": "15. Comment votre personnage réagit-il aux situations stressantes ? (p. 94)", + "q16": "16. Quelles relations votre personnage entretient-il avec des familles, des organisations, des traditions et des clans différents ? (p. 94)" }, "part6": { - "title": "Partie VI: Lignée et Famille" + "title": "Partie VI: Lignée et Famille", + "q17": "17. Comment les parents de votre personnage le décriraient-ils ? (p. 95)", + "q18": "18. En l’honneur de qui votre personnage a-t-il été prénommé ? (p. 95)", + "q19": "19. Quel est le prénom de votre personnage ? (p. 95)" }, "part7": { - "title": "Partie VII: Mort" + "title": "Partie VII: Mort", + "q20": "20. Comment envisagez-vous la mort de votre personnage ? (p. 95)" } } } diff --git a/system/scripts/items/advancement-sheet.js b/system/scripts/items/advancement-sheet.js index b3551b0..e640796 100644 --- a/system/scripts/items/advancement-sheet.js +++ b/system/scripts/items/advancement-sheet.js @@ -14,35 +14,4 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e { tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }], }); } - - getData() { - const sheetData = super.getData(); - sheetData.data.dtypes = ["String", "Number", "Boolean"]; - - sheetData.data.isAdvancement = true; - - return sheetData; - } - - /** - * Subscribe to events from the sheet. - * @param html HTML content of the sheet. - */ - activateListeners(html) { - super.activateListeners(html); - - // Everything below here is only needed if the sheet is editable - if (!this.options.editable) { - return; - } - } - - /** - * Update item with values from the sheet. - * @param event - * @param formData - */ - _updateObject(event, formData) { - return this.object.update(formData); - } } diff --git a/system/scripts/items/armor-sheet.js b/system/scripts/items/armor-sheet.js index 8312428..8f47615 100644 --- a/system/scripts/items/armor-sheet.js +++ b/system/scripts/items/armor-sheet.js @@ -14,34 +14,4 @@ export class ArmorSheetL5r5e extends ItemSheetL5r5e { tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }], }); } - - getData() { - const sheetData = super.getData(); - sheetData.data.dtypes = ["String", "Number", "Boolean"]; - - sheetData.data.isArmor = true; - sheetData.data.isEquipment = true; - - return sheetData; - } - - /** - * Subscribe to events from the sheet. - * @param html HTML content of the sheet. - */ - activateListeners(html) { - super.activateListeners(html); - - // Everything below here is only needed if the sheet is editable - if (!this.options.editable) return; - } - - /** - * Update item with values from the sheet. - * @param event - * @param formData - */ - _updateObject(event, formData) { - return this.object.update(formData); - } } diff --git a/system/scripts/items/item-sheet.js b/system/scripts/items/item-sheet.js index 1068017..b5c5fa4 100644 --- a/system/scripts/items/item-sheet.js +++ b/system/scripts/items/item-sheet.js @@ -19,8 +19,6 @@ export class ItemSheetL5r5e extends ItemSheet { sheetData.data.dtypes = ["String", "Number", "Boolean"]; - sheetData.data.isEquipment = true; - return sheetData; } @@ -32,7 +30,9 @@ export class ItemSheetL5r5e extends ItemSheet { super.activateListeners(html); // Everything below here is only needed if the sheet is editable - if (!this.options.editable) return; + // if (!this.options.editable) { + // return; + // } } /** diff --git a/system/scripts/items/quality-sheet.js b/system/scripts/items/quality-sheet.js index c3a2540..76436a4 100644 --- a/system/scripts/items/quality-sheet.js +++ b/system/scripts/items/quality-sheet.js @@ -14,35 +14,4 @@ export class QualitySheetL5r5e extends ItemSheetL5r5e { tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }], }); } - - getData() { - const sheetData = super.getData(); - sheetData.data.dtypes = ["String", "Number", "Boolean"]; - - sheetData.data.isQuality = true; - - return sheetData; - } - - /** - * Subscribe to events from the sheet. - * @param html HTML content of the sheet. - */ - activateListeners(html) { - super.activateListeners(html); - - // Everything below here is only needed if the sheet is editable - if (!this.options.editable) { - return; - } - } - - /** - * Update item with values from the sheet. - * @param event - * @param formData - */ - _updateObject(event, formData) { - return this.object.update(formData); - } } diff --git a/system/scripts/items/technique-sheet.js b/system/scripts/items/technique-sheet.js index 964018f..dbe6dbe 100644 --- a/system/scripts/items/technique-sheet.js +++ b/system/scripts/items/technique-sheet.js @@ -14,36 +14,4 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e { tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }], }); } - - /** @override */ - getData() { - const sheetData = super.getData(); - sheetData.data.dtypes = ["String", "Number", "Boolean"]; - - sheetData.data.isTechnique = true; - // sheetData.data.isEquipment = false; - - return sheetData; - } - - /** - * Subscribe to events from the sheet. - * @param html HTML content of the sheet. - */ - activateListeners(html) { - super.activateListeners(html); - - // Everything below here is only needed if the sheet is editable - if (!this.options.editable) return; - } - - /** - * Update feat with the data from the sheet. - * @param event - * @param formData - */ - _updateObject(event, formData) { - // Update the Item - return this.object.update(formData); - } } diff --git a/system/scripts/items/weapon-sheet.js b/system/scripts/items/weapon-sheet.js index 2258a10..df9008e 100644 --- a/system/scripts/items/weapon-sheet.js +++ b/system/scripts/items/weapon-sheet.js @@ -20,32 +20,11 @@ export class WeaponSheetL5r5e extends ItemSheetL5r5e { const sheetData = super.getData(); sheetData.data.dtypes = ["String", "Number", "Boolean"]; - sheetData.data.isWeapon = true; - sheetData.data.isEquipment = true; + // Martial skills only sheetData.data.skills = Array.from(L5R5E.skills) .filter(([id, cat]) => cat === "martial") .map(([id, cat]) => id); return sheetData; } - - /** - * Subscribe to events from the sheet. - * @param html HTML content of the sheet. - */ - activateListeners(html) { - super.activateListeners(html); - - // Everything below here is only needed if the sheet is editable - if (!this.options.editable) return; - } - - /** - * Update item with values from the sheet. - * @param event - * @param formData - */ - _updateObject(event, formData) { - return this.object.update(formData); - } } diff --git a/system/scripts/main-l5r5e.js b/system/scripts/main-l5r5e.js index b2db6e8..b7e213a 100644 --- a/system/scripts/main-l5r5e.js +++ b/system/scripts/main-l5r5e.js @@ -83,39 +83,75 @@ Hooks.once("init", async function () { return a === b ? new Handlebars.SafeString('checked="checked"') : ""; }); - Handlebars.registerHelper("localizeSkillCategory", function (skillName) { - const key = "l5r5e.skills." + skillName.toLowerCase() + ".title"; + Handlebars.registerHelper("localizeSkill", function (categoryId, skillId) { + const key = "l5r5e.skills." + categoryId.toLowerCase() + "." + skillId.toLowerCase(); + return game.i18n.localize(key); + }); + Handlebars.registerHelper("localizeSkillId", function (skillId) { + const key = "l5r5e.skills." + L5R5E.skills.get(skillId.toLowerCase()) + "." + skillId.toLowerCase(); return game.i18n.localize(key); }); - Handlebars.registerHelper("localizeSkill", function (skillCategory, skillName) { - const key = "l5r5e.skills." + skillCategory.toLowerCase() + "." + skillName.toLowerCase(); + Handlebars.registerHelper("localizeRing", function (ringId) { + const key = "l5r5e.rings." + ringId.toLowerCase(); return game.i18n.localize(key); }); - Handlebars.registerHelper("localizeSkillId", function (skillName) { - const key = "l5r5e.skills." + L5R5E.skills.get(skillName.toLowerCase()) + "." + skillName.toLowerCase(); - return game.i18n.localize(key); - }); - - Handlebars.registerHelper("localizeRing", function (ringName) { - const key = "l5r5e.rings." + ringName.toLowerCase(); - return game.i18n.localize(key); - }); - - Handlebars.registerHelper("localizeRingTip", function (ringName) { - const key = "l5r5e.rings." + ringName.toLowerCase() + "tip"; - return game.i18n.localize(key); - }); - - Handlebars.registerHelper("localizeStanceTip", function (ringName) { - const key = "l5r5e.conflict.stances." + ringName.toLowerCase() + "tip"; + Handlebars.registerHelper("localizeStanceTip", function (ringId) { + const key = "l5r5e.conflict.stances." + ringId.toLowerCase() + "tip"; return game.i18n.localize(key); }); Handlebars.registerHelper("localizeTechnique", function (techniqueName) { return game.i18n.localize("l5r5e.techniques." + techniqueName.toLowerCase()); }); + + // Utility conditional, usable in nested expression + // ex: {{#ifCond (ifCond advancement.type '==' 'technique') '||' (ifCond advancement.type '==' 'advancement')}} + Handlebars.registerHelper("ifCond", function (a, operator, b, options) { + let result = false; + switch (operator) { + case "==": + result = a == b; + break; + case "===": + result = a === b; + break; + case "!=": + result = a != b; + break; + case "!==": + result = a !== b; + break; + case "<": + result = a < b; + break; + case "<=": + result = a <= b; + break; + case ">": + result = a > b; + break; + case ">=": + result = a >= b; + break; + case "&&": + result = a && b; + break; + case "||": + result = a || b; + break; + case "includes": + result = a && b && a.includes(b); + break; + default: + break; + } + if (typeof options.fn === "function") { + return result ? options.fn(this) : options.inverse(this); + } + return result; + }); }); /* ------------------------------------ */ diff --git a/system/scripts/sheets/base-sheet.js b/system/scripts/sheets/base-sheet.js index 46e07a8..9fd80f7 100644 --- a/system/scripts/sheets/base-sheet.js +++ b/system/scripts/sheets/base-sheet.js @@ -8,11 +8,6 @@ export class BaseSheetL5r5e extends ActorSheet { getData() { const sheetData = super.getData(); - this._prepareItems(sheetData); - - const techniques = sheetData.items.filter((item) => item.type === "technique"); - - sheetData.data.techniques.list = techniques; sheetData.data.stances = CONFIG.L5r5e.stances; return sheetData; @@ -27,55 +22,6 @@ export class BaseSheetL5r5e extends ActorSheet { return this.object.update(formData); } - /** - * Prepare item data to be displayed in the actor sheet. - * @param sheetData Data of the actor been displayed in the sheet. - */ - _prepareItems(sheetData) { - for (let item of sheetData.items) { - switch (item.type) { - case "weapon": - item.isWeapon = true; - item.isEquipment = true; - break; - - case "armor": - item.isArmor = true; - item.isEquipment = true; - break; - - case "technique": - item.isTechnique = true; - break; - - case "quality": - item.isQuality = true; - break; - - case "advancement": - item.isAdvancement = true; - break; - - case "advantage": - item.isAdvantage = true; - break; - - case "disadvantage": - item.isDisadvantage = true; - break; - - default: - item.isEquipment = true; - break; - } - } - } - - /** - * TODO - */ - _prepareTechniques() {} - /** * Subscribe to events from the sheet. * @param html HTML content of the sheet. @@ -83,107 +29,82 @@ export class BaseSheetL5r5e extends ActorSheet { activateListeners(html) { super.activateListeners(html); - // Everything below here is only needed if the sheet is editable - if (!this.options.editable) { - return; - } - - // *** Items *** - // Update Inventory Item - html.find(".item-edit").on("click", (ev) => { - const li = $(ev.currentTarget).parents(".item"); - const itemId = li.data("itemId"); - const item = this.actor.getOwnedItem(itemId); - item.sheet.render(true); - }); - - // Delete Inventory Item - html.find(".item-delete").on("click", (ev) => { - const li = $(ev.currentTarget).parents(".item"); - this.actor.deleteOwnedItem(li.data("itemId")); - }); - - // *** Techniques *** - html.find(".technique-add").on("click", (ev) => { - this._createTechnique(); - }); - - html.find(".technique-delete").on("click", (ev) => { - const li = $(ev.currentTarget).parents(".technique"); - const techniqueId = li.data("techniqueId"); - console.log("Remove technique" + techniqueId + " clicked"); - - this.actor.deleteOwnedItem(techniqueId); - }); - - html.find(".technique-edit").on("click", (ev) => { - const li = $(ev.currentTarget).parents(".technique"); - const techniqueId = li.data("techniqueId"); - const technique = this.actor.getOwnedItem(techniqueId); - technique.sheet.render(true); - }); - // *** Skills *** html.find(".skill-name").on("click", (ev) => { const li = $(ev.currentTarget).parents(".skill"); new game.l5r5e.DicePickerDialog({ skillId: li.data("skill"), actor: this.actor }).render(true); }); + // *** Everything below here is only needed if the sheet is editable *** + if (!this.options.editable) { + return; + } + + // *** Items / Inventory *** + html.find(".item-edit").on("click", (ev) => { + this._editSubItem(ev, "item"); + }); + html.find(".item-delete").on("click", (ev) => { + this._deleteSubItem(ev, "item"); + }); + + // *** Techniques *** + html.find(".technique-add").on("click", (ev) => { + this._addSubItem({ + name: game.i18n.localize("l5r5e.techniques.title_new"), + type: "technique", + }); + }); + html.find(".technique-edit").on("click", (ev) => { + this._editSubItem(ev, "technique"); + }); + html.find(".technique-delete").on("click", (ev) => { + this._deleteSubItem(ev, "technique"); + }); + // *** Advancement *** html.find(".advancement-add").on("click", (ev) => { - this._createAdvancement(); + this._addSubItem({ + name: game.i18n.localize("l5r5e.xp.advancements"), + type: "advancement", + }); }); - html.find(".advancement-edit").on("click", (ev) => { - const li = $(ev.currentTarget).parents(".advancement"); - const advancementId = li.data("advancementId"); - const advancement = this.actor.getOwnedItem(advancementId); - advancement.sheet.render(true); + this._editSubItem(ev, "advancement"); }); - html.find(".advancement-delete").on("click", (ev) => { - const li = $(ev.currentTarget).parents(".advancement"); - this.actor.deleteOwnedItem(li.data("advancementId")); + this._deleteSubItem(ev, "advancement"); }); } /** - * Creates a new feat for the character and shows a window to edit it. + * Add a generic item with sub type + * @private */ - async _createTechnique() { - const data = { - name: game.i18n.localize("l5r5e.techniques.title_new"), - type: "technique", - }; + async _addSubItem(data) { const created = await this.actor.createEmbeddedEntity("OwnedItem", data); - const technique = this.actor.getOwnedItem(created._id); - - // Default values - //technique.rank = 1; - //technique.xp_used = 0; - - technique.sheet.render(true); - - return technique; + const item = this.actor.getOwnedItem(created._id); + item.sheet.render(true); + return item; } /** - * Creates a new feat for the character and shows a window to edit it. + * Edit a generic item with sub type + * @private */ - async _createAdvancement() { - const data = { - name: game.i18n.localize("l5r5e.xp.acquisitions"), - type: "advancement", - }; - const created = await this.actor.createEmbeddedEntity("OwnedItem", data); - const acquisition = this.actor.getOwnedItem(created._id); + async _editSubItem(ev, type) { + const li = $(ev.currentTarget).parents("." + type); + const itemId = li.data(type + "Id"); + const item = this.actor.getOwnedItem(itemId); + item.sheet.render(true); + } - acquisition.sheet.render(true); - - // Default values - //acquisition.rank = 1; - //acquisition.xp_used = 0; - - return acquisition; + /** + * Delete a generic item with sub type + * @private + */ + async _deleteSubItem(ev, type) { + const li = $(ev.currentTarget).parents("." + type); + return this.actor.deleteOwnedItem(li.data(type + "Id")); } } diff --git a/system/templates/item/advancement-entry.html b/system/templates/item/advancement-entry.html index fccc138..a6cb621 100644 --- a/system/templates/item/advancement-entry.html +++ b/system/templates/item/advancement-entry.html @@ -2,8 +2,8 @@