Compare commits

...

54 commits
2.4.1 ... main

Author SHA1 Message Date
WBHarry
26bcc2dddc
[Feature] Reload Check (#2051)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-20 20:08:52 -04:00
WBHarry
8d68166e4c Raised foundry compatability to 14.365
Some checks failed
Project CI / build (24.x) (push) Has been cancelled
2026-07-19 12:42:16 +02:00
Carlos Fernandez
3efdcb6c9a
Allow deleting countdowns via right click context menu on the main panel (#2090) 2026-07-19 11:35:55 +02:00
WBHarry
effab8db0c
[Rework] ChatMessage Damage (#2079)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
* Initial rework

* Removed unneeded method

* Removed outcommented code

* Added migration

* Fixed DamageActions

* Semi-corrected reroll of one of multiple results on a die

* Code improvement

* Added aseDie.rerollResult method to specifically reroll a specific result die in a grouping

* TagTeamDialog somewhat working

* Added migration for TagTeamData

* Fix for mean tagTeamDialog.finish

* .

* Improved migration

* Internalised ChatDamageData.prepareRolls to its own constructor

* Moved DamageTypes to roll.options

* TagTeamDialog fixes to accomodate new flat damage.types structure

* Changed so all default rolls become BaseRolls to access convenience functions and getters

* .

* Fixed so that party.tagTeam now uses a declared damageRollData(ChatDamageData) field. rollData.options.damage is retired.

* Critical damage fixes

* Corrected TagTeamDialog rerender logic when selecting a roll

* Fixed so that DamageTypes are retained and joined together throughout TagTeamDialog

* Removed some remaining types.<>.roll references

* [Rework] Damage and Damage Resource split (#2094)

* Changed the label of ActionSheet damage.resources to Mark Resources

* Fix assigning includeBase

* Localize add resource

* Maybe simplify API

* Fix onRollSimple

* Handle erroring action update differently

---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
2026-07-19 03:02:57 +02:00
Carlos Fernandez
4b651836ff
Start supporting flat damage without custom formulas (#2077)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-18 18:33:19 +02:00
Carlos Fernandez
c181a47cc2
Swap item macro tooltip with system item tooltips (#2092) 2026-07-18 18:28:42 +02:00
Carlos Fernandez
d76b4bb707
Fix chat being jumpy as timestamps get longer (#2095)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-18 11:42:50 +02:00
Carlos Fernandez
79d6522614
[Feature] Add support for GM Notes (#2082)
Some checks failed
Project CI / build (24.x) (push) Has been cancelled
* Add support for GM Notes

* Localize GM Notes header label

* Fix active editor height and menu auto sizing

* Add tooltip to add gm note button
2026-07-14 14:39:53 +02:00
WBHarry
0c2d257871 Raised version 2026-07-14 14:36:56 +02:00
Carlos Fernandez
4974df16d0
Preserve description expand state on re-render (#2089) 2026-07-14 14:35:02 +02:00
Carlos Fernandez
3a5529f1dc
Cleanup secret block styling (#2088)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-14 00:56:34 +02:00
Carlos Fernandez
02a73d774a
Add guard for null placedData (#2087) 2026-07-14 00:31:42 +02:00
WBHarry
450287e4d0
[Fix] Summon Wildcard Handling (#2086) 2026-07-13 16:57:43 -04:00
WBHarry
81e264a477 Raised version
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-13 17:04:27 +02:00
WBHarry
d3d9ddfb41 Fixed an issue with the 2.5.2 migration 2026-07-13 17:02:26 +02:00
WBHarry
7b35feb36d
Corrected translation for damageReductionOnlyMagical (#2084) 2026-07-13 15:01:03 +02:00
Carlos Fernandez
6e0d0b4e2c
Adjust styling of secret blocks (#2080)
* Adjust styling of secret blocks

* Only show button when hovering over the secret section
2026-07-13 14:57:55 +02:00
Carlos Fernandez
3de9c2f909
Remove duplicate action descriptions in environments (#2083) 2026-07-13 14:56:49 +02:00
Carlos Fernandez
3faf588e6c
Fix chat messages with list items or weapon/armor features (#2081)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-13 02:43:56 +02:00
WBHarry
783505da0a Raised verison
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-12 00:37:37 +02:00
WBHarry
76ee777985
[Fix] ActiveEffect Mode OneTime Migration (#2078)
* Migrations for ActiveEffect Mode
* Start on migration handlers

---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
2026-07-12 00:37:02 +02:00
WBHarry
c6411ef0fe
Cleaned up uses of 'mode' for activeEffects in configs (#2076) 2026-07-11 16:51:44 -04:00
WBHarry
2c98070836
Fixed so that the v13/v14 change from mode to type is fixed in SRD (#2075) 2026-07-11 16:27:38 -04:00
WBHarry
780aaf216c
Fixed a typo in getTemplateShape and added stopPropagaton when clicking enriched buttons (#2074)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-11 15:05:15 -04:00
Carlos Fernandez
0fbfe388b0
Remove postEvaluate static method (#2073)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-11 01:52:50 +02:00
WBHarry
7a01793f67 Raised version 2026-07-11 01:47:16 +02:00
WBHarry
1e30ea42ba
Fixed beastform basic attack being available (#2072)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-09 22:56:47 -04:00
Carlos Fernandez
e55ef9fd9e
Support vaulting and unvaulting domain cards via dragdrop (#2070)
Some checks failed
Project CI / build (24.x) (push) Has been cancelled
2026-07-08 14:57:10 -04:00
Carlos Fernandez
6cd19ada8a
Minor tweaks to tooltip card styling (#2069)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-08 16:46:28 +02:00
Carlos Fernandez
b03772b633
Fix missing group roll hint message (#2068)
Some checks failed
Project CI / build (24.x) (push) Has been cancelled
2026-07-07 03:14:20 +02:00
WBHarry
b2eeed7bb7
[Fix] Cleanup RangeDependant (#2039)
* Made the RangeDependent setting for ActiveEffects Nullable
* Removed all RangeDependent data from SRD where enabled was false before
* Fixed random flickerfly SRD
2026-07-07 00:20:48 +02:00
Carlos Fernandez
2782b62793
Fix some issues involving party in observer view (#2067) 2026-07-06 23:52:43 +02:00
WBHarry
4b5550a097
Added Resource capability to armor items (#2060) 2026-07-06 20:08:44 +02:00
Carlos Fernandez
7e6fc03230
Fix padding of party sheet inventory (#2066) 2026-07-06 20:08:22 +02:00
WBHarry
67b0d036a1
Fixed so that a character having ReduceSeverity or ThresholdImmunity rules are considered for popping the DamageReductionDialog (#2064) 2026-07-06 20:06:08 +02:00
WBHarry
5889476b64
[Fix] SRD Towering Stalk Fix (#2063)
* Removed a faulty research cost on the attack action of Towering Stalk

* .
2026-07-06 20:05:16 +02:00
WBHarry
cb43ffed9b
Corrected the description of the vicious maul action (#2065)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-06 00:36:05 +02:00
Carlos Fernandez
eccab6ad64
[UI] Make sheet tab scrollsbars stable, remove fieldsets, and adjust padding (#1944)
Some checks failed
Project CI / build (24.x) (push) Has been cancelled
* Remove certain fieldsets and adjust scrollsbars

* Also remove fieldset for npc features and fix padding issue in full screen notes
2026-07-03 11:32:51 +02:00
WBHarry
1dcfc92a03 Raised version 2026-07-03 11:16:55 +02:00
WBHarry
98fedf3990
[Feature] Transform Linked Actors (#2046)
* Added ability to transform linked actors
* Updated to use the utils getWorldActor function
* Animate change and fix error when converting to unlinked
---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
2026-07-03 11:14:25 +02:00
Gergely Bräutigam
44dd3bd2e1
[Feature] add resources to weapons (#2058)
* feat: add resources to weapons

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>

* remove sidebar resource view

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>

---------

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
2026-07-03 11:05:28 +02:00
Carlos Fernandez
b3d96c25d9
Fix adjusting tiers of higher level creatures and an error that may occur with hordes (#2059) 2026-07-03 10:37:43 +02:00
Carlos Fernandez
53ed9fc792
More preliminary sheet work and refactors (#2057)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-03 01:17:59 +02:00
Carlos Fernandez
e718c6b7b8
Fix item expand state not being retained across rerenders (#2056)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-02 10:33:16 +02:00
WBHarry
cdf6e7fdd0
[Feature] ActiveEffect Auras (#2049)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
* Added Attached type to action areas
* Added functionality to Elemental Aura
2026-07-02 01:00:36 +02:00
Carlos Fernandez
d36c141d36
Tweak retrieving world actor (#2052) 2026-07-02 00:48:07 +02:00
Carlos Fernandez
489f62a379
[UI/UX] Reduce width of adversary sidebar (#2055)
* Reduce width of adversary sidebar

* Fix pips
2026-07-02 00:46:29 +02:00
WBHarry
c25c4d63f7
Changed so that chat messages never show the actor name, instead using alias (#2054) 2026-07-01 22:17:03 +02:00
Carlos Fernandez
1af86d87bb
Refactor styling of sidebar resources (#2050)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-07-01 13:39:16 +02:00
WBHarry
70388dbd73
[Fix] SummonAction Actor Choice (#2045)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
* Fixed logic for picking which actor to summon

* Moved getWorldActor function to utils and updated logic

* .

* Improved logic
2026-06-30 13:05:35 +02:00
Carlos Fernandez
2cc52fae1f
Remove fieldset from top level notes (#2048) 2026-06-30 11:18:13 +02:00
WBHarry
8c6a470d84 Raised version
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-06-29 14:25:16 +02:00
WBHarry
9c58f7058e
[Fix] V13 Migration Fixes (#2044)
* Fixed so that damageParts without an applyTo field is assumed to be hitPoints

* Added the applyTo field to the basic attack for Adversaries and Companions

* Tentative blindfix to issues of entities being null. Can't replicate it

* Added some safety for missing things if someone was on a REALLY old system version and then updated all the way

* Moved v13 countdown migration over to a migrateData

* .
2026-06-29 14:22:12 +02:00
Carlos Fernandez
1ebbad4797
[Fix] quirks involving expanding items and hovering over them (#2033)
Some checks failed
Project CI / build (24.x) (push) Has been cancelled
2026-06-24 17:37:00 -04:00
562 changed files with 6806 additions and 7680 deletions

View file

@ -2,11 +2,17 @@
## Table of Contents
- [Overview](#overview)
- [User Install Guide](#user-install)
- [Documentation](#documentation)
- [Developer Setup](#development-setup)
- [Contribution Info](#contributing)
- [Foundryborne Daggerheart](#foundryborne-daggerheart)
- [Table of Contents](#table-of-contents)
- [Overview](#overview)
- [User Install](#user-install)
- [Documentation](#documentation)
- [Development Setup](#development-setup)
- [Available Scripts](#available-scripts)
- [Notes](#notes)
- [Contributing](#contributing)
- [AI Policy](#ai-policy)
- [Disclaimer](#disclaimer)
## Overview
@ -72,7 +78,7 @@ Looking to contribute to the project? Look no further, check out our [contributi
The Foundryborne Daggerheart system does not make use of AI (generative or otherwise) for any area of its implementation. We expect all contributors to follow this same policy when contributing with a pull request; contributions made using AI will be rejected outright.
## Disclaimer:
## Disclaimer
**Daggerheart System**
Daggerheart is a trademark of Darrington Press LLC. All original content, mechanics, and intellectual property related to the Daggerheart roleplaying game are © Darrington Press LLC.

36
daggerheart.d.ts vendored
View file

@ -4,6 +4,18 @@ import '@common/primitives/global.mjs';
import Canvas from '@client/canvas/board.mjs';
import { ResourceUpdateMap } from './module/data/action/baseAction.mjs';
import * as applications from './module/applications/_module.mjs';
import * as data from './module/data/_module.mjs';
import * as models from './module/data/_module.mjs';
import * as documents from './module/documents/_module.mjs';
import { macros } from './module/_module.mjs';
import * as dice from './module/dice/_module.mjs';
import * as fields from './module/data/fields/_module.mjs';
import { gameSettings } from './module/config/settingsConfig.mjs';
import DhCountdowns from './module/data/countdowns.mjs';
import DhAutomation from './module/data/settings/Automation.mjs';
// Foundry's use of `Object.assign(globalThis) means many globally available objects are not read as such
// This declare global hopefully fixes that
// Note: eslint is not aware of these, whatever is added here should go in the eslint's globals list
@ -80,3 +92,27 @@ declare global {
damageOptions: object;
}
}
declare module '@client/packages/system.mjs' {
export default interface System {
api: {
applications: typeof applications,
data: typeof data,
models: typeof models,
documents: typeof documents,
macros: typeof macros,
dice: typeof dice,
fields: typeof fields
};
}
}
declare module '@client/helpers/client-settings.mjs' {
// Add explicit typed overrides for auto complete. These require /** @type {"string"} on the vars themselves to work */
export default interface ClientSettings {
get(namespace: 'daggerheart', key: typeof gameSettings.Automation): DhAutomation;
get(namespace: 'daggerheart', key: typeof gameSettings.Homebrew): DhHomebrew;
get(namespace: 'daggerheart', key: typeof gameSettings.Countdowns): DhCountdowns;
get(namespace: 'daggerheart', key: string): unknown;
}
}

View file

@ -6,6 +6,7 @@ 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 dice from './module/dice/_module.mjs';
import * as die from './module/dice/die/_module.mjs';
import * as fields from './module/data/fields/_module.mjs';
import RegisterHandlebarsHelpers from './module/helpers/handlebarsHelper.mjs';
import { enricherConfig, enricherRenderSetup } from './module/enrichers/_module.mjs';
@ -23,7 +24,7 @@ import TokenManager from './module/documents/tokenManager.mjs';
CONFIG.DH = SYSTEM;
CONFIG.TextEditor.enrichers.push(...enricherConfig);
CONFIG.Dice.rolls = [BaseRoll, DHRoll, DualityRoll, D20Roll, DamageRoll, FateRoll];
CONFIG.Dice.rolls = [Roll = BaseRoll, DHRoll, DualityRoll, D20Roll, DamageRoll, FateRoll];
CONFIG.Dice.daggerheart = {
DHRoll: DHRoll,
DualityRoll: DualityRoll,
@ -38,6 +39,8 @@ CONFIG.RegionBehavior.dataModels = {
};
Object.assign(CONFIG.Dice.termTypes, dice.diceTypes);
CONFIG.Dice.terms.d = die.BaseDie;
CONFIG.Dice.types = [die.BaseDie, CONFIG.Dice.terms.f];
CONFIG.Actor.documentClass = documents.DhpActor;
CONFIG.Actor.dataModels = models.actors.config;
@ -267,6 +270,10 @@ Hooks.on('i18nInit', () => {
});
Hooks.on('setup', () => {
if (game.user.isGM) {
document.body.dataset.gm = true;
}
CONFIG.statusEffects = [
...CONFIG.statusEffects.filter(x => !['dead', 'unconscious'].includes(x.id)),
...Object.values(SYSTEM.GENERAL.conditions()).map(x => ({
@ -390,7 +397,7 @@ const updateActorsRangeDependentEffects = async token => {
).rangeMeasurement;
for (let effect of token.actor?.allApplicableEffects() ?? []) {
if (!effect.system.rangeDependence?.enabled) continue;
if (!effect.system.rangeDependence) continue;
const { target, range, type } = effect.system.rangeDependence;
// If there are no targets, assume false. Otherwise, start with the effect enabled.

View file

@ -84,6 +84,7 @@
"transformActorMissing": "The assigned actor to transform into does not exist. It was probably deleted or moved in/out of a compendium",
"canvasError": "There is no active scene.",
"prototypeError": "You can only use a transform action from a Token",
"linkedSelectedError": "To transform a linked actor there either needs to be only a single token of it on the canvas, or you need to left-click select only one of them.",
"actorLinkError": "You cannot transform a token with Actor Link set to true"
}
},
@ -103,8 +104,10 @@
"startCountdown": "Start Countdown"
},
"damage": {
"addResource": "Add Resource",
"multiplier": "Multiplier",
"flatMultiplier": "Flat Multiplier"
"flatMultiplier": "Flat Multiplier",
"markResources": "Mark Resources"
},
"general": {
"customFormula": "Custom Formula",
@ -113,7 +116,8 @@
"area": {
"sectionTitle": "Areas",
"shape": "Shape",
"size": "Size"
"size": "Size",
"hasHole": "Area Hole"
},
"displayInChat": "Display in chat",
"deleteTriggerTitle": "Delete Trigger",
@ -122,6 +126,10 @@
"damageOnSave": "Damage on Save",
"useDefaultItemValues": "Use default Item values"
},
"Reload": {
"checkReload": "Check Reload",
"reloadRequired": "Reload Required!"
},
"RollField": {
"diceRolling": {
"compare": "Should be",
@ -165,9 +173,7 @@
},
"ACTIVEEFFECT": {
"Config": {
"rangeDependence": {
"title": "Range Dependence"
},
"rangeDependence": { "title": "Range Dependence" },
"stacking": { "title": "Stacking" },
"targetDispositions": "Affected Dispositions"
},
@ -772,7 +778,7 @@
"removeRoll": "Remove Roll",
"resultsHint": "Results will appear when characters roll",
"selectLeaderHint": "Select one Character to be the leader",
"selectParticipantsHint": "Select one Character to be the leader",
"selectParticipantsHint": "Select all Characters who will participate in the roll",
"startGroupRoll": "Start Group Roll",
"title": "Group Roll"
},
@ -870,6 +876,10 @@
"bruiser": "for each Bruiser adversary.",
"solo": "for each Solo adversary."
},
"AreaTypes": {
"attached": { "label": "Attached To Token" },
"placed": { "label": "Placed In Scene" }
},
"ArmorInteraction": {
"none": { "label": "Ignores Armor" },
"active": { "label": "Active w/ Armor" },
@ -1316,6 +1326,11 @@
"short": "V. Far"
}
},
"ReloadChoices": {
"off": { "label": "Don't Use" },
"button": { "label": "Use button" },
"auto": { "label": "Automatic" }
},
"RollTypes": {
"trait": {
"name": "Trait"
@ -2215,7 +2230,9 @@
},
"Resource": {
"single": "Resource",
"plural": "Resources"
"plural": "Resources",
"unloaded": "The weapon is not loaded",
"loaded": "The weapon is loaded"
},
"Roll": {
"attack": "Attack Roll",
@ -2241,7 +2258,7 @@
"hint": "A used armor slot normally reduces damage by one step. This value increases the number of steps damage is reduced by."
},
"magical": {
"label": "Daamge Reduction: Only Magical",
"label": "Damage Reduction: Only Magical",
"hint": "Armor can only be used to reduce magical damage"
},
"maxArmorMarkedBonus": "Max Armor Used",
@ -2479,7 +2496,6 @@
"reroll": "Reroll",
"rerolled": "Rerolled",
"rerollThing": "Reroll {thing}",
"resource": "Resource",
"result": {
"single": "Result",
"plural": "Results"
@ -2546,6 +2562,9 @@
},
"identifier": {
"label": "Identifier"
},
"gmNotes": {
"label": "GM Notes"
}
},
"Ancestry": {
@ -2561,6 +2580,9 @@
"severe": "Severe Threshold"
}
},
"Base": {
"addGMNote": "Add GM Note"
},
"Beastform": {
"FIELDS": {
"beastformType": { "label": "Beastform Type" },
@ -2786,6 +2808,10 @@
"hint": "Effects with defined range dependency will automatically turn on/off depending on range"
}
},
"reload": {
"label": "Reload Checking",
"hint": "If the system should present a button for checking if the character will need to reload or do it automatically"
},
"resourceScrollTexts": {
"label": "Show Resource Change Scrolltexts",
"hint": "When a character is damaged, uses armor etc, a scrolling text will briefly appear by the token to signify this."
@ -3229,7 +3255,7 @@
"beastformToManyAdvantages": "You cannot select any more advantages.",
"beastformToManyFeatures": "You cannot select any more features.",
"beastformEquipWeapon": "You cannot use weapons while in a Beastform.",
"loadoutMaxReached": "You've reached maximum loadout. Move atleast one domain card to the vault, or increase the limit in homebrew settings if desired.",
"loadoutMaxReached": "You've reached the maximum loadout size. To add more, move at least one domain card to the vault.",
"domainMaxReached": "You've reached the maximum domains for the class. Increase the limit in homebrew settings if desired.",
"insufficientResources": "You don't have enough resources to use that action.",
"actionNoUsesRemaining": "That action doesn't have remaining uses.",
@ -3247,7 +3273,8 @@
"knowTheTide": "Know The Tide gained a token",
"lackingItemTransferPermission": "User {user} lacks owner permission needed to transfer items to {target}",
"noTokenTargeted": "No token is targeted",
"behaviorRegionRequiresGM": "Creating a Region with an attached Behavior requires an online GM"
"behaviorRegionRequiresGM": "Creating a Region with an attached Behavior requires an online GM",
"reloadRequired": "The {weapon} must be reloaded to be used!"
},
"Progress": {
"migrationLabel": "Performing system migration. Please wait and do not close Foundry."

View file

@ -315,15 +315,15 @@ export default class BeastformDialog extends HandlebarsApplicationMixin(Applicat
const beastformEffect = selected.effects.find(x => x.type === 'beastform');
for (const traitBonus of app.modifications.traitBonuses) {
const existingChange = beastformEffect.changes.find(
const existingChange = beastformEffect.system.changes.find(
x => x.key === `system.traits.${traitBonus.trait}.value`
);
if (existingChange) {
existingChange.value = Number.parseInt(existingChange.value) + traitBonus.bonus;
} else {
beastformEffect.changes.push({
beastformEffect.system.changes.push({
key: `system.traits.${traitBonus.trait}.value`,
mode: 2,
type: 'add',
priority: null,
value: traitBonus.bonus
});

View file

@ -51,7 +51,11 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
const context = await super._prepareContext(_options);
context.config = CONFIG.DH;
context.title = this.config.title ?? this.title;
context.formula = this.roll.constructFormula(this.config);
const { damageFormula, resourceFormulas } = this.roll.constructFormulas(this.config);
context.damageFormula = damageFormula;
context.resourceFormulas = resourceFormulas;
context.hasHealing = this.config.hasHealing;
context.directDamage = this.config.directDamage;
context.selectedMessageMode = this.config.selectedMessageMode;
@ -73,7 +77,11 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
static updateRollConfiguration(_event, _, formData) {
const data = foundry.utils.expandObject(formData.object);
foundry.utils.mergeObject(this.config.roll, data.roll);
if (this.config.damageFormula)
foundry.utils.mergeObject(this.config.damageFormula, data.damageFormula);
foundry.utils.mergeObject(this.config.resourceFormulas, data.resourceFormulas);
foundry.utils.mergeObject(this.config.modifiers, data.modifiers);
this.config.selectedMessageMode = data.selectedMessageMode;

View file

@ -139,13 +139,15 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV
name: game.i18n.localize('DAGGERHEART.CONFIG.DeathMoves.blazeOfGlory.name'),
description: game.i18n.localize('DAGGERHEART.CONFIG.DeathMoves.blazeOfGlory.description'),
img: CONFIG.DH.GENERAL.deathMoves.blazeOfGlory.img,
changes: [
{
key: 'system.rules.roll.guaranteedCritical',
mode: 2,
value: 'true'
}
]
system: {
changes: [
{
key: 'system.rules.roll.guaranteedCritical',
type: 'add',
value: 'true'
}
]
}
}
]);
@ -183,8 +185,6 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV
if (result === undefined) return;
const autoExpandDescription = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance)
.expandRollMessage?.desc;
const cls = getDocumentClass('ChatMessage');
const msg = {
@ -200,7 +200,6 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV
img: this.selectedMove.img,
description: game.i18n.localize(this.selectedMove.description),
result: result,
open: autoExpandDescription ? 'open' : '',
showRiskItAllButton: this.showRiskItAllButton,
riskItAllButtonLabel: this.riskItAllButtonLabel,
riskItAllHope: this.riskItAllHope

View file

@ -196,9 +196,6 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
.filter(x => x.testUserPermission(game.user, 'LIMITED'))
.filter(x => x.uuid !== this.actor.uuid);
const autoExpandDescription = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance)
.expandRollMessage?.desc;
const cls = getDocumentClass('ChatMessage');
const msg = {
user: game.user.id,
@ -219,8 +216,7 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
actor: { name: this.actor.name, img: this.actor.img },
moves: moves,
characters: characters,
selfId: this.actor.uuid,
open: autoExpandDescription ? 'open' : ''
selfId: this.actor.uuid
}
),
flags: {

View file

@ -1,7 +1,7 @@
import { ResourceUpdateMap } from '../../data/action/baseAction.mjs';
import { shouldUseHopeFearAutomation } from '../../helpers/utils.mjs';
import { emitGMUpdate, GMUpdateEvent, RefreshType, socketEvent } from '../../systemRegistration/socket.mjs';
import Party from '../sheets/actors/party.mjs';
import PartySheet from '../sheets/actors/party.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
@ -11,7 +11,7 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat
this.party = party;
this.partyMembers = party.system.partyMembers
.filter(x => Party.DICE_ROLL_ACTOR_TYPES.includes(x.type))
.filter(x => PartySheet.DICE_ROLL_ACTOR_TYPES.includes(x.type))
.map(member => ({
...member.toObject(),
uuid: member.uuid,

View file

@ -1,8 +1,9 @@
import { ResourceUpdateMap } from '../../data/action/baseAction.mjs';
import { ChatDamageData } from '../../data/chat-message/chatDamageData.mjs';
import { MemberData } from '../../data/tagTeamData.mjs';
import { getCritDamageBonus, shouldUseHopeFearAutomation } from '../../helpers/utils.mjs';
import { emitGMUpdate, GMUpdateEvent, RefreshType, socketEvent } from '../../systemRegistration/socket.mjs';
import Party from '../sheets/actors/party.mjs';
import PartySheet from '../sheets/actors/party.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
@ -13,7 +14,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
this.usesTagTeamHopeCost = true;
this.party = party;
this.partyMembers = party.system.partyMembers
.filter(x => Party.DICE_ROLL_ACTOR_TYPES.includes(x.type))
.filter(x => PartySheet.DICE_ROLL_ACTOR_TYPES.includes(x.type))
.map(member => ({
...member.toObject(),
uuid: member.uuid,
@ -140,7 +141,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
const hasRolled = Boolean(data.rollData);
if (!hasRolled) return false;
return !data.rollData.options.hasDamage || Boolean(data.rollData.options.damage);
return !data.rollData.options.hasDamage || data.damageRollData.active;
});
return context;
@ -181,7 +182,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
const selectedRoll = Object.values(this.party.system.tagTeam.members).find(member => member.selected);
const critSelected = !selectedRoll
? undefined
: (selectedRoll?.rollData?.options?.roll?.isCritical ?? false);
: (selectedRoll?.roll?.isCritical ?? false);
partContext.hintText = await this.getInfoTexts(this.party.system.tagTeam.members);
partContext.joinedRoll = await this.getJoinedRoll({
@ -208,6 +209,16 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
const rollOptions = [];
const damageRollOptions = [];
if (actor?.system.usedUnarmed) {
damageRollOptions.push({
value: actor.system.attack.uuid,
label: actor.system.usedUnarmed.name,
group: actor.name,
baseAction: actor.system.attack
});
}
for (const item of actor?.items ?? []) {
if (!item.system.metadata.hasActions) continue;
const actions = [...item.system.actions, ...(item.system.attack ? [item.system.attack] : [])];
@ -225,8 +236,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
}
const selectedRoll = Object.values(this.party.system.tagTeam.members).find(member => member.selected);
const critSelected = !selectedRoll ? undefined : (selectedRoll?.rollData?.options?.roll?.isCritical ?? false);
const damage = data.rollData?.options?.damage;
const critSelected = !selectedRoll ? undefined : (selectedRoll?.roll?.isCritical ?? false);
return {
...data,
@ -237,9 +247,9 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
hasRolled: Boolean(data.rollData),
rollOptions,
damageRollOptions,
damage: damage,
critDamage: await this.getCriticalDamage(damage),
useCritDamage: critSelected || (critSelected === undefined && data.rollData?.options?.roll?.isCritical)
damage: data.damageRollData,
critDamage: await this.getCriticalDamage(data.damageRollData),
useCritDamage: critSelected || (critSelected === undefined && data.roll?.isCritical)
};
}
@ -369,7 +379,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
let rollIsSelected = false;
for (const member of Object.values(members)) {
const rollFinished = Boolean(member.rollData);
const damageFinished = member.rollData?.options?.hasDamage ? Boolean(member.rollData.options.damage) : true;
const damageFinished = member.rollData?.options?.hasDamage ? member.damageRollData.active : true;
rollsAreFinished = rollsAreFinished && rollFinished && damageFinished;
rollIsSelected = rollIsSelected || member.selected;
@ -530,17 +540,10 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
await action.workflow.get('damage').execute(config, null, true);
if (!config.damage) return;
const current = this.party.system.tagTeam.members[memberKey].rollData;
await this.updatePartyData(
{
[`system.tagTeam.members.${memberKey}.rollData`]: {
...current,
options: {
...current.options,
damage: config.damage
}
}
[`system.tagTeam.members.${memberKey}.damageRollData`]: config.damage
},
this.getUpdatingParts(button)
);
@ -548,15 +551,11 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
static async #removeDamageRoll(_, button) {
const { memberKey } = button.dataset;
const current = this.party.system.tagTeam.members[memberKey].rollData;
this.updatePartyData(
{
[`system.tagTeam.members.${memberKey}.rollData`]: {
...current,
options: {
...current.options,
damage: null
}
[`system.tagTeam.members.${memberKey}.damageRollData`]: {
main: null,
resources: _replace({})
}
},
this.getUpdatingParts(button)
@ -564,89 +563,44 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
}
static async #rerollDamageDice(_, button) {
const { memberKey, damageKey, part, dice } = button.dataset;
const { isResource, memberKey, damageKey, diceIndex, resultIndex } = button.dataset;
const memberData = this.party.system.tagTeam.members[memberKey];
const partData = memberData.rollData.options.damage[damageKey].parts[part];
const activeDiceResultKey = Object.keys(partData.dice[dice].results).find(
index => partData.dice[dice].results[index].active
);
const { parsedRoll, rerolledDice } = await game.system.api.dice.DamageRoll.reroll(
partData,
dice,
activeDiceResultKey
);
const rollData = this.party.system.tagTeam.members[memberKey].rollData;
rollData.options.damage[damageKey].parts = rollData.options.damage[damageKey].parts.map((damagePart, index) => {
if (index !== Number.parseInt(part)) return damagePart;
return {
...damagePart,
total: parsedRoll.total,
dice: rerolledDice
};
});
rollData.options.damage[damageKey].total = rollData.options.damage[damageKey].parts.reduce((acc, part) => {
acc += part.total;
return acc;
}, 0);
await memberData.damageRollData.rerollDamageDie(isResource, damageKey, diceIndex, resultIndex);
const basePath = `system.tagTeam.members.${memberKey}.damageRollData`;
const updatePath = isResource ? `${basePath}.resources.${damageKey}` : `${basePath}.main`;
const updateValue = isResource ?
memberData.damageRollData.resources[damageKey] : memberData.damageRollData.main;
this.updatePartyData(
{
[`system.tagTeam.members.${memberKey}.rollData`]: rollData
[updatePath]: updateValue.toJSON()
},
this.getUpdatingParts(button)
);
}
async getCriticalDamage(damage) {
const newDamage = foundry.utils.deepClone(damage);
for (let key in newDamage) {
var damage = newDamage[key];
damage.formula = '';
damage.total = 0;
for (let part of damage.parts) {
const criticalDamage = await getCritDamageBonus(part.formula);
if (criticalDamage) {
part.modifierTotal += criticalDamage;
part.total += criticalDamage;
part.formula = `${part.dice.map(x => x.formula).join(' + ')} + ${part.modifierTotal}`;
part.roll = new Roll(part.formula);
}
damage.formula = [damage.formula, part.formula].filter(x => x).join(' + ');
damage.total += part.total;
async getCriticalDamage(origDamage) {
const newDamage = origDamage ? ChatDamageData.fromJSON(JSON.stringify(origDamage)) : null;
if (newDamage?.main) {
const criticalDamage = await getCritDamageBonus(newDamage.main.formula);
if (criticalDamage) {
const criticalTerm = new foundry.dice.terms.NumericTerm({ number: criticalDamage, evaluated: true });
criticalTerm.evaluate();
newDamage.main = await Roll.fromTerms([
...origDamage.main.terms,
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
criticalTerm
]);
newDamage.main.options = foundry.utils.deepClone(origDamage.main.options);
}
}
return newDamage;
}
async getNonCriticalDamage(config) {
const newDamage = foundry.utils.deepClone(config.damage);
for (let key in newDamage) {
var damage = newDamage[key];
damage.formula = '';
damage.total = 0;
for (let part of damage.parts) {
const critDamageBonus = await getCritDamageBonus(part.formula);
part.modifierTotal -= critDamageBonus;
part.total -= critDamageBonus;
part.formula = `${part.dice.map(x => x.formula).join(' + ')} + ${part.modifierTotal}`;
part.roll = new Roll(part.formula);
damage.formula = [damage.formula, part.formula].filter(x => x).join(' + ');
damage.total += part.total;
}
}
}
return newDamage;
}
static async #selectRoll(_, button) {
const { memberKey } = button.dataset;
this.updatePartyData(
{
[`system.tagTeam.members`]: Object.entries(this.party.system.tagTeam.members).reduce(
@ -657,7 +611,12 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
{}
)
},
this.getUpdatingParts(button)
/* Selecting a roll must update all member sections hbs to display the correct damage information incase of a critical */
[
...Object.keys(this.party.system.tagTeam.members),
this.constructor.PARTS.rollSelection.id,
this.constructor.PARTS.result.id
]
);
}
@ -675,29 +634,65 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
if (!baseMainRoll?.rollData || !baseSecondaryRoll) return null;
const mainRoll = new MemberData(baseMainRoll.toObject());
const secondaryRollData = new MemberData(baseSecondaryRoll.toObject()).rollData;
const systemData = mainRoll.rollData.options;
const isCritical = overrideIsCritical ?? systemData.roll.isCritical;
if (isCritical) systemData.damage = await this.getCriticalDamage(systemData.damage);
mainRoll.damageRollData = baseMainRoll.damageRollData ?
ChatDamageData.fromJSON(JSON.stringify(baseMainRoll.damageRollData)) : null;
const secondaryRoll = new MemberData(baseSecondaryRoll.toObject());
secondaryRoll.damageRollData = baseSecondaryRoll.damageRollData ?
ChatDamageData.fromJSON(JSON.stringify(baseSecondaryRoll.damageRollData)) : null;
if (secondaryRollData?.options.hasDamage) {
const isCritical = overrideIsCritical ?? mainRoll.roll.isCritical;
if (isCritical) mainRoll.damageRollData = await this.getCriticalDamage(mainRoll.damageRollData);
if (secondaryRoll.damageRollData) {
const secondaryDamage = (displayVersion ? overrideIsCritical : isCritical)
? await this.getCriticalDamage(secondaryRollData.options.damage)
: secondaryRollData.options.damage;
if (systemData.damage) {
for (const [key, damage] of Object.entries(secondaryDamage ?? {})) {
if (key in systemData.damage) {
systemData.damage[key].formula = [systemData.damage[key]?.formula, damage.formula]
.filter(x => x)
.join(' + ');
systemData.damage[key].total += damage.total;
systemData.damage[key].parts.push(...damage.parts);
? await this.getCriticalDamage(secondaryRoll.damageRollData)
: secondaryRoll.damageRollData;
if (mainRoll.damageRollData) {
if (secondaryDamage.main) {
if (mainRoll.damageRollData.main) {
mainRoll.damageRollData.main = Roll.fromTerms([
...baseMainRoll.damageRollData.main.terms,
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
...baseSecondaryRoll.damageRollData.main.terms
]);
/* Joining the roll.options of both rolls */
const joinedDamageTypes = new Set([
...baseMainRoll.damageRollData.main.options.damageTypes,
...baseSecondaryRoll.damageRollData.main.options.damageTypes
]);
mainRoll.damageRollData.main.options = {
...baseMainRoll.damageRollData.main.options,
damageTypes: [...joinedDamageTypes]
};
} else {
systemData.damage[key] = damage;
mainRoll.damageRollData.main = secondaryDamage.main;
}
}
for (const [key, damage] of Object.entries(secondaryDamage.resources ?? {})) {
if (key in mainRoll.damageRollData.resources) {
mainRoll.damageRollData.resources[key] = Roll.fromTerms([
...baseMainRoll.damageRollData.resources[key].terms,
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
...baseSecondaryRoll.damageRollData.resources[key].terms
]);
/* Joining the roll.options of both rolls */
const joinedDamageTypes = new Set([
...baseMainRoll.damageRollData.resources[key].options.damageTypes,
...baseSecondaryRoll.damageRollData.resources[key].options.damageTypes
]);
mainRoll.damageRollData.resources[key].options = {
...baseMainRoll.damageRollData.resources[key].options,
damageTypes: [...joinedDamageTypes]
};
} else {
mainRoll.damageRollData.resources[key] = damage;
}
}
} else {
systemData.damage = secondaryDamage;
mainRoll.damageRollData = secondaryDamage;
}
}
@ -752,13 +747,27 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
const mainActor = this.party.system.partyMembers.find(x => x.uuid === mainRoll.options.source.actor);
mainRoll.options.title = game.i18n.localize('DAGGERHEART.APPLICATIONS.TagTeamSelect.chatMessageRollTitle');
/* This could assumably be done better. For some reason rolls don't get correctly done through rollData.toJSON */
const systemData = {
...mainRoll.options,
damage: joinedRoll.damageRollData?.toJSON()
};
if (joinedRoll.damageRollData.main) {
systemData.damage.main = joinedRoll.damageRollData.toJSON();
}
for (const type of Object.keys(joinedRoll.damageRollData?.resources ?? {})) {
systemData.damage.resources[type] = joinedRoll.damageRollData.resources[type].toJSON();
}
const cls = getDocumentClass('ChatMessage'),
msgData = {
type: 'dualityRoll',
user: game.user.id,
title: game.i18n.localize('DAGGERHEART.APPLICATIONS.TagTeamSelect.title'),
speaker: cls.getSpeaker({ actor: mainActor }),
system: mainRoll.options,
system: systemData,
rolls: [JSON.stringify(joinedRoll.roll)],
sound: null,
flags: { core: { RollTable: true } }

View file

@ -1,4 +1,4 @@
import { getUnusedDamageTypes } from '../../helpers/utils.mjs';
import { DHDamageData } from '../../data/fields/action/damageField.mjs';
import DaggerheartSheet from '../sheets/daggerheart-sheet.mjs';
const { ApplicationV2 } = foundry.applications.api;
@ -31,8 +31,10 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
removeElement: this.removeElement,
removeTransformActor: this.removeTransformActor,
editEffect: this.editEffect,
addDamage: this.addDamage,
removeDamage: this.removeDamage,
addDamage: this.#onAddDamage,
removeDamage: this.#onRemoveDamage,
addDamageResource: this.#onAddDamageResource,
removeDamageResource: this.#onRemoveDamageResource,
editDoc: this.editDoc,
addTrigger: this.addTrigger,
removeTrigger: this.removeTrigger,
@ -157,9 +159,9 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
context.tabs = this._getTabs(this.constructor.TABS);
context.config = CONFIG.DH;
if (this.action.damage) {
context.allDamageTypesUsed = !getUnusedDamageTypes(this.action.damage.parts).length;
if (this.action.damage.hasOwnProperty('includeBase') && this.action.type === 'attack')
const allKeys = Object.keys(CONFIG.DH.GENERAL.healingTypes);
context.allDamageTypesUsed = allKeys.every(k => k in this.action._source.damage.resources);
if (this.action.damage?.main?.hasOwnProperty('includeBase') && this.action.type === 'attack')
context.hasBaseDamage = !!this.action.parent.attack;
}
@ -253,7 +255,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
const submitData = this._prepareSubmitData(event, formData);
const data = foundry.utils.mergeObject(this.action.toObject(), submitData);
this.action = await this.action.update(data);
this.action = (await this.action.update(data)) ?? this.action;
this.sheetUpdate?.(this.action);
this.render();
@ -299,53 +301,70 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
}
static addDamage(_event) {
if (!this.action.damage.parts) return;
/** @this DHActionBaseConfig */
static #onAddDamage() {
if (!this.action.damage || this.action.damage?.main) return;
const choices = getUnusedDamageTypes(this.action._source.damage.parts);
const data = this.action.toObject();
data.damage.main = {
...DHDamageData.schema.getInitialValue(),
applyTo: 'hitPoints',
type: 'physical'
};
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
}
/** @this DHActionBaseConfig */
static #onRemoveDamage() {
if (!this.action.damage?.main) return;
const data = this.action.toObject();
data.damage.main = null;
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
}
/** @this DHActionBaseConfig */
static #onAddDamageResource(_event) {
if (!this.action.damage) return;
const allKeys = Object.keys(CONFIG.DH.GENERAL.healingTypes);
const unused = allKeys.filter(k => !(k in this.action._source.damage.resources));
const choices = unused.map(k => ({ value: k, label: _loc(CONFIG.DH.GENERAL.healingTypes[k].label) }));
const content = new foundry.data.fields.StringField({
label: game.i18n.localize('Damage Type'),
label: _loc('DAGGERHEART.GENERAL.Resource.single'),
choices,
required: true
}).toFormGroup(
{},
{
name: 'type',
localize: true,
nameAttr: 'value',
labelAttr: 'label'
}
).outerHTML;
}).toFormGroup({}, {
name: 'type',
localize: true,
nameAttr: 'value',
labelAttr: 'label'
}).outerHTML;
const callback = (_, button) => {
const data = this.action.toObject();
const type = choices[button.form.elements.type.value].value;
const part = this.action.schema.fields.damage.fields.parts.element.getInitialValue();
part.applyTo = type;
if (type === CONFIG.DH.GENERAL.healingTypes.hitPoints.id)
part.type = this.action.schema.fields.damage.fields.parts.element.fields.type.element.initial;
data.damage.parts[type] = part;
data.damage.resources[type] = {
...this.action.schema.fields.damage.fields.resources.element.getInitialValue(),
applyTo: type
};
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
};
const typeDialog = new foundry.applications.api.DialogV2({
buttons: [
foundry.utils.mergeObject(
{
action: 'ok',
label: 'Confirm',
icon: 'fas fa-check',
default: true
},
{ callback: callback }
)
{
action: 'ok',
label: 'Confirm',
icon: 'fas fa-check',
default: true,
callback
}
],
content: content,
rejectClose: false,
modal: false,
window: {
title: game.i18n.localize('Add Damage')
title: _loc('DAGGERHEART.ACTIONS.Config.damage.addResource')
},
position: { width: 300 }
});
@ -353,12 +372,12 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
typeDialog.render(true);
}
static removeDamage(_event, button) {
if (!this.action.damage.parts) return;
/** @this DHActionBaseConfig */
static #onRemoveDamageResource(_event, button) {
if (!this.action.damage?.resources) return;
const data = this.action.toObject();
const key = button.dataset.key;
delete data.damage.parts[key];
data.damage.parts[`${key}`] = _del;
data.damage.resources[key] = _del;
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
}

View file

@ -155,6 +155,10 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
.querySelector('.stacking-change-checkbox')
?.addEventListener('change', this.stackingChangeToggle.bind(this));
htmlElement
.querySelector('.range-dependence-change-checkbox')
?.addEventListener('change', this.rangeDependenceChangeToggle.bind(this));
htmlElement
.querySelector('.armor-change-checkbox')
?.addEventListener('change', this.armorChangeToggle.bind(this));
@ -224,6 +228,20 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
return this.submit({ updateData: { system: systemData } });
}
rangeDependenceChangeToggle(event) {
const rangeFields = this.document.system.schema.fields.rangeDependence.fields;
const systemData = {
rangeDependence: event.target.checked
? _replace({
type: rangeFields.type.initial,
target: rangeFields.target.initial,
range: rangeFields.range.initial
})
: null
};
return this.submit({ updateData: { system: systemData } });
}
armorChangeToggle(event) {
if (event.target.checked) {
this.addArmorChange();

View file

@ -1,3 +1,4 @@
import { DHDamageData } from '../../data/fields/action/damageField.mjs';
import DHBaseActorSettings from '../sheets/api/actor-setting.mjs';
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
@ -8,8 +9,10 @@ export default class DHAdversarySettings extends DHBaseActorSettings {
classes: ['adversary-settings'],
position: { width: 455, height: 'auto' },
actions: {
addExperience: DHAdversarySettings.#addExperience,
removeExperience: DHAdversarySettings.#removeExperience
addExperience: this.#onAddExperience,
removeExperience: this.#onRemoveExperience,
addDamage: this.#onAddDamage,
removeDamage: this.#onRemoveDamage
}
};
@ -71,7 +74,7 @@ export default class DHAdversarySettings extends DHBaseActorSettings {
* Adds a new experience entry to the actor.
* @type {ApplicationClickAction}
*/
static async #addExperience() {
static async #onAddExperience() {
const newExperience = {
name: 'Experience',
modifier: 0
@ -83,7 +86,7 @@ export default class DHAdversarySettings extends DHBaseActorSettings {
* Removes an experience entry from the actor.
* @type {ApplicationClickAction}
*/
static async #removeExperience(_, target) {
static async #onRemoveExperience(_, target) {
const experience = this.actor.system.experiences[target.dataset.experience];
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
@ -98,4 +101,28 @@ export default class DHAdversarySettings extends DHBaseActorSettings {
await this.actor.update({ [`system.experiences.${target.dataset.experience}`]: _del });
}
/**
* @this DHAdversarySettings
* @type {ApplicationClickAction}
*/
static #onAddDamage() {
this.actor.update({
'system.attack.damage.main': {
...DHDamageData.schema.getInitialValue(),
applyTo: 'hitPoints',
type: 'physical'
}
});
}
/**
* @this DHAdversarySettings
* @type {ApplicationClickAction}
*/
static #onRemoveDamage() {
this.actor.update({
'system.attack.damage.main': null
});
}
}

View file

@ -1,8 +1,18 @@
import DhCompanion from '../../../data/actor/companion.mjs';
import DhParty from '../../../data/actor/party.mjs';
import DhpActor from '../../../documents/actor.mjs';
declare module './companion.mjs' {
export default interface DhCompanionSheet {
actor: DhpActor<DhCompanion>;
document: DhpActor<DhCompanion>;
}
}
declare module './party.mjs' {
export default interface PartySheet {
actor: DhpActor<DhParty>;
document: DhpActor<DhParty>;
}
}

View file

@ -7,7 +7,7 @@ export default class AdversarySheet extends DHBaseActorSheet {
/** @inheritDoc */
static DEFAULT_OPTIONS = {
classes: ['adversary'],
position: { width: 660, height: 766 },
position: { width: 645, height: 750 },
window: { resizable: true },
actions: {
toggleHitPoints: AdversarySheet.#toggleHitPoints,
@ -58,12 +58,13 @@ export default class AdversarySheet extends DHBaseActorSheet {
template: 'systems/daggerheart/templates/sheets/actors/adversary/features.hbs',
scrollable: ['.feature-section']
},
notes: {
template: 'systems/daggerheart/templates/sheets/actors/adversary/notes.hbs'
},
effects: {
template: 'systems/daggerheart/templates/sheets/actors/adversary/effects.hbs',
scrollable: ['.effects-sections']
},
notes: {
template: 'systems/daggerheart/templates/sheets/actors/adversary/notes.hbs',
scrollable: ['.editor-content']
}
};

View file

@ -3,7 +3,7 @@ import DhDeathMove from '../../dialogs/deathMove.mjs';
import { CharacterLevelup, LevelupViewMode } from '../../levelup/_module.mjs';
import DhCharacterCreation from '../../characterCreation/characterCreation.mjs';
import FilterMenu from '../../ux/filter-menu.mjs';
import { getArmorSources, getDocFromElement, getDocFromElementSync, sortBy } from '../../../helpers/utils.mjs';
import { getArmorSources, getDocFromElement, getDocFromElementSync, itemAbleRollParse, sortBy } from '../../../helpers/utils.mjs';
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
@ -29,6 +29,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
toggleResourceDice: CharacterSheet.#toggleResourceDice,
handleResourceDice: CharacterSheet.#handleResourceDice,
advanceResourceDie: CharacterSheet.#advanceResourceDie,
toggleItemReload: CharacterSheet.#onToggleItemReload,
cancelBeastform: CharacterSheet.#cancelBeastform,
toggleResourceManagement: CharacterSheet.#toggleResourceManagement,
useDowntime: this.useDowntime,
@ -914,7 +915,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
const doc = await getDocFromElement(button);
const { available } = this.document.system.loadoutSlot;
if (doc.system.inVault && !available && !doc.system.loadoutIgnore) {
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.loadoutMaxReached'));
return ui.notifications.warn('DAGGERHEART.UI.Notifications.loadoutMaxReached', { localize: true });
}
await doc?.update({ 'system.inVault': !doc.system.inVault });
@ -954,11 +955,21 @@ export default class CharacterSheet extends DHBaseActorSheet {
});
}
/** */
static #advanceResourceDie(_, target) {
this.updateResourceDie(target, true);
}
static async #onToggleItemReload(_, target) {
const item = await getDocFromElement(target);
if (!item || !item.system.resource?.max)
return;
await item.update({
'system.resource.value': item.system.needsReload ?
itemAbleRollParse(item.system.resource.max, this.document, item) : 0
})
}
lowerResourceDie(event) {
event.preventDefault();
event.stopPropagation();
@ -1057,7 +1068,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
direction: 'DOWN'
});
html.querySelectorAll('.armor-slot').forEach(element => {
html.querySelectorAll('.armor .slot').forEach(element => {
element.addEventListener('click', CharacterSheet.armorSourcePipUpdate);
});
}
@ -1072,7 +1083,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
/** Update specific armor source */
static async armorSourcePipUpdate(event) {
const target = event.target.closest('.armor-slot');
const target = event.target.closest('.slot');
const { uuid, value } = target.dataset;
const document = await foundry.utils.fromUuid(uuid);
@ -1100,7 +1111,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
}
const container = target.closest('.slot-bar');
for (const armorSlot of container.querySelectorAll('.armor-slot i')) {
for (const armorSlot of container.querySelectorAll('.armor .slot i')) {
const index = Number.parseInt(armorSlot.dataset.index);
if (decreasing && index >= newCurrent) {
armorSlot.classList.remove('fa-shield');
@ -1206,10 +1217,22 @@ export default class CharacterSheet extends DHBaseActorSheet {
if (!confirmed) return;
}
if (this.document.uuid === item.parent?.uuid) {
// Check for same actor drag/drop attempts
const isSameActor = this.document.uuid === item.parent?.uuid;
const loadoutFieldset = event.target.closest('[data-in-vault]');
const vaulting = loadoutFieldset?.dataset.inVault === 'true';
if (isSameActor && loadoutFieldset && item.type === 'domainCard' && vaulting !== item.system.inVault) {
// This is likely an attempt to vault or unvault an item
const { available } = this.document.system.loadoutSlot;
if (!vaulting && !available && !item.system.loadoutIgnore) {
return ui.notifications.warn('DAGGERHEART.UI.Notifications.loadoutMaxReached', { localize: true });
}
return item.update({ 'system.inVault': vaulting });
} else if (isSameActor) {
return super._onDropItem(event, item);
}
// Handle beastforms
if (item.type === 'beastform') {
if (this.document.effects.find(x => x.type === 'beastform')) {
return ui.notifications.warn(

View file

@ -6,7 +6,9 @@ import DaggerheartMenu from '../../sidebar/tabs/daggerheartMenu.mjs';
import { socketEvent } from '../../../systemRegistration/socket.mjs';
import DhpActor from '../../../documents/actor.mjs';
export default class Party extends DHBaseActorSheet {
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
export default class PartySheet extends DHBaseActorSheet {
constructor(options) {
super(options);
@ -24,17 +26,17 @@ export default class Party extends DHBaseActorSheet {
resizable: true
},
actions: {
openDocument: Party.#openDocument,
deletePartyMember: Party.#deletePartyMember,
toggleHope: Party.#toggleHope,
toggleHitPoints: Party.#toggleHitPoints,
toggleStress: Party.#toggleStress,
toggleArmorSlot: Party.#toggleArmorSlot,
tempBrowser: Party.#tempBrowser,
refeshActions: Party.#refeshActions,
triggerRest: Party.#triggerRest,
tagTeamRoll: Party.#tagTeamRoll,
groupRoll: Party.#groupRoll
openDocument: PartySheet.#onOpenDocument,
deletePartyMember: PartySheet.#onDeletePartyMember,
toggleHope: PartySheet.#onToggleHope,
toggleHitPoints: PartySheet.#onToggleHitPoints,
toggleStress: PartySheet.#onToggleStress,
toggleArmorSlot: PartySheet.#onToggleArmorSlot,
tempBrowser: PartySheet.#onTempBrowser,
refreshActions: PartySheet.#onRefreshActions,
triggerRest: PartySheet.#onTriggerRest,
tagTeamRoll: PartySheet.#onTagTeamRoll,
groupRoll: PartySheet.#onGroupRoll
},
dragDrop: [{ dragSelector: '[data-item-id]', dropSelector: null }]
};
@ -72,6 +74,23 @@ export default class Party extends DHBaseActorSheet {
this._createSearchFilter();
}
/** @inheritdoc */
_toggleDisabled(disabled) {
// Overriden to only disable text inputs by default if the user is a member
const isMember = this.actor.system.partyMembers.some(
m => m.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER)
);
if (!isMember) return super._toggleDisabled(disabled);
const form = this.form;
for (const input of form.querySelectorAll('input:not([type=search]), .editor.prosemirror')) {
input.disabled = disabled;
}
for (const element of form.querySelectorAll('.input[contenteditable]')) {
element.classList.toggle('disabled', disabled);
}
}
/* -------------------------------------------- */
/* Prepare Context */
/* -------------------------------------------- */
@ -198,8 +217,16 @@ export default class Party extends DHBaseActorSheet {
};
}
}
/* -------------------------------------------- */
/* Event handlers */
/* -------------------------------------------- */
static async #openDocument(_, target) {
/**
* @this PartySheet
* @type {ApplicationClickAction}
*/
static async #onOpenDocument(_, target) {
const uuid = target.dataset.uuid;
const document = await foundry.utils.fromUuid(uuid);
document?.sheet?.render(true);
@ -207,9 +234,10 @@ export default class Party extends DHBaseActorSheet {
/**
* Toggles a hope resource value.
* @this PartySheet
* @type {ApplicationClickAction}
*/
static async #toggleHope(_, target) {
static async #onToggleHope(_, target) {
const hopeValue = Number.parseInt(target.dataset.value);
const actor = await foundry.utils.fromUuid(target.dataset.actorId);
const newValue = actor.system.resources.hope.value >= hopeValue ? hopeValue - 1 : hopeValue;
@ -219,9 +247,10 @@ export default class Party extends DHBaseActorSheet {
/**
* Toggles a hp resource value.
* @this PartySheet
* @type {ApplicationClickAction}
*/
static async #toggleHitPoints(_, target) {
static async #onToggleHitPoints(_, target) {
const hitPointsValue = Number.parseInt(target.dataset.value);
const actor = await foundry.utils.fromUuid(target.dataset.actorId);
const newValue = actor.system.resources.hitPoints.value >= hitPointsValue ? hitPointsValue - 1 : hitPointsValue;
@ -231,9 +260,10 @@ export default class Party extends DHBaseActorSheet {
/**
* Toggles a stress resource value.
* @this PartySheet
* @type {ApplicationClickAction}
*/
static async #toggleStress(_, target) {
static async #onToggleStress(_, target) {
const stressValue = Number.parseInt(target.dataset.value);
const actor = await foundry.utils.fromUuid(target.dataset.actorId);
const newValue = actor.system.resources.stress.value >= stressValue ? stressValue - 1 : stressValue;
@ -243,9 +273,10 @@ export default class Party extends DHBaseActorSheet {
/**
* Toggles a armor slot resource value.
* @this PartySheet
* @type {ApplicationClickAction}
*/
static async #toggleArmorSlot(_, target) {
static async #onToggleArmorSlot(_, target) {
const actor = await foundry.utils.fromUuid(target.dataset.actorId);
const { value, max } = actor.system.armorScore;
const inputValue = Number.parseInt(target.dataset.value);
@ -258,12 +289,19 @@ export default class Party extends DHBaseActorSheet {
/**
* Opens Compedium Browser
* @this PartySheet
* @type {ApplicationClickAction}
*/
static async #tempBrowser(_, target) {
static async #onTempBrowser(_, target) {
new ItemBrowser().render({ force: true });
}
static async #refeshActions() {
/**
* @todo Is this unused?
* @this PartySheet
* @type {ApplicationClickAction}
*/
static async #onRefreshActions() {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: 'New Section',
@ -281,7 +319,11 @@ export default class Party extends DHBaseActorSheet {
if (!confirmed) return;
}
static async #triggerRest(_, button) {
/**
* @this PartySheet
* @type {ApplicationClickAction}
*/
static async #onTriggerRest(_, button) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.localize(`DAGGERHEART.APPLICATIONS.Downtime.${button.dataset.type}.title`),
@ -304,6 +346,30 @@ export default class Party extends DHBaseActorSheet {
});
}
/**
* @this PartySheet
* @type {ApplicationClickAction}
*/
static async #onDeletePartyMember(event, target) {
const doc = await foundry.utils.fromUuid(target.closest('[data-uuid]')?.dataset.uuid);
if (!event.shiftKey) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.format('DAGGERHEART.ACTORS.Party.RemoveConfirmation.title', {
name: doc.name
})
},
content: game.i18n.format('DAGGERHEART.ACTORS.Party.RemoveConfirmation.text', { name: doc.name })
});
if (!confirmed) return;
}
const currentMembers = this.document.system.partyMembers.map(x => x.uuid);
const newMembersList = currentMembers.filter(uuid => uuid !== doc.uuid);
await this.document.update({ 'system.partyMembers': newMembersList });
}
static async downtimeMoveQuery({ actorId, downtimeType }) {
const actor = await foundry.utils.fromUuid(actorId);
if (!actor || !actor?.isOwner) return;
@ -312,11 +378,19 @@ export default class Party extends DHBaseActorSheet {
});
}
static async #tagTeamRoll() {
/**
* @this PartySheet
* @type {ApplicationClickAction}
*/
static async #onTagTeamRoll() {
new game.system.api.applications.dialogs.TagTeamDialog(this.document).render({ force: true });
}
static async #groupRoll(_params) {
/**
* @this PartySheet
* @type {ApplicationClickAction}
*/
static async #onGroupRoll(_params) {
new game.system.api.applications.dialogs.GroupRollDialog(this.document).render({ force: true });
}
@ -460,11 +534,10 @@ export default class Party extends DHBaseActorSheet {
}
}
/* -------------------------------------------- */
/** @inheritdoc */
async _onDropActor(event, document) {
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
if (document instanceof DhpActor && Party.ALLOWED_ACTOR_TYPES.includes(document.type)) {
if (document instanceof DhpActor && PartySheet.ALLOWED_ACTOR_TYPES.includes(document.type)) {
const currentMembers = this.document.system.partyMembers.map(x => x.uuid);
if (currentMembers.includes(data.uuid)) {
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.duplicateCharacter'));
@ -477,24 +550,4 @@ export default class Party extends DHBaseActorSheet {
return null;
}
static async #deletePartyMember(event, target) {
const doc = await foundry.utils.fromUuid(target.closest('[data-uuid]')?.dataset.uuid);
if (!event.shiftKey) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.format('DAGGERHEART.ACTORS.Party.RemoveConfirmation.title', {
name: doc.name
})
},
content: game.i18n.format('DAGGERHEART.ACTORS.Party.RemoveConfirmation.text', { name: doc.name })
});
if (!confirmed) return;
}
const currentMembers = this.document.system.partyMembers.map(x => x.uuid);
const newMembersList = currentMembers.filter(uuid => uuid !== doc.uuid);
await this.document.update({ 'system.partyMembers': newMembersList });
}
}

View file

@ -305,7 +305,7 @@ export default function DHApplicationMixin(Base) {
_preSyncPartState(partId, newElement, priorElement, state) {
super._preSyncPartState(partId, newElement, priorElement, state);
for (const el of priorElement.querySelectorAll('.extensible.extended')) {
const { actionId, itemUuid } = el.parentElement.dataset;
const { actionId, itemUuid } = el.closest('[data-item-uuid], [data-action-id]').dataset;
const selector = `${actionId ? `[data-action-id="${actionId}"]` : `[data-item-uuid="${itemUuid}"]`} .extensible`;
const newExtensible = newElement.querySelector(selector);
newExtensible?.classList.add('extended');
@ -603,7 +603,7 @@ export default function DHApplicationMixin(Base) {
const doc = await fromUuid(itemUuid);
//get inventory-item description element
const descriptionElement = el.querySelector('.invetory-description');
const descriptionElement = el.querySelector('.inventory-description');
if (!doc || !descriptionElement) continue;
// localize the description (idk if it's still necessary)

View file

@ -30,7 +30,8 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
addFeature: DHBaseItemSheet.#addFeature,
deleteFeature: DHBaseItemSheet.#deleteFeature,
addResource: DHBaseItemSheet.#addResource,
removeResource: DHBaseItemSheet.#removeResource
removeResource: DHBaseItemSheet.#removeResource,
editGMNote: DHBaseItemSheet.#onEditGMNote
},
dragDrop: [
{ dragSelector: null, dropSelector: '.drop-section' },
@ -76,10 +77,16 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
/**@inheritdoc */
async _preparePartContext(partId, context, options) {
await super._preparePartContext(partId, context, options);
const TextEditor = foundry.applications.ux.TextEditor.implementation;
switch (partId) {
case 'description':
context.enrichedDescription = await this.document.system.getEnrichedDescription();
context.enrichedDescription = await this.document.system.getEnrichedDescription({ gmNotes: false });
context.enrichedGMNotes = await TextEditor.implementation.enrichHTML(this.item.system.gmNotes, {
relativeTo: this.item,
rollData: this.item.getRollData(),
secrets: this.item.isOwner
})
break;
case 'effects':
await this._prepareEffectsContext(context, options);
@ -331,4 +338,45 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
}
}
}
/**
* Handles the Add GM Note button being pressed. This is only used when an item has no GM notes.
* Later edits to a GM note instead go through the normal editor toggle workflow.
* @this DHBaseItemSheet
*/
static #onEditGMNote() {
// Open the editor, which might be hidden. We remove the css class to hide temporarily
// so that menu auto resizing functions properly.
const editor = this.element.querySelector('prose-mirror[name="system.gmNotes"]');
const wasHidden = editor.classList.contains('hide-if-inactive');
editor.classList.remove('hide-if-inactive');
editor.open = true;
window.setTimeout(() => {
if (wasHidden) editor.classList.add('hide-if-inactive');
}, 0);
}
/** @inheritdoc */
async _onRender(context, options) {
await super._onRender(context, options);
// Render an add gmnotes button if there are no set GM notes.
// We need to re-render on close since its possible to prosemirror to close *without* triggering a full re-render
if (game.user.isGM && !this.item.system.gmNotes) {
const description = this.element.querySelector('[name="system.description"]');
const addButton = () => {
if (description.querySelector('[data-action=editGMNote]')) return;
const button = document.createElement('button');
button.type = 'button';
button.classList.add('icon', 'toggle', 'fa-regular', 'fa-note-medical');
button.dataset.action = 'editGMNote';
button.dataset.tooltip = 'DAGGERHEART.ITEMS.Base.addGMNote';
description.appendChild(button);
}
addButton();
description.addEventListener('close', () => addButton());
}
}
}

View file

@ -110,7 +110,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
const message = game.messages.get(li.dataset.messageId);
return message.system.hasRoll && (game.user.isGM || message.isAuthor);
},
callback: async li => {
onClick: async (_event, li) => {
const message = game.messages.get(li.dataset.messageId);
const reroll = await message.rolls[0].reroll({ liveRoll: true });
message.update({ rolls: [reroll] });
@ -126,7 +126,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
: false;
return (game.user.isGM || message.isAuthor) && hasRolledDamage;
},
callback: async li => {
onClick: async (_event, li) => {
const message = game.messages.get(li.dataset.messageId);
const update = await message.system.getRerolledDamage();
message.update(update);
@ -152,6 +152,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
html.querySelectorAll('.risk-it-all-button').forEach(element =>
element.addEventListener('click', event => this.riskItAllClearStressAndHitPoints(event, data))
);
for (const element of html.querySelectorAll('.roll-reload-check')) {
element.addEventListener('click', event => this.onRollReloadCheck(event, message));
}
};
setupHooks() {
@ -179,28 +182,15 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
}
async onRollSimple(event, message) {
const buttonType = event.target.dataset.type ?? 'damage',
total = message.rolls.reduce((a, c) => a + Roll.fromJSON(c).total, 0),
damages = {
hitPoints: {
parts: [
{
applyTo: 'hitPoints',
damageTypes: [],
total
}
]
}
},
targets = Array.from(game.user.targets);
const buttonType = event.target.dataset.type ?? 'damage';
const total = message.rolls.reduce((a, c) => a + Roll.fromJSON(c).total, 0);
const targets = Array.from(game.user.targets);
if (targets.length === 0)
return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected'));
targets.forEach(target => {
if (buttonType === 'healing') target.actor.takeHealing(damages);
else target.actor.takeDamage(damages);
});
for (const target of targets) {
if (buttonType === 'healing') target.actor.takeHealing({ hitPoints: total });
else target.actor.takeDamage({ total });
}
}
async abilityUseButton(event, message) {
@ -256,26 +246,17 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
}
const message = game.messages.get(messageData._id);
const target = event.target.closest('[data-die-index]');
const target = event.target.closest('[data-result]');
if (target.dataset.type === 'damage') {
const { damageType, part, dice, result } = target.dataset;
const damagePart = message.system.damage[damageType].parts[part];
const { parsedRoll, rerolledDice } = await game.system.api.dice.DamageRoll.reroll(damagePart, dice, result);
const damageParts = message.system.damage[damageType].parts.map((damagePart, index) => {
if (index !== Number(part)) return damagePart;
return {
...damagePart,
total: parsedRoll.total,
dice: rerolledDice
};
});
const updateMessage = game.messages.get(message._id);
await updateMessage.update({
[`system.damage.${damageType}`]: {
total: parsedRoll.total,
parts: damageParts
}
const { isResource, damageType, dice, result } = target.dataset;
await message.system.damage.rerollDamageDie(isResource, damageType, dice, result);
const updatePath = isResource ? `system.damage.resources.${damageType}` : 'system.damage.main';
const updateValue = isResource ?
message.system.damage.resources[damageType] : message.system.damage.main;
await message.update({
[updatePath]: updateValue.toJSON()
});
} else {
const rerollDice = message.system.roll.dice[target.dataset.dieIndex];
@ -297,4 +278,10 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
const actor = game.actors.get(event.target.dataset.actorId);
new game.system.api.applications.dialogs.RiskItAllDialog(actor, resourceValue).render({ force: true });
}
async onRollReloadCheck(_event, messageData) {
const message = game.messages.get(messageData._id);
const needsReload = await message.system.action.handleReload?.({ awaitRoll: true });
await message.update({ 'system.needsReload': needsReload });
}
}

View file

@ -153,7 +153,6 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
action: socketEvent.Refresh,
data: { refreshType: RefreshType.Countdown }
});
Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.Countdown });
}
static #addCountdown() {

View file

@ -12,14 +12,11 @@ const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
export default class DhCountdowns extends HandlebarsApplicationMixin(ApplicationV2) {
previousCountdownData = null;
changedCountdownsForAnimation = new Set();
constructor(options = {}) {
super(options);
this.previousCountdownData =
game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns).countdowns;
this.setupHooks();
}
/** @inheritDoc */
@ -80,7 +77,15 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
return frame;
}
/** @inheritdoc */
async _onFirstRender(context, options) {
await super._onFirstRender(context, options);
this._createContextMenu(this._getCountdownContextOptions, '.countdown-container[data-countdown]', {
parentClassHooks: false, fixed: true
});
}
/** @inheritdoc */
async _onRender(context, options) {
await super._onRender(context, options);
@ -95,7 +100,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
/* Handle animations to draw attention to countdown values changing */
const typesToAnimate = new Set();
for (const countdownKey of this.changedCountdownsForAnimation) {
for (const countdownKey of options.animate ?? []) {
const shimmerAnimation = [
{ backgroundPositionX: '98%' },
{ backgroundPositionX: '0%' }
@ -127,8 +132,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
const element = this.element.querySelector(`.header-type-toggles .header-type[data-type="${type}"]`);
element?.animate(pulseAnimation, pulseTiming);
}
this.changedCountdownsForAnimation.clear();
}
/** Returns countdown data filtered by ownership */
@ -137,17 +140,15 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
const values = Object.entries(setting.countdowns).map(([key, countdown]) => ({
key,
countdown,
ownership: DhCountdowns.#getPlayerOwnership(game.user, setting, countdown)
ownership: countdown.getUserLevel(game.user)
}));
return values.filter(v => v.ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE);
}
_getCountdownData() {
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
return this.#getCountdowns().reduce((acc, { key, countdown, ownership }) => {
const playersWithAccess = game.users.reduce((acc, user) => {
const ownership = DhCountdowns.#getPlayerOwnership(user, setting, countdown);
const ownership = countdown.getUserLevel(user);
if (!user.isGM && ownership && ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE) {
acc.push(user);
}
@ -213,19 +214,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
return context;
}
static #getPlayerOwnership(user, setting, countdown) {
if (user.isGM) return CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER;
const playerOwnership = countdown.ownership[user.id];
return playerOwnership === undefined || playerOwnership === CONST.DOCUMENT_OWNERSHIP_LEVELS.INHERIT
? setting.defaultOwnership
: playerOwnership;
}
cooldownRefresh = ({ refreshType }) => {
if (refreshType === RefreshType.Countdown) this.render();
};
static canPerformEdit() {
if (game.user.isGM) return true;
@ -323,18 +311,12 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
action: socketEvent.Refresh,
data: { refreshType: RefreshType.Countdown }
});
Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.Countdown });
}
setupHooks() {
Hooks.on(socketEvent.Refresh, this.cooldownRefresh.bind());
}
async close(options) {
/* Opt out of Foundry's standard behavior of closing all application windows marked as UI when Escape is pressed */
if (options.closeKey) return;
Hooks.off(socketEvent.Refresh, this.cooldownRefresh);
return super.close(options);
}
@ -377,4 +359,30 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
refreshType: RefreshType.Countdown
});
}
/**
* @returns {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]}
*/
_getCountdownContextOptions() {
/** @param {HTMLElement} element */
const getCountdownFromElement = element => {
const id = element.closest('[data-countdown]').dataset.countdown;
if (!id) return null;
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
return setting.countdowns[id ?? ''];
}
return [
{
label: 'CONTROLS.CommonDelete',
icon: 'fa-solid fa-trash',
visible: element => {
return getCountdownFromElement(element)?.isOwner;
},
onClick: (_, target) => {
getCountdownFromElement(target)?.delete();
}
}
];
}
}

View file

@ -39,6 +39,12 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
}
};
/**
* Debounce and slightly delayed request to re-render this panel. Necessary for situations where it is not possible
* to properly wait for promises to resolve before refreshing the UI.
*/
refresh = foundry.utils.debounce(this.render.bind(this), 50);
get element() {
return document.body.querySelector('.daggerheart.dh-style.effects-display');
}

View file

@ -96,7 +96,7 @@ export default class DhRegionLayer extends foundry.canvas.layers.RegionLayer {
return inBounds.length === 1 ? inBounds[0] : null;
}
static getTemplateShape({ type, angle, range, direction } = {}) {
static getTemplateShape({ shapeType, angle, range, direction, hasHole } = {}) {
const { line, rectangle, inFront, cone, circle, emanation } = CONFIG.DH.GENERAL.templateTypes;
/* Length calculation */
@ -112,11 +112,11 @@ export default class DhRegionLayer extends foundry.canvas.layers.RegionLayer {
const shapeData = {
...canvas.mousePosition,
type: type,
type: shapeType,
direction: direction ?? 0
};
switch (type) {
switch (shapeType) {
case rectangle.id:
shapeData.width = length;
shapeData.height = length;
@ -145,7 +145,8 @@ export default class DhRegionLayer extends foundry.canvas.layers.RegionLayer {
y: 0,
width: 1,
height: 1,
shape: game.canvas.grid.isHexagonal ? CONST.TOKEN_SHAPES.ELLIPSE_1 : CONST.TOKEN_SHAPES.RECTANGLE_1
shape: game.canvas.grid.isHexagonal ? CONST.TOKEN_SHAPES.ELLIPSE_1 : CONST.TOKEN_SHAPES.RECTANGLE_1,
hole: hasHole
};
break;
}

View file

@ -119,6 +119,10 @@ export const advantageState = {
export const areaTypes = {
placed: {
id: 'placed',
label: 'Placed Area'
label: 'DAGGERHEART.CONFIG.AreaTypes.placed.label'
},
attached: {
id: 'attached',
label: 'DAGGERHEART.CONFIG.AreaTypes.attached.label'
}
};

View file

@ -90,18 +90,20 @@ export const BPModifiers = {
name: 'DAGGERHEART.CONFIG.BPModifiers.increaseDamage.effect.name',
description: 'DAGGERHEART.CONFIG.BPModifiers.increaseDamage.effect.description',
img: 'icons/magic/control/buff-flight-wings-red.webp',
changes: [
{
key: 'system.bonuses.damage.physical.dice',
mode: 2,
value: '1d4'
},
{
key: 'system.bonuses.damage.magical.dice',
mode: 2,
value: '1d4'
}
]
system: {
changes: [
{
key: 'system.bonuses.damage.physical.dice',
type: 'add',
value: '1d4'
},
{
key: 'system.bonuses.damage.magical.dice',
type: 'add',
value: '1d4'
}
]
}
}
]
}

View file

@ -825,7 +825,7 @@ export const refreshTypes = {
export const itemAbilityCosts = {
resource: {
id: 'resource',
label: 'DAGGERHEART.GENERAL.resource',
label: 'DAGGERHEART.GENERAL.Resource.single',
group: 'Global'
},
quantity: {

View file

@ -37,13 +37,15 @@ export const armorFeatures = {
name: 'DAGGERHEART.CONFIG.ArmorFeature.channeling.effects.channeling.name',
description: 'DAGGERHEART.CONFIG.ArmorFeature.channeling.effects.channeling.description',
img: 'icons/magic/symbols/rune-sigil-horned-blue.webp',
changes: [
{
key: 'system.bonuses.roll.spellcast',
mode: 2,
value: '1'
}
]
system: {
changes: [
{
key: 'system.bonuses.roll.spellcast',
type: 'add',
value: '1'
}
]
}
}
]
},
@ -55,43 +57,45 @@ export const armorFeatures = {
name: 'DAGGERHEART.CONFIG.ArmorFeature.difficult.effects.difficult.name',
description: 'DAGGERHEART.CONFIG.ArmorFeature.difficult.effects.difficult.description',
img: 'icons/magic/control/buff-flight-wings-red.webp',
changes: [
{
key: 'system.traits.agility.value',
mode: 2,
value: '-1'
},
{
key: 'system.traits.strength.value',
mode: 2,
value: '-1'
},
{
key: 'system.traits.finesse.value',
mode: 2,
value: '-1'
},
{
key: 'system.traits.instinct.value',
mode: 2,
value: '-1'
},
{
key: 'system.traits.presence.value',
mode: 2,
value: '-1'
},
{
key: 'system.traits.knowledge.value',
mode: 2,
value: '-1'
},
{
key: 'system.evasion',
mode: 2,
value: '-1'
}
]
system: {
changes: [
{
key: 'system.traits.agility.value',
type: 'add',
value: '-1'
},
{
key: 'system.traits.strength.value',
type: 'add',
value: '-1'
},
{
key: 'system.traits.finesse.value',
type: 'add',
value: '-1'
},
{
key: 'system.traits.instinct.value',
type: 'add',
value: '-1'
},
{
key: 'system.traits.presence.value',
type: 'add',
value: '-1'
},
{
key: 'system.traits.knowledge.value',
type: 'add',
value: '-1'
},
{
key: 'system.evasion',
type: 'add',
value: '-1'
}
]
}
}
]
},
@ -103,13 +107,15 @@ export const armorFeatures = {
name: 'DAGGERHEART.CONFIG.ArmorFeature.flexible.effects.flexible.name',
description: 'DAGGERHEART.CONFIG.ArmorFeature.flexible.effects.flexible.description',
img: 'icons/magic/movement/abstract-ribbons-red-orange.webp',
changes: [
{
key: 'system.evasion',
mode: 2,
value: '1'
}
]
system: {
changes: [
{
key: 'system.evasion',
type: 'add',
value: '1'
}
]
}
}
]
},
@ -121,13 +127,15 @@ export const armorFeatures = {
name: 'DAGGERHEART.CONFIG.ArmorFeature.fortified.effects.fortified.name',
description: 'DAGGERHEART.CONFIG.ArmorFeature.fortified.effects.fortified.description',
img: 'icons/magic/defensive/shield-barrier-glowing-blue.webp',
changes: [
{
key: 'system.rules.damageReduction.increasePerArmorMark',
mode: 5,
value: '2'
}
]
system: {
changes: [
{
key: 'system.rules.damageReduction.increasePerArmorMark',
type: 'override',
value: '2'
}
]
}
}
]
},
@ -139,13 +147,15 @@ export const armorFeatures = {
name: 'DAGGERHEART.CONFIG.ArmorFeature.gilded.effects.gilded.name',
description: 'DAGGERHEART.CONFIG.ArmorFeature.gilded.effects.gilded.description',
img: 'icons/magic/control/control-influence-crown-gold.webp',
changes: [
{
key: 'system.traits.presence.value',
mode: 2,
value: '1'
}
]
system: {
changes: [
{
key: 'system.traits.presence.value',
type: 'add',
value: '1'
}
]
}
}
]
},
@ -157,13 +167,15 @@ export const armorFeatures = {
name: 'DAGGERHEART.CONFIG.ArmorFeature.heavy.effects.heavy.name',
description: 'DAGGERHEART.CONFIG.ArmorFeature.heavy.effects.heavy.description',
img: 'icons/commodities/metal/ingot-worn-iron.webp',
changes: [
{
key: 'system.evasion',
mode: 2,
value: '-1'
}
]
system: {
changes: [
{
key: 'system.evasion',
type: 'add',
value: '-1'
}
]
}
}
]
},
@ -212,13 +224,15 @@ export const armorFeatures = {
name: 'DAGGERHEART.CONFIG.ArmorFeature.magical.effects.magical.name',
description: 'DAGGERHEART.CONFIG.ArmorFeature.magical.effects.magical.description',
img: 'icons/magic/defensive/barrier-shield-dome-blue-purple.webp',
changes: [
{
key: 'system.rules.damageReduction.magical',
mode: 5,
value: 1
}
]
system: {
changes: [
{
key: 'system.rules.damageReduction.magical',
type: 'override',
value: 1
}
]
}
}
]
},
@ -249,13 +263,15 @@ export const armorFeatures = {
name: 'DAGGERHEART.CONFIG.ArmorFeature.physical.effects.physical.name',
description: 'DAGGERHEART.CONFIG.ArmorFeature.physical.effects.physical.description',
img: 'icons/commodities/stone/ore-pile-tan.webp',
changes: [
{
key: 'system.rules.damageReduction.physical',
mode: 5,
value: 1
}
]
system: {
changes: [
{
key: 'system.rules.damageReduction.physical',
type: 'override',
value: 1
}
]
}
}
]
},
@ -280,18 +296,20 @@ export const armorFeatures = {
name: 'DAGGERHEART.CONFIG.ArmorFeature.reinforced.effects.reinforced.name',
description: 'DAGGERHEART.CONFIG.ArmorFeature.reinforced.effects.reinforced.description',
img: 'icons/magic/defensive/shield-barrier-glowing-triangle-green.webp',
changes: [
{
key: 'system.bunuses.damageThresholds.major',
mode: 2,
value: '2'
},
{
key: 'system.bunuses.damageThresholds.severe',
mode: 2,
value: '2'
}
]
system: {
changes: [
{
key: 'system.bunuses.damageThresholds.major',
type: 'add',
value: '2'
},
{
key: 'system.bunuses.damageThresholds.severe',
type: 'add',
value: '2'
}
]
}
}
]
},
@ -326,18 +344,20 @@ export const armorFeatures = {
name: 'DAGGERHEART.CONFIG.ArmorFeature.sharp.effects.sharp.name',
description: 'DAGGERHEART.CONFIG.ArmorFeature.sharp.effects.sharp.description',
img: 'icons/magic/defensive/shield-barrier-glowing-triangle-green.webp',
changes: [
{
key: 'system.bonuses.damage.primaryWeapon.dice',
mode: 2,
value: '1d4'
},
{
key: 'system.bonuses.damage.secondaryWeapon.dice',
mode: 2,
value: '1d4'
}
]
system: {
changes: [
{
key: 'system.bonuses.damage.primaryWeapon.dice',
type: 'add',
value: '1d4'
},
{
key: 'system.bonuses.damage.secondaryWeapon.dice',
type: 'add',
value: '1d4'
}
]
}
}
]
},
@ -408,18 +428,20 @@ export const armorFeatures = {
name: 'DAGGERHEART.CONFIG.ArmorFeature.veryHeavy.effects.veryHeavy.name',
description: 'DAGGERHEART.CONFIG.ArmorFeature.veryHeavy.effects.veryHeavy.description',
img: 'icons/commodities/metal/ingot-stamped-steel.webp',
changes: [
{
key: 'system.evasion',
mode: 2,
value: '-2'
},
{
key: 'system.traits.agility.value',
mode: 2,
value: '-1'
}
]
system: {
changes: [
{
key: 'system.evasion',
type: 'add',
value: '-2'
},
{
key: 'system.traits.agility.value',
type: 'add',
value: '-1'
}
]
}
}
]
},
@ -431,14 +453,16 @@ export const armorFeatures = {
name: 'DAGGERHEART.CONFIG.ArmorFeature.warded.effects.warded.name',
description: 'DAGGERHEART.CONFIG.ArmorFeature.warded.effects.warded.description',
img: 'icons/magic/defensive/barrier-shield-dome-pink.webp',
changes: [
{
key: 'system.resistance.magical.reduction',
mode: 2,
value: '@system.armorScore',
priority: 21
}
]
system: {
changes: [
{
key: 'system.resistance.magical.reduction',
type: 'add',
value: '@system.armorScore',
priority: 21
}
]
}
}
]
}
@ -488,21 +512,23 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.barrier.effects.barrier.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.barrier.effects.barrier.description',
img: 'icons/skills/melee/shield-block-bash-blue.webp',
changes: [
{
key: 'system.evasion',
mode: 2,
value: '-1'
},
{
key: 'Armor',
type: 'armor',
typeData: {
system: {
changes: [
{
key: 'system.evasion',
type: 'add',
value: '-1'
},
{
key: 'Armor',
type: 'armor',
max: 'ITEM.@system.tier + 1'
typeData: {
type: 'armor',
max: 'ITEM.@system.tier + 1'
}
}
}
]
]
}
}
]
},
@ -514,13 +540,15 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.bonded.effects.damage.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.bonded.effects.damage.description',
img: 'icons/magic/symbols/chevron-elipse-circle-blue.webp',
changes: [
{
key: 'system.bonuses.damage.primaryWeapon.bonus',
mode: 2,
value: '@system.levelData.level.current'
}
]
system: {
changes: [
{
key: 'system.bonuses.damage.primaryWeapon.bonus',
type: 'add',
value: '@system.levelData.level.current'
}
]
}
}
]
},
@ -553,18 +581,20 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.brave.effects.brave.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.brave.effects.brave.description',
img: 'icons/magic/life/heart-cross-strong-flame-purple-orange.webp',
changes: [
{
key: 'system.evasion',
mode: 2,
value: '-1'
},
{
key: 'system.damageThresholds.severe',
mode: 2,
value: 'ITEM.@system.tier'
}
]
system: {
changes: [
{
key: 'system.evasion',
type: 'add',
value: '-1'
},
{
key: 'system.damageThresholds.severe',
type: 'add',
value: 'ITEM.@system.tier'
}
]
}
}
]
},
@ -618,13 +648,15 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.charged.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.charged.description',
img: 'icons/magic/lightning/claws-unarmed-strike-teal.webp',
changes: [
{
key: 'system.proficiency',
mode: 2,
value: '1'
}
]
system: {
changes: [
{
key: 'system.proficiency',
type: 'add',
value: '1'
}
]
}
}
]
}
@ -660,13 +692,15 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.cumbersome.effects.cumbersome.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.cumbersome.effects.cumbersome.description',
img: 'icons/commodities/metal/mail-plate-steel.webp',
changes: [
{
key: 'system.traits.finesse.value',
mode: 2,
value: '-1'
}
]
system: {
changes: [
{
key: 'system.traits.finesse.value',
type: 'add',
value: '-1'
}
]
}
}
]
},
@ -707,14 +741,16 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.deflecting.effects.deflecting.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.deflecting.effects.deflecting.description',
img: 'icons/skills/melee/hand-grip-sword-strike-orange.webp',
changes: [
{
key: 'system.evasion',
mode: 2,
value: '@system.armorScore',
priority: 21
}
]
system: {
changes: [
{
key: 'system.evasion',
type: 'add',
value: '@system.armorScore',
priority: 21
}
]
}
}
]
}
@ -754,13 +790,15 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.destructive.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.destructive.effects.agility',
img: 'icons/skills/melee/strike-flail-spiked-pink.webp',
changes: [
{
key: 'system.traits.agility.value',
mode: 2,
value: '-1'
}
]
system: {
changes: [
{
key: 'system.traits.agility.value',
type: 'add',
value: '-1'
}
]
}
}
]
},
@ -791,14 +829,14 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.doubleDuty.effects.doubleDuty.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.doubleDuty.effects.doubleDuty.description',
img: 'icons/skills/melee/sword-shield-stylized-white.webp',
changes: [
{
key: 'system.bonuses.damage.primaryWeapon.bonus',
mode: 2,
value: '1'
}
],
system: {
changes: [
{
key: 'system.bonuses.damage.primaryWeapon.bonus',
type: 'add',
value: '1'
}
],
rangeDependence: {
enabled: true,
range: 'melee',
@ -902,13 +940,15 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.greedy.actions.greed.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.greedy.actions.greed.description',
img: 'icons/commodities/currency/coins-crown-stack-gold.webp',
changes: [
{
key: 'system.proficiency',
mode: 2,
value: '1'
}
]
system: {
changes: [
{
key: 'system.proficiency',
type: 'add',
value: '1'
}
]
}
}
]
}
@ -951,13 +991,15 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.heavy.effects.heavy.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.heavy.effects.heavy.description',
img: 'icons/commodities/metal/ingot-worn-iron.webp',
changes: [
{
key: 'system.evasion',
mode: 2,
value: '-1'
}
]
system: {
changes: [
{
key: 'system.evasion',
type: 'add',
value: '-1'
}
]
}
}
]
},
@ -1066,13 +1108,15 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.massive.effects.massive.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.massive.effects.massive.description',
img: 'icons/skills/melee/strike-flail-destructive-yellow.webp',
changes: [
{
key: 'system.evasion',
mode: 2,
value: '-1'
}
]
system: {
changes: [
{
key: 'system.evasion',
type: 'add',
value: '-1'
}
]
}
}
]
},
@ -1103,14 +1147,14 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.paired.effects.paired.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.paired.effects.paired.description',
img: 'icons/skills/melee/weapons-crossed-swords-yellow-teal.webp',
changes: [
{
key: 'system.bonuses.damage.primaryWeapon.bonus',
mode: 2,
value: 'ITEM.@system.tier + 1'
}
],
system: {
changes: [
{
key: 'system.bonuses.damage.primaryWeapon.bonus',
type: 'add',
value: 'ITEM.@system.tier + 1'
}
],
rangeDependence: {
enabled: true,
range: 'melee',
@ -1158,13 +1202,15 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.persuasive.effects.persuasive.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.persuasive.effects.persuasive.description',
img: 'icons/magic/control/hypnosis-mesmerism-eye.webp',
changes: [
{
key: 'system.traits.presence.value',
mode: 2,
value: '2'
}
]
system: {
changes: [
{
key: 'system.traits.presence.value',
type: 'add',
value: '2'
}
]
}
}
]
}
@ -1203,17 +1249,20 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.protective.effects.protective.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.protective.effects.protective.description',
img: 'icons/skills/melee/shield-block-gray-orange.webp',
changes: [
{
key: 'Armor',
type: 'armor',
value: 0,
typeData: {
system: {
changes: [
{
key: 'Armor',
type: 'armor',
max: 'ITEM.@system.tier'
value: 0,
typeData: {
type: 'armor',
max: 'ITEM.@system.tier'
}
}
}
]
]
}
}
]
},
@ -1244,13 +1293,15 @@ export const weaponFeatures = {
name: 'DAGGERHEART.CONFIG.WeaponFeature.reliable.effects.reliable.name',
description: 'DAGGERHEART.CONFIG.WeaponFeature.reliable.effects.reliable.description',
img: 'icons/skills/melee/strike-sword-slashing-red.webp',
changes: [
{
key: 'system.bonuses.roll.primaryWeapon.bonus',
mode: 2,
value: 1
}
]
system: {
changes: [
{
key: 'system.bonuses.roll.primaryWeapon.bonus',
type: 'add',
value: 1
}
]
}
}
]
},
@ -1341,7 +1392,7 @@ export const weaponFeatures = {
changes: [
{
key: 'system.bonuses.damage.primaryWeapon.bonus',
mode: 2,
type: 'add',
value: '@system.traits.agility.value',
priority: 21
}

View file

@ -27,8 +27,10 @@ export const menu = {
};
export const gameSettings = {
/** @type {'Automation'} */
Automation: 'Automation',
Metagaming: 'Metagaming',
/** @type {'Homebrew'} */
Homebrew: 'Homebrew',
appearance: 'Appearance',
GlobalOverrides: 'GlobalOverrides',
@ -37,6 +39,7 @@ export const gameSettings = {
Fear: 'ResourcesFear'
},
LevelTiers: 'LevelTiers',
/** @type {'Countdowns'} */
Countdowns: 'Countdowns',
LastMigrationVersion: 'LastMigrationVersion',
SpotlightRequestQueue: 'SpotlightRequestQueue',
@ -59,3 +62,18 @@ export const actionAutomationChoices = {
label: 'DAGGERHEART.CONFIG.ActionAutomationChoices.always'
}
};
export const reloadChoices = {
off: {
id: 'off',
label: 'DAGGERHEART.CONFIG.ReloadChoices.off.label'
},
button: {
id: 'button',
label: 'DAGGERHEART.CONFIG.ReloadChoices.button.label'
},
auto: {
id: 'auto',
label: 'DAGGERHEART.CONFIG.ReloadChoices.auto.label'
}
};

View file

@ -12,6 +12,7 @@ import * as HOOKS from './hooksConfig.mjs';
import * as TRIGGER from './triggerConfig.mjs';
import * as ITEMBROWSER from './itemBrowserConfig.mjs';
/** @type {"daggerheart"} */
export const SYSTEM_ID = 'daggerheart';
export const SYSTEM = {

7
module/data/_types.d.ts vendored Normal file
View file

@ -0,0 +1,7 @@
import { DhCountdown } from './countdowns.mjs'
declare module './countdowns.mjs' {
export default interface DhCountdowns {
countdowns: Record<string, DhCountdown>;
}
}

View file

@ -13,18 +13,19 @@ export default class DHAttackAction extends DHDamageAction {
if (this.damage.includeBase) {
const baseDamage = this.getParentHitPointDamage();
if (baseDamage) {
if (!this.damage.parts.hitPoints) {
this.damage.parts.hitPoints = baseDamage;
if (!this.damage.main) {
this.damage.main = baseDamage;
} else {
for (const type of baseDamage.type) this.damage.parts.hitPoints.type.add(type);
for (const type of baseDamage.type) this.damage.main.type.add(type);
this.damage.parts.hitPoints.value.custom = {
this.damage.main.value.custom = {
enabled: true,
formula: `${baseDamage.value.getFormula()} + ${this.damage.parts.hitPoints.value.getFormula()}`
formula: `${baseDamage.value.getFormula()} + ${this.damage.main.value.getFormula()}`
};
}
}
}
if (this.roll.useDefault) {
this.roll.trait = this.item.system.attack.roll.trait;
this.roll.type = 'attack';
@ -33,24 +34,28 @@ export default class DHAttackAction extends DHDamageAction {
}
getParentHitPointDamage() {
return this.item?.system?.attack.damage.parts.hitPoints;
return this.item?.system?.attack.damage.main;
}
get damageFormula() {
const hitPointsPart = this.damage.parts.hitPoints;
const hitPointsPart = this.damage.main;
if (!hitPointsPart) return '0';
return hitPointsPart.value.getFormula();
}
get altDamageFormula() {
const hitPointsPart = this.damage.parts.hitPoints;
const hitPointsPart = this.damage.main;
if (!hitPointsPart) return '0';
return hitPointsPart.valueAlt.getFormula();
}
async use(event, options) {
if (this.item?.system.needsReload) {
return ui.notifications.error(_loc('DAGGERHEART.UI.Notifications.reloadRequired', { weapon: this.item.name }));
}
const result = await super.use(event, options);
if (result?.message?.system.action?.roll?.type === 'attack') {
@ -61,6 +66,23 @@ export default class DHAttackAction extends DHDamageAction {
return result;
}
async handleReload(options = { awaitRoll: false }) {
const roll = await new Roll('1d6').evaluate();
if (game.modules.get('dice-so-nice')?.active) {
if (options.awaitRoll)
await game.dice3d.showForRoll(roll, game.user, true);
else
game.dice3d.showForRoll(roll, game.user, true);
}
const needsToReload = roll.total === 1;
if (needsToReload) {
this.item.update({ 'system.resource.value': 0 });
}
return needsToReload;
}
/**
* Generate a localized label array for this item subtype.
* @returns {(string | { value: string, icons: string[] })[]} An array of localized strings and damage label objects.
@ -73,7 +95,7 @@ export default class DHAttackAction extends DHDamageAction {
if (range) labels.push(game.i18n.localize(`DAGGERHEART.CONFIG.Range.${range}.short`));
const useAltDamage = this.actor?.effects?.find(x => x.type === 'horde')?.active;
for (const { value, valueAlt, type } of damage.parts) {
for (const { value, valueAlt, type } of [damage.main, ...damage.resources].filter(d => !!d)) {
const usedValue = useAltDamage ? valueAlt : value;
const damageString = Roll.replaceFormulaData(usedValue.getFormula(), this.actor?.getRollData() ?? {});
const str = damageString
@ -82,7 +104,7 @@ export default class DHAttackAction extends DHDamageAction {
x: game.i18n.localize('DAGGERHEART.GENERAL.damage')
});
const icons = Array.from(type)
const icons = Array.from(type ?? [])
.map(t => CONFIG.DH.GENERAL.damageTypes[t]?.icon)
.filter(Boolean);

View file

@ -54,6 +54,10 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
return {};
}
get hasDescription() {
return Boolean(this.description);
}
/**
* Create a Map containing each Action step based on fields define in schema. Ordered by Fields order property.
*
@ -110,7 +114,10 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
return this._id;
}
/** Returns true if the current user is the owner of the containing item */
/**
* Returns true if the current user is the owner of the containing item.
* @returns {boolean}
*/
get isOwner() {
return this.item?.isOwner ?? true;
}
@ -139,6 +146,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
/**
* Return the first Actor parent found.
* @returns {DhpActor | null}
*/
get actor() {
return this.item instanceof DhpActor
@ -151,6 +159,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
/**
* Returns true if the action is usable.
* An action is usable on any actor type. For example, an adversary might have a base attack action.
* @returns {boolean}
*/
get usable() {
const actor = this.actor;
@ -247,7 +256,8 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
if (Hooks.call(`${CONFIG.DH.id}.postUseAction`, this, config) === false) return;
if (this.chatDisplay && !config.skips.createMessage && !config.actionChatMessageHandled) await this.toChat();
if (this.chatDisplay && !config.skips.createMessage && !config.actionChatMessageHandled)
await this.toChat(null, config);
return config;
}
@ -279,7 +289,6 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
hasEffect: this.hasEffect,
hasSave: this.hasSave,
onSave: this.save?.damageMod,
isDirect: !!this.damage?.direct,
selectedMessageMode: game.settings.get('core', 'messageMode'),
data: this.getRollData(),
evaluate: this.hasRoll,
@ -297,20 +306,20 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
};
if (this.damage) {
config.isDirect = this.damage.direct;
config.isDirect = !!this.damage.main?.direct;
const groupAttackTokens = this.damage.groupAttack
const groupAttackTokens = this.damage.main?.groupAttack
? game.system.api.fields.ActionFields.DamageField.getGroupAttackTokens(
this.actor.id,
this.damage.groupAttack
this.damage.main.groupAttack
)
: null;
config.damageOptions = {
groupAttack: this.damage.groupAttack
groupAttack: this.damage.main?.groupAttack
? {
numAttackers: Math.max(groupAttackTokens.length, 1),
range: this.damage.groupAttack
range: this.damage.main.groupAttack
}
: null
};
@ -420,11 +429,11 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
}
get hasDamage() {
return Boolean(Object.keys(this.damage?.parts ?? {}).length) && this.type !== 'healing';
return this.type !== 'healing' && (Boolean(this.damage.main) || !foundry.utils.isEmpty(this.damage.resources));
}
get hasHealing() {
return Boolean(Object.keys(this.damage?.parts ?? {}).length) && this.type === 'healing';
return this.type === 'healing' && !foundry.utils.isEmpty(this.damage.resources);
}
get hasSave() {
@ -447,11 +456,38 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
static migrateData(source) {
if (source.damage?.parts && Array.isArray(source.damage.parts)) {
let hitPointsExists = source.damage.parts.some(x => x.applyTo === 'hitPoints');
source.damage.parts = source.damage.parts.reduce((acc, part) => {
if (!part.applyTo && hitPointsExists) return acc;
if (!part.applyTo) {
hitPointsExists = true;
part.applyTo = 'hitPoints';
}
acc[part.applyTo] = part;
return acc;
}, {});
}
if (source.damage?.parts && !source.damage.resources && !source.damage.main) {
source.damage.main = null;
source.damage.resources = {};
for (const [partKey, part] of Object.entries(source.damage.parts)) {
if (partKey === 'hitPoints' && source.type !== 'healing') {
source.damage.main = {
...part,
includeBase: source.damage.includeBase,
direct: source.damage.direct,
groupAttack: source.damage.groupAttack
};
} else {
source.damage.resources[partKey] = part;
}
}
delete source.damage.parts;
}
}
}

View file

@ -8,11 +8,8 @@ export default class DHDamageAction extends DHBaseAction {
* @returns Formula string
*/
getDamageFormula() {
const strings = [];
for (const { value } of this.damage.parts) {
strings.push(Roll.replaceFormulaData(value.getFormula(), this.actor?.getRollData() ?? {}));
}
if (!this.damage.main) return '';
return strings.join(' + ');
return Roll.replaceFormulaData(this.damage.main.value.getFormula(), this.actor?.getRollData() ?? {});
}
}

View file

@ -57,11 +57,6 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
description: new fields.HTMLField({ label: 'DAGGERHEART.GENERAL.description' })
}),
rangeDependence: new fields.SchemaField({
enabled: new fields.BooleanField({
required: true,
initial: false,
label: 'DAGGERHEART.GENERAL.enabled'
}),
type: new fields.StringField({
required: true,
choices: CONFIG.DH.GENERAL.rangeInclusion,
@ -80,7 +75,7 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
initial: CONFIG.DH.GENERAL.range.melee.id,
label: 'DAGGERHEART.GENERAL.range'
})
}),
}, { nullable: true, initial: null }),
stacking: new fields.SchemaField(
{
value: new fields.NumberField({
@ -146,14 +141,8 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
description: '',
transfer: options.transfer,
statuses: [],
changes: [],
system: {
rangeDependence: {
enabled: false,
type: CONFIG.DH.GENERAL.rangeInclusion.withinRange.id,
target: CONFIG.DH.GENERAL.otherTargetTypes.hostile.id,
range: CONFIG.DH.GENERAL.range.melee.id
}
changes: []
}
};
}
@ -185,4 +174,12 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
if (this.parent.actor && options.scrollingTextData)
this.parent.actor.queueScrollText(options.scrollingTextData);
}
static migrateData(source) {
if (source.rangeDependence?.enabled === false) {
source.rangeDependence = null;
}
return super.migrateData(source);
}
}

View file

@ -84,12 +84,11 @@ export default class DhpAdversary extends DhCreature {
type: 'attack'
},
damage: {
parts: {
hitPoints: {
type: ['physical'],
value: {
multiplier: 'flat'
}
main: {
type: ['physical'],
applyTo: 'hitPoints',
value: {
multiplier: 'flat'
}
}
}

View file

@ -104,14 +104,13 @@ export default class DhCharacter extends DhCreature {
trait: 'strength'
},
damage: {
parts: {
hitPoints: {
type: ['physical'],
value: {
custom: {
enabled: true,
formula: '@profd4'
}
main: {
type: ['physical'],
applyTo: 'hitPoints',
value: {
custom: {
enabled: true,
formula: '@profd4'
}
}
}
@ -837,7 +836,7 @@ export default class DhCharacter extends DhCreature {
isReversed: true
};
this.attack.damage.parts.hitPoints.value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`;
this.attack.damage.main.value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`;
// Clamp resources (must be done last to ensure all updates occur)
this.resources.clamp();

View file

@ -102,6 +102,7 @@ export default class DhCompanion extends DhCreature {
parts: {
hitPoints: {
type: ['physical'],
applyTo: 'hitPoints',
value: {
dice: 'd6',
multiplier: 'prof'

View file

@ -2,8 +2,14 @@ import { calculateExpectedValue, parseTermsFromSimpleFormula } from '../../helpe
import { adversaryExpectedDamage, adversaryScalingData } from '../../config/actorConfig.mjs';
import { parseInlineParams } from '../../enrichers/parser.mjs';
/**
* Accepts source data for an adversary and a target tier, and returns new source data
* @type {object} source
* @type {number} tier
* @returns {object} adjusted source data
*/
export function getTierAdjustedAdversary(source, tier) {
const currentTier = source.tier ?? 1;
const currentTier = source.system.tier ?? 1;
/** @type {(2 | 3 | 4)[]} */
const tiers = new Array(Math.abs(tier - currentTier))
@ -34,20 +40,20 @@ export function getTierAdjustedAdversary(source, tier) {
// Store initial attack damage for abilities that have you deal a "standard attack"
const initialAttack = {
type: source.system.attack.damage?.parts.hitPoints?.type?.toSorted(),
value: getDamagePartsFormula(source.system.attack.damage?.parts.hitPoints?.value)
type: source.system.attack.damage?.main?.type?.toSorted(),
value: getFormula(source.system.attack.damage?.main?.value)
};
// Update damage of base attack.
try {
const damage = source.system.attack.damage;
if (!damage?.parts.hitPoints) throw new Error('Unexpected missing attack in adversary');
if (!damage?.main) throw new Error('Unexpected missing damage in adversary');
for (const property of ['value', 'valueAlt']) {
const data = damage.parts.hitPoints[property];
const previousFormula = getDamagePartsFormula(data);
const { value, formula } = calculateAdjustedDamage(previousFormula, 'attack', damageMeta);
applyAdjustedDamage(data, value, formula);
const data = damage.main[property];
const previousFormula = getFormula(data);
const value = calculateAdjustedDamage(previousFormula, 'attack', damageMeta);
applyAdjustedDamage(data, value);
}
} catch (err) {
ui.notifications.warn('Failed to convert attack damage of adversary');
@ -65,7 +71,7 @@ export function getTierAdjustedAdversary(source, tier) {
if (!formula) return match;
try {
const newFormula = calculateAdjustedDamage(formula, 'action', damageMeta)?.formula;
const newFormula = getFormula(calculateAdjustedDamage(formula, 'action', damageMeta));
descriptionFormulas.push(formula);
return match.replace(formula, newFormula);
} catch {
@ -76,21 +82,21 @@ export function getTierAdjustedAdversary(source, tier) {
// Update damage in item actions and convert all formula matches in the descriptions to the new damage
for (const action of Object.values(item.system.actions)) {
if (!action.damage?.parts.hitPoints) continue;
if (!action.damage?.main) continue;
try {
// Apply conversions and save a record. If it matches attack damage *and* Its not in the description, use attack conversion instead
const result = [];
for (const property of ['value', 'valueAlt']) {
const { [property]: data, type: damageType } = action.damage.parts.hitPoints;
const previousFormula = getDamagePartsFormula(data);
const { [property]: data, type: damageType } = action.damage.main;
const previousFormula = getFormula(data);
const isActuallyAttack =
previousFormula === initialAttack.value &&
foundry.utils.equals(damageType.toSorted(), initialAttack.type) &&
!descriptionFormulas.includes(previousFormula);
const type = isActuallyAttack ? 'attack' : 'action';
const { value, formula } = calculateAdjustedDamage(previousFormula, type, damageMeta);
applyAdjustedDamage(data, value, formula);
result.push({ previousFormula, formula });
const value = calculateAdjustedDamage(previousFormula, type, damageMeta);
applyAdjustedDamage(data, value);
result.push({ previousFormula, formula: getFormula(value) });
}
// Override text in the description with those values
@ -189,24 +195,30 @@ function calculateAdjustedDamage(formula, type, { currentDamageRange, newDamageR
value.bonus = Math.round(expected - getBaseAverage());
}
const newFormula = [value.diceQuantity ? `${value.diceQuantity}d${value.faces}` : null, value.bonus]
.filter(p => !!p)
.join('+');
return { value, formula: newFormula };
return value;
}
function getDamagePartsFormula(data) {
return data.custom.enabled
? data.custom.formula
: [data.flatMultiplier ? `${data.flatMultiplier}${data.dice}` : 0, data.bonus ?? 0].filter(p => !!p).join('+');
/**
* Get formula from either damage data *or* a simple formula object.
* @returns {string} the new formula data
*/
function getFormula(data) {
if (data.custom?.enabled) {
return data.custom.formula;
}
const diceQuantity = data.flatMultiplier ?? data.diceQuantity;
const dice = data.faces ? `d${data.faces}` : data.dice;
const mod = data.bonus;
return [diceQuantity ? `${diceQuantity}${dice}` : 0, mod].filter(p => !!p).join('+');
}
/**
* Updates damage to reflect a specific value.
* @throws if damage structure is invalid for conversion
* @returns the converted formula and value as a simplified term, or null if it doesn't deal HP damage
* @param {object} diceData
* @param {object} value
*/
function applyAdjustedDamage(diceData, value, formula) {
function applyAdjustedDamage(diceData, value) {
if (value.diceQuantity) {
diceData.custom.enabled = false;
diceData.bonus = value.bonus;
@ -214,6 +226,6 @@ function applyAdjustedDamage(diceData, value, formula) {
diceData.flatMultiplier = value.diceQuantity;
} else if (!value.diceQuantity) {
diceData.custom.enabled = true;
diceData.custom.formula = formula;
diceData.custom.formula = getFormula(value);
}
}

View file

@ -1,4 +1,5 @@
import { triggerChatRollFx } from '../../helpers/utils.mjs';
import { ChatDamageData } from './chatDamageData.mjs';
const fields = foundry.data.fields;
@ -41,6 +42,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
hasEffect: new fields.BooleanField({ initial: false }),
hasSave: new fields.BooleanField({ initial: false }),
hasTarget: new fields.BooleanField({ initial: false }),
needsReload: new fields.BooleanField({ initial: false }),
isDirect: new fields.BooleanField({ initial: false }),
onSave: new fields.StringField(),
source: new fields.SchemaField({
@ -49,7 +51,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
originItem: originItemField(),
action: new fields.StringField()
}),
damage: new fields.ObjectField(),
damage: new fields.EmbeddedDataField(ChatDamageData),
damageOptions: new fields.ObjectField(),
costs: new fields.ArrayField(new fields.ObjectField()),
successConsumed: new fields.BooleanField({ initial: false })
@ -132,28 +134,21 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
});
}
/* TODO: Change how damage data is stored somehow to enable better rerolling */
async getRerolledDamage() {
if (!this.damage) return;
if (!this.damage.active) return;
const rerolls = [];
const update = { system: { damage: {} } };
for (const partKey in this.damage) {
const part = this.damage[partKey];
const testRoll = Roll.fromData(part.parts[0].roll);
const rerolled = await testRoll.reroll();
rerolls.push(rerolled);
const update = { system: { damage: { main: null, resources: _replace({}) } } };
if (this.damage.main) {
const reroll = await this.damage.main.reroll();
rerolls.push(reroll);
update.system.damage.main = reroll.toJSON();
}
if (!update.system.damage[partKey]) update.system.damage[partKey] = { parts: [part.parts[0]] };
const partData = update.system.damage[partKey].parts[0];
update.system.damage[partKey].total = rerolled.total;
partData.modifierTotal = rerolled.terms.reduce((acc, x) => {
if (x.isDeterministic && !x.operator) acc += x.total;
return acc;
}, 0);
partData.dice = rerolled.dice.map(d => ({ ...d.toJSON(), dice: d.denomination }));
partData.total = rerolled.total;
partData.roll = rerolled.toJSON();
for (const key of Object.keys(this.damage.resources)) {
const reroll = await this.damage.resources[key].reroll();
rerolls.push(reroll);
update.system.damage.resources[key] = reroll.toJSON();
}
await triggerChatRollFx(rerolls);
@ -198,6 +193,43 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
this.isGM = game.user.isGM; //temp
}
static migrateData(source) {
const { main, resources, ...flatDamageKeys } = source.damage ?? {};
if (source.damage && !main && !resources) {
source.damage.main = null;
source.damage.resources = {};
const getRoll = key => {
const damageData = source.damage[key];
const oldRoll = damageData.parts[0]?.roll;
return oldRoll ? JSON.stringify({
...oldRoll,
class: 'BaseRoll',
options: {
...oldRoll.options,
damageTypes: damageData.parts[0].damageTypes ?? []
}
}) : null;
};
for (const key of Object.keys(flatDamageKeys)) {
if (key === 'hitPoints' && source.hasDamage && !source.hasHealing) {
source.damage.main = getRoll('hitPoints');
}
else {
source.damage.resources[key] = getRoll(key);
}
}
}
for (const key of Object.keys(flatDamageKeys)) {
delete source.damage[key];
}
return source;
}
getTargetList() {
const targets =
this.targetMode && this.parent.isAuthor

View file

@ -0,0 +1,58 @@
import { triggerChatRollFx } from '../../helpers/utils.mjs';
export class ChatDamageData extends foundry.abstract.DataModel {
constructor(data = {}, options = {}) {
super(data, options);
this._prepareRolls();
}
static defineSchema() {
const fields = foundry.data.fields;
return {
main: new fields.JSONField({ nullable: true, validate: ChatDamageData.#validateRoll}),
resources: new fields.TypedObjectField(new fields.JSONField({validate: ChatDamageData.#validateRoll}))
};
}
get active() {
return !!this.main || Boolean(Object.keys(this.resources).length);
}
static #validateRoll(rollJSON) {
if (rollJSON) {
const roll = JSON.parse(rollJSON);
if (!roll.evaluated) throw new Error('Roll objects added to ChatMessage documents must be evaluated');
}
}
_prepareRolls() {
this.main &&= Roll.fromData(this.main);
for (const key of Object.keys(this.resources)) {
this.resources[key] = Roll.fromData(this.resources[key]);
}
}
async rerollDamageDie(isResource, damageType, dice, resultIndex) {
const reroll = isResource ? this.resources[damageType] : this.main;
const rerollDice = reroll.dice[dice];
await rerollDice.rerollResult(resultIndex);
await reroll._evaluate();
const rerolledResult = rerollDice.results[rerollDice.results.length - 1];
if (rerolledResult) {
const fakeRoll = {
_evaluated: true,
dice: [new foundry.dice.terms.Die({
...rerollDice,
results: [rerolledResult],
total: rerolledResult.value,
faces: rerollDice.faces
})],
options: { appearance: {} }
};
await triggerChatRollFx([fakeRoll]);
}
}
}

View file

@ -1,3 +1,4 @@
import { RefreshType, socketEvent } from '../systemRegistration/socket.mjs';
import FormulaField from './fields/formulaField.mjs';
export default class DhCountdowns extends foundry.abstract.DataModel {
@ -14,19 +15,69 @@ export default class DhCountdowns extends foundry.abstract.DataModel {
};
}
handleChange() {
/** @inheritdoc */
_initialize(options) {
super._initialize(options);
for (const [id, countdown] of Object.entries(this.countdowns)) {
countdown.id = id;
}
}
async handleChange() {
const previousCountdowns = foundry.ui.countdowns.previousCountdownData;
const changedCountdowns = Object.entries(this.countdowns).reduce((acc, [key, countdown]) => {
const previousCountdown = previousCountdowns[key];
if (!previousCountdown || (previousCountdown.progress.current !== countdown.progress.current)) {
const previous = previousCountdowns[key];
const currentChanged = !previous || (previous.progress.current !== countdown.progress.current);
if (currentChanged && previous?.progress.start === countdown.progress.start) {
acc.push(key);
}
return acc;
}, []);
for (const countdownKey of changedCountdowns)
foundry.ui.countdowns.changedCountdownsForAnimation.add(countdownKey);
// Re-render countdowns applications. When the change is due to an actual update, resync the editor
if (!foundry.utils.equals(previousCountdowns, this.countdowns)) {
await foundry.ui.countdowns.render({ animate: changedCountdowns });
for (const instance of game.system.api.applications.ui.CountdownEdit.instances()) {
instance.data = this;
await instance.render();
}
}
// Inform modules of updates
Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.Countdown });
}
static migrateData(source) {
const migrateOldCountdowns = (data, type) => {
for (const key of Object.keys(data.countdowns)) {
const countdown = data.countdowns[key];
source.countdowns[key] = {
...countdown,
type: type,
ownership: Object.keys(countdown.ownership.players).reduce((acc, key) => {
acc[key] =
countdown.ownership.players[key].type === 1 ? 2 : countdown.ownership.players[key].type;
return acc;
}, {}),
progress: {
...countdown.progress,
type: countdown.progress.type.value
}
};
}
source[type] = null;
};
if (source.narrative) {
migrateOldCountdowns(source.narrative, 'narrative');
}
if (source.encounter) {
migrateOldCountdowns(source.encounter, 'encounter');
}
return super.migrateData(source);
}
}
@ -127,6 +178,14 @@ export class DhCountdown extends foundry.abstract.DataModel {
}, {});
}
/**
* A boolean indicator for whether the current game User has ownership rights for this countdown
* @returns {boolean}
*/
get isOwner() {
return this.getUserLevel(game.user) === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER;
}
/** @inheritDoc */
static migrateData(source) {
if (source.progress.max) {
@ -137,4 +196,29 @@ export class DhCountdown extends foundry.abstract.DataModel {
return super.migrateData(source);
}
/**
* Get the explicit permission level that a User has over this Document, a value in CONST.DOCUMENT_OWNERSHIP_LEVELS.
* Compendium content ignores the ownership field in favor of User role-based ownership. Otherwise, Documents use
* granular per-User ownership definitions and Embedded Documents defer to their parent ownership.
*
* @param {BaseUser} [user=game.user] The User being tested
* @returns {DocumentOwnershipNumber} A numeric permission level from {@link CONST.DOCUMENT_OWNERSHIP_LEVELS}
*/
getUserLevel(user) {
if (user.isGM) return CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER;
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
const playerOwnership = this.ownership[user.id];
return playerOwnership === undefined || playerOwnership === CONST.DOCUMENT_OWNERSHIP_LEVELS.INHERIT
? setting.defaultOwnership
: playerOwnership;
}
async delete() {
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
const data = foundry.utils.deepClone(setting._source);
delete data.countdowns[this.id];
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns, data);
}
}

View file

@ -33,6 +33,10 @@ export default class AreasField extends fields.ArrayField {
initial: CONFIG.DH.GENERAL.range.veryClose.id,
label: 'DAGGERHEART.ACTIONS.Config.area.size'
}),
hasHole: new fields.BooleanField({
initial: false,
label: 'DAGGERHEART.ACTIONS.Config.area.hasHole'
}),
effects: new fields.ArrayField(new fields.DocumentIdField())
});
super(element, options, context);

View file

@ -12,20 +12,10 @@ export default class DamageField extends fields.SchemaField {
/** @inheritDoc */
constructor(options, context = {}) {
const damageFields = {
parts: new IterableTypedObjectField(DHDamageData),
includeBase: new fields.BooleanField({
initial: false,
label: 'DAGGERHEART.ACTIONS.Settings.includeBase.label'
}),
direct: new fields.BooleanField({ initial: false, label: 'DAGGERHEART.CONFIG.DamageType.direct.name' }),
groupAttack: new fields.StringField({
choices: CONFIG.DH.GENERAL.groupAttackRange,
blank: true,
label: 'DAGGERHEART.ACTIONS.Settings.groupAttack.label'
})
};
super(damageFields, options, context);
super({
main: new fields.EmbeddedDataField(DHDamageData, { nullable: true }),
resources: new IterableTypedObjectField(DHResourceData)
}, options, context);
}
/**
@ -41,25 +31,23 @@ export default class DamageField extends fields.SchemaField {
this.hasRoll &&
DamageField.getAutomation() === CONFIG.DH.SETTINGS.actionAutomationChoices.never.id &&
!force
)
) {
return;
}
let formulas = this.damage.parts.map(p => ({
formula: DamageField.getFormulaValue.call(this, p, config).getFormula(this.actor),
damageTypes: p.applyTo === 'hitPoints' && !p.type.size ? new Set(['physical']) : p.type,
applyTo: p.applyTo
}));
const damageFormula = this.damage.main ?
DamageField.formatFormulas.call(this, [this.damage.main], config)[0] : null;
const resourceFormulas = DamageField.formatFormulas.call(this, this.damage.resources, config);
if (!formulas.length) return false;
formulas = DamageField.formatFormulas.call(this, formulas, config);
if (!damageFormula && !resourceFormulas.length) return false;
messageId = config.message?._id ?? messageId;
const message = game.messages.get(messageId);
const damageConfig = {
dialog: {},
...config,
roll: formulas,
damageFormula,
resourceFormulas,
data: this.getRollData(),
isCritical: Boolean(message?.system.roll?.isCritical)
};
@ -92,7 +80,7 @@ export default class DamageField extends fields.SchemaField {
const targetDamage = [];
const damagePromises = [];
for (let target of targets) {
for (const target of targets) {
const actor = foundry.utils.fromUuidSync(target.actorId);
if (!actor) continue;
if (!config.hasHealing && config.onSave && target.saved?.success === true) {
@ -114,13 +102,12 @@ export default class DamageField extends fields.SchemaField {
actor.takeHealing(config.damage).then(updates => targetDamage.push({ token, updates }))
);
else {
const configDamage = foundry.utils.deepClone(config.damage);
const hpDamageMultiplier = config.actionActor?.system.rules?.attack?.damage?.hpDamageMultiplier ?? 1;
const hpDamageTakenMultiplier = actor.system.rules?.attack?.damage?.hpDamageTakenMultiplier;
if (configDamage.hitPoints) {
for (const part of configDamage.hitPoints.parts) {
part.total = Math.ceil(part.total * hpDamageMultiplier * hpDamageTakenMultiplier);
}
const configDamage = config.damage.clone();
configDamage.main &&= configDamage.main.toJSON();
if (configDamage.main) {
const multiplier = config.actionActor?.system.rules?.attack?.damage?.hpDamageMultiplier ?? 1;
const takenMultiplier = actor.system.rules?.attack?.damage?.hpDamageTakenMultiplier;
configDamage.main.total = Math.ceil(configDamage.main.total * multiplier * takenMultiplier);
}
damagePromises.push(
@ -183,13 +170,19 @@ export default class DamageField extends fields.SchemaField {
/**
* Prepare formulas for Damage Roll
* Must be called within Action context or similar.
* @param {object[]} formulas Array of formatted formulas object
* @param {DHResourceData[]} damageData Array of DHResourceData
* @param {object} data Action getRollData
* @returns
*/
static formatFormulas(formulas, data) {
static formatFormulas(damageData, data) {
const formulas = damageData.map(x => ({
formula: DamageField.getFormulaValue.call(this, x, data).getFormula(this.actor),
damageTypes: x.type ?? new Set(),
applyTo: x.applyTo
}));
const formattedFormulas = [];
formulas.forEach(formula => {
for (const formula of formulas) {
if (isNaN(formula.formula))
formula.formula = Roll.replaceFormulaData(formula.formula, this.getRollData(data));
const same = formattedFormulas.find(
@ -197,7 +190,8 @@ export default class DamageField extends fields.SchemaField {
);
if (same) same.formula += ` + ${formula.formula}`;
else formattedFormulas.push(formula);
});
}
return formattedFormulas;
}
@ -275,10 +269,18 @@ export class DHActionDiceData extends foundry.abstract.DataModel {
};
}
/**
* @returns {string} the formula associated with this damage field
*/
getFormula() {
const multiplier = this.multiplier === 'flat' ? this.flatMultiplier : `@${this.multiplier}`,
bonus = this.bonus ? (this.bonus < 0 ? ` - ${Math.abs(this.bonus)}` : ` + ${this.bonus}`) : '';
return this.custom.enabled ? this.custom.formula : `${multiplier ?? 1}${this.dice}${bonus}`;
if (this.custom.enabled) return this.custom.formula;
const multiplier = this.multiplier === 'flat' ? this.flatMultiplier : `@${this.multiplier}`;
if (!multiplier) return String(this.bonus || 0);
const dice = `${multiplier ?? 1}${this.dice}`;
const sign = this.bonus < 0 ? ' - ' : ' + ';
return this.bonus ? `${dice} ${sign} ${Math.abs(this.bonus)}` : dice;
}
}
@ -286,6 +288,7 @@ export class DHResourceData extends foundry.abstract.DataModel {
/** @override */
static defineSchema() {
return {
base: new fields.BooleanField({ initial: false, readonly: true, label: 'Base' }),
applyTo: new fields.StringField({
choices: CONFIG.DH.GENERAL.healingTypes,
required: true,
@ -308,7 +311,16 @@ export class DHDamageData extends DHResourceData {
static defineSchema() {
return {
...super.defineSchema(),
base: new fields.BooleanField({ initial: false, readonly: true, label: 'Base' }),
includeBase: new fields.BooleanField({
initial: false,
label: 'DAGGERHEART.ACTIONS.Settings.includeBase.label'
}),
direct: new fields.BooleanField({ initial: false, label: 'DAGGERHEART.CONFIG.DamageType.direct.name' }),
groupAttack: new fields.StringField({
choices: CONFIG.DH.GENERAL.groupAttackRange,
blank: true,
label: 'DAGGERHEART.ACTIONS.Settings.groupAttack.label'
}),
type: new fields.SetField(
new fields.StringField({
choices: CONFIG.DH.GENERAL.damageTypes,

View file

@ -1,4 +1,4 @@
import { itemAbleRollParse, triggerChatRollFx } from '../../../helpers/utils.mjs';
import { getWorldActor, itemAbleRollParse, triggerChatRollFx } from '../../../helpers/utils.mjs';
import FormulaField from '../formulaField.mjs';
const fields = foundry.data.fields;
@ -23,7 +23,7 @@ export default class DHSummonField extends fields.ArrayField {
super(summonFields, options, context);
}
static async execute() {
static async execute(config) {
if (!canvas.scene) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.summon.error'));
return;
@ -36,13 +36,14 @@ export default class DHSummonField extends fields.ArrayField {
const rolls = [];
const summonData = [];
const chatMessageData = [];
for (const summon of this.summon) {
const roll = new Roll(itemAbleRollParse(summon.count, this.actor, this.item));
await roll.evaluate();
const count = roll.total;
if (!roll.isDeterministic) rolls.push(roll);
const actor = await DHSummonField.getWorldActor(await foundry.utils.fromUuid(summon.actorUUID));
const actor = await getWorldActor(await foundry.utils.fromUuid(summon.actorUUID));
/* Extending summon data in memory so it's available in actionField.toChat. Think it's harmless, but ugly. Could maybe find a better way. */
summon.actor = actor.toObject();
@ -54,30 +55,18 @@ export default class DHSummonField extends fields.ArrayField {
tokenPreviewName: `${actor.prototypeToken.name}${remaining > 1 ? ` (${remaining}x)` : ''}`
});
}
chatMessageData.push({
data: actor,
quantity: countNumber
});
}
if (rolls.length) await triggerChatRollFx(rolls);
this.actor.sheet?.minimize();
DHSummonField.handleSummon(summonData, this.actor);
}
/* Check for any available instances of the actor present in the world if we're missing artwork in the compendium. If none exists, create one. */
static async getWorldActor(baseActor) {
const dataType = game.system.api.data.actors[`Dh${baseActor.type.capitalize()}`];
if (baseActor.inCompendium && dataType && baseActor.img === dataType.DEFAULT_ICON) {
const worldActorCopy = game.actors.find(x => x.name === baseActor.name);
if (worldActorCopy) return worldActorCopy;
return await game.system.api.documents.DhpActor.create(baseActor.toObject());
}
return baseActor;
}
static async handleSummon(summonData, actionActor) {
await CONFIG.ux.TokenManager.createTokensWithPreview(summonData, { elevation: actionActor.token?.elevation });
return actionActor.sheet?.maximize();
await CONFIG.ux.TokenManager.createTokensWithPreview(summonData, { elevation: this.actor.token?.elevation });
this.actor.sheet?.maximize();
config.summonData = chatMessageData;
}
}

View file

@ -1,5 +1,11 @@
import { getWorldActor } from '../../../helpers/utils.mjs';
const fields = foundry.data.fields;
/**
* @import DHSummonAction from '../../action/summonAction.mjs'
*/
export default class DHSummonField extends fields.SchemaField {
/**
* Action Workflow order
@ -20,6 +26,11 @@ export default class DHSummonField extends fields.SchemaField {
super(transformFields, options, context);
}
/**
* Runs the execute. This is run on behalf of DHSummonAction.
* @todo move this function to be on the summon action.
* @this DHSummonAction
*/
static async execute() {
if (!this.transform.actorUUID) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.transform.noTransformActor'));
@ -37,26 +48,37 @@ export default class DHSummonField extends fields.SchemaField {
return false;
}
if (this.actor.prototypeToken.actorLink) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.transform.actorLinkError'));
const activeTokens = this.actor.getActiveTokens(false, true);
const controlledMatchingTokens = canvas.tokens.controlled
.filter(x => x.actor && x.actor.uuid === this.actor.uuid)
.map(x => x.document);
/** @type {typeof game.system.api.documents.DhToken | null} */
const token = this.actor.token ?? (
activeTokens.length === 1 ? activeTokens[0] :
(controlledMatchingTokens.length === 1 ? controlledMatchingTokens[0] : null)
);
if (!this.actor.token && !token) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.transform.linkedSelectedError'));
return false;
}
if (!this.actor.token) {
if (!token) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.transform.prototypeError'));
return false;
}
const actor = await DHSummonField.getWorldActor(baseActor);
const actor = await getWorldActor(baseActor);
const tokenSizes = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).tokenSizes;
const tokenSize = actor?.system.metadata.usesSize ? tokenSizes[actor.system.size] : actor.prototypeToken.width;
await this.actor.token.update(
{ ...actor.prototypeToken.toJSON(), actorId: actor.id, width: tokenSize, height: tokenSize },
{ diff: false, recursive: false, noHook: true }
// Update token. Avoid using recursive: false, since that prevents animations
await token.update(
{ ...actor.prototypeToken.toObject(), actorId: actor.id, width: tokenSize, height: tokenSize },
{ diff: false, noHook: true }
);
if (this.actor.token.combatant) {
if (token.combatant) {
this.actor.token.combatant.update({ actorId: actor.id, img: actor.prototypeToken.texture.src });
}
@ -64,17 +86,17 @@ export default class DHSummonField extends fields.SchemaField {
if (!this.transform.resourceRefresh.hitPoints) {
marks.hitPoints = Math.min(
this.actor.system.resources.hitPoints.value,
this.actor.token.actor.system.resources.hitPoints.max - 1
token.actor.system.resources.hitPoints.max - 1
);
}
if (!this.transform.resourceRefresh.stress) {
marks.stress = Math.min(
this.actor.system.resources.stress.value,
this.actor.token.actor.system.resources.stress.max - 1
token.actor.system.resources.stress.max - 1
);
}
if (marks.hitPoints || marks.stress) {
this.actor.token.actor.update({
token.actor.update({
'system.resources': {
hitPoints: { value: marks.hitPoints },
stress: { value: marks.stress }
@ -84,20 +106,9 @@ export default class DHSummonField extends fields.SchemaField {
const prevPosition = { ...this.actor.sheet.position };
this.actor.sheet.close();
this.actor.token.actor.sheet.render({ force: true, position: prevPosition });
}
/* Check for any available instances of the actor present in the world, or create a world actor based on compendium */
static async getWorldActor(baseActor) {
if (!baseActor.inCompendium) return baseActor;
const dataType = game.system.api.data.actors[`Dh${baseActor.type.capitalize()}`];
if (dataType && baseActor.img === dataType.DEFAULT_ICON) {
const worldActorCopy = game.actors.find(x => x.name === baseActor.name);
if (worldActorCopy) return worldActorCopy;
token.actor.sheet.render({ force: true, position: prevPosition });
if (token.object.controlled) {
ui.effectsDisplay.refresh();
}
const worldActor = await game.system.api.documents.DhpActor.create(baseActor.toObject());
return worldActor;
}
}

View file

@ -238,6 +238,7 @@ export function ActionMixin(Base) {
result = this.parent;
} else {
result = await this.item.update({ [path]: updates }, options);
if (!result) return result;
}
return this.inCollection
@ -269,10 +270,7 @@ export function ActionMixin(Base) {
return this.delete();
}
async toChat(origin) {
const autoExpandDescription = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance)
.expandRollMessage?.desc;
async toChat(origin, config) {
const cls = getDocumentClass('ChatMessage');
const systemData = {
title: game.i18n.localize('DAGGERHEART.CONFIG.FeatureForm.action'),
@ -282,7 +280,7 @@ export function ActionMixin(Base) {
img: this.baseAction ? this.parent.parent.img : this.img,
tags: this.tags ? this.tags : ['Spell', 'Arcana', 'Lv 10'],
areas: this.areas,
summon: this.summon
summon: config?.summonData
},
source: {
actor: this.actor.uuid,
@ -307,7 +305,7 @@ export function ActionMixin(Base) {
system: systemData,
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/ui/chat/action.hbs',
{ ...systemData, open: autoExpandDescription ? 'open' : '' }
systemData
),
flags: {
daggerheart: {

View file

@ -8,7 +8,8 @@ export default class DHArmor extends AttachableItem {
type: 'armor',
hasDescription: true,
isInventoryItem: true,
hasActions: true
hasActions: true,
hasResource: true
});
}
@ -52,6 +53,10 @@ export default class DHArmor extends AttachableItem {
);
}
get itemFeatures() {
return this.armorFeatures;
}
/**@inheritdoc */
async getDescriptionData() {
const baseDescription = this.description;
@ -169,8 +174,4 @@ export default class DHArmor extends AttachableItem {
const labels = [`${game.i18n.localize('DAGGERHEART.ITEMS.Armor.baseScore')}: ${this.armor.max}`];
return labels;
}
get itemFeatures() {
return this.armorFeatures;
}
}

View file

@ -49,7 +49,10 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
})
};
if (this.metadata.hasDescription) schema.description = new fields.HTMLField({ required: true, nullable: true });
if (this.metadata.hasDescription) {
schema.description = new fields.HTMLField({ required: true, nullable: true });
schema.gmNotes = new fields.HTMLField({ required: true, nullable: true });
}
if (this.metadata.hasResource) {
schema.resource = new fields.SchemaField(
@ -134,7 +137,7 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
/**
* Augments the description for the item with type specific info to display. Implemented in applicable item subtypes.
* @param {object} [options] - Options that modify the styling of the rendered template. { headerStyle: undefined|'none'|'large' }
* @returns {string}
* @returns {Promise<{ prefix: string | null; value: string | null; suffix: string | null }>}
*/
async getDescriptionData(_options) {
return { prefix: null, value: this.description, suffix: null };
@ -143,16 +146,26 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
/**
* Gets the enriched and augmented description for the item.
* @param {object} [options] - Options that modify the styling of the rendered template. { headerStyle: undefined|'none'|'large' }
* @returns {string}
* @returns {Promise<string>}
*/
async getEnrichedDescription() {
async getEnrichedDescription({ gmNotes = true } = {}) {
if (!this.metadata.hasDescription) return '';
const { prefix, value, suffix } = await this.getDescriptionData();
const fullDescription = [prefix, value, suffix].filter(p => !!p).join('\n<hr>\n');
let fullDescription = [prefix, value, suffix].filter(p => !!p).join('\n<hr>\n');
if (this.gmNotes && gmNotes) {
const gmNotesElement = document.createElement('section');
gmNotesElement.classList.add('gm-notes-section');
gmNotesElement.dataset.visibility = 'gm';
const header = document.createElement('header');
header.classList.add('gm-notes');
header.textContent = _loc('DAGGERHEART.ITEMS.FIELDS.gmNotes.label');
gmNotesElement.innerHTML = header.outerHTML + this.gmNotes;
fullDescription += gmNotesElement.outerHTML;
}
return await foundry.applications.ux.TextEditor.implementation.enrichHTML(fullDescription, {
relativeTo: this,
relativeTo: this.parent,
rollData: this.getRollData(),
secrets: this.parent.isOwner
});

View file

@ -9,7 +9,8 @@ export default class DHWeapon extends AttachableItem {
type: 'weapon',
hasDescription: true,
isInventoryItem: true,
hasActions: true
hasActions: true,
hasResource: true
});
}
@ -66,13 +67,11 @@ export default class DHWeapon extends AttachableItem {
type: 'attack'
},
damage: {
parts: {
hitPoints: {
type: ['physical'],
value: {
multiplier: 'prof',
dice: 'd8'
}
main: {
type: ['physical'],
value: {
multiplier: 'prof',
dice: 'd8'
}
}
}
@ -113,6 +112,18 @@ export default class DHWeapon extends AttachableItem {
);
}
get itemFeatures() {
return this.weaponFeatures;
}
get hasReload() {
return Boolean(this.weaponFeatures.find(x => x.value === 'reloading'));
}
get needsReload() {
return this.hasReload && this.resource.value === 0;
}
/**@inheritdoc */
async getDescriptionData() {
const baseDescription = this.description;
@ -225,11 +236,12 @@ export default class DHWeapon extends AttachableItem {
game.i18n.localize(`DAGGERHEART.CONFIG.Burden.${burden}`)
];
for (const { value, type } of attack.damage.parts) {
if (attack.damage.main) {
const { value, type } = attack.damage.main;
const parts = value.custom.enabled ? [game.i18n.localize('DAGGERHEART.GENERAL.custom')] : [value.dice];
if (!value.custom.enabled && value.bonus) parts.push(value.bonus.signedString());
if (type.size > 0) {
if (type?.size) {
const typeTags = Array.from(type)
.map(t => game.i18n.localize(`DAGGERHEART.CONFIG.DamageType.${t}.abbreviation`))
.join(' | ');
@ -238,7 +250,7 @@ export default class DHWeapon extends AttachableItem {
tags.push(parts.join(''));
}
return tags;
}
@ -253,10 +265,10 @@ export default class DHWeapon extends AttachableItem {
if (roll.trait) labels.push(game.i18n.localize(`DAGGERHEART.CONFIG.Traits.${roll.trait}.short`));
if (range) labels.push(game.i18n.localize(`DAGGERHEART.CONFIG.Range.${range}.short`));
for (const { value, type } of damage.parts) {
for (const { value, type } of [damage.main, ...damage.resources].filter(d => !!d)) {
const str = Roll.replaceFormulaData(value.getFormula(), this.actor?.getRollData() ?? {});
const icons = Array.from(type)
const icons = Array.from(type ?? [])
.map(t => CONFIG.DH.GENERAL.damageTypes[t]?.icon)
.filter(Boolean);
@ -269,8 +281,4 @@ export default class DHWeapon extends AttachableItem {
return labels;
}
get itemFeatures() {
return this.weaponFeatures;
}
}

View file

@ -196,6 +196,13 @@ export default class DhAutomation extends foundry.abstract.DataModel {
})
})
}),
reload: new fields.StringField({
required: true,
choices: CONFIG.DH.SETTINGS.reloadChoices,
initial: CONFIG.DH.SETTINGS.reloadChoices.button.id,
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.reload.label',
hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.reload.hint'
}),
autoExpireActiveEffects: new fields.BooleanField({
required: true,
initial: true,

View file

@ -1,3 +1,5 @@
import { ChatDamageData } from './chat-message/chatDamageData.mjs';
export default class TagTeamData extends foundry.abstract.DataModel {
static defineSchema() {
const fields = foundry.data.fields;
@ -37,6 +39,7 @@ export class MemberData extends foundry.abstract.DataModel {
}),
rollChoice: new fields.StringField({ nullable: true, initial: null }),
rollData: new fields.JSONField({ nullable: true, initial: null }),
damageRollData: new fields.EmbeddedDataField(ChatDamageData),
selected: new fields.BooleanField({ initial: false })
};
}

View file

@ -4,4 +4,8 @@ export default class BaseRoll extends Roll {
/** @inheritdoc */
static TOOLTIP_TEMPLATE = 'systems/daggerheart/templates/ui/chat/foundryRollTooltip.hbs';
get modifierTotal() {
return this.total - this.dice.reduce((acc, dice) => acc + dice.total, 0);
}
}

View file

@ -185,8 +185,10 @@ export default class D20Roll extends DHRoll {
return changeKeys;
}
static postEvaluate(roll, config = {}) {
const data = super.postEvaluate(roll, config);
static async buildEvaluate(roll, config = {}, message = {}) {
await super.buildEvaluate(roll, config, message);
const data = config.roll;
data.type = config.actionType;
data.difficulty = config.roll.difficulty;
if (config.targets?.length) {
@ -222,7 +224,6 @@ export default class D20Roll extends DHRoll {
};
});
data.modifierTotal = roll.modifierTotal;
return data;
}
resetFormula() {

View file

@ -13,30 +13,34 @@ export default class DamageRoll extends DHRoll {
static DefaultDialog = DamageDialog;
static async buildEvaluate(roll, config = {}, message = {}) {
if (config.dialog.configure === false) roll.constructFormula(config);
if (config.evaluate !== false) for (const roll of config.roll) await roll.roll.evaluate();
roll._evaluated = true;
const parts = [];
for (const roll of config.roll) {
parts.push(this.postEvaluate(roll));
roll.roll = JSON.stringify(roll.roll.toJSON());
}
config.damage = this.unifyDamageRoll(parts);
static createRollInstance(config) {
return new this(undefined, config.data, config);
}
static postEvaluate(roll, config = {}) {
return {
...roll,
...super.postEvaluate(roll.roll, config),
damageTypes: [...(roll.damageTypes ?? [])],
roll: roll.roll,
type: config.type,
modifierTotal: this.calculateTotalModifiers(roll.roll)
};
/** @inheritdoc */
static async buildEvaluate(roll, config = {}) {
if (config.dialog.configure === false) roll.constructFormulas(config);
const evaluateRoll = async roll => {
await roll.roll.evaluate();
roll.roll.options = { damageTypes: roll.damageTypes ? [...roll.damageTypes] : [] };
return roll.roll;
}
if (!config.damage) config.damage = { main: null, resources: {} };
if (config.damageFormula) {
config.damage.main = await evaluateRoll(config.damageFormula);
config.damage.main.options = { damageTypes:
config.damageFormula.damageTypes ? [...config.damageFormula.damageTypes] : []
};
}
for (const roll of config.resourceFormulas) {
config.damage.resources[roll.applyTo] = await evaluateRoll(roll);
}
roll._evaluated = true;
}
static async buildPost(roll, config, message) {
@ -47,9 +51,10 @@ export default class DamageRoll extends DHRoll {
const diceRolls = [];
if (game.modules.get('dice-so-nice')?.active) {
config.mute = true;
const pool = foundry.dice.terms.PoolTerm.fromRolls(
Object.values(config.damage).flatMap(r => r.parts.map(p => p.roll))
);
const pool = foundry.dice.terms.PoolTerm.fromRolls([
...(config.damage.main ? [config.damage.main] : []),
...Object.values(config.damage.resources)
]);
diceRolls.push(Roll.fromTerms([pool]));
}
@ -60,22 +65,14 @@ export default class DamageRoll extends DHRoll {
await super.buildPost(roll, config, message);
if (config.source?.message) {
chatMessage.update({ 'system.damage': config.damage });
chatMessage.update({ 'system.damage': {
...config.damage.toObject(),
main: config.damage.main,
resources: config.damage.resources
}});
}
}
static unifyDamageRoll(rolls) {
const unified = {};
rolls.forEach(r => {
const resource = unified[r.applyTo] ?? { formula: '', total: 0, parts: [] };
resource.formula += `${resource.formula !== '' ? ' + ' : ''}${r.formula}`;
resource.total += r.total;
resource.parts.push(r);
unified[r.applyTo] = resource;
});
return unified;
}
static formatGlobal(rolls) {
let formula, total;
const applyTo = new Set(rolls.flatMap(r => r.applyTo));
@ -124,12 +121,10 @@ export default class DamageRoll extends DHRoll {
const type = this.options.messageType ?? (this.options.hasHealing ? 'healing' : 'damage');
const changeKeys = [];
for (const roll of this.options.roll) {
for (const damageType of roll.damageTypes?.values?.() ?? []) {
changeKeys.push(`system.bonuses.${type}.${damageType}`);
}
for (const damageType of this.options.damageFormula?.damageTypes?.values?.() ?? []) {
changeKeys.push(`system.bonuses.${type}.${damageType}`);
}
const item = this.data.parent?.items?.get(this.options.source.item);
if (item) {
switch (item.type) {
@ -145,62 +140,69 @@ export default class DamageRoll extends DHRoll {
return changeKeys;
}
constructFormula(config) {
constructFormulas(config) {
return {
damageFormula: this.constructFormula(this.options.damageFormula, config, true),
resourceFormulas: this.options.resourceFormulas.map(x => this.constructFormula(x, config))
};
}
constructFormula(formulaData, config, isDamage) {
if (!formulaData) return null;
this.options.isCritical = config.isCritical;
for (const [index, part] of this.options.roll.entries()) {
const isHitpointPart = part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id;
part.roll = new Roll(Roll.replaceFormulaData(part.formula, config.data));
part.roll.terms = Roll.parse(part.roll.formula, config.data);
if (part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
part.modifiers = this.applyBaseBonus(part);
this.addModifiers(part);
part.modifiers?.forEach(m => {
part.roll.terms.push(...this.formatModifier(m.value));
});
formulaData.roll = new Roll(Roll.replaceFormulaData(formulaData.formula, config.data));
formulaData.roll.terms = Roll.parse(formulaData.roll.formula, config.data);
if (formulaData.extraFormula) {
formulaData.roll.terms.push(
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
...this.constructor.parse(formulaData.extraFormula, this.options.data)
);
}
if (isDamage && formulaData.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
formulaData.modifiers = this.applyBaseBonus(formulaData);
this.addModifiers(formulaData);
formulaData.modifiers?.forEach(m => {
formulaData.roll.terms.push(...this.formatModifier(m.value));
});
/* To Remove When Reaction System */
for (const mod in config.modifiers) {
const modifier = config.modifiers[mod];
if (
modifier.beforeCrit === true &&
(modifier.enabled || modifier.value)
) modifier.callback(formulaData);
}
/* To Remove When Reaction System */
if (index === 0 && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
for (const mod in config.modifiers) {
const modifier = config.modifiers[mod];
if (modifier.beforeCrit === true && (modifier.enabled || modifier.value)) modifier.callback(part);
}
for (const mod in config.modifiers) {
const modifier = config.modifiers[mod];
if (!modifier.beforeCrit && (modifier.enabled || modifier.value)) modifier.callback(formulaData);
}
if (part.extraFormula) {
part.roll.terms.push(
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
...this.constructor.parse(part.extraFormula, this.options.data)
);
}
if (config.damageOptions.groupAttack?.numAttackers > 1 && isHitpointPart) {
if (config.damageOptions.groupAttack?.numAttackers > 1) {
const damageTypes = [foundry.dice.terms.Die, foundry.dice.terms.NumericTerm];
for (const term of part.roll.terms) {
for (const term of formulaData.roll.terms) {
if (damageTypes.some(type => term instanceof type)) {
term.number *= config.damageOptions.groupAttack.numAttackers;
}
}
}
if (config.isCritical && isHitpointPart) {
const total = part.roll.dice.reduce((acc, term) => acc + term._faces * term._number, 0);
if (config.isCritical) {
const total = formulaData.roll.dice.reduce((acc, term) => acc + term._faces * term._number, 0);
if (total > 0) {
part.roll.terms.push(...this.formatModifier(total));
formulaData.roll.terms.push(...this.formatModifier(total));
}
}
/* To Remove When Reaction System */
if (index === 0 && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
for (const mod in config.modifiers) {
const modifier = config.modifiers[mod];
if (!modifier.beforeCrit && (modifier.enabled || modifier.value)) modifier.callback(part);
}
}
part.roll._formula = this.constructor.getFormula(part.roll.terms);
}
return this.options.roll;
formulaData.roll._formula = this.constructor.getFormula(formulaData.roll.terms);
return formulaData;
}
/* To Remove When Reaction System */
@ -293,76 +295,4 @@ export default class DamageRoll extends DHRoll {
config.modifiers = mods;
return mods;
}
static async reroll(rollPart, dice, result) {
let diceIndex = 0;
let parsedRoll = game.system.api.dice.DamageRoll.fromData({
...rollPart.roll,
terms: rollPart.roll.terms.map(term => {
const isDie = term.class === 'Die';
const fixedTerm = {
...term,
...(isDie ? { results: rollPart.dice[diceIndex].results } : {})
};
if (isDie) diceIndex++;
return fixedTerm;
}),
class: 'DamageRoll',
evaluated: false
});
const parsedDiceTerms = Object.keys(parsedRoll.terms).reduce((acc, key) => {
const term = parsedRoll.terms[key];
if (term instanceof CONFIG.Dice.termTypes.DiceTerm) acc[Object.keys(acc).length] = term;
return acc;
}, {});
const term = parsedDiceTerms[dice];
const termResult = parsedDiceTerms[dice].results[result];
const newIndex = parsedDiceTerms[dice].results.length;
await term.reroll(`/r1=${termResult.result}`);
const diceRolls = [];
if (game.modules.get('dice-so-nice')?.active) {
const newResult = parsedDiceTerms[dice].results[newIndex];
diceRolls.push({
_evaluated: true,
dice: [
new foundry.dice.terms.Die({
...term,
total: newResult.result,
faces: term._faces,
results: [newResult]
})
],
options: { appearance: {} }
});
}
await triggerChatRollFx(diceRolls);
await parsedRoll.evaluate();
const results = parsedRoll.dice[dice].results.map(result => ({
...result,
discarded: !result.active
}));
const newResult = results.splice(results.length - 1, 1);
results.splice(Number(result) + 1, 0, newResult[0]);
const rerolledDice = parsedRoll.dice.map((x, index) => {
const isRerollDice = index === Number(dice);
if (!isRerollDice) return { ...x, dice: x.denomination };
return {
dice: parsedRoll.dice[dice].denomination,
total: parsedRoll.dice[dice].total,
results: results.map(result => ({
...result,
hasRerolls: result.hasRerolls || isRerollDice
}))
};
});
return { parsedRoll, rerolledDice };
}
}

View file

@ -1,7 +1,8 @@
import D20RollDialog from '../applications/dialogs/d20RollDialog.mjs';
import { triggerChatRollFx } from '../helpers/utils.mjs';
import BaseRoll from './baseRoll.mjs';
export default class DHRoll extends Roll {
export default class DHRoll extends BaseRoll {
baseTerms = [];
constructor(formula, data = {}, options = {}) {
super(formula, data, foundry.utils.mergeObject(options, { roll: [] }, { overwrite: false }));
@ -33,11 +34,17 @@ export default class DHRoll extends Roll {
if (config.skips?.createMessage) config.messageRoll = roll;
await this.buildEvaluate(roll, config, (message = {}));
if (config.evaluate !== false) {
await this.buildEvaluate(roll, config, (message = {}));
}
await this.buildPost(roll, config, (message = {}));
return config;
}
static createRollInstance(config) {
return new this(config.roll.formula, config.data, config);
}
/**
* @param {Partial<RollConfig>} config
* @returns {Promise<RollConfig>}
@ -55,7 +62,7 @@ export default class DHRoll extends Roll {
this.temporaryModifierBuilder(config);
let roll = new this(config.roll.formula, config.data, config);
let roll = this.createRollInstance(config);
if (config.dialog.configure !== false) {
// Open Roll Dialog
const DialogClass = config.dialog?.class ?? this.DefaultDialog;
@ -72,27 +79,14 @@ export default class DHRoll extends Roll {
return roll;
}
/**
* Evaluates the roll and assigns roll data into the config.
* This is only called if config.evaluate is not set to false
* @protected
*/
static async buildEvaluate(roll, config = {}, message = {}) {
if (config.evaluate !== false) {
await roll.evaluate();
config.roll = this.postEvaluate(roll, config);
}
}
static async buildPost(roll, config, message) {
for (const hook of config.hooks) {
if (Hooks.call(`${CONFIG.DH.id}.postRoll${hook.capitalize()}`, config, message) === false) return null;
}
if (config.skips?.createMessage) {
await triggerChatRollFx([roll]);
} else if (!config.source?.message) {
config.message = await this.toMessage(roll, config);
}
}
static postEvaluate(roll, config = {}) {
return {
await roll.evaluate();
config.roll = {
...roll.options.roll,
total: roll.total,
formula: roll.formula,
@ -105,9 +99,29 @@ export default class DHRoll extends Roll {
};
}
/**
* Runs any post configuration events that need to happen towards the end, such as hooks and dice so nice
* @protected
*/
static async buildPost(roll, config, message) {
for (const hook of config.hooks) {
if (Hooks.call(`${CONFIG.DH.id}.postRoll${hook.capitalize()}`, config, message) === false) return null;
}
if (config.skips?.createMessage) {
await triggerChatRollFx([roll]);
} else if (!config.source?.message) {
config.message = await this.toMessage(roll, config);
}
}
static async toMessage(roll, config) {
const item = config.data.parent?.items?.get?.(config.source.item) ?? null;
const action = item ? item.system.actions.get(config.source.action) : null;
const actions = item ? [
...item.system.actions,
...(item.system.attack?.id === config.source.action ? [item.system.attack] : [])
] : [];
const action = actions.find(x => x.id === config.source.action);
let actionDescription = null;
if (action?.chatDisplay) {
actionDescription = action
@ -119,6 +133,14 @@ export default class DHRoll extends Roll {
config.actionChatMessageHandled = true;
}
const reloadSetting =
game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).reload;
const useReload =
item?.system.hasReload &&
action?.type === 'attack' &&
reloadSetting === CONFIG.DH.SETTINGS.reloadChoices.auto.id;
const needsReload = useReload ? await action?.handleReload?.() : false;
const cls = getDocumentClass('ChatMessage'),
msgData = {
type: this.messageType,
@ -126,7 +148,7 @@ export default class DHRoll extends Roll {
title: roll.title,
speaker: cls.getSpeaker({ actor: roll.data?.parent }),
sound: config.mute ? null : CONFIG.sounds.dice,
system: { ...config, actionDescription },
system: { ...config, actionDescription, needsReload },
rolls: [roll]
};
@ -148,14 +170,17 @@ export default class DHRoll extends Roll {
if (!this._evaluated) return;
const metagamingSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Metagaming);
const automationSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
const chatData = await this._prepareChatRenderContext({ flavor, isPrivate, ...options });
return foundry.applications.handlebars.renderTemplate(template, {
roll: this,
...chatData,
action: chatData.action,
parent: chatData.parent,
targetMode: chatData.targetMode,
areas: chatData.action?.areas,
metagamingSettings
metagamingSettings,
automationSettings
});
}

View file

@ -3,6 +3,7 @@ import HopeDie from './hopeDie.mjs';
import FearDie from './fearDie.mjs';
import AdvantageDie from './advantageDie.mjs';
import DisadvantageDie from './disadvantageDie.mjs';
export { default as BaseDie } from './baseDie.mjs';
export const diceTypes = {
DualityDie,

View file

@ -1,4 +1,6 @@
export default class AdvantageDie extends foundry.dice.terms.Die {
import BaseDie from './baseDie.mjs';
export default class AdvantageDie extends BaseDie {
constructor(options) {
super(options);

View file

@ -0,0 +1,12 @@
export default class BaseDie extends foundry.dice.terms.Die {
async rerollResult(resultIndex) {
const result = this.results[resultIndex];
result.rerolled = true;
result.active = false;
await this.roll({ reroll: true });
const rerolledResult = this.results[this.results.length - 1];
this.results.splice(this.results.length - 1, 1);
this.results.splice(resultIndex, 0, rerolledResult);
}
}

View file

@ -1,4 +1,6 @@
export default class DisadvantageDie extends foundry.dice.terms.Die {
import BaseDie from './baseDie.mjs';
export default class DisadvantageDie extends BaseDie {
constructor(options) {
super(options);

View file

@ -1,6 +1,7 @@
import BaseDie from './baseDie.mjs';
import { updateResourcesForDualityReroll } from '../helpers.mjs';
export default class DualityDie extends foundry.dice.terms.Die {
export default class DualityDie extends BaseDie {
constructor(options) {
super(options);

View file

@ -232,22 +232,10 @@ export default class DualityRoll extends D20Roll {
return changeKeys;
}
/** @inheritdoc */
static async buildEvaluate(roll, config = {}, message = {}) {
await super.buildEvaluate(roll, config, message);
await setDiceSoNiceForDualityRoll(
roll,
config.roll.advantage.type,
config.roll.hope.dice,
config.roll.fear.dice,
config.roll.advantage.dice
);
}
static postEvaluate(roll, config = {}) {
const data = super.postEvaluate(roll, config);
data.hope = {
config.roll.hope = {
dice: roll.dHope.denomination,
value: this.guaranteedCritical ? 0 : roll.dHope.total,
rerolled: {
@ -255,7 +243,7 @@ export default class DualityRoll extends D20Roll {
rerolls: roll.dHope.results.filter(x => x.rerolled)
}
};
data.fear = {
config.roll.fear = {
dice: roll.dFear.denomination,
value: this.guaranteedCritical ? 0 : roll.dFear.total,
rerolled: {
@ -263,11 +251,11 @@ export default class DualityRoll extends D20Roll {
rerolls: roll.dFear.results.filter(x => x.rerolled)
}
};
data.rally = {
config.roll.rally = {
dice: roll.dRally?.denomination,
value: roll.dRally?.total
};
data.result = {
config.roll.result = {
duality: roll.withHope ? 1 : roll.withFear ? -1 : 0,
total: this.guaranteedCritical ? 0 : roll.dHope.total + roll.dFear.total,
label: roll.totalLabel
@ -275,11 +263,18 @@ export default class DualityRoll extends D20Roll {
if (roll._rallyIndex && roll.data?.parent)
roll.data.parent.deleteEmbeddedDocuments('ActiveEffect', [roll._rallyIndex]);
return data;
}
/** @inheritdoc */
static async buildPost(roll, config, message) {
await setDiceSoNiceForDualityRoll(
roll,
config.roll.advantage.type,
config.roll.hope.dice,
config.roll.fear.dice,
config.roll.advantage.dice
);
await super.buildPost(roll, config, message);
await DualityRoll.dualityUpdate(config);
@ -414,8 +409,4 @@ export default class DualityRoll extends D20Roll {
return rerolled;
}
fromJSON(json) {
return super.fromJSON(json);
}
}

View file

@ -75,25 +75,23 @@ export default class FateRoll extends D20Roll {
this.terms[0] = new foundry.dice.terms.Die({ faces: 12 });
}
/** @inheritdoc */
static async buildEvaluate(roll, config = {}, message = {}) {
await super.buildEvaluate(roll, config, message);
config.roll.fate = {
dice: roll.fateDie === 'Hope' ? roll.dHope.denomination : roll.dFear.denomination,
value: roll.fateDie === 'Hope' ? roll.dHope.total : roll.dFear.total,
fateDie: roll.fateDie
};
}
/** @inheritdoc */
static async buildPost(roll, config, message) {
if (roll.fateDie === 'Hope') {
await setDiceSoNiceForHopeFateRoll(roll, config.roll.fate.dice);
} else {
await setDiceSoNiceForFearFateRoll(roll, config.roll.fate.dice);
}
}
static postEvaluate(roll, config = {}) {
const data = super.postEvaluate(roll, config);
data.fate = {
dice: roll.fateDie === 'Hope' ? roll.dHope.denomination : roll.dFear.denomination,
value: roll.fateDie === 'Hope' ? roll.dHope.total : roll.dFear.total,
fateDie: roll.fateDie
};
return data;
return super.buildPost(roll, config, message);
}
}

View file

@ -3,17 +3,26 @@ import DHItem from './item.mjs';
import BaseDataItem from '../data/item/base.mjs';
import DhActiveEffect from './activeEffect.mjs';
import EmbeddedCollection from '@common/abstract/embedded-collection.mjs';
import DHToken from './token.mjs';
import Actor from '@client/documents/actor.mjs';
import Item from '@client/documents/item.mjs';
declare module './actor.mjs' {
export default interface DhpActor<T extends BaseDataActor = BaseDataActor> {
export default interface DhpActor<T extends BaseDataActor = BaseDataActor> extends Actor {
system: T;
items: EmbeddedCollection<DHItem>;
effects: EmbeddedCollection<DhActiveEffect>;
get token(): DHToken | null;
/** @inheritdoc */
getActiveTokens(linked?: boolean, document?: boolean): (DHToken | foundry.canvas.placeables.Token)[];
getActiveTokens(linked?: boolean, document: true): DHToken[];
getActiveTokens(linked?: boolean, document: false): foundry.canvas.placeables.Token[];
}
}
declare module './item.mjs' {
export default interface DHItem<T extends BaseDataItem = BaseDataItem> {
export default interface DHItem<T extends BaseDataItem = BaseDataItem> extends Item {
parent: DhpActor;
actor: DhpActor;
system: T;

View file

@ -65,6 +65,10 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
);
}
get hasDescription() {
return Boolean(this.description);
}
/* -------------------------------------------- */
/* Event Handlers */
/* -------------------------------------------- */

View file

@ -34,12 +34,14 @@ export default class DhpActor extends Actor {
super.prepareData();
// Update effects if it is the user's character or is controlled
if (canvas.ready) {
// A timeout avoids an infinite loop when accessing token actors before the delta is finished constructing
window.setTimeout(() => {
if (!canvas.ready) return;
const controlled = canvas.tokens.controlled.some(t => t.actor === this);
if (game.user.character === this || controlled) {
ui.effectsDisplay.render();
ui.effectsDisplay.refresh();
}
}
}, 0);
}
/* -------------------------------------------- */
@ -620,53 +622,63 @@ export default class DhpActor extends Actor {
return rollData;
}
#canReduceDamage(hpDamage, type) {
const { stressDamageReduction, disabledArmor } = this.system.rules.damageReduction;
/**
* Checks to see if damage can be reduced in one way or another.
* @param {number} hpDamage the amount of marked hp that will be marked
* @param {Set<string>} types a list of damage types
*/
#canReduceDamage(hpDamage, types) {
const { stressDamageReduction, disabledArmor, reduceSeverity, thresholdImmunities } =
this.system.rules.damageReduction;
if (disabledArmor) return false;
const availableStress = this.system.resources.stress.max - this.system.resources.stress.value;
const canUseArmor =
this.system.armorScore.value < this.system.armorScore.max &&
type.every(t => this.system.armorApplicableDamageTypes[t] === true);
types.every(t => this.system.armorApplicableDamageTypes[t] === true);
const canUseStress = Object.keys(stressDamageReduction).reduce((acc, x) => {
const rule = stressDamageReduction[x];
if (damageKeyToNumber(x) <= hpDamage) return acc || (rule.enabled && availableStress >= rule.cost);
return acc;
}, false);
return canUseArmor || canUseStress;
const hasReduceSeverity = types.some(t => reduceSeverity[t]);
const hasThresholdImmunity = Object.entries(thresholdImmunities)
.filter(([key, value]) => Boolean(value) && damageKeyToNumber(key) === hpDamage)
.length;
return canUseArmor || canUseStress || hasReduceSeverity || hasThresholdImmunity;
}
async takeDamage(damages, isDirect = false) {
if (Hooks.call(`${CONFIG.DH.id}.preTakeDamage`, this, damages) === false) return null;
async takeDamage(args, isDirect = false) {
args = this.#parseDamageArgs(args);
if (Hooks.call(`${CONFIG.DH.id}.preTakeDamage`, this, args) === false) return null;
if (this.type === 'companion') {
await this.modifyResource([{ value: 1, key: 'stress' }]);
return;
}
const updates = [];
const updates = args.resourceUpdates;
if (args.main) {
// todo: avoid side effects, but hook currently requires it
args.main.value = this.calculateDamage(args.main.value, args.main.damageTypes);
}
Object.entries(damages).forEach(([key, damage]) => {
damage.parts.forEach(part => {
if (part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id)
part.total = this.calculateDamage(part.total, part.damageTypes);
const update = updates.find(u => u.key === key);
if (update) {
update.value += part.total;
update.damageTypes.add(...new Set(part.damageTypes));
} else updates.push({ value: part.total, key, damageTypes: new Set(part.damageTypes) });
});
});
if (Hooks.call(`${CONFIG.DH.id}.postCalculateDamage`, this, args) === false) return null;
if (Hooks.call(`${CONFIG.DH.id}.postCalculateDamage`, this, damages) === false) return null;
// Convert deducted resources to a record of updates. Return if nothing to do.
if (!updates.some(u => u.value) && !args.main) return;
if (!updates.length) return;
const hpDamage = updates.find(u => u.key === CONFIG.DH.GENERAL.healingTypes.hitPoints.id);
if (hpDamage?.value) {
hpDamage.value = this.convertDamageToThreshold(hpDamage.value);
if (args.main) {
const hpDamage = {
value: this.convertDamageToThreshold(args.main.value),
damageTypes: new Set(args.main.damageTypes),
key: CONFIG.DH.GENERAL.healingTypes.hitPoints.id
};
if (this.type === 'character' && !isDirect && this.#canReduceDamage(hpDamage.value, hpDamage.damageTypes)) {
const armorSlotResult = await this.owner.query(
'armorSlot',
@ -681,7 +693,7 @@ export default class DhpActor extends Actor {
);
if (armorSlotResult) {
const { modifiedDamage, armorChanges, stressSpent } = armorSlotResult;
updates.find(u => u.key === 'hitPoints').value = modifiedDamage;
hpDamage.value = modifiedDamage;
for (const armorChange of armorChanges) {
updates.push({ value: armorChange.amount, key: 'armor', uuid: armorChange.uuid });
}
@ -691,20 +703,24 @@ export default class DhpActor extends Actor {
else updates.push({ value: stressSpent, key: 'stress' });
}
}
}
if (this.type === 'adversary') {
} else if (this.type === 'adversary') {
const reducedSeverity = hpDamage.damageTypes.reduce((value, curr) => {
return Math.max(this.system.rules.damageReduction.reduceSeverity[curr], value);
}, 0);
hpDamage.value = Math.max(hpDamage.value - reducedSeverity, 0);
if (
hpDamage.value &&
this.system.rules.damageReduction.thresholdImmunities[getDamageKey(hpDamage.value)]
) {
hpDamage.value -= 1;
if (this.system.rules.damageReduction.thresholdImmunities[getDamageKey(hpDamage.value)]) {
hpDamage.value = Math.max(0, hpDamage.value - 1);
}
}
// Merge existing hitPoint deduction with finalised damage deduction
const existing = updates.find(u => u.key === CONFIG.DH.GENERAL.healingTypes.hitPoints.id);
if (existing) {
existing.value += hpDamage.value;
existing.damageTypes = hpDamage.damageTypes;
} else {
updates.push(hpDamage);
}
}
const results = await game.system.registeredTriggers.runTrigger(
@ -719,12 +735,10 @@ export default class DhpActor extends Actor {
for (var result of results) resourceMap.addResources(result.updates);
resourceMap.updateResources();
}
updates.forEach(
u =>
(u.value =
u.key === 'fear' || this.system?.resources?.[u.key]?.isReversed === false ? u.value * -1 : u.value)
);
for (const u of updates) {
u.value = u.key === 'fear' || this.system?.resources?.[u.key]?.isReversed === false ? u.value * -1 : u.value;
}
await this.modifyResource(updates);
@ -733,6 +747,36 @@ export default class DhpActor extends Actor {
return updates;
}
async takeHealing(args) {
args = this.#parseDamageArgs({ resources: 'resources' in args ? args.resources : args });
if (Hooks.call(`${CONFIG.DH.id}.preTakeHealing`, this, args) === false) return null;
const updates = args.resourceUpdates;
for (const u of updates) {
const shouldFlip = !(u.key === 'fear' || this.system?.resources?.[u.key]?.isReversed === false);
u.value = shouldFlip ? u.value * -1 : u.value;
}
await this.modifyResource(updates);
if (Hooks.call(`${CONFIG.DH.id}.postTakeHealing`, this, updates) === false) return null;
return updates;
}
/** Parse damage args that may be coming from takeHealing or takeDamage. Used to simplify macro usage and roll vs non-roll usage */
#parseDamageArgs(args = {}) {
const damageRoll = 'total' in args ? args : (args.main ?? args.damage);
const damageValue = typeof damageRoll === 'number' ? damageRoll : damageRoll?.total;
const damageTypes = Array.from(damageRoll?.options?.damageTypes ?? damageRoll?.damageTypes ?? []);
const main = typeof damageValue === 'number' ? { key: 'damage', value: damageValue, damageTypes } : null;
const resourceUpdates = Object.entries(args.resources ?? {}).map(([key, damage]) => ({
key,
value: typeof damage === 'number' ? damage : damage?.total ?? 0
}));
return { main, resourceUpdates };
}
calculateDamage(baseDamage, type) {
if (this.canResist(type, 'immunity')) return 0;
if (this.canResist(type, 'resistance')) baseDamage = Math.ceil(baseDamage / 2);
@ -757,32 +801,6 @@ export default class DhpActor extends Actor {
return reduction === Infinity ? 0 : reduction;
}
async takeHealing(healings) {
if (Hooks.call(`${CONFIG.DH.id}.preTakeHealing`, this, healings) === false) return null;
const updates = [];
Object.entries(healings).forEach(([key, healing]) => {
healing.parts.forEach(part => {
const update = updates.find(u => u.key === key);
if (update) update.value += part.total;
else updates.push({ value: part.total, key });
});
});
updates.forEach(
u =>
(u.value = !(u.key === 'fear' || this.system?.resources?.[u.key]?.isReversed === false)
? u.value * -1
: u.value)
);
await this.modifyResource(updates);
if (Hooks.call(`${CONFIG.DH.id}.postTakeHealing`, this, updates) === false) return null;
return updates;
}
/**
* Resources are modified asynchronously, so be careful not to update the same resource in
* quick succession.

View file

@ -3,6 +3,13 @@ import { emitGMUpdate, emitGMCreate, GMUpdateEvent } from '../systemRegistration
export default class DhpChatMessage extends foundry.documents.ChatMessage {
targetHook = null;
static #EXPAND_SECTIONS = [
{ selector: 'roll-section [data-action="expandRoll"]', key: 'roll' },
{ selector: 'damage-section', key: 'damage' },
{ selector: 'target-section', key: 'target' },
{ selector: 'description-section', key: 'desc' }
];
async renderHTML() {
const actor = game.actors.get(this.speaker.actor);
const actorData =
@ -89,23 +96,26 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
}
}
// Check registered selectors and the main item section for expanding
// Preserving during re-render is handled by core foundry on anything with [data-action=expandRoll]
const autoExpandRoll = game.settings.get(
CONFIG.DH.id,
CONFIG.DH.SETTINGS.gameSettings.appearance
).expandRollMessage,
rollSections = html.querySelectorAll('.roll-part'),
itemDesc = html.querySelector('.domain-card-move');
rollSections.forEach(s => {
if (s.classList.contains('roll-section')) {
const toExpand = s.querySelector('[data-action="expandRoll"]');
toExpand.classList.toggle('expanded', autoExpandRoll.roll);
} else if (s.classList.contains('damage-section'))
s.classList.toggle('expanded', autoExpandRoll.damage);
else if (s.classList.contains('target-section')) s.classList.toggle('expanded', autoExpandRoll.target);
else if (s.classList.contains('description-section'))
s.classList.toggle('expanded', autoExpandRoll.desc);
});
if (itemDesc && autoExpandRoll.desc) itemDesc.setAttribute('open', '');
CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance
).expandRollMessage;
for (const { selector, key } of DhpChatMessage.#EXPAND_SECTIONS) {
const elements = html.querySelectorAll(selector);
for (const element of elements) {
element.classList.toggle('expanded', autoExpandRoll[key]);
}
}
// Auto expand the item description. These are not preserved by foundry during re-renders
const itemDesc = html.querySelector('details');
if (itemDesc) {
const existing = document.querySelector(`.chat-message[data-message-id="${this.id}"] details`);
if (existing?.hasAttribute('open') ?? autoExpandRoll.desc) {
itemDesc.setAttribute('open', '');
}
}
}
if (!this.isAuthor && !this.speakerActor?.isOwner) {
@ -276,8 +286,12 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
async onCreateAreas(event) {
const createArea = async selectedArea => {
const effects = selectedArea.effects.map(effect => this.system.action.item.effects.get(effect).uuid);
const { shape: type, size: range } = selectedArea;
const shapeData = CONFIG.Canvas.layers.regions.layerClass.getTemplateShape({ type, range });
const { shape: shapeType, size: range, hasHole } = selectedArea;
const shapeData = CONFIG.Canvas.layers.regions.layerClass.getTemplateShape({
shapeType,
range,
hasHole
});
const scene = game.scenes.get(game.user.viewedScene);
const level = scene.levels.find(x => x.isView);
@ -305,7 +319,10 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
visibility: CONST.REGION_VISIBILITY.ALWAYS
};
const placeRegion = data => {
canvas.regions.placeRegion(data, { create: true });
canvas.regions.placeRegion(data, {
create: true,
attachToToken: selectedArea.type === CONFIG.DH.ACTIONS.areaTypes.attached.id
});
};
// Regions with effects must be placed by the GM

View file

@ -89,6 +89,10 @@ export default class DHItem extends foundry.documents.Item {
return !pack?.locked && this.isOwner && isValidType && hasActions;
}
get hasDescription() {
return Boolean(this.system.description) || Boolean(this.system.itemFeatures?.length);
}
/** @inheritdoc */
static async createDialog(data = {}, createOptions = {}, options = {}) {
const { folders, types, template, context = {}, ...dialogOptions } = options;
@ -204,10 +208,7 @@ export default class DHItem extends foundry.documents.Item {
tags: this._getTags()
},
actions: item.system.actionsList,
description: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.system.description, {
relativeTo: this.parent,
rollData: this.parent?.getRollData() ?? {}
})
description: await this.system.getEnrichedDescription()
};
const msg = {

View file

@ -38,7 +38,8 @@ export default class DHToken extends CONFIG.Token.documentClass {
tokens.filter(x => x.actor).map(x => x.actor)
);
}
super.createCombatants(tokens, combat ?? {});
await super.createCombatants(tokens, combat ?? {});
}
/**@inheritdoc */

View file

@ -19,10 +19,10 @@ export default class DhTokenManager {
}
}
return await canvas.tokens.placeTokens(
const placedData = await canvas.tokens.placeTokens(
[
{
...actor.prototypeToken.toObject(),
...(await actor.getTokenDocument()).toObject(),
actorId: actor.id,
displayName: 50,
...tokenData
@ -30,6 +30,8 @@ export default class DhTokenManager {
],
{ create: false }
);
return placedData?.[0] ?? null;
}
/**
@ -46,22 +48,24 @@ export default class DhTokenManager {
const createElevation = elevation ?? level.elevation.bottom;
for (const tokenData of tokensData) {
const previewTokens = await this.createPreview(tokenData.actor, {
const previewToken = await this.createPreview(tokenData.actor, {
name: tokenData.tokenPreviewName,
level: game.user.viewedLevel,
elevation: createElevation,
flags: { daggerheart: { createPlacement: true } }
});
if (!previewTokens?.length) return null;
if (!previewToken) return null;
const finalTokenData = {
...previewToken.toObject(),
name: tokenData.actor.prototypeToken.name,
displayName: tokenData.actor.prototypeToken.displayName,
flags: tokenData.actor.prototypeToken.flags
};
await canvas.scene.createEmbeddedDocuments(
'Token',
previewTokens.map(x => ({
...x.toObject(),
name: tokenData.actor.prototypeToken.name,
displayName: tokenData.actor.prototypeToken.displayName,
flags: tokenData.actor.prototypeToken.flags
})),
[finalTokenData],
{ controlObject: true, parent: canvas.scene }
);
}

View file

@ -4,199 +4,234 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
#wide = false;
#bordered = false;
/** @inheritdoc */
async activate(element, options = {}) {
const { TextEditor } = foundry.applications.ux;
this.#wide = false;
this.#bordered = false;
let html = options.html;
if (element.dataset.tooltip?.startsWith('#battlepoints#')) {
this.#wide = true;
this.#bordered = true;
html = await this.getBattlepointHTML(element.dataset.combatId);
options.direction = this._determineItemTooltipDirection(element);
super.activate(element, { ...options, html: html });
const lockedTooltip = this.lockTooltip();
lockedTooltip.querySelectorAll('.battlepoint-toggle-container input').forEach(element => {
element.addEventListener('input', this.toggleModifier.bind(this));
});
return;
} else {
this.#wide = false;
this.#bordered = false;
const isMacro = document.getElementById('action-bar').contains(element);
const macro = isMacro ? game.macros.get(game.user.hotbar[Number(element.dataset.slot)] ?? null) : null;
const macroItemUuid = macro?.type === 'script' ? macro.command.match(/await game\.system\.api\.applications\.ui\.DhHotbar\.useItem\("([^"]+)"\);/)?.[1] : null;
if (macroItemUuid && await fromUuid(macroItemUuid, { strict: false })) {
element.dataset.tooltip = `#item#${macroItemUuid}`;
options.direction = this.constructor.TOOLTIP_DIRECTIONS.UP;
}
if (element.dataset.tooltip === '#effect-display#') {
this.#bordered = true;
let effect = {};
if (element.dataset.uuid) {
const effectItem = await foundry.utils.fromUuid(element.dataset.uuid);
const effectData = effectItem.toObject();
let html = options.html;
const key = element.dataset.tooltip?.match(/^#([\w-]+)#/)?.[1];
switch (key) {
case 'battlepoints':
return this.#activateBattlepoints(element, options);
case 'effect-display':
html = await this.#activateEffectDisplay(element, options);
break;
case 'item':
html = await this.#activateItem(element, options);
break;
case 'attack':
html = await this.#activateAttack(element, options);
break;
case 'shortRest':
case 'longRest':
html = await this.#activateRest(element, options);
break;
case 'advantage':
case 'disadvantage':
html = await this.#activateAdvantageDisadvantage(element, options);
break;
case 'deathMove':
html = await this.#activateDeathMove(element, options);
break;
}
effect = {
...effectData,
name: game.i18n.localize(effectData.name)
this.noOffset = options.noOffset;
super.activate(element, { ...options, html });
}
async #activateBattlepoints(element, options) {
this.#wide = true;
this.#bordered = true;
const html = await this.getBattlepointHTML(element.dataset.combatId);
options.direction = this._determineItemTooltipDirection(element);
super.activate(element, { ...options, html: html });
const lockedTooltip = this.lockTooltip();
lockedTooltip.querySelectorAll('.battlepoint-toggle-container input').forEach(element => {
element.addEventListener('input', this.toggleModifier.bind(this));
});
}
async #activateEffectDisplay(element, options) {
this.#bordered = true;
let effect = {};
if (element.dataset.uuid) {
const effectItem = await foundry.utils.fromUuid(element.dataset.uuid);
const effectData = effectItem.toObject();
effect = {
...effectData,
name: game.i18n.localize(effectData.name)
};
if (effectData.type === 'beastform') {
const beastformData = {
features: [],
advantageOn: effectData.system.advantageOn,
beastformAttackData: game.system.api.data.items.DHBeastform.getBeastformAttackData(effectItem)
};
if (effectData.type === 'beastform') {
const beastformData = {
features: [],
advantageOn: effectData.system.advantageOn,
beastformAttackData: game.system.api.data.items.DHBeastform.getBeastformAttackData(effectItem)
};
const features = effectItem.parent.items.filter(x => effectItem.system.featureIds.includes(x.id));
for (const feature of features) {
const featureData = feature.toObject();
featureData.enrichedDescription = await feature.system.getEnrichedDescription();
beastformData.features.push(featureData);
}
effect.description = await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/ui/tooltip/parts/beastformData.hbs',
{
item: { system: beastformData }
}
);
} else {
effect.description = game.i18n.localize(
effectData.description ?? effectData.parent.system.description
);
const features = effectItem.parent.items.filter(x => effectItem.system.featureIds.includes(x.id));
for (const feature of features) {
const featureData = feature.toObject();
featureData.enrichedDescription = await feature.system.getEnrichedDescription();
beastformData.features.push(featureData);
}
} else {
const conditions = CONFIG.DH.GENERAL.conditions();
const condition = conditions[element.dataset.condition];
effect = {
...condition,
name: game.i18n.localize(condition.name),
description: game.i18n.localize(condition.description),
appliedBy: element.dataset.appliedBy,
isLockedCondition: true
};
}
html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/effect-display.hbs`,
effect.description = await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/ui/tooltip/parts/beastformData.hbs',
{
item: { system: beastformData }
}
);
} else {
effect.description = game.i18n.localize(
effectData.description ?? effectData.parent.system.description
);
}
} else {
const conditions = CONFIG.DH.GENERAL.conditions();
const condition = conditions[element.dataset.condition];
effect = {
...condition,
name: game.i18n.localize(condition.name),
description: game.i18n.localize(condition.description),
appliedBy: element.dataset.appliedBy,
isLockedCondition: true
};
}
const html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/effect-display.hbs`,
{
effect
}
);
this.tooltip.innerHTML = html;
options.direction = this._determineItemTooltipDirection(element);
return html;
}
async #activateItem(element, options) {
const itemUuid = element.dataset.tooltip.slice(6);
const item = await foundry.utils.fromUuid(itemUuid);
if (item) {
const isAction = item instanceof game.system.api.models.actions.actionsTypes.base;
const isEffect = item instanceof ActiveEffect;
await this.enrichText(item);
const type = isAction ? 'action' : isEffect ? 'effect' : item.type;
const html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/${type}.hbs`,
{
effect
item: item,
description: item.system?.enrichedDescription ?? item.enrichedDescription,
config: CONFIG.DH,
allDomains: CONFIG.DH.DOMAIN.allDomains()
}
);
this.tooltip.innerHTML = html;
options.direction = this._determineItemTooltipDirection(element);
} else {
this.#bordered = false;
options.direction ??= this._determineItemTooltipDirection(element);
return html;
}
if (element.dataset.tooltip?.startsWith('#item#')) {
const itemUuid = element.dataset.tooltip.slice(6);
const item = await foundry.utils.fromUuid(itemUuid);
if (item) {
const isAction = item instanceof game.system.api.models.actions.actionsTypes.base;
const isEffect = item instanceof ActiveEffect;
await this.enrichText(item);
return null;
}
const type = isAction ? 'action' : isEffect ? 'effect' : item.type;
html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/${type}.hbs`,
{
item: item,
description: item.system?.enrichedDescription ?? item.enrichedDescription,
config: CONFIG.DH,
allDomains: CONFIG.DH.DOMAIN.allDomains()
}
);
async #activateAttack(element, options) {
const actorUuid = element.dataset.tooltip.slice(8);
const actor = await foundry.utils.fromUuid(actorUuid);
const attack = actor.system.attack;
this.tooltip.innerHTML = html;
options.direction = this._determineItemTooltipDirection(element);
const description = await foundry.applications.ux.TextEditor.enrichHTML(attack.description);
const html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/attack.hbs`,
{
attack: attack,
description: description,
parent: actor,
config: CONFIG.DH
}
} else {
const attack = element.dataset.tooltip?.startsWith('#attack#');
if (attack) {
const actorUuid = element.dataset.tooltip.slice(8);
const actor = await foundry.utils.fromUuid(actorUuid);
const attack = actor.system.attack;
);
const description = await TextEditor.enrichHTML(attack.description);
html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/attack.hbs`,
{
attack: attack,
description: description,
parent: actor,
config: CONFIG.DH
}
);
this.tooltip.innerHTML = html;
return html;
}
this.tooltip.innerHTML = html;
}
async #activateAdvantageDisadvantage(element, options) {
const isAdvantage = element.dataset.tooltip?.startsWith('#advantage#');
const actorUuid = element.dataset.tooltip.slice(isAdvantage ? 11 : 14);
const actor = await foundry.utils.fromUuid(actorUuid);
const shortRest = element.dataset.tooltip?.startsWith('#shortRest#');
const longRest = element.dataset.tooltip?.startsWith('#longRest#');
if (shortRest || longRest) {
const key = element.dataset.tooltip.slice(shortRest ? 11 : 10);
const moves = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).restMoves[
element.dataset.restType
].moves;
const move = moves[key];
const description = await TextEditor.enrichHTML(move.description);
html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/downtime.hbs`,
{
move: move,
description: description
}
);
this.tooltip.innerHTML = html;
options.direction = this._determineItemTooltipDirection(
element,
this.constructor.TOOLTIP_DIRECTIONS.RIGHT
);
}
const isAdvantage = element.dataset.tooltip?.startsWith('#advantage#');
const isDisadvantage = element.dataset.tooltip?.startsWith('#disadvantage#');
if (isAdvantage || isDisadvantage) {
const actorUuid = element.dataset.tooltip.slice(isAdvantage ? 11 : 14);
const actor = await foundry.utils.fromUuid(actorUuid);
if (actor) {
html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/advantage.hbs`,
{
sources: isAdvantage ? actor.system.advantageSources : actor.system.disadvantageSources
}
);
this.tooltip.innerHTML = html;
if (actor) {
const html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/advantage.hbs`,
{
sources: isAdvantage ? actor.system.advantageSources : actor.system.disadvantageSources
}
}
);
const deathMove = element.dataset.tooltip?.startsWith('#deathMove#');
if (deathMove) {
const name = element.dataset.deathName;
const img = element.dataset.deathImg;
const description = element.dataset.deathDescription;
html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/death-move.hbs`,
{
move: { name: name, img: img, description: description }
}
);
this.tooltip.innerHTML = html;
options.direction = this._determineItemTooltipDirection(
element,
this.constructor.TOOLTIP_DIRECTIONS.RIGHT
);
}
this.tooltip.innerHTML = html;
return html;
}
return null;
}
this.noOffset = options.noOffset;
super.activate(element, { ...options, html: html });
async #activateDeathMove(element, options) {
const name = element.dataset.deathName;
const img = element.dataset.deathImg;
const description = element.dataset.deathDescription;
const html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/death-move.hbs`,
{
move: { name: name, img: img, description: description }
}
);
this.tooltip.innerHTML = html;
options.direction = this._determineItemTooltipDirection(
element,
this.constructor.TOOLTIP_DIRECTIONS.RIGHT
);
return html;
}
async #activateRest(element, options) {
const isShortRest = element.dataset.tooltip?.startsWith('#shortRest#');
const key = element.dataset.tooltip.slice(isShortRest ? 11 : 10);
const moves = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).restMoves[
element.dataset.restType
].moves;
const move = moves[key];
const description = await foundry.applications.ux.TextEditor.enrichHTML(move.description);
const html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/downtime.hbs`,
{
move: move,
description: description
}
);
this.tooltip.innerHTML = html;
options.direction = this._determineItemTooltipDirection(
element,
this.constructor.TOOLTIP_DIRECTIONS.RIGHT
);
return html;
}
_setAnchor(direction) {

View file

@ -58,10 +58,11 @@ export const renderMeasuredTemplate = async event => {
if (!type || !range || !game.canvas.scene) return;
const shapeData = CONFIG.Canvas.layers.regions.layerClass.getTemplateShape({
type,
shapeType: type,
angle,
range,
direction
direction,
hasHole: false
});
await canvas.regions.placeRegion(

View file

@ -35,23 +35,24 @@ export const enricherConfig = [
];
export const enricherRenderSetup = element => {
const clickWrapper = func => event => {
event.stopPropagation();
func(event);
};
element
.querySelectorAll('.enriched-damage-button')
.forEach(element => element.addEventListener('click', renderDamageButton));
.forEach(element => element.addEventListener('click', clickWrapper(renderDamageButton)));
element
.querySelectorAll('.duality-roll-button')
.forEach(element => element.addEventListener('click', renderDualityButton));
.forEach(element => element.addEventListener('click', clickWrapper(renderDualityButton)));
element
.querySelectorAll('.fate-roll-button')
.forEach(element => element.addEventListener('click', renderFateButton));
.forEach(element => element.addEventListener('click', clickWrapper(renderFateButton)));
element
.querySelectorAll('.measured-template-button')
.forEach(element => element.addEventListener('click', renderMeasuredTemplate));
// element
// .querySelectorAll('.enriched-effect')
// .forEach(element => element.addEventListener('dragstart', dragEnrichedEffect));
.forEach(element => element.addEventListener('click', clickWrapper(renderMeasuredTemplate)));
};

View file

@ -48,9 +48,8 @@ export default class RegisterHandlebarsHelpers {
return formula;
}
static damageSymbols(damageParts) {
const allTypes = [...new Set([...damageParts].flatMap(x => Array.from(x.type)))];
const symbols = allTypes.map(p => CONFIG.DH.GENERAL.damageTypes[p].icon);
static damageSymbols(damageData) {
const symbols = damageData.type.map(p => CONFIG.DH.GENERAL.damageTypes[p].icon);
return new Handlebars.SafeString(Array.from(symbols).map(symbol => `<i class="fa-solid ${symbol}"></i>`));
}

View file

@ -1,6 +1,10 @@
import { diceTypes, getDiceSoNicePresets, getDiceSoNicePreset, range } from '../config/generalConfig.mjs';
import Tagify from '@yaireo/tagify';
/**
* @import DhpActor from '../documents/actor.mjs';
*/
export const capitalize = string => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
@ -696,19 +700,6 @@ export async function RefreshFeatures(
return refreshedActors;
}
export function getUnusedDamageTypes(parts) {
const usedKeys = Object.keys(parts);
return Object.keys(CONFIG.DH.GENERAL.healingTypes).reduce((acc, key) => {
if (!usedKeys.includes(key))
acc.push({
value: key,
label: game.i18n.localize(CONFIG.DH.GENERAL.healingTypes[key].label)
});
return acc;
}, []);
}
/** Returns resolved armor sources ordered by application order */
export function getArmorSources(actor) {
const rawArmorSources = Array.from(actor.allApplicableEffects()).filter(x => x.system.armorData);
@ -889,4 +880,33 @@ export async function triggerChatRollFx(rolls, options = { whisper: false, blind
export function shouldUseHopeFearAutomation(options = { gmAsPlayer: true }) {
const { hopeFear } = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
return (!game.user.isGM || options.gmAsPlayer) ? hopeFear.players : hopeFear.gm;
}
/**
* Returns the given actor if its a world actor,
* finds a world actor equivalent,
* or imports the actor and returns the imported actor.
* @param {DhpActor} baseActor
* @returns {Promise<DhpActor>} a world actor
*/
export async function getWorldActor(baseActor) {
if (baseActor.inCompendium) {
const worldActorCandidates = game.actors.filter(x =>
x._stats.compendiumSource === baseActor.uuid &&
x.prototypeToken.actorLink === baseActor.prototypeToken.actorLink
);
const worldActorCopy = worldActorCandidates.find(a => a.name === baseActor.name) ?? worldActorCandidates[0];
if (worldActorCopy) return worldActorCopy;
const baseActorData = baseActor;
return await game.system.api.documents.DhpActor.create({
...baseActorData,
_stats: {
...baseActorData._stats,
compendiumSource: baseActor.uuid
}
});
}
return baseActor;
}

View file

@ -0,0 +1,39 @@
import { MigrationHandlerBase } from './base.mjs';
export class Migration_2_5_2 extends MigrationHandlerBase {
version = '2.5.2';
/** @inheritdoc */
async updateActiveEffectSource(effectSource, item) {
let shouldUpdate = false;
const newChanges = [];
const srdItem = item?._stats?.compendiumSource ?
await foundry.utils.fromUuid(item?._stats.compendiumSource) :
null;
for (let i = 0; i < effectSource.system.changes.length; i++) {
const change = effectSource.system.changes[i];
const srdEffect = srdItem?.effects.find(x => x.name === effectSource.name);
if (change.type === 'custom') {
const srdChange = srdEffect ? srdEffect.system.changes[i] : null;
if (srdChange &&
change.key === srdChange.key &&
change.value === srdChange.value &&
change.type !== srdChange.type
) {
shouldUpdate = true;
newChanges.push(srdChange);
}
} else {
newChanges.push(change);
}
}
if (shouldUpdate) {
return {
_id: effectSource._id,
system: { changes: newChanges }
}
}
}
}

View file

@ -0,0 +1,20 @@
import { MigrationHandlerBase } from './base.mjs';
export class Migration_2_6_0 extends MigrationHandlerBase {
version = '2.6.0';
/** @inheritdoc */
async updateActorSource(actor) {
if (actor.type === 'party' && Object.keys(actor.system.tagTeam.members).length) {
return {
_id: actor._id,
system: {
tagTeam: {
initiator: null,
members: _replace({})
}
}
};
}
}
}

View file

@ -0,0 +1,117 @@
/**
* @import DHItem from "../../documents/item.mjs";
* @import DhActor from "../../documents/actor.mjs";
*/
/**
* The base class of an async migration.
* These are generally run between versions for things that require compendiums or must be done in post.
* The migrate() functions calls the various updateXSource() functions.
* Generally a subclass will override the version and the updateXSource() functions.
*/
export class MigrationHandlerBase {
version = null;
/**
* Gets change data for an active effect's source, or null if no changes
* @param {object} effectSource
* @param {DHItem} item
* @returns {Promise<object>}
* @protected
*/
async updateActiveEffectSource(effectSource, item) {
return null;
}
/**
* Update a world actor
* @param {DhActor} actor
* @returns {Promise<object>}
* @protected
*/
async updateActorSource(actor) {
return null;
}
async migrate() {
// todo: handle more than just migrating effects. Right now this can only migrate effects
// NOTE: the preload is hardcoded, we should not hardcode it
const numActors = game.actors.size;
const numItems = game.items.size;
const finalUpdateProgress = 5;
const DhProgress = game.system.api.applications.ui.DhProgress;
const preRunProgress = game.packs.size;
const progress = DhProgress.createMigrationProgress(
preRunProgress + numActors + numItems + finalUpdateProgress
);
// Preload. Avoid hardcoding in the future
for (const pack of game.packs) {
await pack.getDocuments();
progress.advance();
}
const batch = [];
const updateItem = async item => {
const itemUpdates = [];
for (const effect of item.effects) {
const changes = await this.updateActiveEffectSource(effect.toObject(), item);
if (changes) itemUpdates.push(changes);
}
if (itemUpdates.length) {
batch.push({
action: 'update',
documentName: 'ActiveEffect',
updates: itemUpdates,
parent: item
});
}
};
const updateActor = async actor => {
const actorUpdate = await this.updateActorSource(actor);
if (actorUpdate) {
batch.push({
action: 'update',
documentName: 'Actor',
updates: [actorUpdate]
});
}
const aeUpdates = [];
for (const item of actor.items) {
await updateItem(item);
}
for (const effect of actor.effects) {
const changes = await this.updateActiveEffectSource(effect.toObject(), { parent: actor });
if (changes) aeUpdates.push(changes);
}
if (aeUpdates.length) {
batch.push({
action: 'update',
documentName: 'ActiveEffect',
updates: aeUpdates,
parent: actor
});
}
}
for (const actor of game.actors) {
await updateActor(actor);
progress.advance();
}
for (const item of game.items) {
await updateItem(item);
progress.advance();
}
await foundry.documents.modifyBatch(batch);
progress.advance({ by: finalUpdateProgress });
}
}

View file

@ -1,5 +1,6 @@
import { defaultRestOptions } from '../config/generalConfig.mjs';
import { RefreshType, socketEvent } from './socket.mjs';
import { Migration_2_5_2 } from './migration-handlers/2_5_2.mjs';
import { Migration_2_6_0 } from './migration-handlers/2_6_0.mjs';
export async function runMigrations() {
let lastMigrationVersion = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion);
@ -153,61 +154,26 @@ export async function runMigrations() {
await pack.configure({ locked: true });
}
/* Migrate old countdown structure */
const countdownSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
const getCountdowns = (data, type) => {
return Object.keys(data.countdowns).reduce((acc, key) => {
const countdown = data.countdowns[key];
acc[key] = {
...countdown,
type: type,
ownership: Object.keys(countdown.ownership.players).reduce((acc, key) => {
acc[key] =
countdown.ownership.players[key].type === 1 ? 2 : countdown.ownership.players[key].type;
return acc;
}, {}),
progress: {
...countdown.progress,
type: countdown.progress.type.value
}
};
return acc;
}, {});
};
await countdownSettings.updateSource({
countdowns: {
...getCountdowns(countdownSettings.narrative, 'narrative'),
...getCountdowns(countdownSettings.encounter, 'encounter')
}
});
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns, countdownSettings);
game.socket.emit(`system.${CONFIG.DH.id}`, {
action: socketEvent.Refresh,
data: { refreshType: RefreshType.Countdown }
});
Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.Countdown });
lastMigrationVersion = '1.2.0';
}
if (foundry.utils.isNewerVersion('1.2.7', lastMigrationVersion)) {
const tagTeam = game.settings.get(CONFIG.DH.id, 'TagTeamRoll');
const initatorMissing = tagTeam.initiator && !game.actors.some(actor => actor.id === tagTeam.initiator);
const missingMembers = Object.keys(tagTeam.members).reduce((acc, id) => {
if (!game.actors.some(actor => actor.id === id)) {
acc[id] = _del;
}
return acc;
}, {});
try {
const tagTeam = game.settings.get(CONFIG.DH.id, 'TagTeamRoll');
const initatorMissing = tagTeam.initiator && !game.actors.some(actor => actor.id === tagTeam.initiator);
const missingMembers = Object.keys(tagTeam.members).reduce((acc, id) => {
if (!game.actors.some(actor => actor.id === id)) {
acc[id] = _del;
}
return acc;
}, {});
await tagTeam.updateSource({
initiator: initatorMissing ? null : tagTeam.initiator,
members: missingMembers
});
await game.settings.set(CONFIG.DH.id, 'TagTeamRoll', tagTeam);
await tagTeam.updateSource({
initiator: initatorMissing ? null : tagTeam.initiator,
members: missingMembers
});
await game.settings.set(CONFIG.DH.id, 'TagTeamRoll', tagTeam);
} catch { }
lastMigrationVersion = '1.2.7';
}
@ -303,6 +269,8 @@ export async function runMigrations() {
/* Migrate existing effects modifying armor, creating new Armor Effects instead */
const migrateEffects = async entity => {
if (!entity?.effects) return;
for (const effect of entity.effects) {
if (effect.system.changes.every(x => x.key !== 'system.armorScore')) continue;
@ -354,7 +322,20 @@ export async function runMigrations() {
lastMigrationVersion = '2.1.0';
}
//#endregion
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, lastMigrationVersion);
/* -------------------------------------------- */
/* New Style migrations below this point */
/* -------------------------------------------- */
const migrations = [
new Migration_2_5_2(),
new Migration_2_6_0()
].filter(m => m.version && foundry.utils.isNewerVersion(m.version, lastMigrationVersion));
for (const handler of migrations) {
await handler.migrate();
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, handler.version);
}
}

View file

@ -1,5 +1,5 @@
import DamageReductionDialog from '../applications/dialogs/damageReductionDialog.mjs';
import Party from '../applications/sheets/actors/party.mjs';
import PartySheet from '../applications/sheets/actors/party.mjs';
export function handleSocketEvent({ action = null, data = {} } = {}) {
switch (action) {
@ -16,7 +16,7 @@ export function handleSocketEvent({ action = null, data = {} } = {}) {
Hooks.call(socketEvent.Refresh, data);
break;
case socketEvent.DowntimeTrigger:
Party.downtimeMoveQuery(data);
PartySheet.downtimeMoveQuery(data);
break;
case socketEvent.TagTeamStart:
Hooks.callAll(CONFIG.DH.HOOKS.hooksConfig.tagTeamStart, data);

View file

@ -403,12 +403,6 @@
"_id": "9PsnogEPsp1OOK64",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "act"

View file

@ -322,32 +322,23 @@
"_id": "ia0NUIOxE3RHb45P",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
}
"changes": [
{
"key": "system.evasion",
"type": "override",
"value": "@system.evasion / 2",
"priority": 10
}
]
},
"changes": [
{
"key": "system.evasion",
"mode": 5,
"value": "@system.evasion / 2",
"priority": 10
}
],
"disabled": false,
"duration": {
"startTime": null,
"combat": null,
"seconds": null,
"rounds": null,
"turns": null,
"startRound": null,
"startTurn": null
"value": null,
"units": "seconds",
"expiry": null,
"expired": false
},
"description": "<p>When the Flickerfl y makes an attack, the targets Evasion is halved against the attack.</p>",
"disabled": false,
"description": "<p>When the Flickerfly makes an attack, the targets Evasion is halved against the attack.</p>",
"tint": "#ffffff",
"statuses": [],
"sort": 0,

View file

@ -491,12 +491,6 @@
"_id": "KGdf2eqcXkdigg0u",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "temporary",

View file

@ -325,21 +325,15 @@
"_id": "wGuxOLokMqdxVSOo",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
}
"changes": [
{
"key": "system.disadvantageSources",
"type": "add",
"value": "Agility Rolls",
"priority": null
}
]
},
"changes": [
{
"key": "system.disadvantageSources",
"mode": 2,
"value": "Agility Rolls",
"priority": null
}
],
"disabled": false,
"duration": {
"startTime": null,

View file

@ -472,14 +472,8 @@
"disabled": true,
"_id": "bq8hTzQoCXmA3xad",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
}
"changes": []
},
"changes": [],
"duration": {
"startTime": 0,
"combat": null

View file

@ -270,12 +270,6 @@
"_id": "2iBVUGHtGW3I9VIj",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "temporary",
@ -341,23 +335,17 @@
"name": "Out of Nowhere",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
}
"changes": [
{
"key": "system.advantageSources",
"type": "add",
"value": "On attacks if they are Hidden.",
"priority": null
}
]
},
"_id": "qT5nh7OcQ6aGdiWS",
"img": "icons/magic/perception/shadow-stealth-eyes-purple.webp",
"changes": [
{
"key": "system.advantageSources",
"mode": 2,
"value": "On attacks if they are Hidden.",
"priority": null
}
],
"disabled": false,
"duration": {
"startTime": null,
@ -452,12 +440,6 @@
"_id": "yP4ot8VqS56RnxnE",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": []
},
"disabled": false,

View file

@ -680,12 +680,6 @@
"_id": "9NQcCXMhjyBReJRd",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "temporary",
@ -927,12 +921,6 @@
"_id": "S7kJlhnV8Nexzi8l",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "temporary",

View file

@ -363,12 +363,6 @@
"_id": "U50Ccm9emMqAxma6",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "temporary",

View file

@ -371,12 +371,6 @@
"_id": "LmzztuktRkwOCy1a",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "temporary",

View file

@ -447,12 +447,6 @@
"_id": "CjMrSdL6kgD8mKRQ",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "temporary"

View file

@ -232,23 +232,17 @@
"name": "Levitation",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
}
"changes": [
{
"key": "system.rules.conditionImmunities.restrained",
"type": "override",
"value": "1",
"priority": null
}
]
},
"_id": "k6iaQVfMZhrpwYQj",
"img": "icons/magic/air/fog-gas-smoke-blue-gray.webp",
"changes": [
{
"key": "system.rules.conditionImmunities.restrained",
"mode": 5,
"value": "1",
"priority": null
}
],
"disabled": false,
"duration": {
"startTime": null,
@ -301,23 +295,17 @@
"name": "Wards",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
}
"changes": [
{
"key": "system.resistance.magical.resistance",
"type": "override",
"value": "1",
"priority": null
}
]
},
"_id": "4rj6PM0AGrrlbxSc",
"img": "icons/magic/defensive/barrier-shield-dome-blue-purple.webp",
"changes": [
{
"key": "system.resistance.magical.resistance",
"mode": 5,
"value": "1",
"priority": null
}
],
"disabled": false,
"duration": {
"startTime": null,

View file

@ -459,21 +459,15 @@
"_id": "xkDIZk9u2ipDHvOL",
"img": "icons/creatures/magical/construct-golem-stone-blue.webp",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
}
"changes": [
{
"key": "system.bonuses.damage.physical.bonus",
"type": "add",
"value": "10",
"priority": null
}
]
},
"changes": [
{
"key": "system.bonuses.damage.physical.bonus",
"mode": 2,
"value": "10",
"priority": null
}
],
"disabled": true,
"duration": {
"startTime": null,

View file

@ -315,12 +315,6 @@
"_id": "blcRqns0PHqiuPac",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "temporary",

View file

@ -331,12 +331,6 @@
"_id": "YNMhgBZW8ndrCjIp",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "scene"

View file

@ -415,12 +415,6 @@
"_id": "U9lWz1LgeAiK5L85",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [
{
"key": "system.resistance.magical.resistance",
@ -546,12 +540,6 @@
"_id": "lNH6srSPyEprXZ4o",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "temporary",

View file

@ -379,12 +379,6 @@
"_id": "LwWxRz7FTMA80VdA",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "temporary"

View file

@ -410,12 +410,6 @@
"_id": "F3E7fiz01AbF2kr5",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [],
"duration": {
"type": "temporary",

View file

@ -270,23 +270,17 @@
"name": "Numbers Must Go Up",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
}
"changes": [
{
"key": "system.bonuses.roll.attack.bonus",
"type": "add",
"value": "ITEM.@system.resource.value",
"priority": 21
}
]
},
"_id": "iLeiOlUtWvYsgbDQ",
"img": "icons/magic/control/fear-fright-monster-grin-red-orange.webp",
"changes": [
{
"key": "system.bonuses.roll.attack.bonus",
"mode": 2,
"value": "ITEM.@system.resource.value",
"priority": 21
}
],
"disabled": false,
"duration": {
"startTime": null,

View file

@ -238,23 +238,17 @@
"name": "Depths Of Despair",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
}
"changes": [
{
"key": "system.rules.attack.damage.hpDamageMultiplier",
"type": "override",
"value": "2",
"priority": null
}
]
},
"_id": "nofxm1vGZ2TmceA2",
"img": "icons/magic/death/skull-horned-worn-fire-blue.webp",
"changes": [
{
"key": "system.rules.attack.damage.hpDamageMultiplier",
"mode": 5,
"value": "2",
"priority": null
}
],
"disabled": true,
"duration": {
"startTime": null,
@ -356,12 +350,6 @@
"_id": "6WSx03mFbpbPWnOI",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [
{
"key": "system.rules.dualityRoll.defaultHopeDice",

View file

@ -319,12 +319,6 @@
"_id": "gFeHLGgeRoDdd3VG",
"type": "base",
"system": {
"rangeDependence": {
"enabled": false,
"type": "withinRange",
"target": "hostile",
"range": "melee"
},
"changes": [
{
"key": "system.rules.dualityRoll.defaultFearDice",

Some files were not shown because too many files have changed in this diff Show more