From d2f63a7bbf8c1fc446c96ec70e6cd03ea3d0a3c6 Mon Sep 17 00:00:00 2001 From: spyrella <16845165+spyrella@users.noreply.github.com> Date: Wed, 31 Jan 2024 21:52:40 -0500 Subject: [PATCH 1/2] fix: hotfix adding custom to npc specie --- lang/en.json | 1 + lang/it.json | 1 + module/documents/actors/npc/npc-data-model.mjs | 2 +- module/helpers/config.mjs | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lang/en.json b/lang/en.json index 57fe882d..58b96dc5 100644 --- a/lang/en.json +++ b/lang/en.json @@ -438,6 +438,7 @@ "MonsterRule": "Monsters have no special rules", "PlantRule": "Plants are Vulnerable to (choose one: air, bolt, fire, ice) damage.", "UndeadRule": "Undead are Immune to dark and poison damage, immune to poisoned and Vulnerable to light damage.", + "CustomRule": "Custom NPC", "UseEquipment": "Use Equipment?", "Potency": "Potency", "Area": "Area", diff --git a/lang/it.json b/lang/it.json index fafb08c2..36427963 100644 --- a/lang/it.json +++ b/lang/it.json @@ -438,6 +438,7 @@ "MonsterRule": "I mostri non hanno regole speciali.", "PlantRule": "Le piante sono Vulnerabili al danno da (scegliere uno tra aria, fulmine, fuoco, ghiaccio)", "UndeadRule": "I non morti sono Immuni al danno da ombra e da veleno e Vulnerabili al danno da luce.", + "CustomRule": "Custom NPC", "UseEquipment": "Use Equipment?", "Potency": "Power", "Area": "Area", diff --git a/module/documents/actors/npc/npc-data-model.mjs b/module/documents/actors/npc/npc-data-model.mjs index 5f933399..134a26bb 100644 --- a/module/documents/actors/npc/npc-data-model.mjs +++ b/module/documents/actors/npc/npc-data-model.mjs @@ -37,7 +37,7 @@ import {BondDataModel} from '../common/bond-data-model.mjs'; * @property {number} derived.mdef.bonus * @property {BonusesDataModel} bonuses * @property {string} traits.value - * @property {'beast', 'construct', 'demon', 'elemental', 'humanoid', 'monster', 'plant', 'undead'} species.value + * @property {'beast', 'construct', 'demon', 'elemental', 'humanoid', 'monster', 'plant', 'undead', 'custom'} species.value * @property {"", "minor", "major", "supreme"} villain.value * @property {number} phases.value * @property {string} multipart.value diff --git a/module/helpers/config.mjs b/module/helpers/config.mjs index 63466350..cee10a81 100644 --- a/module/helpers/config.mjs +++ b/module/helpers/config.mjs @@ -85,7 +85,7 @@ FU.affTypeAbbr = { 4: 'FU.AffinityRepulsionAbbr', }; -FU.species = ['beast', 'construct', 'demon', 'elemental', 'humanoid', 'monster', 'plant', 'undead']; +FU.species = ['beast', 'construct', 'demon', 'elemental', 'humanoid', 'monster', 'plant', 'undead', 'custom']; FU.villainTypes = ['minor', 'major', 'supreme']; @@ -98,6 +98,7 @@ FU.speciesRule = { monster: 'FU.MonsterRule', plant: 'FU.PlantRule', undead: 'FU.UndeadRule', + custom: 'FU.CustomRule', }; FU.itemTypes = { From 7fe41c3f7a421598a48c5aefb97abfda335c4696 Mon Sep 17 00:00:00 2001 From: spyrella <16845165+spyrella@users.noreply.github.com> Date: Wed, 31 Jan 2024 23:17:40 -0500 Subject: [PATCH 2/2] fix: temporary workaround for undefined primary/secondary, revert later --- module/documents/items/item.mjs | 43 ++++++++++++++++++-------- module/sheets/actor-standard-sheet.mjs | 1 - 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/module/documents/items/item.mjs b/module/documents/items/item.mjs index a4bd0ec2..8c89e388 100644 --- a/module/documents/items/item.mjs +++ b/module/documents/items/item.mjs @@ -42,11 +42,11 @@ export class FUItem extends Item { getWeaponDisplayData() { const isWeaponOrShieldWithDual = this.type === 'weapon' || (this.type === 'shield' && this.system.isDualShield?.value); const isBasic = this.type === 'basic'; - // Check if this item is not a weapon or not a weapon/shield with dual + // Check if this item is not a weapon or not a weapon/shield with dual if (!isBasic && !isWeaponOrShieldWithDual) { return false; } - + function capitalizeFirst(string) { if (typeof string !== 'string') { // Handle the case where string is not a valid string @@ -54,23 +54,40 @@ export class FUItem extends Item { } return string.charAt(0).toUpperCase() + string.slice(1); } - + const hrZeroText = this.system.rollInfo?.useWeapon?.hrZero?.value ? 'HR0' : 'HR'; const qualText = this.system.quality?.value || ''; let qualityString = ''; - - const attackAttributes = [this.system.attributes.primary.value.toUpperCase(), this.system.attributes.secondary.value.toUpperCase()].join(' + '); - - const attackString = `【${attackAttributes}】${this.system.accuracy.value > 0 ? ` +${this.system.accuracy.value}` : ''}`; - - const damageString = `【${hrZeroText} + ${this.system.damage.value}】 ${this.system.damageType.value}`; - + + const primaryAttribute = this.system.attributes?.primary?.value; + const secondaryAttribute = this.system.attributes?.secondary?.value; + + const attackAttributes = [ + (primaryAttribute || '').toUpperCase(), + (secondaryAttribute || '').toUpperCase() + ].join(' + '); + + const accuracyValue = this.system.accuracy?.value ?? 0; + const damageValue = this.system.damage?.value ?? 0; + + const attackString = `【${attackAttributes}】${accuracyValue > 0 ? ` +${accuracyValue}` : ''}`; + + const hrZeroValue = this.system.rollInfo?.useWeapon?.hrZero?.value ?? false; + const damageTypeValue = this.system.damageType?.value || ''; + + const damageString = `【${hrZeroText} + ${damageValue}】 ${damageTypeValue}`; + if (isWeaponOrShieldWithDual) { - qualityString = [capitalizeFirst(this.system.category.value), capitalizeFirst(this.system.hands.value), capitalizeFirst(this.system.type.value), qualText].filter(Boolean).join(' ⬥ '); + qualityString = [ + capitalizeFirst(this.system.category?.value), + capitalizeFirst(this.system.hands?.value), + capitalizeFirst(this.system.type?.value), + qualText + ].filter(Boolean).join(' ⬥ '); } else if (isBasic) { qualityString = [attackString, damageString, qualText].filter(Boolean).join(' ⬥ '); } - + return { attackString, damageString, @@ -819,7 +836,7 @@ export class FUItem extends Item { check: { title: game.i18n.localize('FU.AccuracyCheck'), attr1: { - attribute: attributes.primary.value, + attribute: attributes.primary?.value, dice: this.actor.system.attributes[attributes.primary.value].current, }, attr2: { diff --git a/module/sheets/actor-standard-sheet.mjs b/module/sheets/actor-standard-sheet.mjs index 59188a86..7d54d589 100644 --- a/module/sheets/actor-standard-sheet.mjs +++ b/module/sheets/actor-standard-sheet.mjs @@ -389,7 +389,6 @@ export class FUStandardActorSheet extends ActorSheet { const li = $(ev.currentTarget).parents('.item'); const itemId = li.data('itemId'); const item = this.actor.items.get(itemId); - const currentEquipped = item.system.isEquipped.value; const itemType = item.system.type; const handType = item.system.hands;