Feature/200 beastform (#255)

* Temp

* Dialog setup

* Fixed basic beastform

* Reworked beastform to hold it's data entirely in the beastformEffect

* UpdateActorTokens fix

* Removed hardcoded tierlimit on beastform

* PR fixes
This commit is contained in:
WBHarry 2025-07-04 02:02:14 +02:00 committed by GitHub
parent c4448226e0
commit d071fadf7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 1102 additions and 298 deletions

View file

@ -79,6 +79,7 @@ Hooks.once('init', () => {
Items.registerSheet(SYSTEM.id, applications.DhpConsumable, { types: ['consumable'], makeDefault: true }); Items.registerSheet(SYSTEM.id, applications.DhpConsumable, { types: ['consumable'], makeDefault: true });
Items.registerSheet(SYSTEM.id, applications.DhpWeapon, { types: ['weapon'], makeDefault: true }); Items.registerSheet(SYSTEM.id, applications.DhpWeapon, { types: ['weapon'], makeDefault: true });
Items.registerSheet(SYSTEM.id, applications.DhpArmor, { types: ['armor'], makeDefault: true }); Items.registerSheet(SYSTEM.id, applications.DhpArmor, { types: ['armor'], makeDefault: true });
Items.registerSheet(SYSTEM.id, applications.DhBeastform, { types: ['beastform'], makeDefault: true });
CONFIG.Actor.documentClass = documents.DhpActor; CONFIG.Actor.documentClass = documents.DhpActor;
CONFIG.Actor.dataModels = models.actors.config; CONFIG.Actor.dataModels = models.actors.config;
@ -90,6 +91,8 @@ Hooks.once('init', () => {
Actors.registerSheet(SYSTEM.id, applications.DhpEnvironment, { types: ['environment'], makeDefault: true }); Actors.registerSheet(SYSTEM.id, applications.DhpEnvironment, { types: ['environment'], makeDefault: true });
CONFIG.ActiveEffect.documentClass = documents.DhActiveEffect; CONFIG.ActiveEffect.documentClass = documents.DhActiveEffect;
CONFIG.ActiveEffect.dataModels = models.activeEffects.config;
foundry.applications.apps.DocumentSheetConfig.unregisterSheet( foundry.applications.apps.DocumentSheetConfig.unregisterSheet(
CONFIG.ActiveEffect.documentClass, CONFIG.ActiveEffect.documentClass,
'core', 'core',
@ -300,6 +303,7 @@ const preloadHandlebarsTemplates = async function () {
'systems/daggerheart/templates/views/actionTypes/cost.hbs', 'systems/daggerheart/templates/views/actionTypes/cost.hbs',
'systems/daggerheart/templates/views/actionTypes/range-target.hbs', 'systems/daggerheart/templates/views/actionTypes/range-target.hbs',
'systems/daggerheart/templates/views/actionTypes/effect.hbs', 'systems/daggerheart/templates/views/actionTypes/effect.hbs',
'systems/daggerheart/templates/views/actionTypes/beastform.hbs',
'systems/daggerheart/templates/settings/components/settings-item-line.hbs', 'systems/daggerheart/templates/settings/components/settings-item-line.hbs',
'systems/daggerheart/templates/chat/parts/damage-chat.hbs', 'systems/daggerheart/templates/chat/parts/damage-chat.hbs',
'systems/daggerheart/templates/chat/parts/target-chat.hbs' 'systems/daggerheart/templates/chat/parts/target-chat.hbs'

View file

@ -10,7 +10,8 @@
"consumable": "Consumable", "consumable": "Consumable",
"miscellaneous": "Miscellaneous", "miscellaneous": "Miscellaneous",
"weapon": "Weapon", "weapon": "Weapon",
"armor": "Armor" "armor": "Armor",
"beastform": "Beastform"
}, },
"Actor": { "Actor": {
"character": "Character", "character": "Character",
@ -22,7 +23,9 @@
"DAGGERHEART": { "DAGGERHEART": {
"UI": { "UI": {
"notifications": { "notifications": {
"adversaryMissing": "The linked adversary doesn't exist in the world." "adversaryMissing": "The linked adversary doesn't exist in the world.",
"beastformInapplicable": "A beastform can only be applied to a Character.",
"beastformAlreadyApplied": "The character already has a beastform applied!"
} }
}, },
"Settings": { "Settings": {
@ -1186,6 +1189,7 @@
"LevelUp": "You can level up", "LevelUp": "You can level up",
"Features": "Features", "Features": "Features",
"CompanionFeatures": "Companion Features", "CompanionFeatures": "Companion Features",
"beastformFeatures": "Beastform Features",
"Tabs": { "Tabs": {
"Features": "Features", "Features": "Features",
"Inventory": "Inventory", "Inventory": "Inventory",
@ -1472,8 +1476,26 @@
} }
} }
}, },
"Beastform": {
"FIELDS": {
"tier": { "label": "Tier" },
"examples": { "label": "Examples" },
"advantageOn": { "label": "Gain Advantage On" },
"tokenImg": { "label": "Token Image" },
"tokenSize": {
"placeholder": "Using character dimensions",
"height": { "label": "Height" },
"width": { "label": "Width" }
}
},
"dialogTitle": "Beastform Selection",
"tokenTitle": "Beastform Token",
"transform": "Transform",
"beastformEffect": "Beastform Transformation"
},
"Global": { "Global": {
"Actions": "Actions", "Actions": "Actions",
"Features": "Features",
"Effects": "Effects", "Effects": "Effects",
"activeEffects": "Active Effects", "activeEffects": "Active Effects",
"inativeEffects": "Inative Effects" "inativeEffects": "Inative Effects"
@ -1632,12 +1654,22 @@
}, },
"macro": { "macro": {
"name": "Macro" "name": "Macro"
},
"beastform": {
"name": "Beastform"
} }
}, },
"Settings": { "Settings": {
"ResultBased": { "ResultBased": {
"label": "Formula based on Hope/Fear result." "label": "Formula based on Hope/Fear result."
} }
},
"Config": {
"Beastform": {
"label": "Beastform",
"exact": "Beastform Max Tier",
"exactHint": "The Character's Tier is used if empty"
}
} }
}, },
"RollTypes": { "RollTypes": {

View file

@ -15,7 +15,8 @@ export { default as DhpChatMessage } from './chatMessage.mjs';
export { default as DhpEnvironment } from './sheets/actors/environment.mjs'; export { default as DhpEnvironment } from './sheets/actors/environment.mjs';
export { default as DhActiveEffectConfig } from './sheets/activeEffectConfig.mjs'; export { default as DhActiveEffectConfig } from './sheets/activeEffectConfig.mjs';
export { default as DhContextMenu } from './contextMenu.mjs'; export { default as DhContextMenu } from './contextMenu.mjs';
export { default as DhBeastform } from './sheets/items/beastform.mjs';
export { default as DhTooltipManager } from './tooltipManager.mjs'; export { default as DhTooltipManager } from './tooltipManager.mjs';
export * as api from './sheets/api/_modules.mjs'; export * as api from './sheets/api/_modules.mjs';
export * as ux from "./ux/_module.mjs"; export * as ux from './ux/_module.mjs';

View file

@ -69,6 +69,13 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
context.disableOption = this.disableOption.bind(this); context.disableOption = this.disableOption.bind(this);
context.isNPC = this.action.actor && this.action.actor.type !== 'character'; context.isNPC = this.action.actor && this.action.actor.type !== 'character';
context.hasRoll = this.action.hasRoll; context.hasRoll = this.action.hasRoll;
const settingsTiers = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.LevelTiers).tiers;
context.tierOptions = [
{ key: 1, label: game.i18n.localize('DAGGERHEART.Tiers.tier1') },
...Object.values(settingsTiers).map(x => ({ key: x.tier, label: x.name }))
];
return context; return context;
} }

View file

@ -67,9 +67,9 @@ export default class RollSelectionDialog extends HandlebarsApplicationMixin(Appl
context.fear = this.data.fear; context.fear = this.data.fear;
context.advantage = this.data.advantage; context.advantage = this.data.advantage;
context.experiences = Object.keys(this.experiences).map(id => ({ id, ...this.experiences[id] })); context.experiences = Object.keys(this.experiences).map(id => ({ id, ...this.experiences[id] }));
if(this.costs?.length) { if (this.costs?.length) {
const updatedCosts = this.action.calcCosts(this.costs); const updatedCosts = this.action.calcCosts(this.costs);
context.costs = updatedCosts context.costs = updatedCosts;
context.canRoll = this.action.getRealCosts(updatedCosts)?.hasCost; context.canRoll = this.action.getRealCosts(updatedCosts)?.hasCost;
} else context.canRoll = true; } else context.canRoll = true;

View file

@ -7,6 +7,8 @@ import { abilities } from '../../../config/actorConfig.mjs';
import DhCharacterlevelUp from '../../levelup/characterLevelup.mjs'; import DhCharacterlevelUp from '../../levelup/characterLevelup.mjs';
import DhCharacterCreation from '../../characterCreation.mjs'; import DhCharacterCreation from '../../characterCreation.mjs';
import FilterMenu from '../../ux/filter-menu.mjs'; import FilterMenu from '../../ux/filter-menu.mjs';
import { DhBeastformAction } from '../../../data/action/action.mjs';
import DHActionConfig from '../../config/Action.mjs';
const { ActorSheetV2 } = foundry.applications.sheets; const { ActorSheetV2 } = foundry.applications.sheets;
const { TextEditor } = foundry.applications.ux; const { TextEditor } = foundry.applications.ux;
@ -306,11 +308,14 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
getItem(element) { getItem(element) {
const listElement = (element.target ?? element).closest('[data-item-id]'); const listElement = (element.target ?? element).closest('[data-item-id]');
const document = listElement.dataset.companion ? this.document.system.companion : this.document; const itemId = listElement.dataset.itemId;
if (listElement.dataset.type === 'effect') {
const itemId = listElement.dataset.itemId, return this.document.effects.get(itemId);
item = document.items.get(itemId); } else if (['armor', 'weapon', 'feature', 'consumable', 'miscellaneous'].includes(listElement.dataset.type)) {
return item; return this.document.items.get(itemId);
} else {
return this.document.system[listElement.dataset.type].system.actions.find(x => x.id === itemId);
}
} }
static triggerContextMenu(event, button) { static triggerContextMenu(event, button) {
@ -733,7 +738,9 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
// Should dandle its actions. Or maybe they'll be separate buttons as per an Issue on the board // Should dandle its actions. Or maybe they'll be separate buttons as per an Issue on the board
if (item.type === 'feature') { if (item.type === 'feature') {
item.toChat(); item.use(event);
} else if (item instanceof ActiveEffect) {
item.toChat(this);
} else { } else {
const wasUsed = await item.use(event); const wasUsed = await item.use(event);
if (wasUsed && item.type === 'weapon') { if (wasUsed && item.type === 'weapon') {
@ -746,7 +753,11 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
const item = this.getItem(event); const item = this.getItem(event);
if (!item) return; if (!item) return;
if (item.sheet) {
item.sheet.render(true); item.sheet.render(true);
} else {
await new DHActionConfig(item).render(true);
}
} }
editItem(event) { editItem(event) {

View file

@ -0,0 +1,65 @@
import DHBaseItemSheet from '../api/base-item.mjs';
export default class BeastformSheet extends DHBaseItemSheet {
/**@inheritdoc */
static DEFAULT_OPTIONS = {
classes: ['beastform'],
dragDrop: [{ dragSelector: null, dropSelector: '.drop-section' }],
actions: {
editFeature: this.editFeature,
removeFeature: this.removeFeature
}
};
/**@override */
static PARTS = {
header: { template: 'systems/daggerheart/templates/sheets/items/beastform/header.hbs' },
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
settings: { template: 'systems/daggerheart/templates/sheets/items/beastform/settings.hbs' },
features: {
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-features.hbs',
scrollable: ['.features']
},
effects: {
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-effects.hbs',
scrollable: ['.effects']
}
};
static TABS = {
primary: {
tabs: [{ id: 'settings' }, { id: 'features' }, { id: 'effects' }],
initial: 'settings',
labelPrefix: 'DAGGERHEART.Sheets.TABS'
}
};
/**@inheritdoc */
async _preparePartContext(partId, context) {
await super._preparePartContext(partId, context);
return context;
}
static editFeature(event) {
const target = event.target.closest('[data-action="editFeature"]');
const feature = this.document.system.features[target.dataset.index];
feature.sheet.render({ force: true });
}
static async removeFeature(_, target) {
const current = this.document.system.features.map(x => x.uuid);
await this.document.update({
'system.features': current.filter((_, index) => index !== Number(target.dataset.index))
});
}
async _onDrop(event) {
const data = TextEditor.getDragEventData(event);
const item = await fromUuid(data.uuid);
if (item.type === 'feature') {
const current = this.document.system.features.map(x => x.uuid);
await this.document.update({ 'system.features': [...current, item.uuid] });
}
}
}

View file

@ -38,6 +38,11 @@ export const actionTypes = {
id: 'macro', id: 'macro',
name: 'DAGGERHEART.Actions.Types.macro.name', name: 'DAGGERHEART.Actions.Types.macro.name',
icon: 'fa-scroll' icon: 'fa-scroll'
},
beastform: {
id: 'beastform',
name: 'DAGGERHEART.Actions.Types.beastform.name',
icon: 'fa-paw'
} }
}; };
@ -119,4 +124,4 @@ export const advandtageState = {
label: 'DAGGERHEART.General.Advantage.Full', label: 'DAGGERHEART.General.Advantage.Full',
value: 1 value: 1
} }
} };

View file

@ -245,19 +245,23 @@ export const deathMoves = {
export const tiers = { export const tiers = {
tier1: { tier1: {
id: 'tier1', id: 'tier1',
label: 'DAGGERHEART.Tiers.tier1' label: 'DAGGERHEART.Tiers.tier1',
value: 1
}, },
tier2: { tier2: {
id: 'tier2', id: 'tier2',
label: 'DAGGERHEART.Tiers.tier2' label: 'DAGGERHEART.Tiers.tier2',
value: 2
}, },
tier3: { tier3: {
id: 'tier3', id: 'tier3',
label: 'DAGGERHEART.Tiers.tier3' label: 'DAGGERHEART.Tiers.tier3',
value: 3
}, },
tier4: { tier4: {
id: 'tier4', id: 'tier4',
label: 'DAGGERHEART.Tiers.tier4' label: 'DAGGERHEART.Tiers.tier4',
value: 4
} }
}; };

View file

@ -6,3 +6,4 @@ export * as items from './item/_module.mjs';
export { actionsTypes } from './action/_module.mjs'; export { actionsTypes } from './action/_module.mjs';
export * as messages from './chat-message/_modules.mjs'; export * as messages from './chat-message/_modules.mjs';
export * as fields from './fields/_module.mjs'; export * as fields from './fields/_module.mjs';
export * as activeEffects from './activeEffect/_module.mjs';

View file

@ -1,6 +1,7 @@
import { import {
DHAttackAction, DHAttackAction,
DHBaseAction, DHBaseAction,
DhBeastformAction,
DHDamageAction, DHDamageAction,
DHEffectAction, DHEffectAction,
DHHealingAction, DHHealingAction,
@ -19,5 +20,6 @@ export const actionsTypes = {
healing: DHHealingAction, healing: DHHealingAction,
summon: DHSummonAction, summon: DHSummonAction,
effect: DHEffectAction, effect: DHEffectAction,
macro: DHMacroAction macro: DHMacroAction,
beastform: DhBeastformAction
}; };

View file

@ -1,6 +1,7 @@
import { DHActionDiceData, DHActionRollData, DHDamageData, DHDamageField } from './actionDice.mjs'; import { DHActionDiceData, DHActionRollData, DHDamageData, DHDamageField } from './actionDice.mjs';
import DhpActor from '../../documents/actor.mjs'; import DhpActor from '../../documents/actor.mjs';
import D20RollDialog from '../../dialogs/d20RollDialog.mjs'; import D20RollDialog from '../../dialogs/d20RollDialog.mjs';
import BeastformDialog from '../../dialogs/beastformDialog.mjs';
const fields = foundry.data.fields; const fields = foundry.data.fields;
@ -106,6 +107,11 @@ export class DHBaseAction extends foundry.abstract.DataModel {
}), }),
value: new fields.EmbeddedDataField(DHActionDiceData), value: new fields.EmbeddedDataField(DHActionDiceData),
valueAlt: new fields.EmbeddedDataField(DHActionDiceData) valueAlt: new fields.EmbeddedDataField(DHActionDiceData)
}),
beastform: new fields.SchemaField({
tierAccess: new fields.SchemaField({
exact: new fields.NumberField({ integer: true, nullable: true, initial: null })
})
}) })
}, },
extraSchemas = {}; extraSchemas = {};
@ -757,3 +763,50 @@ 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 settingsTiers = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.LevelTiers).tiers;
const actorLevel = this.actor.system.levelData.level.current;
const actorTier =
Object.values(settingsTiers).find(
tier => actorLevel >= tier.levels.start && actorLevel <= tier.levels.end
) ?? 1;
return {
tierLimit: this.beastform.tierAccess.exact ?? actorTier
};
}
async transform(beastformUuid) {
const beastform = await foundry.utils.fromUuid(beastformUuid);
this.actor.createEmbeddedDocuments('Item', [beastform.toObject()]);
}
async handleActiveTransformations() {
const beastformEffects = this.actor.effects.filter(x => x.type === 'beastform');
if (beastformEffects.length > 0) {
for (let effect of beastformEffects) {
await effect.delete();
}
return true;
}
return false;
}
}

