From 4d8da8f26a0d93773b700724dc7bf7a44e378c37 Mon Sep 17 00:00:00 2001 From: Vlyan Date: Sun, 4 Jul 2021 11:30:09 +0200 Subject: [PATCH] NPC on change : Linked actor for Adversary, unlinked for Minion --- CHANGELOG.md | 3 ++- system/scripts/actor.js | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d55d7f..1ee010c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ## 1.3.2 - Ronin's Bubble -- Replaced moving description in items by a big popup on hover. +- Replaced moving description in items by a big tooltip on hover. - Added PoW Revised 20Q (for old Ronin, just modify the template in 20Q to change the character sheet fields). - Added Bushido tenets on Social tab in sheet for all (I think this is useful for players, and it's in Core rulebook so... why this is not by default ;) ). - Added English/French Journal Compendiums for Conditions and Terrain Qualities (thanks to TesserWract). @@ -9,6 +9,7 @@ - Added PoW Name Tables compendium : Qamarist Names, Ivory Kingdoms Names, Rokugani Names and Ujik Names. - Added ability to drop a (Curriculum) Journal to have a button in school experience tab. - Added properties antagonists (ex : Sacred remove Unholy on drop). +- Added when switching between NPC types, now the prototype token is altered this way : Linked actor for Adversary, unlinked for Minion. - Fixed school compendium: "Kuni Warden School" from "Scorpion" to "Crab". - Fixed roll for RollTable not showing the text. - Fixed some Pdf Copy-Paste error in school cursus that make L instead of I: Lkoma/Lsawa/Luchi... diff --git a/system/scripts/actor.js b/system/scripts/actor.js index dea8169..d0b85aa 100644 --- a/system/scripts/actor.js +++ b/system/scripts/actor.js @@ -65,7 +65,7 @@ export class ActorL5r5e extends Actor { */ async update(data = {}, context = {}) { // Need a _id - if (!data._id) { + if (!data["_id"]) { data["_id"] = this.id; } @@ -73,8 +73,13 @@ export class ActorL5r5e extends Actor { context.parent = this.parent; context.pack = this.pack; + // NPC switch between types : Linked actor for Adversary, unlinked for Minion + if (this.data.type === "npc" && data["data.type"] !== this.data.data.type) { + data["token.actorLink"] = data["data.type"] === "adversary"; + } + // Only on linked Actor - if (data.token?.actorLink || (data.token?.actorLink === undefined && this.data.token.actorLink)) { + if (!!data["token.actorLink"] || (data["token.actorLink"] === undefined && this.data.token.actorLink)) { // Update the token name/image if the sheet name/image changed, but only if they was previously the same ["name", "img"].forEach((fieldName) => { if ( @@ -88,8 +93,7 @@ export class ActorL5r5e extends Actor { } // Now using updateDocuments - data = data instanceof Array ? data : [data]; - return Actor.updateDocuments(data, context); + return Actor.updateDocuments([data], context); } /** @override */