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

@ -1272,7 +1272,11 @@
}, },
"attack": { "attack": {
"damage": { "damage": {
"value": { "label": "Base Attack: Damage" } "dice": {
"label": "Base Attack: Damage Dice Index",
"hint": "Index for the damage dice used on the basic attack. 0=d4, 1=d6, 2=d8, 3=d10, 4=d12, 5=d20"
},
"bonus": { "label": "Base Attack: Damage Bonus" }
}, },
"roll": { "roll": {
"trait": { "label": "Base Attack: Trait" } "trait": { "label": "Base Attack: Trait" }

View file

@ -123,13 +123,15 @@ export default class BeastformDialog extends HandlebarsApplicationMixin(Applicat
); );
const compendiumBeastforms = await game.packs.get(`daggerheart.beastforms`)?.getDocuments(); 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) => { (acc, x) => {
const tier = CONFIG.DH.GENERAL.tiers[x.system.tier]; const tier = CONFIG.DH.GENERAL.tiers[x.system.tier];
if (x.type !== 'beastform' || tier.id > this.configData.tierLimit) return acc; 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 (!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] = { acc[tier.id].values[x.uuid] = {
selected: this.selected?.uuid == x.uuid, selected: this.selected?.uuid == x.uuid,
value: x, value: x,

View file

@ -123,7 +123,14 @@ export default function DHApplicationMixin(Base) {
/**@inheritdoc */ /**@inheritdoc */
async _onFirstRender(context, options) { async _onFirstRender(context, options) {
await super._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(); if (!!this.options.contextMenus.length) this._createContextMenus();
} }

View file

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

View file

@ -112,7 +112,7 @@ export default class DhCharacter extends BaseDataActor {
value: { value: {
custom: { custom: {
enabled: true, enabled: true,
formula: '@system.rules.attack.damage.value' formula: '@profd4'
} }
} }
} }
@ -244,10 +244,19 @@ export default class DhCharacter extends BaseDataActor {
}), }),
attack: new fields.SchemaField({ attack: new fields.SchemaField({
damage: 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, required: true,
initial: '@profd4', initial: 0,
label: 'DAGGERHEART.GENERAL.Rules.attack.damage.value.label' min: 0,
label: 'DAGGERHEART.GENERAL.Rules.attack.damage.bonus.label'
}) })
}), }),
roll: new fields.SchemaField({ 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); const baseHope = this.resources.hope.value + (this.companion?.system?.resources?.hope ?? 0);
this.resources.hope.value = Math.min(baseHope, this.resources.hope.max); this.resources.hope.value = Math.min(baseHope, this.resources.hope.max);
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait; 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() { getRollData() {

View file

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

View file

@ -94,10 +94,13 @@ export default class DHBeastform extends BaseDataItem {
return false; return false;
} }
const features = await this.parent.parent.createEmbeddedDocuments( const beastformFeatures = [];
'Item', for (let featureData of this.features) {
this.features.map(x => x.toObject()) 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( const extraEffects = await this.parent.parent.createEmbeddedDocuments(
'ActiveEffect', 'ActiveEffect',