This commit is contained in:
WBHarry 2025-06-29 22:58:21 +02:00
parent 4f5e693c7f
commit b7f962b22d
16 changed files with 844 additions and 212 deletions

View file

@ -4,7 +4,7 @@ import DhpDowntime from '../downtime.mjs';
import AncestrySelectionDialog from '../ancestrySelectionDialog.mjs';
import DaggerheartSheet from './daggerheart-sheet.mjs';
import { abilities } from '../../config/actorConfig.mjs';
import DhlevelUp from '../levelup.mjs';
import DhCharacterlevelUp from '../levelup/characterLevelup.mjs';
import DhCharacterCreation from '../characterCreation.mjs';
const { ActorSheetV2 } = foundry.applications.sheets;
@ -425,7 +425,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
return;
}
new DhlevelUp(this.document).render(true);
new DhCharacterlevelUp(this.document).render(true);
}
static async useDomainCard(event, button) {

View file

@ -1,3 +1,4 @@
import DhCompanionlevelUp from '../levelup/companionLevelup.mjs';
import DaggerheartSheet from './daggerheart-sheet.mjs';
const { ActorSheetV2 } = foundry.applications.sheets;
@ -7,7 +8,8 @@ export default class DhCompanionSheet extends DaggerheartSheet(ActorSheetV2) {
classes: ['daggerheart', 'sheet', 'actor', 'dh-style', 'companion'],
position: { width: 700, height: 1000 },
actions: {
attackRoll: this.attackRoll
attackRoll: this.attackRoll,
levelUp: this.levelUp
},
form: {
handler: this.updateForm,
@ -20,6 +22,12 @@ export default class DhCompanionSheet extends DaggerheartSheet(ActorSheetV2) {
sidebar: { template: 'systems/daggerheart/templates/sheets/actors/companion/tempMain.hbs' }
};
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
htmlElement.querySelector('.partner-value')?.addEventListener('change', this.onPartnerChange.bind(this));
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.document = this.document;
@ -35,7 +43,22 @@ export default class DhCompanionSheet extends DaggerheartSheet(ActorSheetV2) {
this.render();
}
async onPartnerChange(event) {
if (event.target.value) {
const partner = game.actors.find(a => a.uuid === event.target.value);
await partner.update({ 'system.companion': this.document.uuid });
} else {
await this.document.system.partner.update({ 'system.companion': null });
}
await this.document.update({ 'system.partner': event.target.value });
}
static async attackRoll(event) {
this.actor.system.attack.use(event);
}
static async levelUp() {
new DhCompanionlevelUp(this.document).render(true);
}
}