mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Fixed (#603)
This commit is contained in:
parent
d80b5d158d
commit
4827b337d0
6 changed files with 72 additions and 39 deletions
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,6 +158,8 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
x.type === 'subclass' &&
|
||||
x.system.isMulticlass === (this.parent.system.identifier === 'multiclass')
|
||||
);
|
||||
|
||||
if (subclass) {
|
||||
const featureState = subclass.system.featureState;
|
||||
const featureType = subclass
|
||||
? (subclass.system.features.find(x => x.item?.uuid === this.parent.uuid)?.type ?? null)
|
||||
|
|
@ -172,4 +174,5 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue