mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-13 20:21:06 +01:00
Merged with development
This commit is contained in:
commit
379398f2c7
46 changed files with 968 additions and 73 deletions
|
|
@ -646,6 +646,19 @@ export default class DhpActor extends Actor {
|
|||
}
|
||||
}
|
||||
|
||||
const results = await game.system.registeredTriggers.runTrigger(
|
||||
CONFIG.DH.TRIGGER.triggers.postDamageReduction.id,
|
||||
this,
|
||||
updates,
|
||||
this
|
||||
);
|
||||
|
||||
if (results?.length) {
|
||||
const resourceMap = new ResourceUpdateMap(results[0].originActor);
|
||||
for (var result of results) resourceMap.addResources(result.updates);
|
||||
resourceMap.updateResources();
|
||||
}
|
||||
|
||||
updates.forEach(
|
||||
u =>
|
||||
(u.value =
|
||||
|
|
|
|||
|
|
@ -37,4 +37,30 @@ export default class DhScene extends Scene {
|
|||
this.#sizeSyncBatch.clear();
|
||||
this.updateEmbeddedDocuments('Token', entries, { animation: { movementSpeed: 1.5 } });
|
||||
}, 0);
|
||||
|
||||
prepareBaseData() {
|
||||
super.prepareBaseData();
|
||||
|
||||
if (this instanceof game.system.api.documents.DhScene) {
|
||||
const system = new game.system.api.data.scenes.DHScene(this.flags.daggerheart);
|
||||
|
||||
// Register this scene to all environements
|
||||
for (const environment of system.sceneEnvironments) {
|
||||
environment.system.scenes?.add(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_onDelete(options, userId) {
|
||||
super._onDelete(options, userId);
|
||||
|
||||
if (this instanceof game.system.api.documents.DhScene) {
|
||||
const system = new game.system.api.data.scenes.DHScene(this.flags.daggerheart);
|
||||
|
||||
// Clear this scene from all environments that aren't deleted
|
||||
for (const environment of system.sceneEnvironments) {
|
||||
environment?.system?.scenes?.delete(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ export default class DHToken extends CONFIG.Token.documentClass {
|
|||
if (combat?.system?.battleToggles?.length) {
|
||||
await combat.toggleModifierEffects(
|
||||
true,
|
||||
tokens.map(x => x.actor)
|
||||
tokens.filter(x => x.actor).map(x => x.actor)
|
||||
);
|
||||
}
|
||||
super.createCombatants(tokens, combat ?? {});
|
||||
|
|
@ -95,7 +95,7 @@ export default class DHToken extends CONFIG.Token.documentClass {
|
|||
if (combat?.system?.battleToggles?.length) {
|
||||
await combat.toggleModifierEffects(
|
||||
false,
|
||||
tokens.map(x => x.actor)
|
||||
tokens.filter(x => x.actor).map(x => x.actor)
|
||||
);
|
||||
}
|
||||
super.deleteCombatants(tokens, combat ?? {});
|
||||
|
|
|
|||
|
|
@ -220,12 +220,15 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
|
|||
for (const [index, itemValue] of pathValue.entries()) {
|
||||
const itemIsAction = itemValue instanceof game.system.api.models.actions.actionsTypes.base;
|
||||
const value = itemIsAction || !itemValue?.item ? itemValue : itemValue.item;
|
||||
const enrichedValue = await TextEditor.enrichHTML(value.system?.description ?? value.description);
|
||||
const enrichedValue =
|
||||
(await value.system?.getEnrichedDescription?.()) ??
|
||||
(await TextEditor.enrichHTML(value.system?.description ?? value.description));
|
||||
if (itemIsAction) value.enrichedDescription = enrichedValue;
|
||||
else foundry.utils.setProperty(item, `${basePath}.${index}.enrichedDescription`, enrichedValue);
|
||||
}
|
||||
} else {
|
||||
const enrichedValue = await TextEditor.enrichHTML(pathValue);
|
||||
const enrichedValue =
|
||||
(await item.system?.getEnrichedDescription?.()) ?? (await TextEditor.enrichHTML(pathValue));
|
||||
foundry.utils.setProperty(
|
||||
item,
|
||||
`${data.path ? `${data.path}.` : ''}enriched${data.name.capitalize()}`,
|
||||
|
|
@ -262,7 +265,7 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
|
|||
const combat = game.combats.get(combatId);
|
||||
const adversaries =
|
||||
combat.turns?.filter(x => x.actor?.isNPC)?.map(x => ({ ...x.actor, type: x.actor.system.type })) ?? [];
|
||||
const characters = combat.turns?.filter(x => !x.isNPC) ?? [];
|
||||
const characters = combat.turns?.filter(x => !x.isNPC && x.actor) ?? [];
|
||||
|
||||
const nrCharacters = characters.length;
|
||||
const currentBP = AdversaryBPPerEncounter(adversaries, characters);
|
||||
|
|
@ -272,7 +275,7 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
|
|||
);
|
||||
|
||||
const categories = combat.combatants.reduce((acc, combatant) => {
|
||||
if (combatant.actor.type === 'adversary') {
|
||||
if (combatant.actor?.type === 'adversary') {
|
||||
const keyData = Object.keys(acc).reduce((identifiers, categoryKey) => {
|
||||
if (identifiers) return identifiers;
|
||||
const category = acc[categoryKey];
|
||||
|
|
@ -352,7 +355,7 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
|
|||
|
||||
await combat.toggleModifierEffects(
|
||||
event.target.checked,
|
||||
combat.combatants.filter(x => x.actor.type === 'adversary').map(x => x.actor),
|
||||
combat.combatants.filter(x => x.actor?.type === 'adversary').map(x => x.actor),
|
||||
category,
|
||||
grouping
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue