From 1445baa556c4268fb9eacc7e9a10ef7712247540 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sun, 8 Jun 2025 10:49:29 +0200 Subject: [PATCH] Cleanup of 'pc' references --- daggerheart.mjs | 16 +-- lang/en.json | 2 +- module/applications/sheets/character.mjs | 97 ++----------------- module/config/generalConfig.mjs | 4 +- module/data/item/class.mjs | 6 +- module/data/item/domainCard.mjs | 2 +- module/data/item/subclass.mjs | 6 +- module/documents/actor.mjs | 6 +- module/helpers/utils.mjs | 2 +- .../{pc/pc.hbs => character/character.hbs} | 4 +- .../parts/advancementCard.hbs | 0 .../{pc => character}/parts/heritageCard.hbs | 0 .../{pc => character}/sections/inventory.hbs | 0 .../{pc => character}/sections/loadout.hbs | 10 +- 14 files changed, 38 insertions(+), 117 deletions(-) rename templates/sheets/{pc/pc.hbs => character/character.hbs} (97%) rename templates/sheets/{pc => character}/parts/advancementCard.hbs (100%) rename templates/sheets/{pc => character}/parts/heritageCard.hbs (100%) rename templates/sheets/{pc => character}/sections/inventory.hbs (100%) rename templates/sheets/{pc => character}/sections/loadout.hbs (95%) diff --git a/daggerheart.mjs b/daggerheart.mjs index 044b49a3..21c62365 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -40,7 +40,7 @@ Hooks.once('init', () => { CONFIG.Item.dataModels = models.items.config; const { Items, Actors } = foundry.documents.collections; - Items.unregisterSheet('core', foundry.appv1.sheets.ItemSheet); + Items.unregisterSheet('core', foundry.applications.sheets.ItemSheetV2); Items.registerSheet(SYSTEM.id, applications.DhpAncestry, { types: ['ancestry'], makeDefault: true }); Items.registerSheet(SYSTEM.id, applications.DhpCommunity, { types: ['community'], makeDefault: true }); Items.registerSheet(SYSTEM.id, applications.DhpClassSheet, { types: ['class'], makeDefault: true }); @@ -54,12 +54,12 @@ Hooks.once('init', () => { CONFIG.Actor.documentClass = documents.DhpActor; CONFIG.Actor.dataModels = { - pc: models.DhCharacter, + character: models.DhCharacter, adversary: models.DhpAdversary, environment: models.DhpEnvironment }; - Actors.unregisterSheet('core', foundry.appv1.sheets.ActorSheet); - Actors.registerSheet(SYSTEM.id, applications.DhCharacterSheet, { types: ['pc'], makeDefault: true }); + Actors.unregisterSheet('core', foundry.applications.sheets.ActorSheetV2); + Actors.registerSheet(SYSTEM.id, applications.DhCharacterSheet, { types: ['character'], makeDefault: true }); Actors.registerSheet(SYSTEM.id, applications.DhpAdversarySheet, { types: ['adversary'], makeDefault: true }); Actors.registerSheet(SYSTEM.id, applications.DhpEnvironment, { types: ['environment'], makeDefault: true }); @@ -275,10 +275,10 @@ const preloadHandlebarsTemplates = async function () { 'systems/daggerheart/templates/sheets/parts/heritage.hbs', 'systems/daggerheart/templates/sheets/parts/subclassFeature.hbs', 'systems/daggerheart/templates/sheets/parts/effects.hbs', - 'systems/daggerheart/templates/sheets/pc/sections/inventory.hbs', - 'systems/daggerheart/templates/sheets/pc/sections/loadout.hbs', - 'systems/daggerheart/templates/sheets/pc/parts/heritageCard.hbs', - 'systems/daggerheart/templates/sheets/pc/parts/advancementCard.hbs', + 'systems/daggerheart/templates/sheets/character/sections/inventory.hbs', + 'systems/daggerheart/templates/sheets/character/sections/loadout.hbs', + 'systems/daggerheart/templates/sheets/character/parts/heritageCard.hbs', + 'systems/daggerheart/templates/sheets/character/parts/advancementCard.hbs', 'systems/daggerheart/templates/components/card-preview.hbs', 'systems/daggerheart/templates/views/levelup/parts/selectable-card-preview.hbs', 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs', diff --git a/lang/en.json b/lang/en.json index f64689f9..bb7a20de 100755 --- a/lang/en.json +++ b/lang/en.json @@ -13,7 +13,7 @@ "armor": "Armor" }, "Actor": { - "pc": "PC", + "character": "Character", "npc": "NPC", "adversary": "Adversary", "environment": "Environment" diff --git a/module/applications/sheets/character.mjs b/module/applications/sheets/character.mjs index 3350631d..c7430a36 100644 --- a/module/applications/sheets/character.mjs +++ b/module/applications/sheets/character.mjs @@ -65,8 +65,8 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) { static PARTS = { form: { - id: 'pc', - template: 'systems/daggerheart/templates/sheets/pc/pc.hbs' + id: 'character', + template: 'systems/daggerheart/templates/sheets/character/character.hbs' } }; @@ -675,26 +675,6 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) { } async _onDragStart(_, event) { - if (event.currentTarget.classList.contains('inventory-item')) { - if (!['weapon', 'armor'].includes(event.currentTarget.dataset.type)) { - return; - } - - const targets = { - weapon: ['weapon-section', 'inventory-weapon-section'], - armor: ['armor-section', 'inventory-armor-section'] - }; - - event.dataTransfer.setData( - 'text/plain', - JSON.stringify({ - uuid: event.currentTarget.dataset.item, - internal: true, - targets: targets[event.currentTarget.dataset.type] - }) - ); - } - super._onDragStart(event); } @@ -704,76 +684,17 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) { } async _onDropItem(event, data) { - const element = event.currentTarget; const item = await Item.implementation.fromDropData(data); const itemData = item.toObject(); - const createdItems = []; - - if (item.type === 'domainCard') { - if (this.document.system.domainCards.loadout.length >= 5) { - itemData.system.inVault = true; - } - - if (this.document.uuid === item.parent?.uuid) return this._onSortItem(event, itemData); - const createdItem = await this._onDropItemCreate(itemData); - - return createdItem; - } else { - if (item.type === 'ancestry') { - for (var feature of this.document.items.filter( - x => x.type === 'feature' && x.system.type === SYSTEM.ITEM.featureTypes.ancestry.id - )) { - await feature.delete(); - } - - for (var feature of item.system.abilities) { - const data = (await fromUuid(feature.uuid)).toObject(); - const itemData = await this._onDropItemCreate(data); - createdItems.push(itemData); - } - } else if (item.type === 'community') { - for (var feature of this.document.items.filter( - x => x.type === 'feature' && x.system.type === SYSTEM.ITEM.featureTypes.community.id - )) { - await feature.delete(); - } - - for (var feature of item.system.abilities) { - const data = (await fromUuid(feature.uuid)).toObject(); - const itemData = await this._onDropItemCreate(data); - createdItems.push(itemData); - } - } - - if (this.document.uuid === item.parent?.uuid) return this._onSortItem(event, item); - - if (item.type === 'weapon') { - if (!element) return; - - if (element.classList.contains('weapon-section')) { - await this.document.system.constructor.unequipBeforeEquip.bind(this.document.system)(itemData); - itemData.system.equipped = true; - } - } - - if (item.type === 'armor') { - if (!element) return; - - if (element.classList.contains('armor-section')) { - const existing = this.document.system.armor - ? await fromUuid(this.document.system.armor.uuid) - : null; - await existing?.update({ 'system.equipped': false }); - itemData.system.equipped = true; - } - } - - const createdItem = await this._onDropItemCreate(itemData); - createdItems.push(createdItem); - - return createdItems; + if (item.type === 'domainCard' && this.document.system.domainCards.loadout.length >= 5) { + itemData.system.inVault = true; } + + if (this.document.uuid === item.parent?.uuid) return this._onSortItem(event, itemData); + const createdItem = await this._onDropItemCreate(itemData); + + return createdItem; } async _onDropItemCreate(itemData, event) { diff --git a/module/config/generalConfig.mjs b/module/config/generalConfig.mjs index fb596347..e8c5bc75 100644 --- a/module/config/generalConfig.mjs +++ b/module/config/generalConfig.mjs @@ -198,8 +198,8 @@ export const tiers = { }; export const objectTypes = { - pc: { - name: 'TYPES.Actor.pc' + character: { + name: 'TYPES.Actor.character' }, npc: { name: 'TYPES.Actor.npc' diff --git a/module/data/item/class.mjs b/module/data/item/class.mjs index 423ad8a5..0584f1db 100644 --- a/module/data/item/class.mjs +++ b/module/data/item/class.mjs @@ -56,7 +56,7 @@ export default class DHClass extends BaseDataItem { const allowed = await super._preCreate(data, options, user); if (allowed === false) return; - if (this.actor?.type === 'pc') { + if (this.actor?.type === 'character') { const path = data.system.isMulticlass ? 'system.multiclass.value' : 'system.class.value'; if (foundry.utils.getProperty(this.actor, path)) { ui.notifications.error(game.i18n.localize('DAGGERHEART.Item.Errors.ClassAlreadySelected')); @@ -67,7 +67,7 @@ export default class DHClass extends BaseDataItem { _onCreate(data, options, userId) { super._onCreate(data, options, userId); - if (options.parent?.type === 'pc') { + if (options.parent?.type === 'character') { const path = `system.${data.system.isMulticlass ? 'multiclass.value' : 'class.value'}`; options.parent.update({ [path]: `${options.parent.uuid}.Item.${data._id}` }); } @@ -76,7 +76,7 @@ export default class DHClass extends BaseDataItem { _onDelete(options, userId) { super._onDelete(options, userId); - if (options.parent?.type === 'pc') { + if (options.parent?.type === 'character') { const path = `system.${this.isMulticlass ? 'multiclass' : 'class'}`; options.parent.update({ [`${path}.value`]: null diff --git a/module/data/item/domainCard.mjs b/module/data/item/domainCard.mjs index 75f0b8b9..b5880aad 100644 --- a/module/data/item/domainCard.mjs +++ b/module/data/item/domainCard.mjs @@ -30,7 +30,7 @@ export default class DHDomainCard extends BaseDataItem { const allowed = await super._preCreate(data, options, user); if (allowed === false) return; - if (this.actor?.type === 'pc') { + if (this.actor?.type === 'character') { if (!this.actor.system.class.value) { ui.notifications.error(game.i18n.localize('DAGGERHEART.Item.Errors.NoClassSelected')); return false; diff --git a/module/data/item/subclass.mjs b/module/data/item/subclass.mjs index 883df064..ea506efa 100644 --- a/module/data/item/subclass.mjs +++ b/module/data/item/subclass.mjs @@ -33,7 +33,7 @@ export default class DHSubclass extends BaseDataItem { const allowed = await super._preCreate(data, options, user); if (allowed === false) return; - if (this.actor?.type === 'pc') { + if (this.actor?.type === 'character') { const path = data.system.isMulticlass ? 'system.multiclass' : 'system.class'; const classData = foundry.utils.getProperty(this.actor, path); if (!classData.value) { @@ -52,7 +52,7 @@ export default class DHSubclass extends BaseDataItem { _onCreate(data, options, userId) { super._onCreate(data, options, userId); - if (options.parent?.type === 'pc') { + if (options.parent?.type === 'character') { const path = `system.${data.system.isMulticlass ? 'multiclass.subclass' : 'class.subclass'}`; options.parent.update({ [path]: `${options.parent.uuid}.Item.${data._id}` }); } @@ -61,7 +61,7 @@ export default class DHSubclass extends BaseDataItem { _onDelete(options, userId) { super._onDelete(options, userId); - if (options.parent?.type === 'pc') { + if (options.parent?.type === 'character') { const path = `system.${this.isMulticlass ? 'multiclass.subclass' : 'class.subclass'}`; options.parent.update({ [path]: null }); } diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index 9eb20454..55b00634 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -10,7 +10,7 @@ export default class DhpActor extends Actor { // Configure prototype token settings const prototypeToken = {}; - if (this.type === 'pc') + if (this.type === 'character') Object.assign(prototypeToken, { sight: { enabled: true }, actorLink: true, @@ -28,7 +28,7 @@ export default class DhpActor extends Actor { } async updateLevel(newLevel) { - if (this.type !== 'pc' || newLevel === this.system.levelData.level.changed) return; + if (this.type !== 'character' || newLevel === this.system.levelData.level.changed) return; if (newLevel > this.system.levelData.level.current) { await this.update({ 'system.levelData.level.changed': newLevel }); @@ -124,7 +124,7 @@ export default class DhpActor extends Actor { } async diceRoll(modifier, shiftKey) { - if (this.type === 'pc') { + if (this.type === 'character') { return await this.dualityRoll(modifier, shiftKey); } else { return await this.npcRoll(modifier, shiftKey); diff --git a/module/helpers/utils.mjs b/module/helpers/utils.mjs index 3fbe89c3..d764210a 100644 --- a/module/helpers/utils.mjs +++ b/module/helpers/utils.mjs @@ -114,7 +114,7 @@ export const getCommandTarget = () => { ui.notifications.error(game.i18n.localize('DAGGERHEART.Notification.Error.NoSelectedToken')); return null; } - if (target.type !== 'pc') { + if (target.type !== 'character') { ui.notifications.error(game.i18n.localize('DAGGERHEART.Notification.Error.OnlyUseableByPC')); return null; } diff --git a/templates/sheets/pc/pc.hbs b/templates/sheets/character/character.hbs similarity index 97% rename from templates/sheets/pc/pc.hbs rename to templates/sheets/character/character.hbs index 5f2f5ad9..bf1edd2f 100644 --- a/templates/sheets/pc/pc.hbs +++ b/templates/sheets/character/character.hbs @@ -95,10 +95,10 @@
- {{> "systems/daggerheart/templates/sheets/pc/sections/loadout.hbs" abilities=this.abilities actor=this.document config=this.config }} + {{> "systems/daggerheart/templates/sheets/character/sections/loadout.hbs" abilities=this.abilities actor=this.document config=this.config }}
- {{> "systems/daggerheart/templates/sheets/pc/sections/inventory.hbs" inventory=this.inventory }} + {{> "systems/daggerheart/templates/sheets/character/sections/inventory.hbs" inventory=this.inventory }}
diff --git a/templates/sheets/pc/parts/advancementCard.hbs b/templates/sheets/character/parts/advancementCard.hbs similarity index 100% rename from templates/sheets/pc/parts/advancementCard.hbs rename to templates/sheets/character/parts/advancementCard.hbs diff --git a/templates/sheets/pc/parts/heritageCard.hbs b/templates/sheets/character/parts/heritageCard.hbs similarity index 100% rename from templates/sheets/pc/parts/heritageCard.hbs rename to templates/sheets/character/parts/heritageCard.hbs diff --git a/templates/sheets/pc/sections/inventory.hbs b/templates/sheets/character/sections/inventory.hbs similarity index 100% rename from templates/sheets/pc/sections/inventory.hbs rename to templates/sheets/character/sections/inventory.hbs diff --git a/templates/sheets/pc/sections/loadout.hbs b/templates/sheets/character/sections/loadout.hbs similarity index 95% rename from templates/sheets/pc/sections/loadout.hbs rename to templates/sheets/character/sections/loadout.hbs index 62d76d1e..4feeebe8 100644 --- a/templates/sheets/pc/sections/loadout.hbs +++ b/templates/sheets/character/sections/loadout.hbs @@ -13,7 +13,7 @@
{{#if abilities.foundation.ancestry}} - {{> "systems/daggerheart/templates/sheets/pc/parts/heritageCard.hbs" card=abilities.foundation.ancestry }} + {{> "systems/daggerheart/templates/sheets/character/parts/heritageCard.hbs" card=abilities.foundation.ancestry }} {{else}}
@@ -26,7 +26,7 @@
{{#if abilities.foundation.community}} - {{> "systems/daggerheart/templates/sheets/pc/parts/heritageCard.hbs" card=abilities.foundation.community }} + {{> "systems/daggerheart/templates/sheets/character/parts/heritageCard.hbs" card=abilities.foundation.community }} {{else}}
@@ -41,7 +41,7 @@
{{#if abilities.foundation.advancement.foundation}} - {{> "systems/daggerheart/templates/sheets/pc/parts/advancementCard.hbs" card=abilities.foundation.advancement.foundation }} + {{> "systems/daggerheart/templates/sheets/character/parts/advancementCard.hbs" card=abilities.foundation.advancement.foundation }} {{else}}
@@ -54,7 +54,7 @@
{{#if abilities.foundation.advancement.first}} - {{> "systems/daggerheart/templates/sheets/pc/parts/advancementCard.hbs" card=abilities.foundation.advancement.first }} + {{> "systems/daggerheart/templates/sheets/character/parts/advancementCard.hbs" card=abilities.foundation.advancement.first }} {{else}}
@@ -68,7 +68,7 @@
{{#if abilities.foundation.advancement.second}} - {{> "systems/daggerheart/templates/sheets/pc/parts/advancementCard.hbs" card=abilities.foundation.advancement.second}} + {{> "systems/daggerheart/templates/sheets/character/parts/advancementCard.hbs" card=abilities.foundation.advancement.second}} {{else}}