View file

@ -0,0 +1,7 @@
import beastformEffect from './beastformEffect.mjs';
export { beastformEffect };
export const config = {
beastform: beastformEffect
};

View file

@ -0,0 +1,40 @@
import { updateActorTokens } from '../../helpers/utils.mjs';
export default class BeastformEffect extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
characterTokenData: new fields.SchemaField({
tokenImg: new fields.FilePathField({
categories: ['IMAGE'],
base64: false,
nullable: true
}),
tokenSize: new fields.SchemaField({
height: new fields.NumberField({ integer: true, nullable: true }),
width: new fields.NumberField({ integer: true, nullable: true })
})
}),
advantageOn: new fields.ArrayField(new fields.StringField()),
featureIds: new fields.ArrayField(new fields.StringField()),
effectIds: new fields.ArrayField(new fields.StringField())
};
}
async _preDelete() {
if (this.parent.parent.type === 'character') {
const update = {
height: this.characterTokenData.tokenSize.height,
width: this.characterTokenData.tokenSize.width,
texture: {
src: this.characterTokenData.tokenImg
}
};
await updateActorTokens(this.parent.parent, update);
await this.parent.parent.deleteEmbeddedDocuments('Item', this.featureIds);
await this.parent.parent.deleteEmbeddedDocuments('ActiveEffect', this.effectIds);
}
}
}

View file

@ -8,6 +8,7 @@ import DHFeature from './feature.mjs';
import DHMiscellaneous from './miscellaneous.mjs'; import DHMiscellaneous from './miscellaneous.mjs';
import DHSubclass from './subclass.mjs'; import DHSubclass from './subclass.mjs';
import DHWeapon from './weapon.mjs'; import DHWeapon from './weapon.mjs';
import DHBeastform from './beastform.mjs';
export { export {
DHAncestry, DHAncestry,
@ -19,7 +20,8 @@ export {
DHFeature, DHFeature,
DHMiscellaneous, DHMiscellaneous,
DHSubclass, DHSubclass,
DHWeapon DHWeapon,
DHBeastform
}; };
export const config = { export const config = {
@ -32,5 +34,6 @@ export const config = {
feature: DHFeature, feature: DHFeature,
miscellaneous: DHMiscellaneous, miscellaneous: DHMiscellaneous,
subclass: DHSubclass, subclass: DHSubclass,
weapon: DHWeapon weapon: DHWeapon,
beastform: DHBeastform
}; };

View file

@ -0,0 +1,98 @@
import { updateActorTokens } from '../../helpers/utils.mjs';
import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayField.mjs';
import BaseDataItem from './base.mjs';
export default class DHBeastform extends BaseDataItem {
static LOCALIZATION_PREFIXES = ['DAGGERHEART.Sheets.Beastform'];
/** @inheritDoc */
static get metadata() {
return foundry.utils.mergeObject(super.metadata, {
label: 'TYPES.Item.beastform',
type: 'beastform',
hasDescription: false
});
}
/** @inheritDoc */
static defineSchema() {
const fields = foundry.data.fields;
return {
...super.defineSchema(),
tier: new fields.StringField({
required: true,
choices: SYSTEM.GENERAL.tiers,
initial: SYSTEM.GENERAL.tiers.tier1.id
}),
tokenImg: new fields.FilePathField({
initial: 'icons/svg/mystery-man.svg',
categories: ['IMAGE'],
base64: false
}),
tokenSize: new fields.SchemaField({
height: new fields.NumberField({ integer: true, min: 1, initial: null, nullable: true }),
width: new fields.NumberField({ integer: true, min: 1, initial: null, nullable: true })
}),
examples: new fields.StringField(),
advantageOn: new fields.ArrayField(new fields.StringField()),
features: new ForeignDocumentUUIDArrayField({ type: 'Item' })
};
}
async _preCreate(data, options, user) {
const allowed = await super._preCreate(data, options, user);
if (allowed === false) 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.notifications.beastformAlreadyApplied'));
return false;
}
const features = await this.parent.parent.createEmbeddedDocuments(
'Item',
this.features.map(x => x.toObject())
);
const effects = await this.parent.parent.createEmbeddedDocuments(
'ActiveEffect',
this.parent.effects.map(x => x.toObject())
);
await this.parent.parent.createEmbeddedDocuments('ActiveEffect', [
{
type: 'beastform',
name: game.i18n.localize('DAGGERHEART.Sheets.Beastform.beastformEffect'),
img: 'icons/creatures/abilities/paw-print-pair-purple.webp',
system: {
isBeastform: true,
characterTokenData: {
tokenImg: this.parent.parent.prototypeToken.texture.src,
tokenSize: {
height: this.parent.parent.prototypeToken.height,
width: this.parent.parent.prototypeToken.width
}
},
advantageOn: this.advantageOn,
featureIds: features.map(x => x.id),
effectIds: effects.map(x => x.id)
}
}
]);
await updateActorTokens(this.parent.parent, {
height: this.tokenSize.height,
width: this.tokenSize.width,
texture: {
src: this.tokenImg
}
});
return false;
}
}

View file

@ -0,0 +1,86 @@
import { tiers } from '../config/generalConfig.mjs';
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
export default class BeastformDialog extends HandlebarsApplicationMixin(ApplicationV2) {
constructor(configData) {
super();
this.configData = configData;
this.selected = null;
}
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ['daggerheart', 'views', 'dh-style', 'beastform-selection'],
position: {
width: 600,
height: 'auto'
},
actions: {
selectBeastform: this.selectBeastform,
submitBeastform: this.submitBeastform
},
form: {
handler: this.updateBeastform,
submitOnChange: true,
submitOnClose: false
}
};
get title() {
return game.i18n.localize('DAGGERHEART.Sheets.Beastform.dialogTitle');
}
/** @override */
static PARTS = {
beastform: {
template: 'systems/daggerheart/templates/views/beastformDialog.hbs'
}
};
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.beastformTiers = game.items.reduce((acc, x) => {
const tier = tiers[x.system.tier];
if (x.type !== 'beastform' || tier.value > this.configData.tierLimit) return acc;
if (!acc[tier.value]) acc[tier.value] = { label: game.i18n.localize(tier.label), values: {} };
acc[tier.value].values[x.uuid] = { selected: this.selected == x.uuid, value: x };
return acc;
}, {}); // Also get from compendium when added
context.canSubmit = this.selected;
return context;
}
static updateBeastform(event, _, formData) {
this.selected = foundry.utils.mergeObject(this.selected, formData.object);
this.render();
}
static selectBeastform(_, target) {
this.selected = this.selected === target.dataset.uuid ? null : target.dataset.uuid;
this.render();
}
static async submitBeastform() {
await this.close({ submitted: true });
}
/** @override */
_onClose(options = {}) {
if (!options.submitted) this.config = false;
}
static async configure(configData) {
return new Promise(resolve => {
const app = new this(configData);
app.addEventListener('close', () => resolve(app.selected), { once: true });
app.render({ force: true });
});
}
}

View file

@ -38,7 +38,7 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
const context = await super._prepareContext(_options); const context = await super._prepareContext(_options);
context.title = this.config.title; context.title = this.config.title;
context.extraFormula = this.config.extraFormula; context.extraFormula = this.config.extraFormula;
context.formula = this.roll.constructFormula(this.config);; context.formula = this.roll.constructFormula(this.config);
return context; return context;
} }

View file

@ -28,4 +28,27 @@ export default class DhActiveEffect extends ActiveEffect {
change.value = Roll.safeEval(Roll.replaceFormulaData(change.value, change.effect.parent)); change.value = Roll.safeEval(Roll.replaceFormulaData(change.value, change.effect.parent));
super.applyField(model, change, field); super.applyField(model, change, field);
} }
async toChat(origin) {
const cls = getDocumentClass('ChatMessage');
const systemData = {
title: game.i18n.localize('DAGGERHEART.ActionType.action'),
origin: origin,
img: this.img,
name: this.name,
description: this.description,
actions: []
};
const msg = new cls({
type: 'abilityUse',
user: game.user.id,
system: systemData,
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/chat/ability-use.hbs',
systemData
)
});
cls.create(msg.toObject());
}
} }

View file

@ -97,16 +97,16 @@ export default class DHItem extends foundry.documents.Item {
async use(event) { async use(event) {
const actions = this.system.actions; const actions = this.system.actions;
let response;
if (actions?.length) { if (actions?.length) {
let action = actions[0]; let action = actions[0];
if (actions.length > 1 && !event?.shiftKey) { if (actions.length > 1 && !event?.shiftKey) {
// Actions Choice Dialog // Actions Choice Dialog
action = await this.selectActionDialog(); action = await this.selectActionDialog();
} }
if (action) response = action.use(event); if (action) return action.use(event);
} }
return response;
return this.toChat();
} }
async toChat(origin) { async toChat(origin) {

View file

@ -294,3 +294,15 @@ export const adjustRange = (rangeVal, decrease) => {
const newIndex = decrease ? Math.max(index - 1, 0) : Math.min(index + 1, rangeKeys.length - 1); const newIndex = decrease ? Math.max(index - 1, 0) : Math.min(index + 1, rangeKeys.length - 1);
return range[rangeKeys[newIndex]]; return range[rangeKeys[newIndex]];
}; };
export const updateActorTokens = async (actor, update) => {
await actor.prototypeToken.update(update);
/* Update the tokens in all scenes belonging to Actor */
for (let token of actor.getDependentTokens()) {
const tokenActor = token.baseActor ?? token.actor;
if (tokenActor?.id === actor.id) {
await token.update(update);
}
}
};

View file

@ -372,7 +372,6 @@ div.daggerheart.views.multiclass {
} }
} }
.roll-dialog-experience-container { .roll-dialog-experience-container {
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
@ -509,6 +508,34 @@ div.daggerheart.views.multiclass {
} }
} }
.hint-group {
display: flex;
flex-direction: column;
align-items: end;
.form-fields {
width: 100%;
display: flex;
align-items: center;
label {
flex: 1;
}
input,
select {
flex: 3;
}
}
.hint {
margin: 4px 0 0 0;
font-size: 12px;
font-style: italic;
opacity: 0.6;
}
}
.data-form-array { .data-form-array {
border: 1px solid var(--color-fieldset-border); border: 1px solid var(--color-fieldset-border);
padding: 0.5rem; padding: 0.5rem;

View file

@ -2329,6 +2329,29 @@ div.daggerheart.views.multiclass {
width: 1.5rem; width: 1.5rem;
height: 1.5rem; height: 1.5rem;
} }
.daggerheart.views.action .action-category .action-category-data .hint-group {
display: flex;
flex-direction: column;
align-items: end;
}
.daggerheart.views.action .action-category .action-category-data .hint-group .form-fields {
width: 100%;
display: flex;
align-items: center;
}
.daggerheart.views.action .action-category .action-category-data .hint-group .form-fields label {
flex: 1;
}
.daggerheart.views.action .action-category .action-category-data .hint-group .form-fields input,
.daggerheart.views.action .action-category .action-category-data .hint-group .form-fields select {
flex: 3;
}
.daggerheart.views.action .action-category .action-category-data .hint-group .hint {
margin: 4px 0 0 0;
font-size: 12px;
font-style: italic;
opacity: 0.6;
}
.daggerheart.views.action .action-category .action-category-data .data-form-array { .daggerheart.views.action .action-category .action-category-data .data-form-array {
border: 1px solid var(--color-fieldset-border); border: 1px solid var(--color-fieldset-border);
padding: 0.5rem; padding: 0.5rem;
@ -5003,6 +5026,53 @@ div.daggerheart.views.multiclass {
color: light-dark(#18162e50, #efe6d850); color: light-dark(#18162e50, #efe6d850);
font-family: 'Montserrat', sans-serif; font-family: 'Montserrat', sans-serif;
} }
.theme-light .application.daggerheart.dh-style.views.beastform-selection .beastforms-container .beastforms-tier .beastform-container .beastform-title {
background-image: url('../assets/parchments/dh-parchment-dark.png');
}
.application.daggerheart.dh-style.views.beastform-selection .beastforms-container {
display: flex;
flex-direction: column;
gap: 4px;
}
.application.daggerheart.dh-style.views.beastform-selection .beastforms-container .beastforms-tier {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
gap: 4px;
}
.application.daggerheart.dh-style.views.beastform-selection .beastforms-container .beastforms-tier .beastform-container {
position: relative;
display: flex;
justify-content: center;
border: 1px solid light-dark(#18162e, #f3c267);
border-radius: 6px;
cursor: pointer;
}
.application.daggerheart.dh-style.views.beastform-selection .beastforms-container .beastforms-tier .beastform-container.inactive {
opacity: 0.4;
}
.application.daggerheart.dh-style.views.beastform-selection .beastforms-container .beastforms-tier .beastform-container img {
width: 100%;
border-radius: 6px;
}
.application.daggerheart.dh-style.views.beastform-selection .beastforms-container .beastforms-tier .beastform-container .beastform-title {
position: absolute;
top: 4px;
display: flex;
flex-wrap: wrap;
font-size: 16px;
margin: 0 4px;
border: 1px solid light-dark(#18162e, #f3c267);
border-radius: 6px;
color: light-dark(#efe6d8, #222);
background-image: url('../assets/parchments/dh-parchment-light.png');
}
.application.daggerheart.dh-style.views.beastform-selection footer {
margin-top: 8px;
display: flex;
}
.application.daggerheart.dh-style.views.beastform-selection footer button {
flex: 1;
}
.application.sheet.daggerheart.actor.dh-style.companion .companion-header-sheet { .application.sheet.daggerheart.actor.dh-style.companion .companion-header-sheet {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -5418,6 +5488,20 @@ div.daggerheart.views.multiclass {
font-family: 'Montserrat', sans-serif; font-family: 'Montserrat', sans-serif;
opacity: 0.8; opacity: 0.8;
} }
/**
* Applies theme-specific styles.
* @param {Rules} @darkRules - Styles to apply when `.theme-dark` is present
* @param {Rules} @lightRules - Styles to apply when `.theme-light` is present
*/
.themed.theme-dark .application.sheet.dh-style,
.themed.theme-dark.application.sheet.dh-style {
background: rgba(24, 22, 46, 0.33);
backdrop-filter: blur(9px);
}
.themed.theme-light .application.sheet.dh-style,
.themed.theme-light.application.sheet.dh-style {
background: url('../assets/parchments/dh-parchment-light.png') no-repeat center;
}
.application.sheet.dh-style { .application.sheet.dh-style {
border-radius: 10px; border-radius: 10px;
} }
@ -5463,15 +5547,6 @@ div.daggerheart.views.multiclass {
.application.sheet.dh-style:not(.minimized) .window-content { .application.sheet.dh-style:not(.minimized) .window-content {
opacity: 1; opacity: 1;
} }
.themed.theme-dark .application.sheet.dh-style,
.themed.theme-dark.application.sheet.dh-style {
background: rgba(24, 22, 46, 0.33);
backdrop-filter: blur(9px);
}
.themed.theme-light .application.sheet.dh-style,
.themed.theme-light.application.sheet.dh-style {
background: url('../assets/parchments/dh-parchment-light.png') no-repeat center;
}
.themed.theme-dark .application.sheet.dh-style.dialog, .themed.theme-dark .application.sheet.dh-style.dialog,
.themed.theme-dark.application.sheet.dh-style.dialog { .themed.theme-dark.application.sheet.dh-style.dialog {
background-image: url('../assets/parchments/dh-parchment-dark.png'); background-image: url('../assets/parchments/dh-parchment-dark.png');
@ -5973,6 +6048,44 @@ div.daggerheart.views.multiclass {
justify-content: center; justify-content: center;
gap: 10px; gap: 10px;
} }
.sheet.daggerheart.dh-style .tab.features .features-list {
display: flex;
flex-direction: column;
list-style: none;
padding: 0;
margin: 0;
width: 100%;
gap: 5px;
}
.sheet.daggerheart.dh-style .tab.features .features-list .feature-item {
display: grid;
align-items: center;
grid-template-columns: 1fr 4fr 1fr;
cursor: pointer;
}
.sheet.daggerheart.dh-style .tab.features .features-list .feature-item img {
height: 40px;
width: 40px;
object-fit: cover;
border-radius: 3px;
}
.sheet.daggerheart.dh-style .tab.features .features-list .feature-item h4 {
font-family: 'Montserrat', sans-serif;
font-weight: lighter;
color: #efe6d8;
}
.sheet.daggerheart.dh-style .tab.features .features-list .feature-item .image {
height: 40px;
width: 40px;
object-fit: cover;
border-radius: 6px;
border: none;
}
.sheet.daggerheart.dh-style .tab.features .features-list .feature-item .controls {
display: flex;
justify-content: center;
gap: 10px;
}
.sheet.daggerheart.dh-style .tab.effects .effects-list { .sheet.daggerheart.dh-style .tab.effects .effects-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View file

@ -40,6 +40,8 @@
@import './less/applications/environment-settings/actions.less'; @import './less/applications/environment-settings/actions.less';
@import './less/applications/environment-settings/adversaries.less'; @import './less/applications/environment-settings/adversaries.less';
@import './less/applications//beastform.less';
@import './less/actors/companion/header.less'; @import './less/actors/companion/header.less';
@import './less/actors/companion/details.less'; @import './less/actors/companion/details.less';
@import './less/actors/companion/sheet.less'; @import './less/actors/companion/sheet.less';
@ -60,13 +62,14 @@
@import './less/global/tab-navigation.less'; @import './less/global/tab-navigation.less';
@import './less/global/tab-form-footer.less'; @import './less/global/tab-form-footer.less';
@import './less/global/tab-actions.less'; @import './less/global/tab-actions.less';
@import './less/global/tab-features.less';
@import './less/global/tab-effects.less'; @import './less/global/tab-effects.less';
@import './less/global/item-header.less'; @import './less/global/item-header.less';
@import './less/global/feature-section.less'; @import './less/global/feature-section.less';
@import './less/global/inventory-item.less'; @import './less/global/inventory-item.less';
@import './less/global/inventory-fieldset-items.less'; @import './less/global/inventory-fieldset-items.less';
@import './less/global/prose-mirror.less'; @import './less/global/prose-mirror.less';
@import "./less/global/filter-menu.less"; @import './less/global/filter-menu.less';
@import '../node_modules/@yaireo/tagify/dist/tagify.css'; @import '../node_modules/@yaireo/tagify/dist/tagify.css';

View file

@ -1,4 +1,3 @@
// Theme header backgrounds // Theme header backgrounds
.appTheme({ .appTheme({
@ -12,7 +11,6 @@
}); });
.application.sheet.daggerheart.actor.dh-style.companion { .application.sheet.daggerheart.actor.dh-style.companion {
// .profile { // .profile {
// height: 80px; // height: 80px;
// width: 80px; // width: 80px;

View file

@ -12,7 +12,6 @@
}); });
.application.sheet.daggerheart.actor.dh-style.environment { .application.sheet.daggerheart.actor.dh-style.environment {
.tab { .tab {
max-height: 300px; max-height: 300px;
overflow-y: auto; overflow-y: auto;

View file

@ -0,0 +1,59 @@
.theme-light .application.daggerheart.dh-style.views.beastform-selection {
.beastforms-container .beastforms-tier .beastform-container .beastform-title {
background-image: url('../assets/parchments/dh-parchment-dark.png');
}
}
.application.daggerheart.dh-style.views.beastform-selection {
.beastforms-container {
display: flex;
flex-direction: column;
gap: 4px;
.beastforms-tier {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
gap: 4px;
.beastform-container {
position: relative;
display: flex;
justify-content: center;
border: 1px solid light-dark(@dark-blue, @golden);
border-radius: 6px;
cursor: pointer;
&.inactive {
opacity: 0.4;
}
img {
width: 100%;
border-radius: 6px;
}
.beastform-title {
position: absolute;
top: 4px;
display: flex;
flex-wrap: wrap;
font-size: 16px;
margin: 0 4px;
border: 1px solid light-dark(@dark-blue, @golden);
border-radius: 6px;
color: light-dark(@beige, @dark);
background-image: url('../assets/parchments/dh-parchment-light.png');
}
}
}
}
footer {
margin-top: 8px;
display: flex;
button {
flex: 1;
}
}
}

View file

@ -0,0 +1,50 @@
@import '../utils/colors.less';
@import '../utils/fonts.less';
.sheet.daggerheart.dh-style {
.tab.features {
.features-list {
display: flex;
flex-direction: column;
list-style: none;
padding: 0;
margin: 0;
width: 100%;
gap: 5px;
.feature-item {
display: grid;
align-items: center;
grid-template-columns: 1fr 4fr 1fr;
cursor: pointer;
img {
height: 40px;
width: 40px;
object-fit: cover;
border-radius: 3px;
}
h4 {
font-family: @font-body;
font-weight: lighter;
color: @beige;
}
.image {
height: 40px;
width: 40px;
object-fit: cover;
border-radius: 6px;
border: none;
}
.controls {
display: flex;
justify-content: center;
gap: 10px;
}
}
}
}
}

View file

@ -5,7 +5,7 @@
"version": "0.0.1", "version": "0.0.1",
"compatibility": { "compatibility": {
"minimum": "13", "minimum": "13",
"verified": "13.345", "verified": "13.346",
"maximum": "13" "maximum": "13"
}, },
"authors": [ "authors": [
@ -247,7 +247,11 @@
}, },
"armor": { "armor": {
"htmlFields": ["description"] "htmlFields": ["description"]
} },
"beastform": {}
},
"ActiveEffect": {
"beastform": {}
}, },
"Combat": { "Combat": {
"combat": {} "combat": {}

View file

@ -14,11 +14,6 @@
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=action type=../type}} {{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=action type=../type}}
{{/if}} {{/if}}
{{/each}} {{/each}}
{{#each document.system.ancestry.system.actions as |action|}}
{{#if (or (eq ../type 'ancestry'))}}
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=action type=../type}}
{{/if}}
{{/each}}
{{#each document.system.class.value.system.classFeatures as |classFeature|}} {{#each document.system.class.value.system.classFeatures as |classFeature|}}
{{#if (or (eq ../type 'class'))}} {{#if (or (eq ../type 'class'))}}
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=classFeature type=../type}} {{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=classFeature type=../type}}

View file

@ -1,4 +1,4 @@
<li class="inventory-item" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-companion="{{companion}}" {{#if (not noTooltip)}}data-tooltip="{{concat "#item#" item.uuid}}"{{/if}}> <li class="inventory-item" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-type="{{type}}" data-companion="{{companion}}" {{#if (not noTooltip)}}data-tooltip="{{concat "#item#" item.uuid}}"{{/if}}>
<img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" data-action="useItem"/> <img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" data-action="useItem"/>
<div class="item-label"> <div class="item-label">
{{#if isCompanion}} {{#if isCompanion}}

View file

@ -0,0 +1,23 @@
<section
class='tab {{tabs.features.cssClass}} {{tabs.features.id}}'
data-tab='{{tabs.features.id}}'
data-group='{{tabs.features.group}}'
>
<fieldset class="one-column drop-section">
<legend>{{localize "DAGGERHEART.Sheets.Global.Features"}}</legend>
<div class="features-list">
{{#each document.system.features as |feature index|}}
<div class="feature-item"
data-action="editFeature"
data-index="{{index}}"
>
<img class="image" src="{{feature.img}}" />
<span>{{feature.name}}</span>
<div class="controls">
<a data-action="removeFeature" data-index="{{index}}"><i class="fa-solid fa-trash"></i></a>
</div>
</div>
{{/each}}
</div>
</fieldset>
</section>

View file

@ -0,0 +1,10 @@
<header class='item-sheet-header'>
<img class='profile' src='{{source.img}}' data-action='editImage' data-edit='img' />
<div class='item-info'>
<line-div></line-div>
<h1 class='item-name'><input type='text' name='name' value='{{source.name}}' /></h1>
<div class='item-description'>
<h3>{{localize 'TYPES.Item.beastform'}}</h3>
</div>
</div>
</header>

View file

@ -0,0 +1,27 @@
<section
class='tab {{tabs.settings.cssClass}} {{tabs.settings.id}}'
data-tab='{{tabs.settings.id}}'
data-group='{{tabs.settings.group}}'
>
<div class="two-columns">
{{formGroup systemFields.tier value=source.system.tier localize=true}}
{{formGroup systemFields.examples value=source.system.examples localize=true}}
</div>
<fieldset class="two-columns">
<legend>{{localize "DAGGERHEART.Sheets.Beastform.FIELDS.advantageOn.label"}}</legend>
{{!-- {{formGroup systemFields.examples value=source.system.examples localize=true}} --}}
</fieldset>
<fieldset class="two-columns even">
<legend>{{localize "DAGGERHEART.Sheets.Beastform.tokenTitle"}}</legend>
<div class="full-width">
{{formGroup systemFields.tokenImg value=source.system.tokenImg localize=true}}
</div>
{{formGroup systemFields.tokenSize.fields.height value=source.system.tokenSize.height localize=true placeholder=(localize "DAGGERHEART.Sheets.Beastform.FIELDS.tokenSize.placeholder") }}
{{formGroup systemFields.tokenSize.fields.width value=source.system.tokenSize.width localize=true placeholder=(localize "DAGGERHEART.Sheets.Beastform.FIELDS.tokenSize.placeholder")}}
</fieldset>
</section>

View file

@ -0,0 +1,6 @@
<div>
<div>{{name}}</div>
<img src="{{system.tokenImg}}" />
<div>{{{system.examples}}}</div>
<div>{{system.advantageOn}}</div>
</div>

View file

@ -45,6 +45,7 @@
{{#if fields.resource}}{{> 'systems/daggerheart/templates/views/actionTypes/resource.hbs' fields=fields.resource.fields source=source.resource}}{{/if}} {{#if fields.resource}}{{> 'systems/daggerheart/templates/views/actionTypes/resource.hbs' fields=fields.resource.fields source=source.resource}}{{/if}}
{{#if fields.documentUUID}}{{> 'systems/daggerheart/templates/views/actionTypes/uuid.hbs' fields=fields.documentUUID source=source.documentUUID}}{{/if}} {{#if fields.documentUUID}}{{> 'systems/daggerheart/templates/views/actionTypes/uuid.hbs' fields=fields.documentUUID source=source.documentUUID}}{{/if}}
{{#if fields.effects}}{{> 'systems/daggerheart/templates/views/actionTypes/effect.hbs' fields=fields.effects.element.fields source=source.effects}}{{/if}} {{#if fields.effects}}{{> 'systems/daggerheart/templates/views/actionTypes/effect.hbs' fields=fields.effects.element.fields source=source.effects}}{{/if}}
{{#if fields.beastform}}{{> 'systems/daggerheart/templates/views/actionTypes/beastform.hbs' fields=fields.effects.element.fields source=source.beastform}}{{/if}}
</div> </div>
</section> </section>
</div> </div>

View file

@ -0,0 +1,17 @@
<fieldset class="action-category">
<legend class="action-category-label">
<div>{{localize "DAGGERHEART.Actions.Config.Beastform.label"}}</div>
</legend>
<div class="action-category-data open">
<div class="hint-group">
<div class="form-fields">
<label>{{localize "DAGGERHEART.Actions.Config.Beastform.exact"}}</label>
<select name="beastform.tierAccess.exact" data-dtype="Number">
{{selectOptions tierOptions selected=@root.source.beastform.tierAccess.exact labelAttr="label" valueAttr="key" blank="" }}
</select>
</div>
<p class="hint">{{localize "DAGGERHEART.Actions.Config.Beastform.exactHint"}}</p>
</div>
</div>
</fieldset>

View file

@ -0,0 +1,18 @@
<div>
<div class="beastforms-container">
{{#each beastformTiers as |tier tierKey|}}
<fieldset class="beastforms-tier">
<legend>{{tier.label}}</legend>
{{#each tier.values as |form uuid|}}
<div data-action="selectBeastform" data-uuid="{{uuid}}" data-tooltip="{{concat "#item#" uuid}}" class="beastform-container {{#if (and @root.canSubmit (not form.selected))}}inactive{{/if}}">
<img src="{{form.value.img}}" />
<div class="beastform-title">{{form.value.name}}</div>
</div>
{{/each}}
</fieldset>
{{/each}}
</div>
<footer>
<button type="button" data-action="submitBeastform" {{#if (not canSubmit)}}disabled{{/if}}>{{localize "DAGGERHEART.Sheets.Beastform.transform"}}</button>
</footer>
</div>