mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-13 04:01:06 +01:00
Refactor/275 actor sheets simplification (#291)
* FEAT: create isNPC geeter and add the prop on metada on actors FEAT: create common method for documents sheets FEAT: create BaseActorSheet and implementation * FIX: tabs label * REFACTOR: remove unused methods REFACTOR: simplify CharacterSheet's click actions methods REFACTOR: minor fix on DHActor class * REFACTOR: remove unused methods REFACTOR: create method on BaseActorSheet REFACTOR: make Datamodel metadata getter * REFACTOR: remove unused method on setting sheet FEAT: create BaseActorSetting FIX: add type="button" to button on actor's sheet * FIX jsdoc * PRETTIER --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com>
This commit is contained in:
parent
7d7fb88035
commit
87b3677956
34 changed files with 723 additions and 1253 deletions
|
|
@ -4,7 +4,16 @@ import DamageReductionDialog from '../applications/dialogs/damageReductionDialog
|
|||
import { LevelOptionType } from '../data/levelTier.mjs';
|
||||
import DHFeature from '../data/item/feature.mjs';
|
||||
|
||||
export default class DhpActor extends Actor {
|
||||
export default class DhpActor extends foundry.documents.Actor {
|
||||
|
||||
/**
|
||||
* Whether this actor is an NPC.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
get isNPC() {
|
||||
return this.system.metadata.isNPC;
|
||||
}
|
||||
|
||||
async _preCreate(data, options, user) {
|
||||
if ((await super._preCreate(data, options, user)) === false) return false;
|
||||
|
||||
|
|
@ -351,16 +360,16 @@ export default class DhpActor extends Actor {
|
|||
const modifier = roll.modifier !== null ? Number.parseInt(roll.modifier) : null;
|
||||
return modifier !== null
|
||||
? [
|
||||
{
|
||||
value: modifier,
|
||||
label: roll.label
|
||||
? modifier >= 0
|
||||
? `${roll.label} +${modifier}`
|
||||
: `${roll.label} ${modifier}`
|
||||
: null,
|
||||
title: roll.label
|
||||
}
|
||||
]
|
||||
{
|
||||
value: modifier,
|
||||
label: roll.label
|
||||
? modifier >= 0
|
||||
? `${roll.label} +${modifier}`
|
||||
: `${roll.label} ${modifier}`
|
||||
: null,
|
||||
title: roll.label
|
||||
}
|
||||
]
|
||||
: [];
|
||||
}
|
||||
|
||||
|
|
@ -440,10 +449,10 @@ export default class DhpActor extends Actor {
|
|||
damage >= this.system.damageThresholds.severe
|
||||
? 3
|
||||
: damage >= this.system.damageThresholds.major
|
||||
? 2
|
||||
: damage >= this.system.damageThresholds.minor
|
||||
? 1
|
||||
: 0;
|
||||
? 2
|
||||
: damage >= this.system.damageThresholds.minor
|
||||
? 1
|
||||
: 0;
|
||||
|
||||
if (
|
||||
this.type === 'character' &&
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ export default class DHItem extends foundry.documents.Item {
|
|||
* @returns {boolean} Returns `true` if the item is an inventory item.
|
||||
*/
|
||||
get isInventoryItem() {
|
||||
return this.system.constructor.metadata.isInventoryItem ?? false;
|
||||
return this.system.metadata.isInventoryItem ?? false;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
|
|
@ -53,17 +53,17 @@ export default class DHItem extends foundry.documents.Item {
|
|||
const isInventoryItem = CONFIG.Item.dataModels[type]?.metadata?.isInventoryItem;
|
||||
const group =
|
||||
isInventoryItem === true
|
||||
? 'Inventory Items'
|
||||
? 'Inventory Items' //TODO localize
|
||||
: isInventoryItem === false
|
||||
? 'Character Items'
|
||||
: 'Other';
|
||||
? 'Character Items' //TODO localize
|
||||
: 'Other'; //TODO localize
|
||||
|
||||
return { value: type, label, group };
|
||||
}
|
||||
);
|
||||
|
||||
if (!documentTypes.length) {
|
||||
throw new Error('No document types were permitted to be created.');
|
||||
throw new Error('No document types were permitted to be created.'); //TODO localize
|
||||
}
|
||||
|
||||
const sortedTypes = documentTypes.sort((a, b) => a.label.localeCompare(b.label, game.i18n.lang));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue