This commit is contained in:
WBHarry 2025-07-04 01:22:18 +02:00
parent 72dfc54705
commit 266a2806ab
13 changed files with 102 additions and 52 deletions

View file

@ -275,18 +275,6 @@ export class DHBaseAction extends foundry.abstract.DataModel {
}) */
}
if (this instanceof DhBeastformAction) {
config.beastform = this.prepareBeastformConfig();
const abort = await this.handleActiveTransformations();
if (abort) return;
const beastformUuid = await BeastformDialog.configure(config);
if (!beastformUuid) return;
await this.transform(beastformUuid);
}
if (this.doFollowUp()) {
if (this.rollDamage) await this.rollDamage(event, config);
if (this.rollHealing) await this.rollHealing(event, config);
@ -779,11 +767,23 @@ export class DHMacroAction extends DHBaseAction {
export class DhBeastformAction extends DHBaseAction {
static extraSchemas = ['beastform'];
async use(event, ...args) {
const beastformConfig = this.prepareBeastformConfig();
const abort = await this.handleActiveTransformations();
if (abort) return;
const beastformUuid = await BeastformDialog.configure(beastformConfig);
if (!beastformUuid) return;
await this.transform(beastformUuid);
}
prepareBeastformConfig(config) {
const settingsTier = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.LevelTiers).tiers;
const settingsTiers = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.LevelTiers).tiers;
const actorLevel = this.actor.system.levelData.level.current;
const actorTier =
Object.values(settingsTier).find(
Object.values(settingsTiers).find(
tier => actorLevel >= tier.levels.start && actorLevel <= tier.levels.end
) ?? 1;

View file

@ -4,7 +4,6 @@ export default class BeastformEffect extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
isBeastform: new fields.BooleanField({ initial: false }),
characterTokenData: new fields.SchemaField({
tokenImg: new fields.FilePathField({
categories: ['IMAGE'],
@ -34,13 +33,8 @@ export default class BeastformEffect extends foundry.abstract.TypeDataModel {
await updateActorTokens(this.parent.parent, update);
for (var feature of this.parent.parent.items.filter(x => this.featureIds.includes(x.id))) {
await feature.delete();
}
for (var effect of this.parent.parent.effects.filter(x => this.effectIds.includes(x.id))) {
await effect.delete();
}
await this.parent.parent.deleteEmbeddedDocuments('Item', this.featureIds);
await this.parent.parent.deleteEmbeddedDocuments('ActiveEffect', this.effectIds);
}
}
}

View file

@ -43,14 +43,16 @@ export default class DHBeastform extends BaseDataItem {
const allowed = await super._preCreate(data, options, user);
if (allowed === false) return;
if (this.actor?.type !== 'character') {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.beastformInapplicable'));
return;
if (!this.actor) return;
if (this.actor.type !== 'character') {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.notifications.beastformInapplicable'));
return false;
}
if (this.actor.items.find(x => x.type === 'beastform')) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.beastformAlreadyApplied'));
return;
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.notifications.beastformAlreadyApplied'));
return false;
}
const features = await this.parent.parent.createEmbeddedDocuments(