Added fixes to make beastforms work

This commit is contained in:
WBHarry 2025-07-27 19:26:01 +02:00
parent e55809f988
commit e223aab42c
7 changed files with 44 additions and 17 deletions

View file

@ -123,13 +123,15 @@ export default class BeastformDialog extends HandlebarsApplicationMixin(Applicat
);
const compendiumBeastforms = await game.packs.get(`daggerheart.beastforms`)?.getDocuments();
const beastformTiers = [...(compendiumBeastforms ? compendiumBeastforms : []), ...game.items].reduce(
const beastformTiers = [...game.items, ...(compendiumBeastforms ? compendiumBeastforms : [])].reduce(
(acc, x) => {
const tier = CONFIG.DH.GENERAL.tiers[x.system.tier];
if (x.type !== 'beastform' || tier.id > this.configData.tierLimit) return acc;
if (!acc[tier.id]) acc[tier.id] = { label: game.i18n.localize(tier.label), values: {} };
if (Object.values(acc[tier.id].values).find(existing => existing.value.name === x.name)) return acc;
acc[tier.id].values[x.uuid] = {
selected: this.selected?.uuid == x.uuid,
value: x,

View file

@ -123,7 +123,14 @@ export default function DHApplicationMixin(Base) {
/**@inheritdoc */
async _onFirstRender(context, options) {
await super._onFirstRender(context, options);
this.relatedDocs.filter(doc => doc).map(doc => (doc.apps[this.id] = this));
const docs = [];
for (var docData of this.relatedDocs) {
const doc = await foundry.utils.fromUuid(docData.uuid);
docs.push(doc);
}
docs.filter(doc => doc).map(doc => (doc.apps[this.id] = this));
if (!!this.options.contextMenus.length) this._createContextMenus();
}

View file

@ -4,15 +4,13 @@ import DHBaseAction from './baseAction.mjs';
export default class DhBeastformAction extends DHBaseAction {
static extraSchemas = [...super.extraSchemas, 'beastform'];
async use(event, ...args) {
async use(_event, ...args) {
const beastformConfig = this.prepareBeastformConfig();
const abort = await this.handleActiveTransformations();
if (abort) return;
const item = args[0];
const { selected, evolved, hybrid } = await BeastformDialog.configure(beastformConfig, item);
const { selected, evolved, hybrid } = await BeastformDialog.configure(beastformConfig, this.item);
if (!selected) return;
await this.transform(selected, evolved, hybrid);

View file

@ -112,7 +112,7 @@ export default class DhCharacter extends BaseDataActor {
value: {
custom: {
enabled: true,
formula: '@system.rules.attack.damage.value'
formula: '@profd4'
}
}
}
@ -244,10 +244,19 @@ export default class DhCharacter extends BaseDataActor {
}),
attack: new fields.SchemaField({
damage: new fields.SchemaField({
value: new fields.StringField({
diceIndex: new fields.NumberField({
integer: true,
min: 0,
max: 5,
initial: 0,
label: 'DAGGERHEART.GENERAL.Rules.attack.damage.dice.label',
hint: 'DAGGERHEART.GENERAL.Rules.attack.damage.dice.hint'
}),
bonus: new fields.NumberField({
required: true,
initial: '@profd4',
label: 'DAGGERHEART.GENERAL.Rules.attack.damage.value.label'
initial: 0,
min: 0,
label: 'DAGGERHEART.GENERAL.Rules.attack.damage.bonus.label'
})
}),
roll: new fields.SchemaField({
@ -547,6 +556,10 @@ export default class DhCharacter extends BaseDataActor {
const baseHope = this.resources.hope.value + (this.companion?.system?.resources?.hope ?? 0);
this.resources.hope.value = Math.min(baseHope, this.resources.hope.max);
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
const diceTypes = Object.keys(CONFIG.DH.GENERAL.diceTypes);
const attackDiceIndex = Math.max(Math.min(this.rules.attack.damage.diceIndex, 5), 0);
this.attack.damage.parts[0].value.custom.formula = `@prof${diceTypes[attackDiceIndex]}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`;
}
getRollData() {

View file

@ -10,12 +10,12 @@ export class DHActionRollData extends foundry.abstract.DataModel {
bonus: new fields.NumberField({ nullable: true, initial: null, integer: true }),
advState: new fields.StringField({
choices: CONFIG.DH.ACTIONS.advantageState,
initial: CONFIG.DH.ACTIONS.advantageState.neutral.label
initial: 'neutral'
}),
diceRolling: new fields.SchemaField({
multiplier: new fields.StringField({
choices: CONFIG.DH.GENERAL.diceSetNumbers,
initial: CONFIG.DH.GENERAL.diceSetNumbers.prof,
initial: 'prof',
label: 'DAGGERHEART.ACTIONS.RollField.diceRolling.multiplier'
}),
flatMultiplier: new fields.NumberField({

View file

@ -94,10 +94,13 @@ export default class DHBeastform extends BaseDataItem {
return false;
}
const features = await this.parent.parent.createEmbeddedDocuments(
'Item',
this.features.map(x => x.toObject())
);
const beastformFeatures = [];
for (let featureData of this.features) {
const feature = await foundry.utils.fromUuid(featureData.uuid);
beastformFeatures.push(feature.toObject());
}
const features = await this.parent.parent.createEmbeddedDocuments('Item', beastformFeatures);
const extraEffects = await this.parent.parent.createEmbeddedDocuments(
'ActiveEffect',