From 971c33321e6f62de63fca6a099ef0011ca88ab6e Mon Sep 17 00:00:00 2001 From: Vlyan Date: Tue, 15 Dec 2020 10:56:19 +0100 Subject: [PATCH] add armor item --- system/lang/en-en.json | 9 +++- system/lang/es-es.json | 9 +++- system/lang/fr-fr.json | 9 +++- system/scripts/items/armor-sheet.js | 47 ++++++++++++++++++++ system/scripts/main-l5r5e.js | 2 + system/scripts/preloadTemplates.js | 2 + system/scripts/sheets/actor-sheet.js | 25 ++++++++--- system/scripts/sheets/npc-sheet.js | 25 ++++++++--- system/template.json | 12 ++++- system/templates/item/armor-entry.html | 12 +++++ system/templates/item/armor-sheet.html | 41 +++++++++++++++++ system/templates/item/armors.html | 10 +++++ system/templates/sheets/actor/narrative.html | 6 +-- system/templates/sheets/actor/social.html | 6 +-- system/templates/sheets/npc-sheet.html | 2 + 15 files changed, 190 insertions(+), 27 deletions(-) create mode 100644 system/scripts/items/armor-sheet.js create mode 100644 system/templates/item/armor-entry.html create mode 100644 system/templates/item/armor-sheet.html create mode 100644 system/templates/item/armors.html diff --git a/system/lang/en-en.json b/system/lang/en-en.json index 9c5d92b..507fbcf 100644 --- a/system/lang/en-en.json +++ b/system/lang/en-en.json @@ -85,6 +85,11 @@ "range": "Range", "properties": "Properties", "weapons": "Weapons", + "armors": { + "title": "Armors", + "physical": "physical", + "spiritual": "spiritual" + }, "items": "Items", "feats": "Feats", "skill": "Skill", @@ -96,14 +101,14 @@ "equipment": "Equipment", "rank": "Rank", "name": "Name", - "socialstanding": { + "social": { "title": "Social Standing", "honor": "Honor", "glory": "Glory", "status": "Status", "ninjo": "Ninjo", "giri": "Giri", - "socialtitles": "Titles" + "titles": "Titles" }, "skills": { "title": "Skills", diff --git a/system/lang/es-es.json b/system/lang/es-es.json index 32c252d..6a72324 100644 --- a/system/lang/es-es.json +++ b/system/lang/es-es.json @@ -85,6 +85,11 @@ "range": "Rango", "properties": "Propiedades", "weapons": "Armas", + "armors": { + "title": "Armors", + "physical": "physical", + "spiritual": "spiritual" + }, "items": "Equipo", "feats": "Rasgos", "skill": "Habilidad", @@ -96,14 +101,14 @@ "equipment": "Equipo", "rank": "Rango", "name": "Nombre", - "socialstanding": { + "social": { "title": "Posición Social", "honor": "Honor", "glory": "Gloria", "status": "Estatus", "ninjo": "Ninjo", "giri": "Giri", - "socialtitles": "Títulos" + "titles": "Títulos" }, "skills": { "title": "Habilidades", diff --git a/system/lang/fr-fr.json b/system/lang/fr-fr.json index ec76b9e..66448fe 100644 --- a/system/lang/fr-fr.json +++ b/system/lang/fr-fr.json @@ -85,6 +85,11 @@ "range": "Distance", "properties": "Propriétés", "weapons": "Armement", + "armors": { + "title": "Armures", + "physical": "Physique", + "spiritual": "Spirituelle" + }, "items": "Equipement", "feats": "Techniques", "skill": "Compétence", @@ -96,14 +101,14 @@ "equipment": "Equipement", "rank": "Rang", "name": "Nom", - "socialstanding": { + "social": { "title": "Position Social", "honor": "Honneur", "glory": "Gloire", "status": "Status", "ninjo": "Ninjo", "giri": "Giri", - "socialtitles": "Titres" + "titles": "Titres" }, "skills": { "title": "Compétences", diff --git a/system/scripts/items/armor-sheet.js b/system/scripts/items/armor-sheet.js new file mode 100644 index 0000000..8312428 --- /dev/null +++ b/system/scripts/items/armor-sheet.js @@ -0,0 +1,47 @@ +import { ItemSheetL5r5e } from "./item-sheet.js"; + +/** + * @extends {ItemSheet} + */ +export class ArmorSheetL5r5e extends ItemSheetL5r5e { + /** @override */ + static get defaultOptions() { + return mergeObject(super.defaultOptions, { + classes: ["l5r5e", "sheet", "armor"], + template: CONFIG.L5r5e.paths.templates + "item/armor-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.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/main-l5r5e.js b/system/scripts/main-l5r5e.js index 2a304cd..5b527f5 100644 --- a/system/scripts/main-l5r5e.js +++ b/system/scripts/main-l5r5e.js @@ -8,6 +8,7 @@ import { NpcSheetL5r5e } from "./sheets/npc-sheet.js"; import { RollL5r5e, AbilityDie, RingDie, DicePickerDialog } from "./dice-l5r5e.js"; import { ItemL5r5e } from "./items/item.js"; import { ItemSheetL5r5e } from "./items/item-sheet.js"; +import { ArmorSheetL5r5e } from "./items/armor-sheet.js"; import { WeaponSheetL5r5e } from "./items/weapon-sheet.js"; import { FeatSheetL5r5e } from "./items/feat-sheet.js"; @@ -63,6 +64,7 @@ Hooks.once("init", async function () { // Items sheet Items.unregisterSheet("core", ItemSheet); Items.registerSheet("l5r5e", ItemSheetL5r5e, { types: ["item"], makeDefault: true }); + Items.registerSheet("l5r5e", ArmorSheetL5r5e, { types: ["armor"], makeDefault: true }); Items.registerSheet("l5r5e", WeaponSheetL5r5e, { types: ["weapon"], makeDefault: true }); Items.registerSheet("l5r5e", FeatSheetL5r5e, { types: ["feat"], makeDefault: true }); diff --git a/system/scripts/preloadTemplates.js b/system/scripts/preloadTemplates.js index 56ad80a..2ce0e6d 100644 --- a/system/scripts/preloadTemplates.js +++ b/system/scripts/preloadTemplates.js @@ -19,6 +19,8 @@ export const PreloadTemplates = async function () { "systems/l5r5e/templates/item/item-entry.html", "systems/l5r5e/templates/item/weapons.html", "systems/l5r5e/templates/item/weapon-entry.html", + "systems/l5r5e/templates/item/armors.html", + "systems/l5r5e/templates/item/armor-entry.html", "systems/l5r5e/templates/item/feat-sheet.html", "systems/l5r5e/templates/item/feat-entry.html", ]; diff --git a/system/scripts/sheets/actor-sheet.js b/system/scripts/sheets/actor-sheet.js index 44ec24f..71aa6ce 100644 --- a/system/scripts/sheets/actor-sheet.js +++ b/system/scripts/sheets/actor-sheet.js @@ -58,13 +58,24 @@ export class ActorSheetL5r5e extends ActorSheet { */ _prepareItems(sheetData) { for (let item of sheetData.items) { - if (item.type === "weapon") { - item.isWeapon = true; - item.isEquipment = true; - } else if (item.type === "feat") { - item.isFeat = true; - } else { - item.isEquipment = true; + switch (item.type) { + case "weapon": + item.isWeapon = true; + item.isEquipment = true; + break; + + case "armor": + item.isArmor = true; + item.isEquipment = true; + break; + + case "feat": + item.isFeat = true; + break; + + default: + item.isEquipment = true; + break; } } } diff --git a/system/scripts/sheets/npc-sheet.js b/system/scripts/sheets/npc-sheet.js index 3d868f4..93aaf8d 100644 --- a/system/scripts/sheets/npc-sheet.js +++ b/system/scripts/sheets/npc-sheet.js @@ -40,13 +40,24 @@ export class NpcSheetL5r5e extends ActorSheet { */ _prepareItems(sheetData) { for (let item of sheetData.items) { - if (item.type === "weapon") { - item.isWeapon = true; - item.isEquipment = true; - } else if (item.type === "feat") { - item.isFeat = true; - } else { - item.isEquipment = true; + switch (item.type) { + case "weapon": + item.isWeapon = true; + item.isEquipment = true; + break; + + case "armor": + item.isArmor = true; + item.isEquipment = true; + break; + + case "feat": + item.isFeat = true; + break; + + default: + item.isEquipment = true; + break; } } } diff --git a/system/template.json b/system/template.json index aa8d004..1f606c7 100644 --- a/system/template.json +++ b/system/template.json @@ -121,12 +121,22 @@ } }, "Item": { - "types": ["item", "weapon", "feat", "xp-advancement"], + "types": ["item", "armor", "weapon", "feat", "xp-advancement"], "item": { "description": "", "quantity": 1, "weight": 0 }, + "armor": { + "quantity": 1, + "weight": 0, + "description": "", + "armor": { + "physical": 0, + "spiritual": 0 + }, + "properties": "" + }, "weapon": { "quantity": 1, "weight": 0, diff --git a/system/templates/item/armor-entry.html b/system/templates/item/armor-entry.html new file mode 100644 index 0000000..71bcad6 --- /dev/null +++ b/system/templates/item/armor-entry.html @@ -0,0 +1,12 @@ +
  • + +
    {{{ item.data.properties }}}
    +
  • \ No newline at end of file diff --git a/system/templates/item/armor-sheet.html b/system/templates/item/armor-sheet.html new file mode 100644 index 0000000..a0d0dd9 --- /dev/null +++ b/system/templates/item/armor-sheet.html @@ -0,0 +1,41 @@ +
    +
    + +
    +

    +
    + + +
    +
    + + +
    +
    +
    + {{!-- Sheet Body --}} +
    + {{!-- Sheet Tab Navigation --}} + + {{!-- Description Tab --}} +
    + {{ localize 'l5r5e.armors.title' }} +
    + + +
    +
    + {{ localize 'l5r5e.properties' }} + {{editor content=data.properties target="data.properties" button=true owner=owner editable=editable}} +
    +
    +
    +
    diff --git a/system/templates/item/armors.html b/system/templates/item/armors.html new file mode 100644 index 0000000..77006d0 --- /dev/null +++ b/system/templates/item/armors.html @@ -0,0 +1,10 @@ +
    + {{ localize 'l5r5e.armors.title' }} + +
    \ No newline at end of file diff --git a/system/templates/sheets/actor/narrative.html b/system/templates/sheets/actor/narrative.html index 9e958ad..a4b03ac 100644 --- a/system/templates/sheets/actor/narrative.html +++ b/system/templates/sheets/actor/narrative.html @@ -1,14 +1,14 @@ diff --git a/system/templates/sheets/actor/social.html b/system/templates/sheets/actor/social.html index 25e0557..97efdc3 100644 --- a/system/templates/sheets/actor/social.html +++ b/system/templates/sheets/actor/social.html @@ -1,19 +1,19 @@