diff --git a/module/applications/characterCreation/characterCreation.mjs b/module/applications/characterCreation/characterCreation.mjs index fc819e66..ddcaaaea 100644 --- a/module/applications/characterCreation/characterCreation.mjs +++ b/module/applications/characterCreation/characterCreation.mjs @@ -1,5 +1,6 @@ import { abilities } from '../../config/actorConfig.mjs'; import { burden } from '../../config/generalConfig.mjs'; +import { createEmbeddedItemWithEffects } from '../../helpers/utils.mjs'; const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api; @@ -550,34 +551,46 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl } }; - await this.character.createEmbeddedDocuments('Item', [ancestry]); - await this.character.createEmbeddedDocuments('Item', [this.setup.community]); - await this.character.createEmbeddedDocuments('Item', [this.setup.class]); - await this.character.createEmbeddedDocuments('Item', [this.setup.subclass]); - await this.character.createEmbeddedDocuments('Item', Object.values(this.setup.domainCards)); - - if (this.equipment.armor.uuid) - await this.character.createEmbeddedDocuments('Item', [ - { ...this.equipment.armor, system: { ...this.equipment.armor.system, equipped: true } } - ]); - if (this.equipment.primaryWeapon.uuid) - await this.character.createEmbeddedDocuments('Item', [ - { ...this.equipment.primaryWeapon, system: { ...this.equipment.primaryWeapon.system, equipped: true } } - ]); - if (this.equipment.secondaryWeapon.uuid) - await this.character.createEmbeddedDocuments('Item', [ - { - ...this.equipment.secondaryWeapon, - system: { ...this.equipment.secondaryWeapon.system, equipped: true } - } - ]); - if (this.equipment.inventory.choiceA.uuid) - await this.character.createEmbeddedDocuments('Item', [this.equipment.inventory.choiceA]); - if (this.equipment.inventory.choiceB.uuid) - await this.character.createEmbeddedDocuments('Item', [this.equipment.inventory.choiceB]); + await createEmbeddedItemWithEffects(this.character, ancestry); + await createEmbeddedItemWithEffects(this.character, this.setup.community); + await createEmbeddedItemWithEffects(this.character, this.setup.class); + await createEmbeddedItemWithEffects(this.character, this.setup.subclass); await this.character.createEmbeddedDocuments( 'Item', - this.setup.class.system.inventory.take.filter(x => x) + Object.values(this.setup.domainCards).map(x => ({ + ...x, + effects: x.effects?.map(effect => effect.toObject()) + })) + ); + + if (this.equipment.armor.uuid) + await createEmbeddedItemWithEffects(this.character, this.equipment.armor, { + ...this.equipment.armor, + system: { ...this.equipment.armor.system, equipped: true } + }); + if (this.equipment.primaryWeapon.uuid) + await createEmbeddedItemWithEffects(this.character, this.equipment.primaryWeapon, { + ...this.equipment.primaryWeapon, + system: { ...this.equipment.primaryWeapon.system, equipped: true } + }); + if (this.equipment.secondaryWeapon.uuid) + await createEmbeddedItemWithEffects(this.character, this.equipment.secondaryWeapon, { + ...this.equipment.secondaryWeapon, + system: { ...this.equipment.secondaryWeapon.system, equipped: true } + }); + if (this.equipment.inventory.choiceA.uuid) + await createEmbeddedItemWithEffects(this.character, this.equipment.inventory.choiceA); + if (this.equipment.inventory.choiceB.uuid) + await createEmbeddedItemWithEffects(this.character, this.equipment.inventory.choiceB); + + await this.character.createEmbeddedDocuments( + 'Item', + this.setup.class.system.inventory.take + .filter(x => x) + .map(x => ({ + ...x, + effects: x.effects?.map(effect => effect.toObject()) + })) ); await this.character.update({ diff --git a/module/data/item/domainCard.mjs b/module/data/item/domainCard.mjs index 8d050158..67c3ab04 100644 --- a/module/data/item/domainCard.mjs +++ b/module/data/item/domainCard.mjs @@ -46,12 +46,13 @@ export default class DHDomainCard extends BaseDataItem { if (allowed === false) return; if (this.actor?.type === 'character') { - if (!this.actor.system.class.value) { + const actorClasses = this.actor.items.filter(x => x.type === 'class'); + if (!actorClasses.length) { ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.noClassSelected')); return false; } - if (!this.actor.system.domains.find(x => x === this.domain)) { + if (!actorClasses.some(c => c.system.domains.find(x => x === this.domain))) { ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.lacksDomain')); return false; } diff --git a/module/documents/activeEffect.mjs b/module/documents/activeEffect.mjs index 86860170..337805a7 100644 --- a/module/documents/activeEffect.mjs +++ b/module/documents/activeEffect.mjs @@ -158,16 +158,19 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect { x.type === 'subclass' && x.system.isMulticlass === (this.parent.system.identifier === 'multiclass') ); - const featureState = subclass.system.featureState; - const featureType = subclass - ? (subclass.system.features.find(x => x.item?.uuid === this.parent.uuid)?.type ?? null) - : null; - if ( - (featureType === CONFIG.DH.ITEM.featureSubTypes.specialization && featureState < 2) || - (featureType === CONFIG.DH.ITEM.featureSubTypes.mastery && featureState < 3) - ) { - this.transfer = false; + if (subclass) { + const featureState = subclass.system.featureState; + const featureType = subclass + ? (subclass.system.features.find(x => x.item?.uuid === this.parent.uuid)?.type ?? null) + : null; + + if ( + (featureType === CONFIG.DH.ITEM.featureSubTypes.specialization && featureState < 2) || + (featureType === CONFIG.DH.ITEM.featureSubTypes.mastery && featureState < 3) + ) { + this.transfer = false; + } } } } diff --git a/module/documents/chatMessage.mjs b/module/documents/chatMessage.mjs index 2c5160ac..302ba1d8 100644 --- a/module/documents/chatMessage.mjs +++ b/module/documents/chatMessage.mjs @@ -40,6 +40,8 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { elements.forEach(e => { const uuid = e.dataset.permId, document = fromUuidSync(uuid); + if (!document) return; + e.setAttribute('data-view-perm', document.testUserPermission(game.user, 'OBSERVER')); e.setAttribute('data-use-perm', document.testUserPermission(game.user, 'OWNER')); }); diff --git a/module/helpers/utils.mjs b/module/helpers/utils.mjs index ebbe5131..83935356 100644 --- a/module/helpers/utils.mjs +++ b/module/helpers/utils.mjs @@ -355,3 +355,17 @@ export function createScrollText(actor, optionsData) { }); } } + +export async function createEmbeddedItemWithEffects(actor, baseData, update) { + const data = baseData.uuid.startsWith('Compendium') ? await foundry.utils.fromUuid(baseData.uuid) : baseData; + const [doc] = await actor.createEmbeddedDocuments('Item', [ + { + ...(update ?? data), + id: data.id, + uuid: data.uuid, + effects: data.effects?.map(effect => effect.toObject()) + } + ]); + + return doc; +} diff --git a/src/packs/domains/domainCard_Untouchable_9QElncQUDSakuSdR.json b/src/packs/domains/domainCard_Untouchable_9QElncQUDSakuSdR.json index b6564df1..89b4cbee 100644 --- a/src/packs/domains/domainCard_Untouchable_9QElncQUDSakuSdR.json +++ b/src/packs/domains/domainCard_Untouchable_9QElncQUDSakuSdR.json @@ -42,7 +42,7 @@ { "key": "system.evasion", "mode": 2, - "value": "@system.traits.agility.value / 2", + "value": "ceil(@system.traits.agility.value / 2)", "priority": null } ], @@ -71,7 +71,7 @@ "systemId": "daggerheart", "systemVersion": "0.0.1", "createdTime": 1754247027320, - "modifiedTime": 1754247067643, + "modifiedTime": 1754403424797, "lastModifiedBy": "MQSznptE5yLT7kj8" }, "_key": "!items.effects!9QElncQUDSakuSdR.H8hazlQe4Wj4JFO6"