From f8afea9513fcfd5cf64a1d389f76e83a1a2ee443 Mon Sep 17 00:00:00 2001 From: Vlyan Date: Sat, 22 May 2021 23:12:54 +0200 Subject: [PATCH] Working on 0.8.x - Showing titles (title_ability) in techniques pc/npc --- system/scripts/actors/base-sheet.js | 16 ++++++++++------ system/scripts/actors/npc-sheet.js | 4 +++- system/scripts/config.js | 2 +- system/template.json | 14 +++++--------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/system/scripts/actors/base-sheet.js b/system/scripts/actors/base-sheet.js index e59f729..d32c67c 100644 --- a/system/scripts/actors/base-sheet.js +++ b/system/scripts/actors/base-sheet.js @@ -16,11 +16,8 @@ export class BaseSheetL5r5e extends ActorSheet { }); } - /** - * Commons datas - * @override - */ - getData(options) { + /** @inheritdoc */ + getData(options = {}) { const sheetData = super.getData(options); sheetData.data.dtypes = ["String", "Number", "Boolean"]; @@ -64,11 +61,17 @@ export class BaseSheetL5r5e extends ActorSheet { break; case "title": + // Embed technique in titles Array.from(item.data.items).forEach(([id, embedItem]) => { if (embedItem.data.type === "technique") { out[embedItem.data.data.technique_type].push(embedItem.data); } }); + + // If unlocked, add the "title_ability" as technique (or always displayed for npc) + if (item.data.xp_used >= item.data.xp_cost || this.document.type === "npc") { + out["title_ability"].push(item); + } break; } //swi }); @@ -84,10 +87,11 @@ export class BaseSheetL5r5e extends ActorSheet { sheetData.data.data.techniques["school_ability"] = out["school_ability"].length === 0; sheetData.data.data.techniques["mastery_ability"] = out["mastery_ability"].length === 0; - // Always display "school_ability", but display "mastery_ability" only if rank >= 5 + // Always display "school_ability", but display a empty "mastery_ability" field only if rank >= 5 if (sheetData.data.data.identity?.school_rank < 5 && out["mastery_ability"].length === 0) { delete out["mastery_ability"]; } + return out; } diff --git a/system/scripts/actors/npc-sheet.js b/system/scripts/actors/npc-sheet.js index 0e97094..7325068 100644 --- a/system/scripts/actors/npc-sheet.js +++ b/system/scripts/actors/npc-sheet.js @@ -16,9 +16,11 @@ export class NpcSheetL5r5e extends BaseSheetL5r5e { }); } - getData() { + /** @inheritdoc */ + getData(options = {}) { const sheetData = super.getData(); + // NPC Subtypes sheetData.data.data.types = NpcSheetL5r5e.types.map((e) => ({ id: e, label: game.i18n.localize("l5r5e.character_types." + e), diff --git a/system/scripts/config.js b/system/scripts/config.js index c8e3325..92f60f3 100644 --- a/system/scripts/config.js +++ b/system/scripts/config.js @@ -23,7 +23,7 @@ L5R5E.techniques.set("ninjutsu", { type: "core", displayInTypes: true }); L5R5E.techniques.set("school_ability", { type: "school", displayInTypes: false }); L5R5E.techniques.set("mastery_ability", { type: "school", displayInTypes: false }); // Title -// L5R5E.techniques.set("title_ability", { type: "title", displayInTypes: false }); +L5R5E.techniques.set("title_ability", { type: "title", displayInTypes: false }); // Custom L5R5E.techniques.set("specificity", { type: "custom", displayInTypes: false }); diff --git a/system/template.json b/system/template.json index cb7cf2c..1440f54 100644 --- a/system/template.json +++ b/system/template.json @@ -162,6 +162,7 @@ "advancement": { "in_curriculum": false, "xp_used": 3, + "xp_cost": 3, "rank": 1, "bought_at_rank": 1, "ring": "void" @@ -198,8 +199,7 @@ }, "technique": { "templates": ["basics", "advancement"], - "technique_type": "kata", - "xp_cost": 3 + "technique_type": "kata" }, "property": { "templates": ["basics"] @@ -216,23 +216,19 @@ }, "title": { "templates": ["basics", "advancement"], - "xp_cost": 3, "advancements": [] }, "bond": { "templates": ["basics", "advancement"], - "bond_type": "", - "xp_cost": 3 + "bond_type": "" }, "item_pattern": { "templates": ["basics", "advancement"], "linked_property_id": null, - "rarity_modifier": "", - "xp_cost": 3 + "rarity_modifier": "" }, "signature_scroll": { - "templates": ["basics", "advancement"], - "xp_cost": 3 + "templates": ["basics", "advancement"] } } }