mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Fixed
This commit is contained in:
parent
110bfa3492
commit
c8babc5873
5 changed files with 70 additions and 37 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,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue