From 1405feb3b7beff0ec5cab350c98223c28fa37e2d Mon Sep 17 00:00:00 2001 From: Vlyan Date: Wed, 16 Dec 2020 12:46:02 +0100 Subject: [PATCH] working on advancements --- system/lang/en-en.json | 1 + system/lang/es-es.json | 1 + system/lang/fr-fr.json | 1 + system/scripts/items/advancement-sheet.js | 48 +++++++++++++++++++ system/scripts/main-l5r5e.js | 4 +- system/scripts/preloadTemplates.js | 3 ++ system/template.json | 5 +- system/templates/item/advancement-entry.html | 9 ++++ system/templates/item/advancement-sheet.html | 31 ++++++++++++ system/templates/item/advancements.html | 10 ++++ system/templates/item/item-sheet.html | 2 +- .../templates/sheets/actor/advancement.html | 6 +-- system/templates/sheets/actor/experience.html | 8 ++-- system/templates/sheets/actor/techniques.html | 2 +- system/templates/sheets/npc/techniques.html | 2 +- 15 files changed, 121 insertions(+), 12 deletions(-) create mode 100644 system/scripts/items/advancement-sheet.js create mode 100644 system/templates/item/advancement-entry.html create mode 100644 system/templates/item/advancement-sheet.html create mode 100644 system/templates/item/advancements.html diff --git a/system/lang/en-en.json b/system/lang/en-en.json index 569f382..fe39b40 100644 --- a/system/lang/en-en.json +++ b/system/lang/en-en.json @@ -90,6 +90,7 @@ "physical": "physical", "supernatural": "supernatural" }, + "add": "Add", "items": "Items", "feats": "Feats", "techniques": { diff --git a/system/lang/es-es.json b/system/lang/es-es.json index 8c5a997..1a8140f 100644 --- a/system/lang/es-es.json +++ b/system/lang/es-es.json @@ -90,6 +90,7 @@ "physical": "physical", "supernatural": "supernatural" }, + "add": "Add", "items": "Equipo", "feats": "Feats", "techniques": { diff --git a/system/lang/fr-fr.json b/system/lang/fr-fr.json index f018467..63549d4 100644 --- a/system/lang/fr-fr.json +++ b/system/lang/fr-fr.json @@ -90,6 +90,7 @@ "physical": "Physique", "supernatural": "Spirituelle" }, + "add": "Ajouter", "items": "Objets", "feats": "Prouesses", "techniques": { diff --git a/system/scripts/items/advancement-sheet.js b/system/scripts/items/advancement-sheet.js new file mode 100644 index 0000000..b3551b0 --- /dev/null +++ b/system/scripts/items/advancement-sheet.js @@ -0,0 +1,48 @@ +import { ItemSheetL5r5e } from "./item-sheet.js"; + +/** + * @extends {ItemSheet} + */ +export class AdvancementSheetL5r5e extends ItemSheetL5r5e { + /** @override */ + static get defaultOptions() { + return mergeObject(super.defaultOptions, { + classes: ["l5r5e", "sheet", "advancement"], + template: CONFIG.L5r5e.paths.templates + "item/advancement-sheet.html", + width: 520, + height: 480, + 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/main-l5r5e.js b/system/scripts/main-l5r5e.js index 7e6e8a4..b2db6e8 100644 --- a/system/scripts/main-l5r5e.js +++ b/system/scripts/main-l5r5e.js @@ -12,6 +12,7 @@ import { ArmorSheetL5r5e } from "./items/armor-sheet.js"; import { WeaponSheetL5r5e } from "./items/weapon-sheet.js"; import { TechniqueSheetL5r5e } from "./items/technique-sheet.js"; import { QualitySheetL5r5e } from "./items/quality-sheet.js"; +import { AdvancementSheetL5r5e } from "./items/advancement-sheet.js"; // Import Dice Types @@ -69,6 +70,7 @@ Hooks.once("init", async function () { Items.registerSheet("l5r5e", WeaponSheetL5r5e, { types: ["weapon"], makeDefault: true }); Items.registerSheet("l5r5e", TechniqueSheetL5r5e, { types: ["technique"], makeDefault: true }); Items.registerSheet("l5r5e", QualitySheetL5r5e, { types: ["quality"], makeDefault: true }); + Items.registerSheet("l5r5e", AdvancementSheetL5r5e, { types: ["advancement"], makeDefault: true }); // for debug Handlebars.registerHelper("json", function (...objects) { @@ -111,7 +113,7 @@ Hooks.once("init", async function () { return game.i18n.localize(key); }); - Handlebars.registerHelper("localizeTechniques", function (techniqueName) { + Handlebars.registerHelper("localizeTechnique", function (techniqueName) { return game.i18n.localize("l5r5e.techniques." + techniqueName.toLowerCase()); }); }); diff --git a/system/scripts/preloadTemplates.js b/system/scripts/preloadTemplates.js index 16686bc..acf9c41 100644 --- a/system/scripts/preloadTemplates.js +++ b/system/scripts/preloadTemplates.js @@ -35,6 +35,9 @@ export const PreloadTemplates = async function () { "systems/l5r5e/templates/item/qualities.html", "systems/l5r5e/templates/item/quality-sheet.html", "systems/l5r5e/templates/item/quality-entry.html", + "systems/l5r5e/templates/item/advancements.html", + "systems/l5r5e/templates/item/advancement-sheet.html", + "systems/l5r5e/templates/item/advancement-entry.html", ]; return loadTemplates(templatePaths); diff --git a/system/template.json b/system/template.json index 0007374..fe0aa96 100644 --- a/system/template.json +++ b/system/template.json @@ -101,7 +101,6 @@ }, "character": { "templates": ["identity", "rings", "social", "skills", "techniques", "conflict", "xp"], - "advancements": [], "zeni": 0, "notes": "", "twenty_questions": {} @@ -189,7 +188,9 @@ "description": "" }, "advancement": { - "description": "TODO" + "xp_used": 0, + "rank": "", + "description": "" } } } diff --git a/system/templates/item/advancement-entry.html b/system/templates/item/advancement-entry.html new file mode 100644 index 0000000..fccc138 --- /dev/null +++ b/system/templates/item/advancement-entry.html @@ -0,0 +1,9 @@ +
  • + +
    {{{ advancement.data.description }}}
    +
  • \ No newline at end of file diff --git a/system/templates/item/advancement-sheet.html b/system/templates/item/advancement-sheet.html new file mode 100644 index 0000000..db88efb --- /dev/null +++ b/system/templates/item/advancement-sheet.html @@ -0,0 +1,31 @@ +
    +
    + +
    +

    +
    +
    + {{!-- Sheet Body --}} +
    + {{!-- Sheet Tab Navigation --}} + + {{!-- Description Tab --}} +
    + {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} +
    + {{!-- Attributes Tab --}} +
    + + +
    +
    +
    \ No newline at end of file diff --git a/system/templates/item/advancements.html b/system/templates/item/advancements.html new file mode 100644 index 0000000..07dae67 --- /dev/null +++ b/system/templates/item/advancements.html @@ -0,0 +1,10 @@ +
    + {{ localize 'l5r5e.xp.Acquisitions' }} + +
    \ No newline at end of file diff --git a/system/templates/item/item-sheet.html b/system/templates/item/item-sheet.html index eab797f..72a8a2e 100644 --- a/system/templates/item/item-sheet.html +++ b/system/templates/item/item-sheet.html @@ -42,7 +42,7 @@
  • Value
  • Label
  • Data Type
  • -
  • +
    1. {{#each data.attributes as |attr key|}} diff --git a/system/templates/sheets/actor/advancement.html b/system/templates/sheets/actor/advancement.html index 3ed1ef7..1cf4504 100644 --- a/system/templates/sheets/actor/advancement.html +++ b/system/templates/sheets/actor/advancement.html @@ -1,5 +1,5 @@ - {{ acquisition.name }} - {{ acquisition.data.xp_used }} - {{ acquisition.data.rank }} + {{ advancement.name }} + {{ advancement.data.xp_used }} + {{ advancement.data.rank }} \ No newline at end of file diff --git a/system/templates/sheets/actor/experience.html b/system/templates/sheets/actor/experience.html index 52a709f..d0ea3bb 100644 --- a/system/templates/sheets/actor/experience.html +++ b/system/templates/sheets/actor/experience.html @@ -24,9 +24,11 @@ - {{#each data.advancements as |acquisition acquisitionId| }} - {{> 'systems/l5r5e/templates/sheets/actor/advancement.html' acquisition=acquisition }} - {{/each}} + {{#each actor.items as |advancement advancementId|}} + {{#if advancement.isAdvancement }} + {{> 'systems/l5r5e/templates/sheets/actor/advancement.html' advancement=advancement }} + {{/if}} + {{/each}} \ No newline at end of file diff --git a/system/templates/sheets/actor/techniques.html b/system/templates/sheets/actor/techniques.html index 978c7ed..422bc98 100644 --- a/system/templates/sheets/actor/techniques.html +++ b/system/templates/sheets/actor/techniques.html @@ -2,7 +2,7 @@
      {{ localize 'l5r5e.techniques.title' }} - +
        {{#each actor.items as |item id|}} diff --git a/system/templates/sheets/npc/techniques.html b/system/templates/sheets/npc/techniques.html index 978c7ed..422bc98 100644 --- a/system/templates/sheets/npc/techniques.html +++ b/system/templates/sheets/npc/techniques.html @@ -2,7 +2,7 @@
        {{ localize 'l5r5e.techniques.title' }} - +
          {{#each actor.items as |item id|}}