diff --git a/system/lang/en-en.json b/system/lang/en-en.json index 73496ea..68060da 100644 --- a/system/lang/en-en.json +++ b/system/lang/en-en.json @@ -211,11 +211,12 @@ "voidtip": "You do not receive strife from Strife symbols on checks." } }, - "xp": { + "advancements": { + "title": "Advancements", + "title_new": "New advancement", "total": "Total", "spent": "Used", - "saved": "Saved", - "advancements": "Advancements" + "saved": "Saved" }, "twenty_questions": { "title": "Twenty questions", diff --git a/system/lang/es-es.json b/system/lang/es-es.json index b698d73..f20343c 100644 --- a/system/lang/es-es.json +++ b/system/lang/es-es.json @@ -210,11 +210,12 @@ "voidtip": "No acumulas Conflicto de los símbolos de Conflicto de tus tiradas." } }, - "xp": { + "advancements": { + "title": "Advancements", + "title_new": "New advancement", "total": "Total", "spent": "Usada", - "saved": "Restante", - "advancements": "Advancements" + "saved": "Restante" }, "twenty_questions": { "title": "Twenty questions", diff --git a/system/lang/fr-fr.json b/system/lang/fr-fr.json index 705a703..f8f53ba 100644 --- a/system/lang/fr-fr.json +++ b/system/lang/fr-fr.json @@ -215,11 +215,12 @@ "voidtip": "Tant que vous êtes dans cette posture, vous ne subissez aucun point de Conflit en cas de Conflit." } }, - "xp": { + "advancements": { + "title": "Progressions", + "title_new": "Nouvelle progression", "total": "Totale", "spent": "Dépensée", - "saved": "Restante", - "advancements": "Progressions" + "saved": "Restante" }, "twenty_questions": { "title": "Vingt questions", diff --git a/system/scripts/items/advancement-sheet.js b/system/scripts/items/advancement-sheet.js index e640796..2c42080 100644 --- a/system/scripts/items/advancement-sheet.js +++ b/system/scripts/items/advancement-sheet.js @@ -4,6 +4,11 @@ import { ItemSheetL5r5e } from "./item-sheet.js"; * @extends {ItemSheet} */ export class AdvancementSheetL5r5e extends ItemSheetL5r5e { + /** + * Sub Types of advancements + */ + static types = ["ring", "skill", "advantage"]; // "technique" has it's own type + /** @override */ static get defaultOptions() { return mergeObject(super.defaultOptions, { @@ -14,4 +19,13 @@ 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.subTypesList = AdvancementSheetL5r5e.types; + + return sheetData; + } } diff --git a/system/scripts/items/item-sheet.js b/system/scripts/items/item-sheet.js index b5c5fa4..dc577e6 100644 --- a/system/scripts/items/item-sheet.js +++ b/system/scripts/items/item-sheet.js @@ -19,6 +19,20 @@ export class ItemSheetL5r5e extends ItemSheet { sheetData.data.dtypes = ["String", "Number", "Boolean"]; + sheetData.data.ringsList = CONFIG.L5r5e.stances.map((e) => { + return { + id: e, + label: game.i18n.localize(`l5r5e.rings.${e}`), + }; + }); + + sheetData.data.techniquesList = CONFIG.L5r5e.techniques.map((e) => { + return { + id: e, + label: game.i18n.localize(`l5r5e.techniques.${e}`), + }; + }); + return sheetData; } diff --git a/system/scripts/items/peculiarity-sheet.js b/system/scripts/items/peculiarity-sheet.js index 595abc9..5046647 100644 --- a/system/scripts/items/peculiarity-sheet.js +++ b/system/scripts/items/peculiarity-sheet.js @@ -8,7 +8,7 @@ export class PeculiaritySheetL5r5e extends ItemSheetL5r5e { /** * Sub Types of Advantage/Disadvantage */ - static SUB_TYPES = ["distinction", "passion", "adversity", "anxiety"]; + static types = ["distinction", "passion", "adversity", "anxiety"]; /** @override */ static get defaultOptions() { @@ -23,7 +23,10 @@ export class PeculiaritySheetL5r5e extends ItemSheetL5r5e { getData() { const sheetData = super.getData(); + sheetData.data.dtypes = ["String", "Number", "Boolean"]; + sheetData.data.subTypesList = PeculiaritySheetL5r5e.types; + return sheetData; } } diff --git a/system/scripts/main-l5r5e.js b/system/scripts/main-l5r5e.js index b7e213a..920b0d2 100644 --- a/system/scripts/main-l5r5e.js +++ b/system/scripts/main-l5r5e.js @@ -13,6 +13,7 @@ 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 { PeculiaritySheetL5r5e } from "./items/peculiarity-sheet.js"; // Import Dice Types @@ -70,6 +71,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", PeculiaritySheetL5r5e, { types: ["peculiarity"], makeDefault: true }); Items.registerSheet("l5r5e", AdvancementSheetL5r5e, { types: ["advancement"], makeDefault: true }); // for debug diff --git a/system/scripts/preloadTemplates.js b/system/scripts/preloadTemplates.js index acf9c41..92ea930 100644 --- a/system/scripts/preloadTemplates.js +++ b/system/scripts/preloadTemplates.js @@ -38,6 +38,9 @@ export const PreloadTemplates = async function () { "systems/l5r5e/templates/item/advancements.html", "systems/l5r5e/templates/item/advancement-sheet.html", "systems/l5r5e/templates/item/advancement-entry.html", + "systems/l5r5e/templates/item/peculiarities.html", + "systems/l5r5e/templates/item/peculiarity-sheet.html", + "systems/l5r5e/templates/item/peculiarity-entry.html", ]; return loadTemplates(templatePaths); diff --git a/system/scripts/sheets/actor-sheet.js b/system/scripts/sheets/actor-sheet.js index 30ba8e9..ea914dd 100644 --- a/system/scripts/sheets/actor-sheet.js +++ b/system/scripts/sheets/actor-sheet.js @@ -31,7 +31,44 @@ export class ActorSheetL5r5e extends BaseSheetL5r5e { await new TwentyQuestionsDialog({}, this.actor).render(true); }, }); - return buttons; } + + /** + * Commons datas + */ + getData() { + const sheetData = super.getData(); + + // Sort Items by rank 0->6 for advancements tab + sheetData.items.sort((a, b) => { + return (a.data.bought_at_rank || 0) - (b.data.bought_at_rank || 0); + }); + + // Xp spent only in current rank + sheetData.data.advancement.xp_spent_rank = this.getXpSpentInThisRank(); + + return sheetData; + } + + /** + * Return the current total xp spent for this rank + */ + getXpSpentInThisRank() { + const currentRank = this.actor.data.data.identity.school_rank || 0; + const spent = this.actor.items.reduce((tot, item) => { + // TODO c'est bien par rang actuel +1 ? + if (currentRank + 1 === item.data.data.rank) { + let xp = item.data.data.xp_used || 0; + + // if not in curriculum, xp spent /2 for this item + if (!item.data.data.in_curriculum && xp > 0) { + xp = Math.floor(xp / 2); + } + return tot + xp; + } + return tot; + }, 0); + return spent; + } } diff --git a/system/scripts/sheets/base-sheet.js b/system/scripts/sheets/base-sheet.js index 0f6df4d..b2023ee 100644 --- a/system/scripts/sheets/base-sheet.js +++ b/system/scripts/sheets/base-sheet.js @@ -8,6 +8,7 @@ export class BaseSheetL5r5e extends ActorSheet { getData() { const sheetData = super.getData(); + sheetData.data.dtypes = ["String", "Number", "Boolean"]; sheetData.data.stances = CONFIG.L5r5e.stances; return sheetData; @@ -48,41 +49,35 @@ export class BaseSheetL5r5e extends ActorSheet { 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"); + // *** Items : edit, delete *** + ["item", "peculiarity", "technique", "advancement"].forEach((type) => { + html.find(`.${type}-edit`).on("click", (ev) => { + this._editSubItem(ev, type); + }); + html.find(`.${type}-delete`).on("click", (ev) => { + this._deleteSubItem(ev, type); + }); + + if (type !== "item") { + html.find(`.${type}-curriculum`).on("click", (ev) => { + this._switchSubItemCurriculum(ev, type); + }); + } }); - // *** Techniques *** + // *** Items : add *** 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._addSubItem({ - name: game.i18n.localize("l5r5e.xp.advancements"), + name: game.i18n.localize("l5r5e.advancements.title_new"), type: "advancement", }); }); - html.find(".advancement-edit").on("click", (ev) => { - this._editSubItem(ev, "advancement"); - }); - html.find(".advancement-delete").on("click", (ev) => { - this._deleteSubItem(ev, "advancement"); - }); } /** @@ -115,4 +110,19 @@ export class BaseSheetL5r5e extends ActorSheet { const li = $(ev.currentTarget).parents("." + type); return this.actor.deleteOwnedItem(li.data(type + "Id")); } + + /** + * Switch "in_curriculum" + * @private + */ + _switchSubItemCurriculum(ev, type) { + const li = $(ev.currentTarget).parents("." + type); + const itemId = li.data(type + "Id"); + const item = this.actor.getOwnedItem(itemId); + return item.update({ + data: { + in_curriculum: !item.data.data.in_curriculum, + }, + }); + } } diff --git a/system/scripts/sheets/twenty-questions-dialog.js b/system/scripts/sheets/twenty-questions-dialog.js index a80ed3e..c9b852d 100644 --- a/system/scripts/sheets/twenty-questions-dialog.js +++ b/system/scripts/sheets/twenty-questions-dialog.js @@ -128,21 +128,21 @@ export class TwentyQuestionsDialog extends FormApplication { let data; try { data = JSON.parse(event.dataTransfer.getData("text/plain")); - if (data.type !== "Item") return; - - const item = game.items.get(data.id); - - if (item.data.type !== type) { + if (data.type !== "Item") { return; } + + const item = game.items.get(data.id); + if (item || item.data.type !== type) { + return; + } + + // TODO console.log("** OK ", item); // sub_type === 'peculiarity' } catch (err) { - return false; + console.warn(err); } - - // TODO - return false; } diff --git a/system/template.json b/system/template.json index d32af32..2808b81 100644 --- a/system/template.json +++ b/system/template.json @@ -81,7 +81,7 @@ "strife": 0, "stance": "void" }, - "xp": { + "advancement": { "xp_total": 0, "xp_spent": 0, "xp_saved": 0 @@ -134,10 +134,10 @@ } }, "Item": { - "types": ["item", "armor", "weapon", "technique", "quality", "advantage", "disadvantage", "advancement"], + "types": ["item", "armor", "weapon", "technique", "quality", "peculiarity", "advancement"], "item": { "description": "", - "properties": "", + "properties": [], "quantity": 1, "rarity": 0, "weight": 0, @@ -152,7 +152,7 @@ "physical": 0, "supernatural": 0 }, - "properties": "", + "properties": [], "rarity": 0, "zeni": 0, "equipped": false @@ -165,7 +165,7 @@ "deadliness": 0, "grip_1": "", "grip_2": "", - "properties": "", + "properties": [], "quantity": 1, "rarity": 0, "weight": 0, @@ -175,8 +175,10 @@ }, "technique": { "technique_type": "", + "in_curriculum": false, "xp_used": 0, - "rank": 0, + "rank": 1, + "bought_at_rank": 1, "ring": "", "effects": "", "description": "" @@ -184,15 +186,22 @@ "quality": { "description": "" }, - "advantage": { - "description": "" - }, - "disadvantage": { + "peculiarity": { + "peculiarity_type": "distinction", + "in_curriculum": false, + "xp_used": 0, + "rank": 1, + "bought_at_rank": 1, + "ring": "void", + "types": "", "description": "" }, "advancement": { + "advancement_type": "", + "in_curriculum": false, "xp_used": 0, - "rank": "", + "rank": 1, + "bought_at_rank": 1, "description": "" } } diff --git a/system/templates/item/advancement-sheet.html b/system/templates/item/advancement-sheet.html index 44a3ebe..f7aa824 100644 --- a/system/templates/item/advancement-sheet.html +++ b/system/templates/item/advancement-sheet.html @@ -18,14 +18,32 @@ {{!-- Attributes Tab --}}
+ + + + + +
\ No newline at end of file diff --git a/system/templates/item/advancements.html b/system/templates/item/advancements.html index 25b7fcf..5dc9f97 100644 --- a/system/templates/item/advancements.html +++ b/system/templates/item/advancements.html @@ -1,5 +1,5 @@
- {{ localize 'l5r5e.xp.advancements' }} + {{ localize 'l5r5e.advancements.title' }}
    - {{#each data.attributes as |attr key|}} -
  1. - - {{#if attr.isCheckbox}} - - {{else}} - - {{/if}} - - - -
  2. - {{/each}} +
    + {{ localize 'l5r5e.properties' }} + +
    +
diff --git a/system/templates/item/peculiarities.html b/system/templates/item/peculiarities.html new file mode 100644 index 0000000..5dc9f97 --- /dev/null +++ b/system/templates/item/peculiarities.html @@ -0,0 +1,10 @@ +
+ {{ localize 'l5r5e.advancements.title' }} + +
\ No newline at end of file diff --git a/system/templates/item/peculiarity-entry.html b/system/templates/item/peculiarity-entry.html new file mode 100644 index 0000000..a6cb621 --- /dev/null +++ b/system/templates/item/peculiarity-entry.html @@ -0,0 +1,9 @@ +
  • + +
    {{{ advancement.data.description }}}
    +
  • \ No newline at end of file diff --git a/system/templates/item/peculiarity-sheet.html b/system/templates/item/peculiarity-sheet.html new file mode 100644 index 0000000..d58dc7d --- /dev/null +++ b/system/templates/item/peculiarity-sheet.html @@ -0,0 +1,64 @@ +
    +
    + +
    +

    +
    +
    + + {{!-- Sheet Body --}} +
    + {{!-- Sheet Tab Navigation --}} + + {{!-- Description Tab --}} +
    + {{editor content=item.data.description target="item.data.description" button=true owner=owner editable=editable}} +
    + {{!-- Attributes Tab --}} +
    + + + + + + + + + + + + +
    +
    +
    \ No newline at end of file diff --git a/system/templates/item/technique-sheet.html b/system/templates/item/technique-sheet.html index 44a3ebe..7fbf0e1 100644 --- a/system/templates/item/technique-sheet.html +++ b/system/templates/item/technique-sheet.html @@ -18,14 +18,46 @@ {{!-- Attributes Tab --}}
    + + + + + + + + + + +
    \ No newline at end of file diff --git a/system/templates/item/weapon-sheet.html b/system/templates/item/weapon-sheet.html index 0ea9eec..d3d8c2e 100644 --- a/system/templates/item/weapon-sheet.html +++ b/system/templates/item/weapon-sheet.html @@ -28,6 +28,10 @@ {{/select}} +
    @@ -72,7 +76,7 @@
    {{ localize 'l5r5e.properties' }} - {{editor content=data.properties target="data.properties" button=true owner=owner editable=editable}} +
    {{ localize 'l5r5e.description' }} diff --git a/system/templates/sheets/actor/advancement.html b/system/templates/sheets/actor/advancement.html index e311233..c8b7eea 100644 --- a/system/templates/sheets/actor/advancement.html +++ b/system/templates/sheets/actor/advancement.html @@ -1,8 +1,9 @@ - {{ advancement.name }} + {{#if advancement.data.in_curriculum}} {{/if}}{{ advancement.name }} {{ advancement.data.xp_used }} {{ advancement.data.rank }} +
  • diff --git a/system/templates/sheets/actor/experience.html b/system/templates/sheets/actor/experience.html index fac810c..9e8d292 100644 --- a/system/templates/sheets/actor/experience.html +++ b/system/templates/sheets/actor/experience.html @@ -1,35 +1,41 @@
    {{ localize 'l5r5e.experience'}} + + +
    - {{ localize 'l5r5e.xp.advancements'}} + {{ localize 'l5r5e.advancements.title'}} - + {{#each actor.items as |advancement advancementId|}} - {{#ifCond (ifCond advancement.type '==' 'technique') '||' (ifCond advancement.type '==' 'advancement')}} + {{#ifCond '["peculiarity", "technique","advancement"]' 'includes' advancement.type}} {{> 'systems/l5r5e/templates/sheets/actor/advancement.html' advancement=advancement }} {{/ifCond}} {{/each}}
    {{ localize 'l5r5e.name' }}{{ localize 'l5r5e.xp.spent' }}{{ localize 'l5r5e.advancements.spent' }} {{ localize 'l5r5e.rank' }}
    -
    \ No newline at end of file +
    diff --git a/system/templates/sheets/actor/rings.html b/system/templates/sheets/actor/rings.html index 86eac77..a20d1f4 100644 --- a/system/templates/sheets/actor/rings.html +++ b/system/templates/sheets/actor/rings.html @@ -3,35 +3,35 @@
  • \ No newline at end of file