mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 19:51:08 +01:00
* FIX: Add enritch to HTMLField FIX: Remove no-HTMLField from Manifest FIX: Convert Scar's HTMLField to StringField FIX: Remove unused HTMLField * REMOVE unused hanldebars helpers * FEAT: add inventory-fieldset-items-V2 and inventory-item-V2 partials for Actors * FIX showLabels to hideTags * FEAT: add template to items sheet * FEAT: add effects tabs on ItemSheet * FEAT: add context menus for all inventory-items * FEAT: add resources to inventory-item template * FEAT: add enritch on inventory-item description FEAT: add extensible behavior on inventory-item-content FEAT: add fade effect on item-img to roll-itmg * FEAT: add eritch to NPC description FIX: missing htmlFieldss on manfiest FIX: add misisng localizations * FIX_ minor fixes * Little resource fix. Noone will notice ._. * FIX: remove default list styles FIX: .extended css reduce max-height, shorten animation duration to 0.5s, and set overflow to auto. FIX: set enriched=notes.enriche on notes.hbs FIX: set experience.value on sidebar.hbs FIX: move tooltip from item-img to img-portrait on inventory-item-V2.hbs REMOVE: unused files --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> Co-authored-by: WBHarry <williambjrklund@gmail.com>
133 lines
5 KiB
JavaScript
133 lines
5 KiB
JavaScript
import BaseDataActor from './base.mjs';
|
|
import DhLevelData from '../levelData.mjs';
|
|
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
|
|
import ActionField from '../fields/actionField.mjs';
|
|
import { adjustDice, adjustRange } from '../../helpers/utils.mjs';
|
|
import DHCompanionSettings from '../../applications/sheets-configs/companion-settings.mjs';
|
|
import { resourceField, bonusField } from '../fields/actorField.mjs';
|
|
|
|
export default class DhCompanion extends BaseDataActor {
|
|
static LOCALIZATION_PREFIXES = ['DAGGERHEART.ACTORS.Companion'];
|
|
|
|
static get metadata() {
|
|
return foundry.utils.mergeObject(super.metadata, {
|
|
label: 'TYPES.Actor.companion',
|
|
type: 'companion',
|
|
isNPC: false,
|
|
settingSheet: DHCompanionSettings
|
|
});
|
|
}
|
|
|
|
static defineSchema() {
|
|
const fields = foundry.data.fields;
|
|
|
|
return {
|
|
...super.defineSchema(),
|
|
partner: new ForeignDocumentUUIDField({ type: 'Actor' }),
|
|
resources: new fields.SchemaField({
|
|
stress: resourceField(3, 'DAGGERHEART.GENERAL.stress', true),
|
|
hope: new fields.NumberField({ initial: 0, integer: true, label: 'DAGGERHEART.GENERAL.hope' })
|
|
}),
|
|
evasion: new fields.NumberField({
|
|
required: true,
|
|
min: 1,
|
|
initial: 10,
|
|
integer: true,
|
|
label: 'DAGGERHEART.GENERAL.evasion'
|
|
}),
|
|
experiences: new fields.TypedObjectField(
|
|
new fields.SchemaField({
|
|
name: new fields.StringField({}),
|
|
value: new fields.NumberField({ integer: true, initial: 0 })
|
|
}),
|
|
{
|
|
initial: {
|
|
experience1: { value: 2 },
|
|
experience2: { value: 2 }
|
|
}
|
|
}
|
|
),
|
|
attack: new ActionField({
|
|
initial: {
|
|
name: 'Attack',
|
|
img: 'icons/creatures/claws/claw-bear-paw-swipe-brown.webp',
|
|
_id: foundry.utils.randomID(),
|
|
systemPath: 'attack',
|
|
type: 'attack',
|
|
range: 'melee',
|
|
target: {
|
|
type: 'any',
|
|
amount: 1
|
|
},
|
|
roll: {
|
|
type: 'attack',
|
|
bonus: 0
|
|
},
|
|
damage: {
|
|
parts: [
|
|
{
|
|
type: ['physical'],
|
|
value: {
|
|
dice: 'd6',
|
|
multiplier: 'prof'
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}),
|
|
actions: new fields.ArrayField(new ActionField()),
|
|
levelData: new fields.EmbeddedDataField(DhLevelData),
|
|
bonuses: new fields.SchemaField({
|
|
damage: new fields.SchemaField({
|
|
physical: bonusField('DAGGERHEART.GENERAL.Damage.physicalDamage'),
|
|
magical: bonusField('DAGGERHEART.GENERAL.Damage.magicalDamage')
|
|
})
|
|
})
|
|
};
|
|
}
|
|
|
|
get proficiency() {
|
|
return this.partner?.system?.proficiency ?? 1;
|
|
}
|
|
|
|
prepareBaseData() {
|
|
this.attack.roll.bonus = this.partner?.system?.spellcastModifier ?? 0;
|
|
|
|
for (let levelKey in this.levelData.levelups) {
|
|
const level = this.levelData.levelups[levelKey];
|
|
for (let selection of level.selections) {
|
|
switch (selection.type) {
|
|
case 'hope':
|
|
this.resources.hope += selection.value;
|
|
break;
|
|
case 'vicious':
|
|
if (selection.data[0] === 'damage') {
|
|
this.attack.damage.parts[0].value.dice = adjustDice(this.attack.damage.parts[0].value.dice);
|
|
} else {
|
|
this.attack.range = adjustRange(this.attack.range);
|
|
}
|
|
break;
|
|
case 'stress':
|
|
this.resources.stress.max += selection.value;
|
|
break;
|
|
case 'evasion':
|
|
this.evasion += selection.value;
|
|
break;
|
|
case 'experience':
|
|
Object.keys(this.experiences).forEach(key => {
|
|
const experience = this.experiences[key];
|
|
experience.value += selection.value;
|
|
});
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async _preDelete() {
|
|
if (this.partner) {
|
|
await this.partner.update({ 'system.companion': null });
|
|
}
|
|
}
|
|
}
|