mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Fixed multiclass
This commit is contained in:
parent
b83adbf09b
commit
2d20fb0df4
5 changed files with 8 additions and 15 deletions
|
|
@ -317,7 +317,7 @@ export default class DhCharacter extends BaseDataActor {
|
|||
}
|
||||
|
||||
get multiclass() {
|
||||
const value = this.parent.items.find(x => x.type === 'Class' && x.system.isMulticlass);
|
||||
const value = this.parent.items.find(x => x.type === 'class' && x.system.isMulticlass);
|
||||
const subclass = this.parent.items.find(x => x.type === 'subclass' && x.system.isMulticlass);
|
||||
|
||||
return {
|
||||
|
|
@ -443,7 +443,8 @@ export default class DhCharacter extends BaseDataActor {
|
|||
classFeatures.push(item);
|
||||
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.subclass.id) {
|
||||
if (this.class.subclass) {
|
||||
const subclassState = this.class.subclass.system.featureState;
|
||||
const prop = item.system.multiclassOrigin ? 'multiclass' : 'class';
|
||||
const subclassState = this[prop].subclass.system.featureState;
|
||||
|
||||
if (
|
||||
item.system.identifier === CONFIG.DH.ITEM.featureSubTypes.foundation ||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,6 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
for (let f of this.features) {
|
||||
const fBase = f.item ?? f;
|
||||
const feature = fBase.system ? fBase : await foundry.utils.fromUuid(fBase.uuid);
|
||||
const multiclass = this.isMulticlass ? 'multiclass' : null;
|
||||
features.push(
|
||||
foundry.utils.mergeObject(
|
||||
feature.toObject(),
|
||||
|
|
@ -156,7 +155,8 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
_stats: { compendiumSource: fBase.uuid },
|
||||
system: {
|
||||
originItemType: this.parent.type,
|
||||
identifier: multiclass ?? (f.item ? f.type : null)
|
||||
identifier: f.item ? f.type : null,
|
||||
multiclassOrigin: this.isMulticlass
|
||||
}
|
||||
},
|
||||
{ inplace: false }
|
||||
|
|
|
|||
|
|
@ -102,15 +102,6 @@ export default class DHClass extends BaseDataItem {
|
|||
if (allowed === false) return;
|
||||
}
|
||||
|
||||
_onDelete(options, userId) {
|
||||
super._onDelete(options, userId);
|
||||
|
||||
if (options.parent?.type === 'character') {
|
||||
const path = `system.${this.isMulticlass ? 'multiclass' : 'class'}`;
|
||||
foundry.utils.getProperty(options.parent, `${path}.subclass`)?.delete();
|
||||
}
|
||||
}
|
||||
|
||||
async _preUpdate(changed, options, userId) {
|
||||
const allowed = await super._preUpdate(changed, options, userId);
|
||||
if (allowed === false) return false;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ export default class DHFeature extends BaseDataItem {
|
|||
nullable: true,
|
||||
initial: null
|
||||
}),
|
||||
multiclassOrigin: new fields.BooleanField({ initial: false }),
|
||||
identifier: new fields.StringField()
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,10 +164,10 @@ export default class DhpActor extends Actor {
|
|||
if (multiclass) {
|
||||
const multiclassItem = this.items.find(x => x.uuid === multiclass.itemUuid);
|
||||
const multiclassFeatures = this.items.filter(
|
||||
x => x.system.originItemType === 'class' && x.system.identifier === 'multiclass'
|
||||
x => x.system.originItemType === 'class' && x.system.multiclassOrigin
|
||||
);
|
||||
const subclassFeatures = this.items.filter(
|
||||
x => x.system.originItemType === 'subclass' && x.system.identifier === 'multiclass'
|
||||
x => x.system.originItemType === 'subclass' && x.system.multiclassOrigin
|
||||
);
|
||||
|
||||
this.deleteEmbeddedDocuments(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue