diff --git a/module/applications/sheets/character.mjs b/module/applications/sheets/character.mjs index a114e1c1..941ed1c8 100644 --- a/module/applications/sheets/character.mjs +++ b/module/applications/sheets/character.mjs @@ -320,25 +320,8 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) { const context = await super._prepareContext(_options); context.document = this.document; context.tabs = super._getTabs(this.constructor.TABS); - context.config = SYSTEM; - const selectedAttributes = Object.values(this.document.system.traits).map(x => x.base); - context.abilityScoreArray = await game.settings - .get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Homebrew) - .traitArray.reduce((acc, x) => { - const selectedIndex = selectedAttributes.indexOf(x); - if (selectedIndex !== -1) { - selectedAttributes.splice(selectedIndex, 1); - } else { - acc.push({ name: x, value: x }); - } - - return acc; - }, []); - if (!context.abilityScoreArray.includes(0)) context.abilityScoreArray.push({ name: 0, value: 0 }); - context.abilityScoresFinished = context.abilityScoreArray.every(x => x.value === 0); - context.attributes = Object.keys(this.document.system.traits).reduce((acc, key) => { acc[key] = { ...this.document.system.traits[key], @@ -349,73 +332,6 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) { return acc; }, {}); - const ancestry = await this.mapFeatureType( - this.document.system.ancestry ? [this.document.system.ancestry] : [], - SYSTEM.GENERAL.objectTypes - ); - const community = await this.mapFeatureType( - this.document.system.community ? [this.document.system.community] : [], - SYSTEM.GENERAL.objectTypes - ); - const foundation = { - ancestry: ancestry[0], - community: community[0], - advancement: {} - }; - - const nrLoadoutCards = this.document.system.domainCards.loadout.length; - const loadout = await this.mapFeatureType(this.document.system.domainCards.loadout, SYSTEM.DOMAIN.cardTypes); - const vault = await this.mapFeatureType(this.document.system.domainCards.vault, SYSTEM.DOMAIN.cardTypes); - context.abilities = { - foundation: foundation, - loadout: { - top: loadout.slice(0, Math.min(2, nrLoadoutCards)), - bottom: nrLoadoutCards > 2 ? loadout.slice(2, Math.min(5, nrLoadoutCards)) : [], - nrTotal: nrLoadoutCards, - listView: game.user.getFlag(SYSTEM.id, SYSTEM.FLAGS.displayDomainCardsAsList) - }, - vault: vault.map(x => ({ - ...x, - uuid: x.uuid, - sendToLoadoutDisabled: this.document.system.domainCards.loadout.length >= 5 - })) - }; - - context.inventory = { - consumable: { - titles: { - name: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.ConsumableTitle'), - quantity: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.QuantityTitle') - }, - items: this.document.items.filter(x => x.type === 'consumable') - }, - miscellaneous: { - titles: { - name: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.MiscellaneousTitle'), - quantity: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.QuantityTitle') - }, - items: this.document.items.filter(x => x.type === 'miscellaneous') - }, - weapons: { - titles: { - name: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.WeaponsTitle'), - quantity: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.QuantityTitle') - }, - items: this.document.items.filter(x => x.type === 'weapon') - }, - armor: { - titles: { - name: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.ArmorsTitle'), - quantity: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.QuantityTitle') - }, - items: this.document.items.filter(x => x.type === 'armor') - } - }; - - if (context.inventory.length === 0) { - context.inventory = Array(1).fill(Array(5).fill([])); - } - return context; } @@ -424,26 +340,6 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) { this.render(); } - async mapFeatureType(data, configType) { - return await Promise.all( - data.map(async x => { - const abilities = x.system.abilities - ? await Promise.all(x.system.abilities.map(async x => await fromUuid(x.uuid))) - : []; - - return { - ...x, - uuid: x.uuid, - system: { - ...x.system, - abilities: abilities, - type: game.i18n.localize(configType[x.system.type ?? x.type].label) - } - }; - }) - ); - } - static async rollAttribute(event, button) { const abilityLabel = game.i18n.localize(abilities[button.dataset.attribute].label); const config = { diff --git a/module/applications/sheets/companion.mjs b/module/applications/sheets/companion.mjs index fd5dd3d6..b438550e 100644 --- a/module/applications/sheets/companion.mjs +++ b/module/applications/sheets/companion.mjs @@ -6,7 +6,9 @@ export default class DhCompanionSheet extends DaggerheartSheet(ActorSheetV2) { tag: 'form', classes: ['daggerheart', 'sheet', 'actor', 'dh-style', 'companion'], position: { width: 700, height: 1000 }, - actions: {}, + actions: { + attackRoll: this.attackRoll + }, form: { handler: this.updateForm, submitOnChange: true, @@ -32,4 +34,8 @@ export default class DhCompanionSheet extends DaggerheartSheet(ActorSheetV2) { await this.document.update(formData.object); this.render(); } + + static async attackRoll(event) { + this.actor.system.attack.use(event); + } } diff --git a/module/data/actor/companion.mjs b/module/data/actor/companion.mjs index f0561629..24f7906c 100644 --- a/module/data/actor/companion.mjs +++ b/module/data/actor/companion.mjs @@ -1,6 +1,7 @@ import BaseDataActor from './base.mjs'; import DhLevelData from '../levelData.mjs'; import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs'; +import ActionField from '../fields/actionField.mjs'; export default class DhCompanion extends BaseDataActor { static LOCALIZATION_PREFIXES = ['DAGGERHEART.Sheets.Companion']; @@ -41,28 +42,38 @@ export default class DhCompanion extends BaseDataActor { } } ), - attack: new fields.SchemaField({ - name: new fields.StringField({}), - range: new fields.StringField({ - required: true, - choices: SYSTEM.GENERAL.range, - initial: SYSTEM.GENERAL.range.melee.id - }), - damage: new fields.SchemaField({ - value: new fields.StringField({ initial: 'd6' }), - type: new fields.StringField({ - required: true, - choices: SYSTEM.GENERAL.damageTypes, - initial: SYSTEM.GENERAL.damageTypes.physical.id - }) - }) + attack: new ActionField({ + base: { + name: 'Attack', + _id: foundry.utils.randomID(), + systemPath: 'attack', + type: 'attack', + range: 'melee', + target: { + type: 'any', + amount: 1 + }, + roll: { + type: 'weapon', + bonus: 0 + }, + damage: { + parts: [ + { + multiplier: 'flat' + } + ] + } + } }), levelData: new fields.EmbeddedDataField(DhLevelData) }; } prepareBaseData() { - this.attack.modifier = this.partner?.system?.spellcastingModifiers?.main ?? 0; // Needs to expand on which modifier it is that should be used because of multiclassing; + const partnerSpellcastingModifier = this.partner?.system?.spellcastingModifiers?.main; + const spellcastingModifier = this.partner?.system?.traits?.[partnerSpellcastingModifier]?.total; + this.attack.roll.bonus = spellcastingModifier ?? 0; // Needs to expand on which modifier it is that should be used because of multiclassing; } prepareDerivedData() { diff --git a/templates/sheets/actors/companion/tempMain.hbs b/templates/sheets/actors/companion/tempMain.hbs index bfdcbe0e..d12d60c7 100644 --- a/templates/sheets/actors/companion/tempMain.hbs +++ b/templates/sheets/actors/companion/tempMain.hbs @@ -21,7 +21,13 @@ {{/each}} -
- {{formGroup systemFields.attack.fields.name value=source.system.attack.name localize=true }} +
+
+
+ + + +
+
\ No newline at end of file