Compare commits

..

No commits in common. "394d1d338d3cd0e6b6e2445233a28e0d34752f57" and "e3e1395de6f088613dc71472b18e937e9f8e4115" have entirely different histories.

12 changed files with 17 additions and 92 deletions

View file

@ -3,7 +3,6 @@ import * as applications from './module/applications/_module.mjs';
import * as data from './module/data/_module.mjs'; import * as data from './module/data/_module.mjs';
import * as models from './module/data/_module.mjs'; import * as models from './module/data/_module.mjs';
import * as documents from './module/documents/_module.mjs'; import * as documents from './module/documents/_module.mjs';
import { macros } from './module/_module.mjs';
import * as collections from './module/documents/collections/_module.mjs'; import * as collections from './module/documents/collections/_module.mjs';
import * as dice from './module/dice/_module.mjs'; import * as dice from './module/dice/_module.mjs';
import * as fields from './module/data/fields/_module.mjs'; import * as fields from './module/data/fields/_module.mjs';
@ -95,7 +94,6 @@ Hooks.once('init', () => {
data, data,
models, models,
documents, documents,
macros,
dice, dice,
fields fields
}; };

View file

@ -2547,14 +2547,6 @@
"secondaryWeapon": "Secondary Weapon" "secondaryWeapon": "Secondary Weapon"
} }
}, },
"MACROS": {
"Spotlight": {
"errors": {
"noActiveCombat": "There is no active encounter",
"noCombatantSelected": "A combatant token must be either selected or hovered to spotlight it"
}
}
},
"ROLLTABLES": { "ROLLTABLES": {
"FIELDS": { "FIELDS": {
"formulaName": { "label": "Formula Name" } "formulaName": { "label": "Formula Name" }
@ -2798,12 +2790,6 @@
"setResourceIdentifier": "Set Resource Identifier" "setResourceIdentifier": "Set Resource Identifier"
} }
}, },
"Keybindings": {
"spotlight": {
"name": "Spotlight Combatant",
"hint": "Move the spotlight to a hovered or selected token that's present in an active encounter"
}
},
"Menu": { "Menu": {
"title": "Daggerheart Game Settings", "title": "Daggerheart Game Settings",
"automation": { "automation": {

View file

@ -7,4 +7,3 @@ export * as documents from './documents/_module.mjs';
export * as enrichers from './enrichers/_module.mjs'; export * as enrichers from './enrichers/_module.mjs';
export * as helpers from './helpers/_module.mjs'; export * as helpers from './helpers/_module.mjs';
export * as systemRegistration from './systemRegistration/_module.mjs'; export * as systemRegistration from './systemRegistration/_module.mjs';
export * as macros from './macros/_modules.mjs';

View file

@ -1,7 +1,3 @@
export const keybindings = {
spotlight: 'DHSpotlight'
};
export const menu = { export const menu = {
Automation: { Automation: {
Name: 'GameSettingsAutomation', Name: 'GameSettingsAutomation',

View file

@ -161,11 +161,12 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
this.parent.actor?.type === 'character' && this.parent.actor?.type === 'character' &&
this.parent.actor.system.resources.armor this.parent.actor.system.resources.armor
) { ) {
const armorEffect = changed.system?.changes?.find(x => x.type === 'armor'); const newArmorTotal = (changed.system?.changes ?? []).reduce((acc, change) => {
const newArmorTotal = if (change.type === 'armor') acc += change.value.current;
armorEffect?.value?.current + (this.parent.actor.system.armor?.system?.armor?.current ?? 0); return acc;
}, this.parent.actor.system.armor?.system?.armor?.current ?? 0);
if (armorEffect && newArmorTotal !== this.parent.actor.system.armorScore.value) { if (newArmorTotal !== this.parent.actor.system.armorScore.value) {
const armorData = getScrollTextData(this.parent.actor, { value: newArmorTotal }, 'armor'); const armorData = getScrollTextData(this.parent.actor, { value: newArmorTotal }, 'armor');
options.scrollingTextData = [armorData]; options.scrollingTextData = [armorData];
} }

View file

@ -757,6 +757,7 @@ export default class DhCharacter extends DhCreature {
prepareDerivedData() { prepareDerivedData() {
super.prepareDerivedData(); super.prepareDerivedData();
let baseHope = this.resources.hope.value;
if (this.companion) { if (this.companion) {
for (let levelKey in this.companion.system.levelData.levelups) { for (let levelKey in this.companion.system.levelData.levelups) {
const level = this.companion.system.levelData.levelups[levelKey]; const level = this.companion.system.levelData.levelups[levelKey];
@ -771,6 +772,7 @@ export default class DhCharacter extends DhCreature {
} }
this.resources.hope.max -= this.scars; this.resources.hope.max -= this.scars;
this.resources.hope.value = Math.min(baseHope, this.resources.hope.max);
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait; this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
this.resources.armor = { this.resources.armor = {

View file

@ -60,14 +60,4 @@ export default class DhCreature extends BaseDataActor {
} }
} }
} }
prepareDerivedData() {
const minLimitResource = resource => {
if (resource) resource.value = Math.min(resource.value, resource.max);
};
minLimitResource(this.resources.stress);
minLimitResource(this.resources.hitPoints);
minLimitResource(this.resources.hope);
}
} }

View file

@ -94,9 +94,8 @@ class ResourcesField extends fields.TypedObjectField {
const resources = CONFIG.DH.RESOURCE[this.actorType].all; const resources = CONFIG.DH.RESOURCE[this.actorType].all;
if (first in resources) { if (first in resources) {
const field = this.element._getField(path); this.element.label = resources[first].label;
field.label = resources[first].label; return this.element._getField(path);
return field;
} }
return undefined; return undefined;

View file

@ -30,18 +30,6 @@ export default class DhpActor extends Actor {
return this.system.metadata.isNPC; return this.system.metadata.isNPC;
} }
prepareData() {
super.prepareData();
// Update effects if it is the user's character or is controlled
if (canvas.ready) {
const controlled = canvas.tokens.controlled.some(t => t.actor === this);
if (game.user.character === this || controlled) {
ui.effectsDisplay.render();
}
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
/** @inheritDoc */ /** @inheritDoc */
@ -134,6 +122,14 @@ export default class DhpActor extends Actor {
} }
} }
_onUpdateDescendantDocuments(parent, collection, documents, changes, options, userId) {
if (collection === 'effects') {
ui.effectsDisplay.render();
}
super._onUpdateDescendantDocuments(parent, collection, documents, changes, options, userId);
}
async updateLevel(newLevel) { async updateLevel(newLevel) {
if (!['character', 'companion'].includes(this.type) || newLevel === this.system.levelData.level.changed) return; if (!['character', 'companion'].includes(this.type) || newLevel === this.system.levelData.level.changed) return;

View file

@ -1 +0,0 @@
export { default as spotlightCombatant } from './spotlightCombatant.mjs';

View file

@ -1,21 +0,0 @@
/**
* Spotlights a combatant.
* The combatant can be selected in a number of ways. If many are applied at the same time, the following order is used:
* 1) SelectedCombatant
* 2) HoveredCombatant
*/
const spotlightCombatant = () => {
if (!game.combat)
return ui.notifications.error(game.i18n.localize('DAGGERHEART.MACROS.Spotlight.errors.noActiveCombat'));
const selectedCombatant = canvas.tokens.controlled.length > 0 ? canvas.tokens.controlled[0].combatant : null;
const hoveredCombatant = game.canvas.tokens.hover?.combatant;
const combatant = selectedCombatant ?? hoveredCombatant;
if (!combatant)
return ui.notifications.error(game.i18n.localize('DAGGERHEART.MACROS.Spotlight.errors.noCombatantSelected'));
ui.combat.setCombatantSpotlight(combatant.id);
};
export default spotlightCombatant;

View file

@ -18,7 +18,6 @@ import {
import { CompendiumBrowserSettings } from '../data/_module.mjs'; import { CompendiumBrowserSettings } from '../data/_module.mjs';
export const registerDHSettings = () => { export const registerDHSettings = () => {
registerKeyBindings();
registerMenuSettings(); registerMenuSettings();
registerMenus(); registerMenus();
registerNonConfigSettings(); registerNonConfigSettings();
@ -34,25 +33,6 @@ export const registerDHSettings = () => {
}); });
}; };
export const registerKeyBindings = () => {
game.keybindings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.keybindings.spotlight, {
name: game.i18n.localize('DAGGERHEART.SETTINGS.Keybindings.spotlight.name'),
hint: game.i18n.localize('DAGGERHEART.SETTINGS.Keybindings.spotlight.hint'),
uneditable: [],
editable: [
{
key: 's',
modifiers: []
}
],
onDown: game.system.api.macros.spotlightCombatant,
onUp: () => {},
restricted: true,
reservedModifiers: [],
precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL
});
};
const registerMenuSettings = () => { const registerMenuSettings = () => {
game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules, { game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules, {
scope: 'world', scope: 'world',