mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Feature] Manual Character Editing (#490)
* Initial * Added Character-Settings * Finalized Character-Settings * Hide CharacterSetup if any part is done manually * Fixed class/subclass drag-drop * Fixed relinking of Features from items created on Character * Adding features on CharacterItems now adds them on the Character and relinks * Made suggested items inactive in the Class sheet if rendered from inside a Character * Added hope to CharacterSetting * add style to textarea element, add spellcasting and domain class into char sheet and move rest buttons to another place * Fixed characterCreation experience description --------- Co-authored-by: moliloo <dev.murilobrito@gmail.com>
This commit is contained in:
parent
263dfa69ae
commit
e1d8f8784a
49 changed files with 1205 additions and 386 deletions
|
|
@ -125,6 +125,7 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
}
|
||||
|
||||
if (this.actor && this.actor.type === 'character' && this.features) {
|
||||
const featureUpdates = {};
|
||||
for (let f of this.features) {
|
||||
const fBase = f.item ?? f;
|
||||
const feature = fBase.system ? fBase : await foundry.utils.fromUuid(fBase.uuid);
|
||||
|
|
@ -134,14 +135,26 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
system: {
|
||||
originItemType: this.parent.type,
|
||||
originId: data._id,
|
||||
identifier: feature.identifier,
|
||||
subType: feature.item ? feature.type : undefined
|
||||
identifier: this.isMulticlass ? 'multiclass' : null
|
||||
}
|
||||
},
|
||||
{ inplace: false }
|
||||
);
|
||||
await this.actor.createEmbeddedDocuments('Item', [createData]);
|
||||
const [doc] = await this.actor.createEmbeddedDocuments('Item', [createData]);
|
||||
|
||||
if (!featureUpdates.features)
|
||||
featureUpdates.features = this.features.map(x => (x.item ? { ...x, item: x.item.uuid } : x.uuid));
|
||||
|
||||
if (f.item) {
|
||||
const existingFeature = featureUpdates.features.find(x => x.item === f.item.uuid);
|
||||
existingFeature.item = doc.uuid;
|
||||
} else {
|
||||
const replaceIndex = featureUpdates.features.findIndex(x => x === f.uuid);
|
||||
featureUpdates.features.splice(replaceIndex, 1, doc.uuid);
|
||||
}
|
||||
}
|
||||
|
||||
await this.updateSource(featureUpdates);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,16 +62,37 @@ export default class DHClass extends BaseDataItem {
|
|||
}
|
||||
|
||||
async _preCreate(data, options, user) {
|
||||
const allowed = await super._preCreate(data, options, user);
|
||||
if (allowed === false) return;
|
||||
|
||||
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.UI.Notifications.classAlreadySelected'));
|
||||
return false;
|
||||
const levelupAuto = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).levelupAuto;
|
||||
if (levelupAuto) {
|
||||
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.UI.Notifications.classAlreadySelected'));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (this.actor.system.class.value) {
|
||||
if (this.actor.system.multiclass.value) {
|
||||
ui.notifications.warn(
|
||||
game.i18n.localize('DAGGERHEART.UI.Notifications.multiclassAlreadyPresent')
|
||||
);
|
||||
return false;
|
||||
} else {
|
||||
const selectedDomain =
|
||||
await game.system.api.applications.dialogs.MulticlassChoiceDialog.configure(
|
||||
this.actor,
|
||||
this
|
||||
);
|
||||
if (!selectedDomain) return false;
|
||||
|
||||
await this.updateSource({ isMulticlass: true, domains: [selectedDomain] });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const allowed = await super._preCreate(data, options, user);
|
||||
if (allowed === false) return;
|
||||
}
|
||||
|
||||
_onCreate(data, options, userId) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ export default class DHFeature extends BaseDataItem {
|
|||
nullable: true,
|
||||
initial: null
|
||||
}),
|
||||
subType: new fields.StringField({ choices: CONFIG.DH.ITEM.featureSubTypes, nullable: true, initial: null }),
|
||||
originId: new fields.StringField({ nullable: true, initial: null }),
|
||||
identifier: new fields.StringField()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -41,27 +41,48 @@ export default class DHSubclass extends BaseDataItem {
|
|||
}
|
||||
|
||||
async _preCreate(data, options, user) {
|
||||
const allowed = await super._preCreate(data, options, user);
|
||||
if (allowed === false) return;
|
||||
|
||||
if (this.actor?.type === 'character') {
|
||||
const classData = this.actor.items.find(
|
||||
x => x.type === 'class' && x.system.isMulticlass === data.system.isMulticlass
|
||||
);
|
||||
const subclassData = this.actor.items.find(
|
||||
x => x.type === 'subclass' && x.system.isMulticlass === data.system.isMulticlass
|
||||
);
|
||||
if (!classData) {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.missingClass'));
|
||||
return false;
|
||||
} else if (subclassData) {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassAlreadySelected'));
|
||||
return false;
|
||||
} else if (classData.system.subclasses.every(x => x.uuid !== (data.uuid ?? `Item.${data._id}`))) {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInClass'));
|
||||
return false;
|
||||
if (this.actor.system.class.subclass) {
|
||||
if (this.actor.system.multiclass.subclass) {
|
||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassesAlreadyPresent'));
|
||||
return false;
|
||||
} else {
|
||||
if (!this.actor.system.multiclass.value) {
|
||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.missingMulticlass'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
this.actor.system.multiclass.value.system.subclasses.every(
|
||||
x => x.uuid !== (data.uuid ?? `Item.${data._id}`)
|
||||
)
|
||||
) {
|
||||
ui.notifications.error(
|
||||
game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInMulticlass')
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
await this.updateSource({ isMulticlass: true });
|
||||
}
|
||||
} else {
|
||||
if (!this.actor.system.class.value) {
|
||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.missingClass'));
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
this.actor.system.class.value.system.subclasses.every(
|
||||
x => x.uuid !== (data.uuid ?? `Item.${data._id}`)
|
||||
)
|
||||
) {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInClass'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const allowed = await super._preCreate(data, options, user);
|
||||
if (allowed === false) return;
|
||||
}
|
||||
|
||||
_onCreate(data, options, userId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue