From b883689b6395cbec1b09e7b0bd81b2382c6dac25 Mon Sep 17 00:00:00 2001 From: Vlyan Date: Wed, 26 May 2021 13:55:39 +0200 Subject: [PATCH] Added a "description" field on the PC/NPC sheet, displayed in limited view --- CHANGELOG.md | 1 + system/scripts/actors/base-sheet.js | 9 ++- system/scripts/hooks.js | 2 +- system/scripts/migration.js | 64 +++++++++++-------- system/template.json | 4 +- .../templates/actors/character/narrative.html | 10 ++- system/templates/actors/limited-sheet.html | 34 +--------- system/templates/actors/npc-sheet.html | 4 +- 8 files changed, 60 insertions(+), 68 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a967b9..f99f1a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ __! Be certain to carefully back up any critical user data before installing thi - To change the linked property, drop any property on the item pattern sheet. - Added an optional "Specificity" technique type to serve as a catch-all (by request). - Added Mantis Clan compendium entries. +- Added a "Description" in PC/NPC sheet: this field is used in limited view (public description, "notes" are private). - Fix : rnkMessage not passing on actor object for NPCs (thanks to Bragma). - Fix : The "Crescent Moon Style" technique rank from 4 to 2. - Fix : Drop an advancement on a PC/NPC sheet now correctly add the bonus to the Actor (ex Air +1). diff --git a/system/scripts/actors/base-sheet.js b/system/scripts/actors/base-sheet.js index 70d6687..aff2421 100644 --- a/system/scripts/actors/base-sheet.js +++ b/system/scripts/actors/base-sheet.js @@ -134,7 +134,7 @@ export class BaseSheetL5r5e extends ActorSheet { * @override */ activateEditor(name, options = {}, initialContent = "") { - if (name === "data.notes.value" && initialContent) { + if (["data.notes", "data.description"].includes(name) && initialContent) { initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false); } super.activateEditor(name, options, initialContent); @@ -148,8 +148,11 @@ export class BaseSheetL5r5e extends ActorSheet { * @override */ async _updateObject(event, formData) { - if (formData["data.notes.value"]) { - formData["data.notes.value"] = game.l5r5e.HelpersL5r5e.convertSymbols(formData["data.notes.value"], true); + if (formData["data.notes"]) { + formData["data.notes"] = game.l5r5e.HelpersL5r5e.convertSymbols(formData["data.notes"], true); + } + if (formData["data.description"]) { + formData["data.description"] = game.l5r5e.HelpersL5r5e.convertSymbols(formData["data.description"], true); } return super._updateObject(event, formData); } diff --git a/system/scripts/hooks.js b/system/scripts/hooks.js index 66feb3a..5a55888 100644 --- a/system/scripts/hooks.js +++ b/system/scripts/hooks.js @@ -22,7 +22,7 @@ export default class HooksL5r5e { */ static async ready() { // Migration stuff - if (game.l5r5e.migrations.needUpdate()) { + if (game.l5r5e.migrations.needUpdate(game.l5r5e.migrations.NEEDED_VERSION)) { game.l5r5e.migrations.migrateWorld(); } diff --git a/system/scripts/migration.js b/system/scripts/migration.js index 3451cd3..bf8c099 100644 --- a/system/scripts/migration.js +++ b/system/scripts/migration.js @@ -9,12 +9,13 @@ export class MigrationL5r5e { static NEEDED_VERSION = "1.3.0"; /** - * Return true if the current world need some updates - * @returns {boolean} + * Return true if the version need some updates + * @param {string} version + * @return {boolean} */ - static needUpdate() { + static needUpdate(version) { const currentVersion = game.settings.get("l5r5e", "systemMigrationVersion"); - return currentVersion && foundry.utils.isNewerVersion(MigrationL5r5e.NEEDED_VERSION, currentVersion); + return currentVersion && foundry.utils.isNewerVersion(version, currentVersion); } /** @@ -26,6 +27,10 @@ export class MigrationL5r5e { return; } + // if (MigrationL5r5e.needUpdate("1.3.0")) { + // ChatMessage.create({"content": "L5R5E v1.3.0 :
"}); + // } + // Warn the users ui.notifications.info( `Applying L5R5e System Migration for version ${game.system.data.version}.` + @@ -190,35 +195,42 @@ export class MigrationL5r5e { const actorData = actor.data; // ***** Start of 1.1.0 ***** - // Add "Prepared" in actor - if (actorData.prepared === undefined) { - updateData["data.prepared"] = true; - } + if (MigrationL5r5e.needUpdate("1.1.0")) { + // Add "Prepared" in actor + if (actorData.prepared === undefined) { + updateData["data.prepared"] = true; + } - // NPC are now without autostats, we need to save the value - if (actor.type === "npc") { - if (actorData.endurance < 1) { - updateData["data.endurance"] = (Number(actorData.rings.earth) + Number(actorData.rings.fire)) * 2; - updateData["data.composure"] = (Number(actorData.rings.earth) + Number(actorData.rings.water)) * 2; - updateData["data.focus"] = Number(actorData.rings.air) + Number(actorData.rings.fire); - updateData["data.vigilance"] = Math.ceil( - (Number(actorData.rings.air) + Number(actorData.rings.water)) / 2 - ); + // NPC are now without autostats, we need to save the value + if (actor.type === "npc") { + if (actorData.endurance < 1) { + updateData["data.endurance"] = (Number(actorData.rings.earth) + Number(actorData.rings.fire)) * 2; + updateData["data.composure"] = (Number(actorData.rings.earth) + Number(actorData.rings.water)) * 2; + updateData["data.focus"] = Number(actorData.rings.air) + Number(actorData.rings.fire); + updateData["data.vigilance"] = Math.ceil( + (Number(actorData.rings.air) + Number(actorData.rings.water)) / 2 + ); + } } } // ***** End of 1.1.0 ***** // ***** Start of 1.3.0 ***** - // NPC have now more thant a Strength and a Weakness - if (actor.type === "npc" && actorData.rings_affinities) { - updateData["data.rings_affinities." + actorData.rings_affinities.strength.ring] = - actorData.rings_affinities.strength.value; - updateData["data.rings_affinities." + actorData.rings_affinities.weakness.ring] = - actorData.rings_affinities.weakness.value; + if (MigrationL5r5e.needUpdate("1.3.0")) { + // PC/NPC removed notes useless props "value" + updateData["data.notes"] = actorData.notes.value; - // Delete old keys : not working :'( - updateData["-=data.rings_affinities.strength"] = null; - updateData["-=data.rings_affinities.weakness"] = null; + // NPC have now more thant a Strength and a Weakness + if (actor.type === "npc" && actorData.rings_affinities) { + updateData["data.rings_affinities." + actorData.rings_affinities.strength.ring] = + actorData.rings_affinities.strength.value; + updateData["data.rings_affinities." + actorData.rings_affinities.weakness.ring] = + actorData.rings_affinities.weakness.value; + + // Delete old keys : not working :'( + updateData["-=data.rings_affinities.strength"] = null; + updateData["-=data.rings_affinities.weakness"] = null; + } } // ***** End of 1.3.0 ***** diff --git a/system/template.json b/system/template.json index 0e9cf05..46c3108 100644 --- a/system/template.json +++ b/system/template.json @@ -21,6 +21,8 @@ } }, "social": { + "notes": "", + "description": "", "social": { "honor": 0, "glory": 0, @@ -109,14 +111,12 @@ "character": { "templates": ["identity", "rings", "social", "skills", "techniques", "conflict", "advancement"], "zeni": 0, - "notes": "", "twenty_questions": {} }, "npc": { "templates": ["rings", "social", "techniques", "conflict"], "type": "minion", "attitude": "", - "notes": "", "conflict_rank": { "martial": 0, "social": 0 diff --git a/system/templates/actors/character/narrative.html b/system/templates/actors/character/narrative.html index 26f5ee5..0057b34 100644 --- a/system/templates/actors/character/narrative.html +++ b/system/templates/actors/character/narrative.html @@ -55,7 +55,15 @@ +{{!-- Description (npc have it on header) --}} +{{#ifCond data.type '==' "character"}} +
+ {{localize 'l5r5e.description' }} + {{editor content=data.data.description target="data.description" button=true editable=options.editable}} +
+{{/ifCond}} +{{!-- Notes (private) --}}
{{localize 'l5r5e.notes' }} - {{editor content=data.data.notes.value target="data.notes.value" button=true editable=options.editable}} + {{editor content=data.data.notes target="data.notes" button=true editable=options.editable}}
\ No newline at end of file diff --git a/system/templates/actors/limited-sheet.html b/system/templates/actors/limited-sheet.html index 37a484c..27bd2d0 100644 --- a/system/templates/actors/limited-sheet.html +++ b/system/templates/actors/limited-sheet.html @@ -3,38 +3,6 @@ {{!-- Sheet Header --}}

- {{!-- Sheet identity --}} - + {{{data.data.description}}}
diff --git a/system/templates/actors/npc-sheet.html b/system/templates/actors/npc-sheet.html index 4c2de75..68e6c1d 100644 --- a/system/templates/actors/npc-sheet.html +++ b/system/templates/actors/npc-sheet.html @@ -7,8 +7,8 @@ {{> 'systems/l5r5e/templates/actors/npc/identity.html'}}
- {{localize 'l5r5e.notes'}} - {{editor content=data.data.notes.value target="data.notes.value" button=true editable=options.editable}} + {{localize 'l5r5e.description'}} + {{editor content=data.data.description target="data.description" button=true editable=options.editable}}

{{localize 'l5r5e.social.title'}}