Compare commits

...

166 commits
1.9.4 ... main

Author SHA1 Message Date
WBHarry
e6d5a2f7d3
[Feature] Action Area SRD Updates (#1822)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
* Updated Environments

* Added remaining
2026-04-22 00:27:11 +02:00
Carlos Fernandez
545934aa60
Add background color to light theme header button (#1823) 2026-04-22 00:13:11 +02:00
Carlos Fernandez
7a4f9d7bc8
Tighten appearance of ability use chat messages (#1821) 2026-04-21 23:44:03 +02:00
WBHarry
3eda3c4c05
[Feature] Action Areas (#1815)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
* Functioning setup

* .

* Fixes

* Completed

* Apply suggestions from code review

Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com>

* using function.call instead of function.bind

* Run lint fix on action areas PR (#1820)

* .

* .

* Restructured getTemplateShape to be a lot more readable

* .

* .

* Changed from 'area' to 'areas'

* .

* Moved the areas button to the left

* Fix regression with actions list

* Updated all SRD adversaries

---------

Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com>
Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
2026-04-21 22:27:52 +02:00
WBHarry
646e0debbd Fixed a situation where TagTeamDialog's rollSelection part could get rendered in a bad situation 2026-04-21 18:25:23 +02:00
Carlos Fernandez
3cbc18f42b
Add eslint and run linter in workflow (#1819)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-04-21 10:15:39 +10:00
Carlos Fernandez
f850cbda76
[Feature] Updates to inventory icons, context menus, action use, and observer visibility (#1814)
* Update inventory controls and permissions filtering

* Also disable prosemirror editors

* Address context menu deprecation warnings

* Fix context menu detection for actions

* Refine logic for use action when hovering over item icon
2026-04-20 15:30:43 +02:00
WBHarry
f2ec5ef458 Merge branch 'main' of https://github.com/Foundryborne/daggerheart 2026-04-20 15:20:42 +02:00
WBHarry
c683bc4352 Fixed IncludeBaseDamage to be an override 2026-04-20 15:20:35 +02:00
Carlos Fernandez
fa04c9920f
Fix translation string (#1817) 2026-04-20 08:11:17 +02:00
WBHarry
03110377e1 Fixed so that resource reset on downtime can handle math expressions 2026-04-20 00:04:03 +02:00
WBHarry
1fea8438ba Fixed DowntimeMove actions not opening 2026-04-19 11:29:47 +02:00
Carlos Fernandez
4944722139
Avoid error when backing out of action (#1813) 2026-04-18 23:31:56 +02:00
Carlos Fernandez
4b92001f97
Fix issues with party sheet resources in light mode (#1810) 2026-04-17 19:29:37 +02:00
Carlos Fernandez
2fde61a1d5
[Feature] Make all item types quantifiable in the party (#1808)
* Show notification when invalid item types are added to actors

* Make all item types quantifiable in the party actor

* Remove from comment

* Use isInventoryItem to set quantity

* Fix formatting
2026-04-16 11:12:36 +02:00
Carlos Fernandez
d9b322406d
Fix party sheet rerenders from member updates interfering with currency and note input (#1809) 2026-04-16 10:23:55 +02:00
WBHarry
16c07d23bb Changed diceFaces->dieFaces for consistency 2026-04-16 09:57:16 +02:00
WBHarry
91aff8b10d
[Feature] Advantage Default Dice (#1802) 2026-04-16 03:55:12 -04:00
Carlos Fernandez
7e9385bc39
Add toggle for party sheet (#1806) 2026-04-16 09:22:26 +02:00
Carlos Fernandez
aa8771bf0d
Show notification when invalid item types are added to actors (#1807) 2026-04-16 08:23:25 +02:00
WBHarry
7d5cdeb09d
[Feature] Active Party (#1803) 2026-04-15 20:26:39 -04:00
WBHarry
8808e4646d Corrected use of Foundry's Reset translation 2026-04-15 18:47:20 +02:00
Carlos Fernandez
a77d2088a0
Increase reuse of gold and inventory styling (#1804) 2026-04-15 18:42:30 +02:00
WBHarry
c6335980ba Merge branch 'v14-dev' 2026-04-14 20:55:14 +02:00
WBHarry
1176328f62 Updated deploy.yml 2026-04-14 20:55:10 +02:00
a62d28cd96
updated contributing guidelines (#1800) 2026-04-14 18:51:28 +02:00
WBHarry
8d8dea81fe
[Fix] Compendium Advantage Sources (#1796)
* Duration Description field didn't show initially for type temporary

* Corrected SRD
2026-04-13 20:41:28 +02:00
Nikhil Nagarajan
fb07938e54
container fix (#1795) 2026-04-12 19:10:51 +02:00
WBHarry
c337338c8b Merge branch 'v14-dev' of https://github.com/Foundryborne/daggerheart into v14-dev 2026-04-12 13:58:51 +02:00
WBHarry
f900011510 Fixed trait counting in CharacterCreation. Fixed description layout and labels in CharacterCreation. Fixed drag/drop images from Compendium Browser 2026-04-12 13:58:43 +02:00
WBHarry
56a6613a73
Fixed more missing translations (#1792) 2026-04-12 11:38:15 +02:00
WBHarry
e003db3ec1 Corrected updateActorsRangeDependentEffects when token is null 2026-04-12 11:22:00 +02:00
WBHarry
66c90d69e3 Added saefety to updateActorsRangeDepenedentEffects 2026-04-12 11:10:02 +02:00
WBHarry
a839ca0066 Corrected deploy.yml for new branch 2026-04-12 00:36:24 +02:00
WBHarry
6ed975f5b7 Merge branch 'v14-dev' of https://github.com/Foundryborne/daggerheart into v14-dev 2026-04-12 00:33:04 +02:00
WBHarry
e2c97a7b61 Raised version 2026-04-12 00:32:59 +02:00
WBHarry
3ec013ff50
Reworked summon action and clowncar functionality to work with levels (#1791) 2026-04-12 00:25:43 +02:00
WBHarry
94f1fbdd9b Updated system.json 2026-04-12 00:21:16 +02:00
WBHarry
f22b67367b Updated system.json to point to V14 2026-04-11 23:57:33 +02:00
WBHarry
8a0b1b8e22
[Fix] Translation Fixes (#1789)
* Fixed translations

* .
2026-04-11 22:55:26 +02:00
WBHarry
1a57b55723 Fixed H4 elements in editors being hard to see in light mode 2026-04-11 22:51:23 +02:00
WBHarry
f910cf9795 Fixed Battlepoints menu being hard to see in light-mode 2026-04-11 22:46:30 +02:00
WBHarry
6804bfe047 Fixed so that bonus rest moves can be negative 2026-04-11 19:23:34 +02:00
WBHarry
28d9254883 Changed TagTeam initiasation cost label to be 'Hope Cost' 2026-04-11 16:23:41 +02:00
WBHarry
b076c2481b Fixed the extra unarmored severe threshold bonus being applied to Bare Bones 2026-04-11 14:59:44 +02:00
WBHarry
bdfc97bb3b Style improvements to groupRoll when a character name is long 2026-04-11 14:24:00 +02:00
WBHarry
e111f7c2ae Corrected BareBones damageThreshold application 2026-04-11 13:58:57 +02:00
WBHarry
bb179db758 Corrected minimum foundy compatability 2026-04-11 11:23:20 +02:00
WBHarry
bbc1781d01 Raised version 2026-04-11 11:20:07 +02:00
WBHarry
a897037dc4
[Feature] Group Roll Rework (#1785)
* Initial

* .

* Improvements

* .

* Renamed 'Main Charater' to 'Leader'

* Localization fixes

* .

* Fixed roll sound coming when canceling a roll. Fixed the leader PART not being disabled when the player isn't the leader
2026-04-11 11:14:36 +02:00
WBHarry
97636fa134 Fixed Countdown Actions not actually setting their DefaultOwnership. Fixed GMs not always getting Ownership of a countdown 2026-04-11 02:53:51 +02:00
WBHarry
e7be2a7d2b Raised Foundry version 2026-04-11 02:34:18 +02:00
WBHarry
9bea8d6a97 Merged with main 2026-04-11 00:05:18 +02:00
Carlos Fernandez
7ca420ae0e
[Feature] Redesign and merge party members and resources tabs (#1784) 2026-04-10 15:33:44 -04:00
WBHarry
ae480157d1
[Feature] 1766 - Group Attack (#1770)
* Implemented group attack logic

* Updated all minions in the SRD to use the group attack functionality

* .

* Renamed groupAttack.nr to groupAttack.numAttackers

* Moved the flag vs global setting logic to documents/scene

* .
2026-04-09 22:07:51 +02:00
Carlos Fernandez
b505e15eb2
Fix editing of bar attributes in v14 (#1786) 2026-04-09 21:36:48 +02:00
WBHarry
087e69694c
Changed the character setup button to be more obvious (#1782) 2026-04-06 11:40:57 +02:00
WBHarry
fad830580c
Added checkboxes for muting the sounds of dice animations (#1781) 2026-04-06 00:18:43 +02:00
WBHarry
4c2d31b2f4
Fixed so that expanded damage info without any dice will show the correct value (#1780) 2026-04-05 19:28:27 +02:00
WBHarry
67d142df3d Fixed migration 2026-04-05 17:27:02 +02:00
WBHarry
fdfd8c5a8d Fixed selecting which roll to use in TagTeamRolls becoming impossible when using an Ability option 2026-04-05 11:28:41 +02:00
WBHarry
dbcef140a2 Fixed armorEffects erroring on isSuppressed when not on an actor 2026-04-05 11:09:00 +02:00
WBHarry
90f4339898 Restoring current version number 2026-04-05 10:23:02 +02:00
WBHarry
0d7469801e
Updated the longrest repair armor to the new armor max path along with a migration (#1777) 2026-04-04 23:22:25 +02:00
WBHarry
70e21f34db Corrected system.json 2026-04-04 13:21:17 +02:00
WBHarry
7057504a9e
Fixes (#1774) 2026-04-04 13:01:24 +02:00
WBHarry
331f1ebf75 Fixed prose-mirror width 2026-04-04 12:42:50 +02:00
WBHarry
f91c140d34
Fixed so that multi term expressions get evaluated into a single number (#1772) 2026-04-04 11:48:41 +02:00
WBHarry
3a117ef117
Added evasion to party resources (#1771) 2026-04-03 23:32:30 +02:00
WBHarry
01619ef067 Corrected github deploy manifest path 2026-04-03 19:15:20 +02:00
WBHarry
622b38ac08 Fixed certain fields in actionConfig not getting translated 2026-04-03 19:05:49 +02:00
WBHarry
02cca277da Updated github deploy manifest to be the latest on the main branch 2026-04-03 00:13:07 +02:00
WBHarry
3265613767
[Fix] Template Scene Awareness (#1769)
* .

* Using foundry values from schema for fallback gridSize and gridDistance

* .
2026-04-02 23:22:09 +02:00
WBHarry
36ffe8a23a Fixed labrys axe and unneccessary hr separations in enrichedItemDescriptions when prefix is empty 2026-04-02 22:18:18 +02:00
WBHarry
96eba49dc1 Fixed RainofBlades 2026-04-02 22:04:07 +02:00
WBHarry
f92f9f7132 Fixed so that tokens with vision range set to Infinity doesn't make summon actions error out 2026-04-02 17:10:13 +02:00
WBHarry
0747994686 Improved TagTeamRoll initialization when done by a player 2026-04-02 16:00:04 +02:00
WBHarry
56dc9afe8f Corrected some action labels and missing translations 2026-04-02 13:37:38 +02:00
WBHarry
0f1ac406df Fixed adding a new damage instance to an action default to prof, which doesn't work for adversaries 2026-04-02 12:22:31 +02:00
WBHarry
e8ac3012ad Raised version 2026-04-02 11:24:17 +02:00
WBHarry
582a15be77 Fixed scene-navigation styling for levels 2026-04-02 11:23:57 +02:00
WBHarry
7fa03c58e0 Fixed armor-slots styling in CharacterSheet 2026-04-01 23:53:13 +02:00
WBHarry
1df248925e Raised foundry version 2026-04-01 23:10:16 +02:00
Carlos Fernandez
2a55e317fc Fix adversary damage rolls 2026-04-01 16:56:44 -04:00
Carlos Fernandez
2b8e4cb2fa
[v14] Add toggle for critical damage (#1762)
* Fix rolling critical damage after rerolling into a crit

* Add toggle for critical damage

---------

Co-authored-by: WBHarry <williambjrklund@gmail.com>
2026-04-01 19:39:26 +02:00
Nikhil Nagarajan
e3b433cce9
Text edit for Rally implementation in Bard Class (#1760) 2026-04-01 09:53:30 +02:00
Carlos Fernandez
29734c5fb5
Fix rolling critical damage after rerolling into a crit (#1761) 2026-04-01 09:47:20 +02:00
WBHarry
25264c26e9 Fixed Adversary roll failing 2026-03-31 18:01:12 +02:00
Nikhil Nagarajan
d284bd7398
[Fix] Fix CSS trait consistency in Character Creator and Sheet (#1737)
* Fixed on CC and sheet

* SVG fixes

* Revert "SVG fixes"

This reverts commit 72c5075f3f.

* SVG repaired and CSS padding revert

* Remove comments

---------

Co-authored-by: WBHarry <williambjrklund@gmail.com>
2026-03-31 17:31:21 +02:00
Carlos Fernandez
259b66236c
[V14] Update duality and fate chat commands (#1759)
* Update duality and fate chat commands for v14

* FateRoll withfear/withHope wasn't working after merging with v14-Dev. Fixed

---------

Co-authored-by: WBHarry <williambjrklund@gmail.com>
2026-03-31 17:26:45 +02:00
WBHarry
f156b12d79
[V14] Message Rolls Rework (#1757)
* Basic rework to the roll data in messages

* .

* Fixed advantage/disadvantage

* .

* .

* Fixed TagTeamDialog

* Reuse getter in faces setter

* Simplify fate roll type css class

* Add more caution to the dualityRoll fromData function

* Apply suggestion from @CarlosFdez

* Compute modifiers using deterministic terms (#1758)

---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com>
2026-03-31 17:20:22 +02:00
WBHarry
dbd5ef8bb0
Added fall and collision damage buttons in the GM Menu (#1756) 2026-03-29 23:54:45 +02:00
WBHarry
e2b13d6717 Removed a temporary override function in document/token. Doesn't seem needed anymore, and it was outdated, making bar2 on tokens never visualy update 2026-03-29 12:50:34 +02:00
WBHarry
e8f052faf3 Fixed drag/drop on application-sheet 2026-03-29 11:07:16 +02:00
WBHarry
740216ada2 Fixed spotlight case outside of combat 2026-03-28 03:09:41 +01:00
WBHarry
24d22dde59
[V14] [Feature] Spotlight Without Combat (#1755) 2026-03-27 22:01:50 -04:00
WBHarry
2a294684d4
Remade branch (#1754) 2026-03-28 00:38:50 +01:00
WBHarry
c730cc3d4d
[Feature] 1740 - Beastform Info (#1750)
* Improved the EffectDisplay tooltip of the beastform effect to show the info about the active beastform

* .

* Move template to more sorted location

---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
2026-03-28 00:18:35 +01:00
WBHarry
e3c4f1ce9f Raised version to Testing 3 2026-03-28 00:17:53 +01:00
WBHarry
7f8e3fee6e Fixed ActiveEffect preCreate blocking multiple effects with origin=null 2026-03-27 22:24:13 +01:00
WBHarry
d79c236cfe Fixed effects not being creatable when not on an actor 2026-03-27 22:11:01 +01:00
WBHarry
d7ce388cad Fixed resource error on TagTeamDialog reroll 2026-03-27 10:29:01 +01:00
WBHarry
8d8fa983ef Merge branch 'main' into v14-Dev 2026-03-27 08:27:37 +01:00
WBHarry
94a2a5723b Removed default spotlight keybind key 2026-03-26 16:34:24 +01:00
WBHarry
394d1d338d Corrected BaseEffect scrollText armorUpdate logic 2026-03-26 16:27:09 +01:00
WBHarry
4319fbabb9 Merged with main 2026-03-26 16:17:23 +01:00
WBHarry
a4adbf8ac4
Added system keybind for spotlighting a combatant (#1749) 2026-03-26 16:12:05 +01:00
Carlos Fernandez
eb9e47c39d
Refresh effects display after actor preparation (#1752) 2026-03-26 15:50:52 +01:00
WBHarry
a4fff56461 Fixed base resources getting their values capped to max at prepareDerivedData. Fixed effect autocomplete not having labels for baseResources. 2026-03-25 17:07:20 +01:00
WBHarry
e3e1395de6 Minor ActionConfig improvements 2026-03-25 16:36:36 +01:00
WBHarry
931217577a Fixed BaseEffect emiting a scroll text of 0 armor change on every update 2026-03-25 14:30:42 +01:00
WBHarry
aa1d117c43
[V14] Effect Stacking (#1667)
* Added the ability for effects to have stacks

* Fixed effect stacking

* Improved token overlay spacing

* Compendium updaetes

* Simplify effect click event (#1748)

* Fixed a bunch of deprecations

* Corrected AgileScout Beastform json data

* Updated TokenHUD to the new v14

* Removed DestroyOnEmpty from consumables

* Fixed so that tooltips don't get stuck (#1745)

* [Feature] TagTeam Partial Rendering (#1735)

* I done did it, I think

* Think I fixed the partial rendering bug for gm->player

* [V14] 1743 - Damage Update Error (#1746)

* Fixed DamageParts causing errors on update

* Fixed ActionBaseConfig error when no damage present on the action

* Fix removal of damage field

* Removed unneccessary default value function for parts

---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>

* Simplify effect click event

---------

Co-authored-by: WBHarry <williambjrklund@gmail.com>
Co-authored-by: WBHarry <89362246+WBHarry@users.noreply.github.com>

* Fixed stacking-value pointer event

* Set the stacking value in EffectsDisplay to be tabular-nums for monospacing

* Made baseEffect.stacking nullable instead of having an enabled property

* .

* Fixed so that actor._onUpdateDescantDocuments re-renders the EffectDisplay if effects were updated

---------

Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com>
2026-03-25 13:54:14 +01:00
WBHarry
64ce615116
[V14] 1743 - Damage Update Error (#1746)
* Fixed DamageParts causing errors on update

* Fixed ActionBaseConfig error when no damage present on the action

* Fix removal of damage field

* Removed unneccessary default value function for parts

---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
2026-03-24 17:33:17 +01:00
WBHarry
f119daff07
[Feature] TagTeam Partial Rendering (#1735)
* I done did it, I think

* Think I fixed the partial rendering bug for gm->player
2026-03-23 17:07:22 +01:00
WBHarry
7a7940aa04 Merged with main 2026-03-23 01:14:20 +01:00
WBHarry
d258478218
Fixed so that tooltips don't get stuck (#1745) 2026-03-23 01:11:21 +01:00
WBHarry
848a7ab466 Removed DestroyOnEmpty from consumables 2026-03-23 00:33:02 +01:00
WBHarry
3d25ceeb4a Updated TokenHUD to the new v14 2026-03-23 00:19:22 +01:00
WBHarry
2de0b490e9 Corrected AgileScout Beastform json data 2026-03-22 17:13:21 +01:00
WBHarry
de801924e6 Fixed a bunch of deprecations 2026-03-22 16:59:23 +01:00
WBHarry
ef53a7c561
[V14] 1354 - Armor Effect (#1652)
* Initial

* progress

* Working armor application

* .

* Added a updateArmorValue function that updates armoreffects according to an auto order

* .

* Added createDialog

* .

* Updated Armor SRD

* .

* Fixed character sheet armor update

* Updated itemconfig

* Actions now use createDialog for effects

* .

* .

* Fixed ArmorEffect max being a string

* Fixed SRD armor effects

* Finally finished the migration ._.

* SRD finalization

* Added ArmoreEffect.armorInteraction option

* Added ArmorManagement menu

* Fixed DamageReductionDialog

* Fixed ArmorManagement pip syle

* feat: add style to armors tooltip, add a style to make armor slot label more clear that was a button and add a tooltip location

* .

* Removed tooltip on manageArmor

* Fixes

* Fixed Downtime armor repair

* Removed ArmorScore from character data model and instead adding it in basePrep

* [Feature] ArmorEffect reworked into ChangeType on BaseEffect (#1739)

* Initial

* .

* Single armor rework start

* More fixes

* Fixed DamageReductionDialog

* Removed last traces of ArmorEffect

* .

* Corrected the SRD to use base effects again

* Removed bare bones armor item

* [V14] Refactor ArmorChange schema and fix some bugs (#1742)

* Refactor ArmorChange schema and fix some bugs

* Add current back to schema

* Fixed so changing armor values and taking damage works again

* Fixed so that scrolltexts for armor changes work again

* Removed old marks on armor.system

* Restored damageReductionDialog armorScore.value

* Use toggle for css class addition/removal

* Fix armor change type choices

* Added ArmorChange DamageThresholds

---------

Co-authored-by: WBHarry <williambjrklund@gmail.com>

* [V14] Armor System ArmorScore (#1744)

* Readded so that armor items have their system defined armor instead of using an ActiveEffect

* Consolidate armor source retrieval

* Fix regression with updating armor when sources are disabled

* Simplify armor pip update

* Use helper in damage reduction dialog

* .

* Corrected SRD Armor Items

---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>

* Updated migrations

* Migrations are now not horrible =D

---------

Co-authored-by: Murilo Brito <dev.murilobrito@gmail.com>
Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com>
Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
2026-03-22 01:57:46 +01:00
WBHarry
a3f515cf6d Fixed TokenConfig error:ing on save 2026-03-21 11:39:18 +01:00
WBHarry
461247b285 Raised version 2026-03-21 00:52:37 +01:00
Carlos Fernandez
b3e9c3fd9f
Use ActiveEffect Config for settings as well (#1741) 2026-03-21 00:46:30 +01:00
Carlos Fernandez
15fc879f9b
Fix damage icon when retrieving tooltip for attack (#1736) 2026-03-18 18:34:11 -04:00
WBHarry
d5244eedbf Merged with main 2026-03-17 22:46:08 +01:00
WBHarry
ad8caabf71 TagTeam Fixes 2026-03-16 20:29:12 +01:00
WBHarry
3031531b14
[V14] TagTeamRoll Rework (#1732)
* Initial rolls working

* Fixed reroll

* more

* More work

* Added results section

* .

* Visual improvements

* .

* Removed traces of old TagTeamRoll

* Added initiator handling

* Added updating for other players

* Fixed sync start

* Completed finish method

* Damage reroll

* Fixed localization

* Fixed crit damage

* Fixes

* Added visual of advantage and disadvantage dice
2026-03-16 09:31:15 +01:00
WBHarry
a7eda31aec Merged with main 2026-03-16 01:33:50 +01:00
WBHarry
e77b927a75 Merged with main 2026-03-15 11:45:21 +01:00
Carlos Fernandez
37b088fe7d Apply low performance styling to all daggerheart sheets 2026-03-13 20:00:05 -04:00
WBHarry
7c0ab25e10 Fixed contextmenu 2026-03-14 00:10:48 +01:00
Carlos Fernandez
1160f51347 Fix hasDamage checks on non-attack actions 2026-03-13 18:47:55 -04:00
Carlos Fernandez
92bcaf4962 Fix clean type in v14 2026-03-13 18:09:19 -04:00
WBHarry
fb4ddf227c Merged with main 2026-03-13 01:29:29 +01:00
WBHarry
b87e630a0a Merged main 2026-03-13 00:25:50 +01:00
WBHarry
ee3bbaec53 Fixed drag/drop 2026-03-12 22:12:45 +01:00
WBHarry
5c8d16e100 Raised version 2026-03-12 21:35:26 +01:00
WBHarry
fcadf119b7
[V14] Emanation AutoSizing (#1686)
* Added so that emanation templates auto size their base to any token at the spot its placed

* Correct option useage

* Also snap emanations when done from scene controls

---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
2026-03-09 11:30:03 +01:00
WBHarry
5a4bbc91f5
[Feature] Damage Iterrable Rework (#1685)
* Initial

* More

* Fixed current actionConfig damage

* Reworked ActionConfig damage ui

* .

* Updated all Adversary compendium damage entries

* more

* The rest

* Fixed misses

* .

* .

* Also migrate sub fields of MappingField

* Removed MappingField

* Fix regression with re-tiering adversaries when dealing non-hp damage

* Allow iterable object to be detected as an object by foundry

---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
2026-03-08 00:58:24 +01:00
WBHarry
d3ebd30e59 . 2026-03-07 22:26:54 +01:00
WBHarry
c2807e0676 Added in the new v14 subtract changeMode type for ActiveEffects 2026-03-07 18:02:01 +01:00
WBHarry
876e496d24 Merged with main 2026-03-07 01:39:52 +01:00
WBHarry
1ca866f87b Merged with main 2026-02-26 16:12:06 +01:00
WBHarry
37c53ad74e Fixed Template range texts 2026-02-25 22:45:55 +01:00
WBHarry
bcb30a6ff7 Fixed environment potentialAdversaries 2026-02-25 21:57:28 +01:00
WBHarry
4aab5d315a
[V14] 1604 - ActiveEffect Durations (#1634)
* Added daggerheart durations and auto expiration of them

* Added duration to all tier1 adversaries

* Finished all adversaries and environments

* Remaining compendiums updated

* Improved styling of duration in tooltips

* .
2026-02-17 18:57:03 +01:00
WBHarry
e2eb31c12e Merged with main 2026-02-16 20:40:28 +01:00
WBHarry
9b63371f4a Merged with main 2026-02-13 13:17:00 +01:00
WBHarry
063ff3d999 Merged with main 2026-02-09 15:44:54 +01:00
WBHarry
593105b163 Fixed ActiveEffect create dialog options 2026-02-04 20:08:52 +01:00
WBHarry
115a31423e Corrected ActiveEffect template styling and added useage of the new 'showIcon' property 2026-02-04 10:15:42 +01:00
WBHarry
ac998adaa6 Merged with development 2026-02-04 00:25:58 +01:00
WBHarry
6a0a8d8d6e Updated the sidebar so the new Placeables tab coems in 2026-02-02 23:56:57 +01:00
WBHarry
c17020c2c8 Fixed ActiveEffect.getChangeValue not expecting a number as change.value 2026-02-02 20:00:15 +01:00
WBHarry
578b090f08
[V14] 1605 - Template Migration (#1621)
* Fixed so that our templates make use of SceneRegions instead

* Fixed visibility
2026-02-01 17:21:56 +01:00
WBHarry
57e51ee841 Added in comments about Beastform failing 2026-02-01 00:25:40 +01:00
WBHarry
da368f3df5 Merge branch 'development' into v14-Dev 2026-01-31 19:46:47 +01:00
WBHarry
307af5b990 Merged with development 2026-01-31 19:35:46 +01:00
WBHarry
ae91d6786f Fixed actions not being delete:able 2026-01-31 19:32:51 +01:00
WBHarry
cd52aa8f9c Updated from special database update syntax to DataFieldOperators 2026-01-31 18:31:10 +01:00
WBHarry
9553f3387f
Fixed sceneConfig, sceneNavigation and SceneEnvironments (#1616) 2026-01-31 15:09:07 +01:00
WBHarry
4c51bb5899 1613-Rolltable-delete-formula-buttons 2026-01-31 15:08:07 +01:00
WBHarry
2c36da8433 Raised v14 version and fixed startup warnings 2026-01-31 01:46:24 +01:00
WBHarry
6e2d700945 . 2026-01-29 18:51:13 +01:00
WBHarry
1a928e950c Initial v14 fixes 2026-01-29 18:46:39 +01:00
927 changed files with 18213 additions and 10009 deletions

View file

@ -1,3 +1,5 @@
[*]
indent_size = 4
indent_style = spaces
[*.yml]
indent_size = 2

42
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,42 @@
name: Project CI
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [24.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: pnpm/action-setup@v4
with:
version: 10
- name: Cache NPM Deps
id: cache-npm
uses: actions/cache@v3
with:
path: node_modules/
key: npm-${{ hashFiles('package-lock.json') }}
- name: Install NPM Deps
if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
run: npm ci
- name: Lint
run: npm run lint

View file

@ -35,7 +35,7 @@ jobs:
env:
version: ${{steps.get_version.outputs.version-without-v}}
url: https://github.com/${{github.repository}}
manifest: https://github.com/${{github.repository}}/releases/latest/download/system.json
manifest: https://raw.githubusercontent.com/${{github.repository}}/v14/system.json
download: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/system.zip
# Create a zip file with all files required by the module to add to the release

View file

@ -1,78 +1,9 @@
# Contributing to Foundryborne
# Contributing to Daggerheart
Welcome! This is a community-driven project to bring [Daggerheart](https://www.daggerheart.com/) to [FoundryVTT](https://foundryvtt.com/) as a full system. We're excited to have you here and appreciate your interest in contributing.
Thank you for your interest in contributing to the Foundryborne project!
---
To ensure that all contributions align with our project goals and architectural standards, we ask that you **do not submit outside contributions without first receiving feedback from the development team.**
## 🤝 How to Contribute
If you have an idea or a fix you'd like to contribute, please start a discussion or open an issue first. We'd love to hear from you and collaborate on the best way to move forward!
We welcome contributions of all kinds:
- Bug reports
- Feature suggestions
- Code contributions
- UI/UX mockups
- Documentation improvements
- Questions and discussions
Please be respectful and collaborative — were all here to build something great together.
### Community Translations
Please note that we are not accepting community translations in the main project. Instead, community translations should be published as a module.
---
## 🧭 General Guidelines
- **Use GitHub Issues** to report bugs or propose features
- **Start a Discussion** for larger ideas or questions
- **Open a Pull Request** once you've confirmed your work aligns with project direction
- **Keep things modular and maintainable** — if you're not sure how to structure something, ask!
- **Orient your code on existing examples**, and feel free to suggest a standard if it makes things clearer
---
## 🗂️ Project Structure
Please try to follow the general logic of the existing code when submitting PRs.
We encourage contributors to leave comments or open Discussions when proposing structural or organizational changes.
---
## 🧾 Issue & PR Best Practices
**For Issues:**
- Use clear, descriptive titles
- Provide a concise explanation of the problem or idea
- Include reproduction steps or example scenarios if it's a bug
- Add screenshots or logs if helpful
**For Pull Requests:**
- Use a clear title summarizing the change
- Provide a brief description of what your code does and why
- Link to any related Issues
- Keep PRs focused — smaller is better
---
## 🔖 Labels and Boards
We use GitHub labels to help organize contributions. If your issue or PR relates to a specific category, feel free to tag it. There is also a GitHub Project Board to help track active work and priorities.
---
## 📣 Communication
Discussions are currently happening on GitHub — in Issues, PRs, and [GitHub Discussions](https://github.com/Foundryborne/daggerheart/discussions). You're welcome to use any of these, though we may consolidate to one in the future.
---
## 🤗 Thank You!
Whether you're fixing a typo or designing entire mechanics — every contribution matters. Thank you for helping bring _Daggerheart_ to life in FoundryVTT through **Foundryborne**!
🐸🛠️
Thank you for your understanding and support.

View file

@ -1,3 +1,3 @@
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.12012 0.5H51.8799C55.2901 0.500041 57.8779 3.57175 57.2998 6.93262L50.4639 46.6777C50.1604 48.4411 49.0179 49.9467 47.4014 50.7139L31.3584 58.3271C29.8661 59.0354 28.1339 59.0354 26.6416 58.3271L10.5986 50.7139C8.98214 49.9467 7.83959 48.4411 7.53613 46.6777L0.700195 6.93262C0.122088 3.57175 2.7099 0.500042 6.12012 0.5Z" fill="transparent" stroke="#18162e"/>
<path d="M 7.12 0.5 H 52.88 C 56.29 0.5 58.88 3.57 58.3 6.93 L 51.46 46.68 C 51.16 48.44 50.02 49.95 48.4 50.71 L 32.36 58.33 C 30.87 59.04 29.13 59.04 27.64 58.33 L 11.6 50.71 C 9.98 49.95 8.84 48.44 8.54 46.68 L 1.7 6.93 C 1.12 3.57 3.71 0.5 7.12 0.5 Z" fill="transparent" stroke="#18162e"/>
</svg>

Before

Width:  |  Height:  |  Size: 476 B

After

Width:  |  Height:  |  Size: 397 B

Before After
Before After

View file

@ -1,3 +1,3 @@
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.12012 0.5H51.8799C55.2901 0.500041 57.8779 3.57175 57.2998 6.93262L50.4639 46.6777C50.1604 48.4411 49.0179 49.9467 47.4014 50.7139L31.3584 58.3271C29.8661 59.0354 28.1339 59.0354 26.6416 58.3271L10.5986 50.7139C8.98214 49.9467 7.83959 48.4411 7.53613 46.6777L0.700195 6.93262C0.122088 3.57175 2.7099 0.500042 6.12012 0.5Z" fill="#18152E" stroke="#F3C267"/>
<path d="M 7.12 0.5 H 52.88 C 56.29 0.5 58.88 3.57 58.3 6.93 L 51.46 46.68 C 51.16 48.44 50.02 49.95 48.4 50.71 L 32.36 58.33 C 30.87 59.04 29.13 59.04 27.64 58.33 L 11.6 50.71 C 9.98 49.95 8.84 48.44 8.54 46.68 L 1.7 6.93 C 1.12 3.57 3.71 0.5 7.12 0.5 Z" fill="#18152E" stroke="#F3C267"/>
</svg>

Before

Width:  |  Height:  |  Size: 472 B

After

Width:  |  Height:  |  Size: 393 B

Before After
Before After

View file

@ -3,15 +3,13 @@ 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 collections from './module/documents/collections/_module.mjs';
import * as dice from './module/dice/_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';
import { getCommandTarget, rollCommandToJSON } from './module/helpers/utils.mjs';
import { BaseRoll, DHRoll, DualityRoll, D20Roll, DamageRoll, FateRoll } from './module/dice/_module.mjs';
import { enrichedDualityRoll } from './module/enrichers/DualityRollEnricher.mjs';
import { enrichedFateRoll, getFateTypeData } from './module/enrichers/FateRollEnricher.mjs';
import {
handlebarsRegistration,
runMigrations,
@ -20,7 +18,6 @@ import {
} from './module/systemRegistration/_module.mjs';
import { placeables, DhTokenLayer } from './module/canvas/_module.mjs';
import './node_modules/@yaireo/tagify/dist/tagify.css';
import TemplateManager from './module/documents/templateManager.mjs';
import TokenManager from './module/documents/tokenManager.mjs';
CONFIG.DH = SYSTEM;
@ -35,6 +32,13 @@ CONFIG.Dice.daggerheart = {
FateRoll: FateRoll
};
CONFIG.RegionBehavior.dataModels = {
...CONFIG.RegionBehavior.dataModels,
...data.regionBehaviors
};
Object.assign(CONFIG.Dice.termTypes, dice.diceTypes);
CONFIG.Actor.documentClass = documents.DhpActor;
CONFIG.Actor.dataModels = models.actors.config;
CONFIG.Actor.collection = collections.DhActorCollection;
@ -44,6 +48,7 @@ CONFIG.Item.dataModels = models.items.config;
CONFIG.ActiveEffect.documentClass = documents.DhActiveEffect;
CONFIG.ActiveEffect.dataModels = models.activeEffects.config;
CONFIG.ActiveEffect.changeTypes = { ...CONFIG.ActiveEffect.changeTypes, ...models.activeEffects.changeEffects };
CONFIG.Combat.documentClass = documents.DhpCombat;
CONFIG.Combat.dataModels = { base: models.DhCombat };
@ -55,11 +60,13 @@ CONFIG.ChatMessage.documentClass = documents.DhChatMessage;
CONFIG.ChatMessage.template = 'systems/daggerheart/templates/ui/chat/chat-message.hbs';
CONFIG.Canvas.rulerClass = placeables.DhRuler;
CONFIG.Canvas.layers.templates.layerClass = placeables.DhTemplateLayer;
CONFIG.Canvas.layers.regions.layerClass = placeables.DhRegionLayer;
CONFIG.Canvas.layers.tokens.layerClass = DhTokenLayer;
CONFIG.MeasuredTemplate.objectClass = placeables.DhMeasuredTemplate;
CONFIG.Region.objectClass = placeables.DhRegion;
CONFIG.RollTable.documentClass = documents.DhRollTable;
CONFIG.RollTable.resultTemplate = 'systems/daggerheart/templates/ui/chat/table-result.hbs';
@ -83,7 +90,6 @@ CONFIG.ui.resources = applications.ui.DhFearTracker;
CONFIG.ui.countdowns = applications.ui.DhCountdowns;
CONFIG.ux.ContextMenu = applications.ux.DHContextMenu;
CONFIG.ux.TooltipManager = documents.DhTooltipManager;
CONFIG.ux.TemplateManager = new TemplateManager();
CONFIG.ux.TokenManager = new TokenManager();
CONFIG.debug.triggers = false;
@ -93,6 +99,7 @@ Hooks.once('init', () => {
data,
models,
documents,
macros,
dice,
fields
};
@ -211,6 +218,7 @@ Hooks.once('init', () => {
SYSTEM.id,
applications.sheetConfigs.ActiveEffectConfig,
{
types: ['base', 'beastform', 'horde'],
makeDefault: true,
label: sheetLabel('DOCUMENT.ActiveEffect')
}
@ -268,7 +276,6 @@ Hooks.on('setup', () => {
...damageThresholds,
'proficiency',
'evasion',
'armorScore',
'scars',
'levelData.level.current'
]
@ -330,79 +337,31 @@ Hooks.on('renderHandlebarsApplication', (_, element) => {
enricherRenderSetup(element);
});
Hooks.on('chatMessage', (_, message) => {
if (message.startsWith('/dr')) {
const result =
message.trim().toLowerCase() === '/dr' ? { result: {} } : rollCommandToJSON(message.replace(/\/dr\s?/, ''));
if (!result) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.dualityParsing'));
return false;
Hooks.on(CONFIG.DH.HOOKS.hooksConfig.tagTeamStart, async data => {
if (data.openForAllPlayers && data.partyId) {
const party = game.actors.get(data.partyId);
if (!party) return;
const dialog = new game.system.api.applications.dialogs.TagTeamDialog(party);
dialog.tabGroups.application = 'tagTeamRoll';
await dialog.render({ force: true });
}
});
const { result: rollCommand, flavor } = result;
Hooks.on(CONFIG.DH.HOOKS.hooksConfig.groupRollStart, async data => {
if (data.openForAllPlayers && data.partyId) {
const party = game.actors.get(data.partyId);
if (!party) return;
const reaction = rollCommand.reaction;
const traitValue = rollCommand.trait?.toLowerCase();
const advantage = rollCommand.advantage
? CONFIG.DH.ACTIONS.advantageState.advantage.value
: rollCommand.disadvantage
? CONFIG.DH.ACTIONS.advantageState.disadvantage.value
: undefined;
const difficulty = rollCommand.difficulty;
const grantResources = rollCommand.grantResources;
const target = getCommandTarget({ allowNull: true });
const title =
(flavor ?? traitValue)
? game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
ability: game.i18n.localize(SYSTEM.ACTOR.abilities[traitValue].label)
})
: game.i18n.localize('DAGGERHEART.GENERAL.duality');
enrichedDualityRoll({
reaction,
traitValue,
target,
difficulty,
title,
label: game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll'),
actionType: null,
advantage,
grantResources
});
return false;
}
if (message.startsWith('/fr')) {
const result =
message.trim().toLowerCase() === '/fr' ? { result: {} } : rollCommandToJSON(message.replace(/\/fr\s?/, ''));
if (!result) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateParsing'));
return false;
}
const { result: rollCommand, flavor } = result;
const fateTypeData = getFateTypeData(rollCommand?.type);
if (!fateTypeData)
return ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
const { value: fateType, label: fateTypeLabel } = fateTypeData;
const target = getCommandTarget({ allowNull: true });
const title = flavor ?? game.i18n.localize('DAGGERHEART.GENERAL.fateRoll');
enrichedFateRoll({
target,
title,
label: fateTypeLabel,
fateType
});
return false;
const dialog = new game.system.api.applications.dialogs.GroupRollDialog(party);
dialog.tabGroups.application = 'groupRoll';
await dialog.render({ force: true });
}
});
const updateActorsRangeDependentEffects = async token => {
if (!token) return;
const rangeMeasurement = game.settings.get(
CONFIG.DH.id,
CONFIG.DH.SETTINGS.gameSettings.variantRules

14
eslint.config.mjs Normal file
View file

@ -0,0 +1,14 @@
import globals from 'globals';
import { defineConfig } from 'eslint/config';
import prettier from 'eslint-plugin-prettier';
export default defineConfig([
{ files: ['**/*.{js,mjs,cjs}'], languageOptions: { globals: globals.browser } },
{ plugins: { prettier } },
{
files: ['**/*.{js,mjs,cjs}'],
rules: {
'prettier/prettier': 'error'
}
}
]);

View file

@ -14,7 +14,9 @@
"beastform": "Beastform"
},
"ActiveEffect": {
"beastform": "Beastform"
"base": "Standard",
"beastform": "Beastform",
"horde": "Horde"
},
"Actor": {
"character": "Character",
@ -53,6 +55,7 @@
},
"damage": {
"name": "Damage",
"critical": "Damage (Critical)",
"tooltip": "Direct damage without a roll."
},
"effect": {
@ -71,9 +74,7 @@
"name": "Summon",
"tooltip": "Create tokens in the scene.",
"error": "You do not have permission to summon tokens or there is no active scene.",
"invalidDrop": "You can only drop Actor entities to summon.",
"chatMessageTitle": "Test2",
"chatMessageHeaderTitle": "Summoning"
"invalidDrop": "You can only drop Actor entities to summon."
},
"transform": {
"name": "Transform",
@ -87,9 +88,14 @@
},
"Config": {
"beastform": {
"exact": "Beastform Max Tier",
"exactHint": "The Character's Tier is used if empty",
"label": "Beastform"
"exact": { "label": "Beastform Max Tier", "hint": "The Character's Tier is used if empty" },
"modifications": {
"traitBonuses": {
"label": { "single": "Trait Bonus", "plural": "Trait Bonuses" },
"hint": "Pick bonuses you apply to freely chosen traits at the time of transforming",
"bonus": "Bonus Amount"
}
}
},
"countdown": {
"defaultOwnership": "Default Ownership",
@ -103,9 +109,18 @@
"customFormula": "Custom Formula",
"formula": "Formula"
},
"area": {
"sectionTitle": "Areas",
"shape": "Shape",
"size": "Size"
},
"displayInChat": "Display in chat",
"deleteTriggerTitle": "Delete Trigger",
"deleteTriggerContent": "Are you sure you want to delete the {trigger} trigger?"
"deleteTriggerContent": "Are you sure you want to delete the {trigger} trigger?",
"advantageState": "Advantage State",
"damageOnSave": "Damage on Save",
"useDefaultItemValues": "Use default Item values",
"itemDamageIsUsed": "Item Damage Is Used"
},
"RollField": {
"diceRolling": {
@ -117,10 +132,11 @@
}
},
"Settings": {
"attackBonus": "Attack Bonus",
"attackModifier": "Attack Modifier",
"attackName": "Attack Name",
"criticalThreshold": "Critical Threshold",
"includeBase": { "label": "Include Item Damage" },
"includeBase": { "label": "Use Item Damage" },
"groupAttack": { "label": "Group Attack" },
"multiplier": "Multiplier",
"saveHint": "Set a default Trait to enable Reaction Roll. It can be changed later in Reaction Roll Dialog.",
"resultBased": {
@ -151,7 +167,9 @@
"Config": {
"rangeDependence": {
"title": "Range Dependence"
}
},
"stacking": { "title": "Stacking" },
"targetDispositions": "Affected Dispositions"
},
"RangeDependance": {
"hint": "Settings for an optional distance at which this effect should activate",
@ -198,7 +216,13 @@
"type": { "label": "Type" }
},
"hordeDamage": "Horde Damage",
"horderHp": "Horde/HP"
"horderHp": "Horde/HP",
"adversaryReactionRoll": {
"headerTitle": "Adversary Reaction Roll"
}
},
"Base": {
"CannotAddType": "Cannot add {itemType} items to {actorType} actors."
},
"Character": {
"advantageSources": {
@ -223,6 +247,8 @@
},
"defaultHopeDice": "Default Hope Dice",
"defaultFearDice": "Default Fear Dice",
"defaultAdvantageDice": "Default Advantage Dice",
"defaultDisadvantageDice": "Default Disadvantage Dice",
"disadvantageSources": {
"label": "Disadvantage Sources",
"hint": "Add single words or short text as reminders and hints of what a character has disadvantage on."
@ -307,6 +333,22 @@
}
},
"newAdversary": "New Adversary"
},
"Party": {
"Subtitle": {
"character": "{community} {ancestry} | {subclass} {class}",
"companion": "Companion of {partner}"
},
"RemoveConfirmation": {
"title": "Remove member {name}",
"text": "Are you sure you want to remove {name} from the party?"
},
"Thresholds": {
"minor": "MIN",
"major": "MAJ",
"severe": "SEV"
},
"triggerRestContent": "This will trigger a dialog to players make their downtime moves. Are you sure?"
}
},
"APPLICATIONS": {
@ -342,7 +384,7 @@
"selectSecondaryWeapon": "Select Secondary Weapon",
"selectSubclass": "Select Subclass",
"setupSkipTitle": "Skipping Character Setup",
"setupSkipContent": "You are skipping the Character Setup by adding this manually. The character setup is the blinking arrows in the top-right. Are you sure you want to continue?",
"setupSkipContent": "You are skipping the Character Setup by adding this manually. The character setup is the blinking button in the top-right. Are you sure you want to continue?",
"startingItems": "Starting Items",
"story": "Story",
"storyExplanation": "Select which background and connection prompts you want to copy into your character's background.",
@ -440,16 +482,21 @@
"defaultOwnershipTooltip": "The default player ownership of countdowns",
"hideNewCountdowns": "Hide New Countdowns"
},
"CreateItemDialog": {
"createItem": "Create Item",
"browseCompendium": "Browse Compendium"
},
"DaggerheartMenu": {
"title": "GM Tools",
"refreshFeatures": "Refresh Features"
"refreshFeatures": "Refresh Features",
"fallingAndCollision": "Falling And Collision Damage"
},
"DeleteConfirmation": {
"title": "Delete {type} - {name}",
"text": "Are you sure you want to delete {name}?"
},
"DamageReduction": {
"armorMarks": "Armor Marks",
"maxUseableArmor": "Useable Armor Slots",
"armorWithStress": "Spend 1 stress to use an extra mark",
"thresholdImmunities": "Threshold Immunities",
"stress": "Stress",
@ -653,6 +700,12 @@
"noPlayers": "No players to assign ownership to",
"default": "Default Ownership"
},
"PendingReactionsDialog": {
"title": "Pending Reaction Rolls Found",
"unfinishedRolls": "Some Tokens still need to roll their Reaction Roll.",
"confirmation": "Are you sure you want to continue ?",
"warning": "Undone reaction rolls will be considered as failed"
},
"ReactionRoll": {
"title": "Reaction Roll: {trait}"
},
@ -675,16 +728,46 @@
},
"TagTeamSelect": {
"title": "Tag Team Roll",
"FIELDS": {
"initiator": {
"memberId": { "label": "Initiating Character" },
"cost": { "label": "Hope Cost" }
}
},
"leaderTitle": "Initiating Character",
"membersTitle": "Participants",
"partyTeam": "Party Team",
"hopeCost": "Hope Cost",
"initiatingCharacter": "Initiating Character",
"selectParticipants": "Select the two participants",
"startTagTeamRoll": "Start Tag Team Roll",
"openDialogForAll": "Open Dialog For All",
"rollType": "Roll Type",
"makeYourRoll": "Make your roll",
"cancelTagTeamRoll": "Cancel Tag Team Roll",
"finishTagTeamRoll": "Finish Tag Team Roll",
"linkMessageHint": "Make a roll from your character sheet to link it to the Tag Team Roll",
"damageNotRolled": "Damage not rolled in chat message yet",
"insufficientHope": "The initiating character doesn't have enough hope",
"createTagTeam": "Create TagTeam Roll",
"chatMessageRollTitle": "Roll"
"createTagTeam": "Create Tag Team Roll",
"chatMessageRollTitle": "Roll",
"cancelConfirmTitle": "Cancel Tag Team Roll",
"cancelConfirmText": "Are you sure you want to cancel the Tag Team Roll? This will close it for all other players too.",
"hints": {
"completeRolls": "Set up and complete the rolls for the characters",
"selectRoll": "Select which roll value to be used for the Tag Team"
}
},
"GroupRollSelect": {
"title": "Group Roll",
"aidingCharacters": "Aiding Characters",
"leader": "Leader",
"leaderRoll": "Leader Roll",
"openDialogForAll": "Open Dialog For All",
"startGroupRoll": "Start Group Roll",
"finishGroupRoll": "Finish Group Roll",
"cancelConfirmTitle": "Cancel Group Roll",
"cancelConfirmText": "Are you sure you want to cancel the Group Roll? This will close it for all other players too."
},
"TokenConfig": {
"actorSizeUsed": "Actor size is set, determining the dimensions"
@ -697,6 +780,20 @@
}
},
"CONFIG": {
"ActiveEffectDuration": {
"temporary": "Temporary",
"act": "Next Spotlight",
"scene": "Next Scene",
"shortRest": "Next Rest",
"longRest": "Next Long Rest",
"session": "Next Session",
"custom": "Custom"
},
"ActionAutomationChoices": {
"never": "Never",
"showDialog": "Show Dialog Only",
"always": "Always"
},
"AdversaryTrait": {
"relentless": {
"name": "Relentless",
@ -764,6 +861,11 @@
"bruiser": "for each Bruiser adversary.",
"solo": "for each Solo adversary."
},
"ArmorInteraction": {
"none": { "label": "Ignores Armor" },
"active": { "label": "Active w/ Armor" },
"inactive": { "label": "Inactive w/ Armor" }
},
"ArmorFeature": {
"burning": {
"name": "Burning",
@ -1114,6 +1216,12 @@
"description": ""
}
},
"fallAndCollision": {
"veryClose": { "label": "Very Close", "chatTitle": "Fall Damage: Very Close" },
"close": { "label": "Close", "chatTitle": "Fall Damage: Close" },
"far": { "label": "Far", "chatTitle": "Fall Damage: Far" },
"collision": { "label": "Collision", "chatTitle": "Dangerous Collision" }
},
"FeatureForm": {
"label": "Feature Form",
"passive": "Passive",
@ -1215,10 +1323,20 @@
"on": "On",
"onWithToggle": "On With Toggle"
},
"SceneRangeMeasurementTypes": {
"disable": "Disable Daggerheart Range Measurement",
"default": "Default",
"custom": "Custom"
},
"SelectAction": {
"selectType": "Select Action Type",
"selectAction": "Action Selection"
},
"TagTeamRollTypes": {
"trait": "Trait",
"ability": "Ability",
"damageAbility": "Damage Ability"
},
"TargetTypes": {
"any": "Any",
"friendly": "Friendly",
@ -1231,8 +1349,8 @@
"cone": "Cone",
"emanation": "Emanation",
"inFront": "In Front",
"rect": "Rectangle",
"ray": "Ray"
"rectangle": "Rectangle",
"line": "Line"
},
"TokenSize": {
"tiny": "Tiny",
@ -1847,6 +1965,17 @@
"name": "Healing Roll"
}
},
"ChangeTypes": {
"armor": {
"newArmorEffect": "Armor Effect",
"FIELDS": {
"interaction": {
"label": "Armor Interaction",
"hint": "Does the character wearing armor suppress this effect?"
}
}
}
},
"Duration": {
"passive": "Passive",
"temporary": "Temporary"
@ -1871,6 +2000,10 @@
}
},
"GENERAL": {
"Ability": {
"single": "Ability",
"plural": "Abilities"
},
"Action": {
"single": "Action",
"plural": "Actions"
@ -1894,6 +2027,10 @@
"hint": "Multiply any damage dealt to you by this number"
}
},
"Battlepoints": {
"full": "Battlepoints",
"short": "BP"
},
"Bonuses": {
"rest": {
"downtimeAction": "Downtime Action",
@ -2252,6 +2389,7 @@
"duality": "Duality",
"dualityDice": "Duality Dice",
"dualityRoll": "Duality Roll",
"effect": "Effect",
"enabled": "Enabled",
"evasion": "Evasion",
"equipment": "Equipment",
@ -2303,10 +2441,13 @@
"maxWithThing": "Max {thing}",
"missingDragDropThing": "Drop {thing} here",
"multiclass": "Multiclass",
"name": "Name",
"newCategory": "New Category",
"newThing": "New {thing}",
"next": "Next",
"none": "None",
"noTarget": "No current target",
"optionalThing": "Optional {thing}",
"partner": "Partner",
"player": {
"single": "Player",
@ -2324,14 +2465,20 @@
"rerolled": "Rerolled",
"rerollThing": "Reroll {thing}",
"resource": "Resource",
"result": {
"single": "Result",
"plural": "Results"
},
"roll": "Roll",
"rollAll": "Roll All",
"rollDamage": "Roll Damage",
"rollWith": "{roll} Roll",
"save": "Save",
"saveSettings": "Save Settings",
"scalable": "Scalable",
"scars": "Scars",
"situationalBonus": "Situational Bonus",
"searchPlaceholder": "Search...",
"spent": "Spent",
"step": "Step",
"stress": "Stress",
@ -2461,8 +2608,7 @@
"featuresLabel": "Community Feature"
},
"Consumable": {
"consumeOnUse": "Consume On Use",
"destroyOnEmpty": "Destroy On Empty"
"consumeOnUse": "Consume On Use"
},
"DomainCard": {
"type": "Type",
@ -2483,8 +2629,21 @@
},
"Weapon": {
"weaponType": "Weapon Type",
"primaryWeapon": "Primary Weapon",
"secondaryWeapon": "Secondary Weapon"
"primaryWeapon": {
"full": "Primary Weapon",
"short": "Primary"
},
"secondaryWeapon": {
"full": "Secondary Weapon",
"short": "Secondary"
}
}
},
"MACROS": {
"Spotlight": {
"errors": {
"noTokenSelected": "A token on the canvas must either be selected or hovered to spotlight it"
}
}
},
"ROLLTABLES": {
@ -2558,6 +2717,10 @@
"hint": "Automatically increase the GM's fear pool on a fear duality roll result."
},
"FIELDS": {
"autoExpireActiveEffects": {
"label": "Auto Expire Active Effects",
"hint": "Active Effects with set durations will automatically be removed when their durations are up"
},
"damageReductionRulesDefault": {
"label": "Damage Reduction Rules Default",
"hint": "Wether using armor and reductions has rules on by default"
@ -2726,6 +2889,16 @@
"setResourceIdentifier": "Set Resource Identifier"
}
},
"Keybindings": {
"partySheet": {
"name": "Toggle Party Sheet",
"hint": "Open or close the active party's sheet"
},
"spotlight": {
"name": "Spotlight Combatant",
"hint": "Move the spotlight to a hovered or selected token that's present in an active encounter"
}
},
"Menu": {
"title": "Daggerheart Game Settings",
"automation": {
@ -2765,6 +2938,7 @@
"system": "Dice Preset",
"font": "Font",
"critical": "Duality Critical Animation",
"muted": "Muted",
"diceAppearance": "Dice Appearance",
"animations": "Animations",
"defaultAnimations": "Set Animations As Player Defaults",
@ -2873,18 +3047,6 @@
"immunityTo": "Immunity: {immunities}"
},
"featureTitle": "Class Feature",
"groupRoll": {
"title": "Group Roll",
"leader": "Leader",
"partyTeam": "Party Team",
"team": "Team",
"selectLeader": "Select a Leader",
"selectMember": "Select a Member",
"rerollTitle": "Reroll Group Roll",
"rerollContent": "Are you sure you want to reroll your {trait} roll?",
"rerollTooltip": "Reroll",
"wholePartySelected": "The whole party is selected"
},
"healingRoll": {
"title": "Heal - {damage}",
"heal": "Heal",
@ -2902,6 +3064,9 @@
"resourceRoll": {
"playerMessage": "{user} rerolled their {name}"
},
"saveRoll": {
"reactionRollAllTargets": "Reaction Roll All Targets"
},
"tagTeam": {
"title": "Tag Team",
"membersTitle": "Members"
@ -2924,13 +3089,15 @@
},
"EffectsDisplay": {
"removeThing": "[Right Click] Remove {thing}",
"increaseStacks": "[Left Click] Increment Stacks",
"decreaseStacks": "[Right Click] Decrement Stacks",
"appliedBy": "Applied By: {by}"
},
"ItemBrowser": {
"title": "Daggerheart Compendium Browser",
"windowTitle": "Compendium Browser",
"hint": "Select a Folder in sidebar to start browsing through the compendium",
"browserSettings": "Browser Settings",
"searchPlaceholder": "Search...",
"columnName": "Name",
"tooltipFilters": "Filters",
"tooltipErase": "Erase",
@ -2966,7 +3133,7 @@
"weapons": "Weapons",
"armors": "Armors",
"consumables": "Consumables",
"loots": "Loots"
"loots": "Loot"
}
},
"Notifications": {
@ -3048,7 +3215,11 @@
"tokenActorsMissing": "[{names}] missing Actors",
"domainTouchRequirement": "This domain card requires {nr} {domain} cards in the loadout to be used",
"knowTheTide": "Know The Tide gained a token",
"lackingItemTransferPermission": "User {user} lacks owner permission needed to transfer items to {target}"
"lackingItemTransferPermission": "User {user} lacks owner permission needed to transfer items to {target}",
"noTokenTargeted": "No token is targeted"
},
"Progress": {
"migrationLabel": "Performing system migration. Please wait and do not close Foundry."
},
"Sidebar": {
"actorDirectory": {
@ -3057,6 +3228,9 @@
"companion": "Level {level} - {partner}",
"companionNoPartner": "No Partner",
"duplicateToNewTier": "Duplicate to New Tier",
"activateParty": "Make Active Party",
"partyIsActive": "Active",
"createAdversary": "Create Adversary",
"pickTierTitle": "Pick a new tier for this adversary"
},
"daggerheartMenu": {
@ -3068,6 +3242,7 @@
"Tooltip": {
"disableEffect": "Disable Effect",
"enableEffect": "Enable Effect",
"edit": "Edit",
"openItemWorld": "Open Item World",
"openActorWorld": "Open Actor World",
"sendToChat": "Send to Chat",

View file

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

View file

@ -11,7 +11,10 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
this.character = character;
this.setup = {
traits: this.character.system.traits,
traits: Object.keys(this.character.system.traits).reduce((acc, key) => {
acc[key] = { value: null };
return acc;
}, {}),
ancestryName: {
primary: '',
secondary: ''
@ -377,8 +380,10 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
];
return Object.values(this.setup.traits).reduce((acc, x) => {
const index = traitCompareArray.indexOf(x.value);
if (index === -1) return acc;
traitCompareArray.splice(index, 1);
acc += index !== -1;
acc += 1;
return acc;
}, 0);
}
@ -554,7 +559,7 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
experiences: {
...this.setup.experiences,
...Object.keys(this.character.system.experiences).reduce((acc, key) => {
acc[`-=${key}`] = null;
acc[`${key}`] = _del;
return acc;
}, {})
}

View file

@ -13,7 +13,7 @@ export { default as OwnershipSelection } from './ownershipSelection.mjs';
export { default as RerollDamageDialog } from './rerollDamageDialog.mjs';
export { default as ResourceDiceDialog } from './resourceDiceDialog.mjs';
export { default as ActionSelectionDialog } from './actionSelectionDialog.mjs';
export { default as GroupRollDialog } from './group-roll-dialog.mjs';
export { default as TagTeamDialog } from './tagTeamDialog.mjs';
export { default as GroupRollDialog } from './groupRollDialog.mjs';
export { default as RiskItAllDialog } from './riskItAllDialog.mjs';
export { default as CompendiumBrowserSettingsDialog } from './CompendiumBrowserSettings.mjs';

View file

@ -72,8 +72,8 @@ export default class ActionSelectionDialog extends HandlebarsApplicationMixin(Ap
static async #onChooseAction(event, button) {
const { actionId } = button.dataset;
this.#action = this.#item.system.actionsList.find(a => a._id === actionId);
Object.defineProperty(this.#event, 'shiftKey', {
this.action = this.item.system.actionsList.find(a => a._id === actionId);
Object.defineProperty(this.event, 'shiftKey', {
get() {
return event.shiftKey;
}

View file

@ -10,6 +10,12 @@ export default class BeastformDialog extends HandlebarsApplicationMixin(Applicat
this.selected = null;
this.evolved = { form: null };
this.hybrid = { forms: {}, advantages: {}, features: {} };
this.modifications = {
traitBonuses: configData.modifications.traitBonuses.map(x => ({
trait: null,
bonus: x.bonus
}))
};
this._dragDrop = this._createDragDropHandlers();
}
@ -28,6 +34,7 @@ export default class BeastformDialog extends HandlebarsApplicationMixin(Applicat
selectBeastform: this.selectBeastform,
toggleHybridFeature: this.toggleHybridFeature,
toggleHybridAdvantage: this.toggleHybridAdvantage,
toggleTraitBonus: this.toggleTraitBonus,
submitBeastform: this.submitBeastform
},
form: {
@ -48,6 +55,7 @@ export default class BeastformDialog extends HandlebarsApplicationMixin(Applicat
tabs: { template: 'systems/daggerheart/templates/dialogs/beastform/tabs.hbs' },
beastformTier: { template: 'systems/daggerheart/templates/dialogs/beastform/beastformTier.hbs' },
advanced: { template: 'systems/daggerheart/templates/dialogs/beastform/advanced.hbs' },
modifications: { template: 'systems/daggerheart/templates/dialogs/beastform/modifications.hbs' },
footer: { template: 'systems/daggerheart/templates/dialogs/beastform/footer.hbs' }
};
@ -146,6 +154,9 @@ export default class BeastformDialog extends HandlebarsApplicationMixin(Applicat
{}
);
context.modifications = this.modifications;
context.traits = CONFIG.DH.ACTOR.abilities;
context.tier = beastformTiers[this.tabGroups.primary];
context.tierKey = this.tabGroups.primary;
@ -155,6 +166,9 @@ export default class BeastformDialog extends HandlebarsApplicationMixin(Applicat
}
canSubmit() {
const modificationsFinished = this.modifications.traitBonuses.every(x => x.trait);
if (!modificationsFinished) return false;
if (this.selected) {
switch (this.selected.system.beastformType) {
case 'normal':
@ -261,6 +275,13 @@ export default class BeastformDialog extends HandlebarsApplicationMixin(Applicat
this.render();
}
static toggleTraitBonus(_, button) {
const { index, trait } = button.dataset;
this.modifications.traitBonuses[index].trait =
this.modifications.traitBonuses[index].trait === trait ? null : trait;
this.render();
}
static async submitBeastform() {
await this.close({ submitted: true });
}
@ -292,6 +313,23 @@ 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(
x => x.key === `system.traits.${traitBonus.trait}.value`
);
if (existingChange) {
existingChange.value = Number.parseInt(existingChange.value) + traitBonus.bonus;
} else {
beastformEffect.changes.push({
key: `system.traits.${traitBonus.trait}.value`,
mode: 2,
priority: null,
value: traitBonus.bonus
});
}
}
resolve({
selected: selected,
evolved: { ...app.evolved, form: evolved },

View file

@ -77,8 +77,8 @@ export default class CharacterResetDialog extends HandlebarsApplicationMixin(App
if (!this.data.optional.portrait.keep) {
foundry.utils.setProperty(update, 'img', this.actor.schema.fields.img.initial(this.actor));
foundry.utils.setProperty(update, 'prototypeToken.==texture', {});
foundry.utils.setProperty(update, 'prototypeToken.==ring', {});
foundry.utils.setProperty(update, 'prototypeToken.texture', _replace({}));
foundry.utils.setProperty(update, 'prototypeToken.ring', _replace({}));
}
if (this.data.optional.biography.keep)
@ -89,7 +89,7 @@ export default class CharacterResetDialog extends HandlebarsApplicationMixin(App
const { system, ...rest } = update;
await this.actor.update({
...rest,
'==system': system ?? {}
system: _replace(system ?? {})
});
const inventoryItemTypes = ['weapon', 'armor', 'consumable', 'loot'];

View file

@ -35,7 +35,6 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
updateIsAdvantage: this.updateIsAdvantage,
selectExperience: this.selectExperience,
toggleReaction: this.toggleReaction,
toggleTagTeamRoll: this.toggleTagTeamRoll,
toggleSelectedEffect: this.toggleSelectedEffect,
submitRoll: this.submitRoll
},
@ -71,8 +70,8 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
context.rollConfig = this.config;
context.hasRoll = !!this.config.roll;
context.canRoll = true;
context.selectedRollMode = this.config.selectedRollMode ?? game.settings.get('core', 'rollMode');
context.rollModes = Object.entries(CONFIG.Dice.rollModes).map(([action, { label, icon }]) => ({
context.selectedMessageMode = this.config.selectedMessageMode ?? game.settings.get('core', 'messageMode');
context.rollModes = Object.entries(CONFIG.ChatMessage.modes).map(([action, { label, icon }]) => ({
action,
label,
icon
@ -124,6 +123,10 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
context.advantage = this.config.roll?.advantage;
context.disadvantage = this.config.roll?.disadvantage;
context.diceOptions = CONFIG.DH.GENERAL.diceTypes;
context.dieFaces = CONFIG.DH.GENERAL.dieFaces.reduce((acc, face) => {
acc[face] = `d${face}`;
return acc;
}, {});
context.isLite = this.config.roll?.lite;
context.extraFormula = this.config.extraFormula;
context.formula = this.roll.constructFormula(this.config);
@ -133,12 +136,6 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
context.reactionOverride = this.reactionOverride;
}
const tagTeamSetting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll);
if (this.actor && tagTeamSetting.members[this.actor.id] && !this.config.skips?.createMessage) {
context.activeTagTeamRoll = true;
context.tagTeamSelected = this.config.tagTeamSelected;
}
return context;
}
@ -149,19 +146,17 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
}));
}
static updateRollConfiguration(event, _, formData) {
static updateRollConfiguration(_event, _, formData) {
const { ...rest } = foundry.utils.expandObject(formData.object);
this.config.selectedRollMode = rest.selectedRollMode;
this.config.selectedMessageMode = rest.selectedMessageMode;
if (this.config.costs) {
this.config.costs = foundry.utils.mergeObject(this.config.costs, rest.costs);
}
if (this.config.uses) this.config.uses = foundry.utils.mergeObject(this.config.uses, rest.uses);
if (rest.roll?.dice) {
Object.entries(rest.roll.dice).forEach(([key, value]) => {
this.roll[key] = value;
});
this.roll = foundry.utils.mergeObject(this.roll, rest.roll.dice);
}
if (rest.hasOwnProperty('trait')) {
this.config.roll.trait = rest.trait;
@ -180,6 +175,15 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
this.disadvantage = advantage === -1;
this.config.roll.advantage = this.config.roll.advantage === advantage ? 0 : advantage;
if (this.config.roll.advantage === 1 && this.config.data.rules.roll.defaultAdvantageDice) {
const faces = Number.parseInt(this.config.data.rules.roll.defaultAdvantageDice);
this.roll.advantageFaces = Number.isNaN(faces) ? this.roll.advantageFaces : faces;
} else if (this.config.roll.advantage === -1 && this.config.data.rules.roll.defaultDisadvantageDice) {
const faces = Number.parseInt(this.config.data.rules.roll.defaultDisadvantageDice);
this.roll.advantageFaces = Number.isNaN(faces) ? this.roll.advantageFaces : faces;
}
this.render();
}
@ -215,11 +219,6 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
}
}
static toggleTagTeamRoll() {
this.config.tagTeamSelected = !this.config.tagTeamSelected;
this.render();
}
static toggleSelectedEffect(_event, button) {
this.selectedEffects[button.dataset.key].selected = !this.selectedEffects[button.dataset.key].selected;
this.render();

View file

@ -22,6 +22,8 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
},
actions: {
toggleSelectedEffect: this.toggleSelectedEffect,
updateGroupAttack: this.updateGroupAttack,
toggleCritical: this.toggleCritical,
submitRoll: this.submitRoll
},
form: {
@ -52,8 +54,9 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
context.formula = this.roll.constructFormula(this.config);
context.hasHealing = this.config.hasHealing;
context.directDamage = this.config.directDamage;
context.selectedRollMode = this.config.selectedRollMode;
context.rollModes = Object.entries(CONFIG.Dice.rollModes).map(([action, { label, icon }]) => ({
context.selectedMessageMode = this.config.selectedMessageMode;
context.isCritical = this.config.isCritical;
context.rollModes = Object.entries(CONFIG.ChatMessage.modes).map(([action, { label, icon }]) => ({
action,
label,
icon
@ -62,15 +65,45 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
context.hasSelectedEffects = Boolean(Object.keys(this.selectedEffects).length);
context.selectedEffects = this.selectedEffects;
context.damageOptions = this.config.damageOptions;
context.rangeOptions = CONFIG.DH.GENERAL.groupAttackRange;
return context;
}
static updateRollConfiguration(_event, _, formData) {
const { ...rest } = foundry.utils.expandObject(formData.object);
foundry.utils.mergeObject(this.config.roll, rest.roll);
foundry.utils.mergeObject(this.config.modifiers, rest.modifiers);
this.config.selectedRollMode = rest.selectedRollMode;
const data = foundry.utils.expandObject(formData.object);
foundry.utils.mergeObject(this.config.roll, data.roll);
foundry.utils.mergeObject(this.config.modifiers, data.modifiers);
this.config.selectedMessageMode = data.selectedMessageMode;
if (data.damageOptions) {
const numAttackers = data.damageOptions.groupAttack?.numAttackers;
if (typeof numAttackers !== 'number' || numAttackers % 1 !== 0) {
data.damageOptions.groupAttack.numAttackers = null;
}
foundry.utils.mergeObject(this.config.damageOptions, data.damageOptions);
}
this.render();
}
static updateGroupAttack() {
const targets = Array.from(game.user.targets);
if (targets.length === 0)
return ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.noTokenTargeted'));
const actorId = this.roll.data.parent.id;
const range = this.config.damageOptions.groupAttack.range;
const groupAttackTokens = game.system.api.fields.ActionFields.DamageField.getGroupAttackTokens(actorId, range);
this.config.damageOptions.groupAttack.numAttackers = groupAttackTokens.length;
this.render();
}
static toggleCritical() {
this.config.isCritical = !this.config.isCritical;
this.render();
}

View file

@ -1,4 +1,4 @@
import { damageKeyToNumber, getDamageLabel } from '../../helpers/utils.mjs';
import { damageKeyToNumber, getArmorSources, getDamageLabel } from '../../helpers/utils.mjs';
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
@ -10,6 +10,7 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
this.reject = reject;
this.actor = actor;
this.damage = damage;
this.damageType = damageType;
this.rulesDefault = game.settings.get(
CONFIG.DH.id,
@ -20,14 +21,20 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
this.rulesDefault
);
const canApplyArmor = damageType.every(t => actor.system.armorApplicableDamageTypes[t] === true);
const availableArmor = actor.system.armorScore - actor.system.armor.system.marks.value;
const maxArmorMarks = canApplyArmor ? availableArmor : 0;
const armor = [...Array(maxArmorMarks).keys()].reduce((acc, _) => {
acc[foundry.utils.randomID()] = { selected: false };
const orderedArmorSources = getArmorSources(actor).filter(s => !s.disabled);
const armor = orderedArmorSources.reduce((acc, { document }) => {
const { current, max } = document.type === 'armor' ? document.system.armor : document.system.armorData;
acc.push({
effect: document,
marks: [...Array(max).keys()].reduce((acc, _, index) => {
const spent = index < current;
acc[foundry.utils.randomID()] = { selected: false, disabled: spent, spent };
return acc;
}, {});
}, {})
});
return acc;
}, []);
const stress = [...Array(actor.system.rules.damageReduction.maxArmorMarked.stressExtra ?? 0).keys()].reduce(
(acc, _) => {
acc[foundry.utils.randomID()] = { selected: false };
@ -121,13 +128,11 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
context.thresholdImmunities =
Object.keys(this.thresholdImmunities).length > 0 ? this.thresholdImmunities : null;
const { selectedArmorMarks, selectedStressMarks, stressReductions, currentMarks, currentDamage } =
const { selectedStressMarks, stressReductions, currentMarks, currentDamage, maxArmorUsed, availableArmor } =
this.getDamageInfo();
context.armorScore = this.actor.system.armorScore;
context.armorScore = this.actor.system.armorScore.max;
context.armorMarks = currentMarks;
context.basicMarksUsed =
selectedArmorMarks.length === this.actor.system.rules.damageReduction.maxArmorMarked.value;
const stressReductionStress = this.availableStressReductions
? stressReductions.reduce((acc, red) => acc + red.cost, 0)
@ -141,16 +146,30 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
}
: null;
const maxArmor = this.actor.system.rules.damageReduction.maxArmorMarked.value;
context.marks = {
armor: Object.keys(this.marks.armor).reduce((acc, key, index) => {
const mark = this.marks.armor[key];
if (!this.rulesOn || index + 1 <= maxArmor) acc[key] = mark;
context.maxArmorUsed = maxArmorUsed;
context.availableArmor = availableArmor;
context.basicMarksUsed = availableArmor === 0 || selectedStressMarks.length;
return acc;
}, {}),
const armorSources = [];
for (const source of this.marks.armor) {
const parent = source.effect.origin
? await foundry.utils.fromUuid(source.effect.origin)
: source.effect.parent;
const useEffectName = parent.type === 'armor' || parent instanceof Actor;
const label = useEffectName ? source.effect.name : parent.name;
armorSources.push({
label: label,
uuid: source.effect.uuid,
marks: source.marks
});
}
context.marks = {
armor: armorSources,
stress: this.marks.stress
};
context.usesStressArmor = Object.keys(context.marks.stress).length;
context.availableStressReductions = this.availableStressReductions;
context.damage = getDamageLabel(this.damage);
@ -167,27 +186,31 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
}
getDamageInfo = () => {
const selectedArmorMarks = Object.values(this.marks.armor).filter(x => x.selected);
const selectedArmorMarks = this.marks.armor.flatMap(x => Object.values(x.marks).filter(x => x.selected));
const selectedStressMarks = Object.values(this.marks.stress).filter(x => x.selected);
const stressReductions = this.availableStressReductions
? Object.values(this.availableStressReductions).filter(red => red.selected)
: [];
const currentMarks =
this.actor.system.armor.system.marks.value + selectedArmorMarks.length + selectedStressMarks.length;
const currentMarks = this.actor.system.armorScore.value + selectedArmorMarks.length;
const maxArmorUsed = this.actor.system.rules.damageReduction.maxArmorMarked.value + selectedStressMarks.length;
const availableArmor =
maxArmorUsed -
this.marks.armor.reduce((acc, source) => {
acc += Object.values(source.marks).filter(x => x.selected).length;
return acc;
}, 0);
const armorMarkReduction =
selectedArmorMarks.length * this.actor.system.rules.damageReduction.increasePerArmorMark;
let currentDamage = Math.max(
this.damage - armorMarkReduction - selectedStressMarks.length - stressReductions.length,
0
);
let currentDamage = Math.max(this.damage - armorMarkReduction - stressReductions.length, 0);
if (this.reduceSeverity) {
currentDamage = Math.max(currentDamage - this.reduceSeverity, 0);
}
if (this.thresholdImmunities[currentDamage]) currentDamage = 0;
return { selectedArmorMarks, selectedStressMarks, stressReductions, currentMarks, currentDamage };
return { selectedStressMarks, stressReductions, currentMarks, currentDamage, maxArmorUsed, availableArmor };
};
static toggleRules() {
@ -195,13 +218,10 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
const maxArmor = this.actor.system.rules.damageReduction.maxArmorMarked.value;
this.marks = {
armor: Object.keys(this.marks.armor).reduce((acc, key, index) => {
const mark = this.marks.armor[key];
armor: this.marks.armor.map((mark, index) => {
const keepSelectValue = !this.rulesOn || index + 1 <= maxArmor;
acc[key] = { ...mark, selected: keepSelectValue ? mark.selected : false };
return acc;
}, {}),
return { ...mark, selected: keepSelectValue ? mark.selected : false };
}),
stress: this.marks.stress
};
@ -209,8 +229,8 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
}
static setMarks(_, target) {
const currentMark = this.marks[target.dataset.type][target.dataset.key];
const { selectedStressMarks, stressReductions, currentMarks, currentDamage } = this.getDamageInfo();
const currentMark = foundry.utils.getProperty(this.marks, target.dataset.path);
const { selectedStressMarks, stressReductions, currentDamage, availableArmor } = this.getDamageInfo();
if (!currentMark.selected && currentDamage === 0) {
ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.damageAlreadyNone'));
@ -218,12 +238,18 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
}
if (this.rulesOn) {
if (!currentMark.selected && currentMarks === this.actor.system.armorScore) {
if (target.dataset.type === 'armor' && !currentMark.selected && !availableArmor) {
ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noAvailableArmorMarks'));
return;
}
}
const stressUsed = selectedStressMarks.length;
if (target.dataset.type === 'armor' && stressUsed) {
const updateResult = this.updateStressArmor(target.dataset.id, !currentMark.selected);
if (updateResult === false) return;
}
if (currentMark.selected) {
const currentDamageLabel = getDamageLabel(currentDamage);
for (let reduction of stressReductions) {
@ -232,8 +258,16 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
}
}
if (target.dataset.type === 'armor' && selectedStressMarks.length > 0) {
selectedStressMarks.forEach(mark => (mark.selected = false));
if (target.dataset.type === 'stress' && currentMark.armorMarkId) {
for (const source of this.marks.armor) {
const match = Object.keys(source.marks).find(key => key === currentMark.armorMarkId);
if (match) {
source.marks[match].selected = false;
break;
}
}
currentMark.armorMarkId = null;
}
}
@ -241,6 +275,25 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
this.render();
}
updateStressArmor(armorMarkId, select) {
let stressMarkKey = null;
if (select) {
stressMarkKey = Object.keys(this.marks.stress).find(
key => this.marks.stress[key].selected && !this.marks.stress[key].armorMarkId
);
} else {
stressMarkKey = Object.keys(this.marks.stress).find(
key => this.marks.stress[key].armorMarkId === armorMarkId
);
if (!stressMarkKey)
stressMarkKey = Object.keys(this.marks.stress).find(key => this.marks.stress[key].selected);
}
if (!stressMarkKey) return false;
this.marks.stress[stressMarkKey].armorMarkId = select ? armorMarkId : null;
}
static useStressReduction(_, target) {
const damageValue = Number(target.dataset.reduction);
const stressReduction = this.availableStressReductions[damageValue];
@ -279,11 +332,18 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
}
static async takeDamage() {
const { selectedArmorMarks, selectedStressMarks, stressReductions, currentDamage } = this.getDamageInfo();
const armorSpent = selectedArmorMarks.length + selectedStressMarks.length;
const stressSpent = selectedStressMarks.length + stressReductions.reduce((acc, red) => acc + red.cost, 0);
const { selectedStressMarks, stressReductions, currentDamage } = this.getDamageInfo();
const armorChanges = this.marks.armor.reduce((acc, source) => {
const amount = Object.values(source.marks).filter(x => x.selected).length;
if (amount) acc.push({ uuid: source.effect.uuid, amount });
this.resolve({ modifiedDamage: currentDamage, armorSpent, stressSpent });
return acc;
}, []);
const stressSpent =
selectedStressMarks.filter(x => x.armorMarkId).length +
stressReductions.reduce((acc, red) => acc + red.cost, 0);
this.resolve({ modifiedDamage: currentDamage, armorChanges, stressSpent });
await this.close(true);
}

View file

@ -1,4 +1,4 @@
import { refreshIsAllowed } from '../../helpers/utils.mjs';
import { expireActiveEffects, refreshIsAllowed } from '../../helpers/utils.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
@ -203,7 +203,7 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
const msg = {
user: game.user.id,
system: {
moves: moves,
moves: moves.map(move => ({ ...move, actions: Array.from(move.actions) })),
actor: this.actor.uuid
},
speaker: cls.getSpeaker(),
@ -259,11 +259,14 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
const resetValue = increasing
? 0
: feature.system.resource.max
? Roll.replaceFormulaData(feature.system.resource.max, this.actor)
? new Roll(Roll.replaceFormulaData(feature.system.resource.max, this.actor)).evaluateSync().total
: 0;
await feature.update({ 'system.resource.value': resetValue });
}
expireActiveEffects(this.actor, [this.shortRest ? 'shortRest' : 'longRest']);
this.close();
} else {
this.render();

View file

@ -1,204 +0,0 @@
import autocomplete from 'autocompleter';
import { abilities } from '../../config/actorConfig.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
export default class GroupRollDialog extends HandlebarsApplicationMixin(ApplicationV2) {
constructor(actors) {
super();
this.actors = actors;
this.actorLeader = {};
this.actorsMembers = [];
}
get title() {
return 'Group Roll';
}
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ['daggerheart', 'views', 'dh-style', 'dialog', 'group-roll'],
position: { width: 'auto', height: 'auto' },
window: {
title: 'DAGGERHEART.UI.Chat.groupRoll.title'
},
actions: {
roll: GroupRollDialog.#roll,
removeLeader: GroupRollDialog.#removeLeader,
removeMember: GroupRollDialog.#removeMember
},
form: { handler: this.updateData, submitOnChange: true, closeOnSubmit: false }
};
static PARTS = {
application: {
id: 'group-roll',
template: 'systems/daggerheart/templates/dialogs/group-roll/group-roll.hbs'
}
};
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
const leaderChoices = this.actors.filter(x => this.actorsMembers.every(member => member.actor?.id !== x.id));
const memberChoices = this.actors.filter(
x => this.actorLeader?.actor?.id !== x.id && this.actorsMembers.every(member => member.actor?.id !== x.id)
);
htmlElement.querySelectorAll('.leader-change-input').forEach(element => {
autocomplete({
input: element,
fetch: function (text, update) {
if (!text) {
update(leaderChoices);
} else {
text = text.toLowerCase();
var suggestions = leaderChoices.filter(n => n.name.toLowerCase().includes(text));
update(suggestions);
}
},
render: function (actor, search) {
const actorName = game.i18n.localize(actor.name);
const matchIndex = actorName.toLowerCase().indexOf(search);
const beforeText = actorName.slice(0, matchIndex);
const matchText = actorName.slice(matchIndex, matchIndex + search.length);
const after = actorName.slice(matchIndex + search.length, actorName.length);
const img = document.createElement('img');
img.src = actor.img;
const element = document.createElement('li');
element.appendChild(img);
const label = document.createElement('span');
label.innerHTML =
`${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`.replaceAll(
' ',
'&nbsp;'
);
element.appendChild(label);
return element;
},
renderGroup: function (label) {
const itemElement = document.createElement('div');
itemElement.textContent = game.i18n.localize(label);
return itemElement;
},
onSelect: actor => {
element.value = actor.uuid;
this.actorLeader = { actor: actor, trait: 'agility', difficulty: 0 };
this.render();
},
click: e => e.fetch(),
customize: function (_input, _inputRect, container) {
container.style.zIndex = foundry.applications.api.ApplicationV2._maxZ;
},
minLength: 0
});
});
htmlElement.querySelectorAll('.team-push-input').forEach(element => {
autocomplete({
input: element,
fetch: function (text, update) {
if (!text) {
update(memberChoices);
} else {
text = text.toLowerCase();
var suggestions = memberChoices.filter(n => n.name.toLowerCase().includes(text));
update(suggestions);
}
},
render: function (actor, search) {
const actorName = game.i18n.localize(actor.name);
const matchIndex = actorName.toLowerCase().indexOf(search);
const beforeText = actorName.slice(0, matchIndex);
const matchText = actorName.slice(matchIndex, matchIndex + search.length);
const after = actorName.slice(matchIndex + search.length, actorName.length);
const img = document.createElement('img');
img.src = actor.img;
const element = document.createElement('li');
element.appendChild(img);
const label = document.createElement('span');
label.innerHTML =
`${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`.replaceAll(
' ',
'&nbsp;'
);
element.appendChild(label);
return element;
},
renderGroup: function (label) {
const itemElement = document.createElement('div');
itemElement.textContent = game.i18n.localize(label);
return itemElement;
},
onSelect: actor => {
element.value = actor.uuid;
this.actorsMembers.push({ actor: actor, trait: 'agility', difficulty: 0 });
this.render({ force: true });
},
click: e => e.fetch(),
customize: function (_input, _inputRect, container) {
container.style.zIndex = foundry.applications.api.ApplicationV2._maxZ;
},
minLength: 0
});
});
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.leader = this.actorLeader;
context.members = this.actorsMembers;
context.traitList = abilities;
context.allSelected = this.actorsMembers.length + (this.actorLeader?.actor ? 1 : 0) === this.actors.length;
context.rollDisabled = context.members.length === 0 || !this.actorLeader?.actor;
return context;
}
static updateData(event, _, formData) {
const { actorLeader, actorsMembers } = foundry.utils.expandObject(formData.object);
this.actorLeader = foundry.utils.mergeObject(this.actorLeader, actorLeader);
this.actorsMembers = foundry.utils.mergeObject(this.actorsMembers, actorsMembers);
this.render(true);
}
static async #removeLeader(_, button) {
this.actorLeader = null;
this.render();
}
static async #removeMember(_, button) {
this.actorsMembers = this.actorsMembers.filter(m => m.actor.uuid !== button.dataset.memberUuid);
this.render();
}
static async #roll() {
const cls = getDocumentClass('ChatMessage');
const systemData = {
leader: this.actorLeader,
members: this.actorsMembers
};
const msg = {
type: 'groupRoll',
user: game.user.id,
speaker: cls.getSpeaker(),
title: game.i18n.localize('DAGGERHEART.UI.Chat.groupRoll.title'),
system: systemData,
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/ui/chat/groupRoll.hbs',
{ system: systemData }
)
};
cls.create(msg);
this.close();
}
}

View file

@ -0,0 +1,527 @@
import { ResourceUpdateMap } from '../../data/action/baseAction.mjs';
import { emitAsGM, GMUpdateEvent, RefreshType, socketEvent } from '../../systemRegistration/socket.mjs';
import Party from '../sheets/actors/party.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
export default class GroupRollDialog extends HandlebarsApplicationMixin(ApplicationV2) {
constructor(party) {
super();
this.party = party;
this.partyMembers = party.system.partyMembers
.filter(x => Party.DICE_ROLL_ACTOR_TYPES.includes(x.type))
.map(member => ({
...member.toObject(),
uuid: member.uuid,
id: member.id,
selected: true,
owned: member.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER)
}));
this.leader = null;
this.openForAllPlayers = true;
this.tabGroups.application = Object.keys(party.system.groupRoll.participants).length
? 'groupRoll'
: 'initialization';
Hooks.on(socketEvent.Refresh, this.groupRollRefresh.bind());
}
get title() {
return game.i18n.localize('DAGGERHEART.APPLICATIONS.GroupRollSelect.title');
}
static DEFAULT_OPTIONS = {
tag: 'form',
id: 'GroupRollDialog',
classes: ['daggerheart', 'views', 'dh-style', 'dialog', 'group-roll-dialog'],
position: { width: 550, height: 'auto' },
actions: {
toggleSelectMember: this.#toggleSelectMember,
startGroupRoll: this.#startGroupRoll,
makeRoll: this.#makeRoll,
removeRoll: this.#removeRoll,
rerollDice: this.#rerollDice,
makeLeaderRoll: this.#makeLeaderRoll,
removeLeaderRoll: this.#removeLeaderRoll,
rerollLeaderDice: this.#rerollLeaderDice,
markSuccessfull: this.#markSuccessfull,
cancelRoll: this.#onCancelRoll,
finishRoll: this.#finishRoll
},
form: { handler: this.updateData, submitOnChange: true, closeOnSubmit: false }
};
static PARTS = {
initialization: {
id: 'initialization',
template: 'systems/daggerheart/templates/dialogs/groupRollDialog/initialization.hbs'
},
leader: {
id: 'leader',
template: 'systems/daggerheart/templates/dialogs/groupRollDialog/leader.hbs'
},
groupRoll: {
id: 'groupRoll',
template: 'systems/daggerheart/templates/dialogs/groupRollDialog/groupRoll.hbs'
},
footer: {
id: 'footer',
template: 'systems/daggerheart/templates/dialogs/groupRollDialog/footer.hbs'
}
};
/** @inheritdoc */
static TABS = {
application: {
tabs: [{ id: 'initialization' }, { id: 'groupRoll' }]
}
};
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
htmlElement
.querySelector('.main-character-field')
?.addEventListener('input', this.updateLeaderField.bind(this));
}
_configureRenderParts(options) {
const { initialization, leader, groupRoll, footer } = super._configureRenderParts(options);
const augmentedParts = { initialization };
for (const memberKey of Object.keys(this.party.system.groupRoll.aidingCharacters)) {
augmentedParts[memberKey] = {
id: memberKey,
template: 'systems/daggerheart/templates/dialogs/groupRollDialog/groupRollMember.hbs'
};
}
augmentedParts.leader = leader;
augmentedParts.groupRoll = groupRoll;
augmentedParts.footer = footer;
return augmentedParts;
}
/**@inheritdoc */
async _onRender(context, options) {
await super._onRender(context, options);
if (this.element.querySelector('.team-container')) return;
if (this.tabGroups.application !== this.constructor.PARTS.initialization.id) {
const initializationPart = this.element.querySelector('.initialization-container');
initializationPart.insertAdjacentHTML('afterend', '<div class="team-container"></div>');
initializationPart.insertAdjacentHTML(
'afterend',
`<div class="section-title">${game.i18n.localize('DAGGERHEART.APPLICATIONS.GroupRollSelect.aidingCharacters')}</div>`
);
const teamContainer = this.element.querySelector('.team-container');
for (const memberContainer of this.element.querySelectorAll('.team-member-container'))
teamContainer.appendChild(memberContainer);
}
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.isGM = game.user.isGM;
context.isEditable = this.getIsEditable();
context.fields = this.party.system.schema.fields.groupRoll.fields;
context.data = this.party.system.groupRoll;
context.traitOptions = CONFIG.DH.ACTOR.abilities;
context.members = {};
context.allHaveRolled = Object.keys(context.data.participants).every(key => {
const data = context.data.participants[key];
return Boolean(data.rollData);
});
return context;
}
async _preparePartContext(partId, context, options) {
const partContext = await super._preparePartContext(partId, context, options);
partContext.partId = partId;
switch (partId) {
case 'initialization':
partContext.groupRollFields = this.party.system.schema.fields.groupRoll.fields;
partContext.memberSelection = this.partyMembers;
const selectedMembers = partContext.memberSelection.filter(x => x.selected);
partContext.selectedLeader = this.leader;
partContext.selectedLeaderOptions = selectedMembers
.filter(actor => actor.owned)
.map(x => ({ value: x.id, label: x.name }));
partContext.selectedLeaderDisabled = !selectedMembers.length;
partContext.canStartGroupRoll = selectedMembers.length > 1 && this.leader?.memberId;
partContext.openForAllPlayers = this.openForAllPlayers;
break;
case 'leader':
partContext.leader = this.getRollCharacterData(this.party.system.groupRoll.leader);
break;
case 'groupRoll':
const leader = this.party.system.groupRoll.leader;
partContext.hasRolled =
leader?.rollData ||
Object.values(this.party.system.groupRoll?.aidingCharacters ?? {}).some(
x => x.successfull !== null
);
const { modifierTotal, modifiers } = Object.values(this.party.system.groupRoll.aidingCharacters).reduce(
(acc, curr) => {
const modifier = curr.successfull === true ? 1 : curr.successfull === false ? -1 : null;
if (modifier) {
acc.modifierTotal += modifier;
acc.modifiers.push(modifier);
}
return acc;
},
{ modifierTotal: 0, modifiers: [] }
);
const leaderTotal = leader?.rollData ? leader.roll.total : null;
partContext.groupRoll = {
totalLabel: leader?.rollData
? game.i18n.format('DAGGERHEART.GENERAL.withThing', {
thing: leader.roll.totalLabel
})
: null,
totalDualityClass: leader?.roll?.isCritical ? 'critical' : leader?.roll?.withHope ? 'hope' : 'fear',
total: leaderTotal + modifierTotal,
leaderTotal: leaderTotal,
modifiers
};
break;
case 'footer':
partContext.canFinishRoll =
Boolean(this.party.system.groupRoll.leader?.rollData) &&
Object.values(this.party.system.groupRoll.aidingCharacters).every(x => x.successfull !== null);
break;
}
if (Object.keys(this.party.system.groupRoll.aidingCharacters).includes(partId)) {
const characterData = this.party.system.groupRoll.aidingCharacters[partId];
partContext.members[partId] = this.getRollCharacterData(characterData, partId);
}
return partContext;
}
getRollCharacterData(data, partId) {
if (!data) return {};
const actor = game.actors.get(data.id);
return {
...data,
roll: data.roll,
isEditable: actor.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER),
key: partId,
readyToRoll: Boolean(data.rollChoice),
hasRolled: Boolean(data.rollData)
};
}
static async updateData(event, _, formData) {
const partyData = foundry.utils.expandObject(formData.object);
this.updatePartyData(partyData, this.getUpdatingParts(event.target));
}
async updatePartyData(update, updatingParts, options = { render: true }) {
if (!game.users.activeGM)
return ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.gmRequired'));
const gmUpdate = async update => {
await this.party.update(update);
this.render({ parts: updatingParts });
game.socket.emit(`system.${CONFIG.DH.id}`, {
action: socketEvent.Refresh,
data: { refreshType: RefreshType.GroupRoll, action: 'refresh', parts: updatingParts }
});
};
await emitAsGM(
GMUpdateEvent.UpdateDocument,
gmUpdate,
update,
this.party.uuid,
options.render ? { refreshType: RefreshType.GroupRoll, action: 'refresh', parts: updatingParts } : undefined
);
}
getUpdatingParts(target) {
const { initialization, leader, groupRoll, footer } = this.constructor.PARTS;
const isInitialization = this.tabGroups.application === initialization.id;
const updatingMember = target.closest('.team-member-container')?.dataset?.memberKey;
const updatingLeader = target.closest('.main-character-outer-container');
return [
...(isInitialization ? [initialization.id] : []),
...(updatingMember ? [updatingMember] : []),
...(updatingLeader ? [leader.id] : []),
...(!isInitialization ? [groupRoll.id, footer.id] : [])
];
}
getIsEditable() {
return this.party.system.partyMembers.some(actor => {
const selected = Boolean(this.party.system.groupRoll.participants[actor.id]);
return selected && actor.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER);
});
}
groupRollRefresh = ({ refreshType, action, parts }) => {
if (refreshType !== RefreshType.GroupRoll) return;
switch (action) {
case 'startGroupRoll':
this.tabGroups.application = 'groupRoll';
break;
case 'refresh':
this.render({ parts });
break;
case 'close':
this.close();
break;
}
};
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.groupRollRefresh);
return super.close(options);
}
//#region Initialization
static #toggleSelectMember(_, button) {
const member = this.partyMembers.find(x => x.id === button.dataset.id);
member.selected = !member.selected;
this.render();
}
updateLeaderField(event) {
if (!this.leader) this.leader = {};
this.leader.memberId = event.target.value;
this.render();
}
static async #startGroupRoll() {
const leader = this.partyMembers.find(x => x.id === this.leader.memberId);
const aidingCharacters = this.partyMembers.reduce((acc, curr) => {
if (curr.selected && curr.id !== this.leader.memberId)
acc[curr.id] = { id: curr.id, name: curr.name, img: curr.img };
return acc;
}, {});
await this.party.update({
'system.groupRoll': _replace(
new game.system.api.data.GroupRollData({
...this.party.system.groupRoll.toObject(),
leader: { id: leader.id, name: leader.name, img: leader.img },
aidingCharacters
})
)
});
const hookData = { openForAllPlayers: this.openForAllPlayers, partyId: this.party.id };
Hooks.callAll(CONFIG.DH.HOOKS.hooksConfig.groupRollStart, hookData);
game.socket.emit(`system.${CONFIG.DH.id}`, {
action: socketEvent.GroupRollStart,
data: hookData
});
this.render();
}
//#endregion
async makeRoll(button, characterData, path) {
const actor = game.actors.find(x => x.id === characterData.id);
if (!actor) return;
const result = await actor.rollTrait(characterData.rollChoice, {
skips: {
createMessage: true,
resources: true,
triggers: true
}
});
if (!result) return;
if (!game.modules.get('dice-so-nice')?.active) foundry.audio.AudioHelper.play({ src: CONFIG.sounds.dice });
const rollData = result.messageRoll.toJSON();
delete rollData.options.messageRoll;
this.updatePartyData(
{
[path]: rollData
},
this.getUpdatingParts(button)
);
}
static async #makeRoll(_event, button) {
const { member } = button.dataset;
const character = this.party.system.groupRoll.aidingCharacters[member];
this.makeRoll(button, character, `system.groupRoll.aidingCharacters.${member}.rollData`);
}
static async #makeLeaderRoll(_event, button) {
const character = this.party.system.groupRoll.leader;
this.makeRoll(button, character, 'system.groupRoll.leader.rollData');
}
async removeRoll(button, path) {
this.updatePartyData(
{
[path]: {
rollData: null,
rollChoice: null,
selected: false,
successfull: null
}
},
this.getUpdatingParts(button)
);
}
static async #removeRoll(_event, button) {
this.removeRoll(button, `system.groupRoll.aidingCharacters.${button.dataset.member}`);
}
static async #removeLeaderRoll(_event, button) {
this.removeRoll(button, 'system.groupRoll.leader');
}
async rerollDice(button, data, path) {
const { diceType } = button.dataset;
const dieIndex = diceType === 'hope' ? 0 : diceType === 'fear' ? 1 : 2;
const newRoll = game.system.api.dice.DualityRoll.fromData(data.rollData);
const dice = newRoll.dice[dieIndex];
await dice.reroll(`/r1=${dice.total}`, {
liveRoll: {
roll: newRoll,
isReaction: true
}
});
const rollData = newRoll.toJSON();
this.updatePartyData(
{
[path]: rollData
},
this.getUpdatingParts(button)
);
}
static async #rerollDice(_, button) {
const { member } = button.dataset;
this.rerollDice(
button,
this.party.system.groupRoll.aidingCharacters[member],
`system.groupRoll.aidingCharacters.${member}.rollData`
);
}
static async #rerollLeaderDice(_, button) {
this.rerollDice(button, this.party.system.groupRoll.leader, `system.groupRoll.leader.rollData`);
}
static #markSuccessfull(_event, button) {
const previousValue = this.party.system.groupRoll.aidingCharacters[button.dataset.member].successfull;
const newValue = Boolean(button.dataset.successfull === 'true');
this.updatePartyData(
{
[`system.groupRoll.aidingCharacters.${button.dataset.member}.successfull`]:
previousValue === newValue ? null : newValue
},
this.getUpdatingParts(button)
);
}
static async #onCancelRoll(_event, _button, options = { confirm: true }) {
this.cancelRoll(options);
}
async cancelRoll(options = { confirm: true }) {
if (options.confirm) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.localize('DAGGERHEART.APPLICATIONS.GroupRollSelect.cancelConfirmTitle')
},
content: game.i18n.localize('DAGGERHEART.APPLICATIONS.GroupRollSelect.cancelConfirmText')
});
if (!confirmed) return;
}
await this.updatePartyData(
{
'system.groupRoll': {
leader: null,
aidingCharacters: _replace({})
}
},
[],
{ render: false }
);
this.close();
game.socket.emit(`system.${CONFIG.DH.id}`, {
action: socketEvent.Refresh,
data: { refreshType: RefreshType.GroupRoll, action: 'close' }
});
}
static async #finishRoll() {
const totalRoll = this.party.system.groupRoll.leader.roll;
for (const character of Object.values(this.party.system.groupRoll.aidingCharacters)) {
totalRoll.terms.push(new foundry.dice.terms.OperatorTerm({ operator: character.successfull ? '+' : '-' }));
totalRoll.terms.push(new foundry.dice.terms.NumericTerm({ number: 1 }));
}
await totalRoll._evaluate();
const systemData = totalRoll.options;
const actor = game.actors.get(this.party.system.groupRoll.leader.id);
const cls = getDocumentClass('ChatMessage'),
msgData = {
type: 'dualityRoll',
user: game.user.id,
title: game.i18n.localize('DAGGERHEART.APPLICATIONS.GroupRollSelect.title'),
speaker: cls.getSpeaker({ actor }),
system: systemData,
rolls: [JSON.stringify(totalRoll)],
sound: null,
flags: { core: { RollTable: true } }
};
await cls.create(msgData);
const resourceMap = new ResourceUpdateMap(actor);
if (totalRoll.isCritical) {
resourceMap.addResources([
{ key: 'stress', value: -1, total: 1 },
{ key: 'hope', value: 1, total: 1 }
]);
} else if (totalRoll.withHope) {
resourceMap.addResources([{ key: 'hope', value: 1, total: 1 }]);
} else {
resourceMap.addResources([{ key: 'fear', value: 1, total: 1 }]);
}
resourceMap.updateResources();
/* Fin */
this.cancelRoll({ confirm: false });
}
}

View file

@ -38,13 +38,15 @@ export default class ItemTransferDialog extends HandlebarsApplicationMixin(Appli
originActor ??= item?.actor;
const homebrewKey = CONFIG.DH.SETTINGS.gameSettings.Homebrew;
const currencySetting = game.settings.get(CONFIG.DH.id, homebrewKey).currency?.[currency] ?? null;
const max = item?.system.quantity ?? originActor.system.gold[currency] ?? 0;
return {
originActor,
targetActor,
itemImage: item?.img,
currencyIcon: currencySetting?.icon,
max: item?.system.quantity ?? originActor.system.gold[currency] ?? 0,
max,
initial: targetActor.system.metadata.quantifiable?.includes(item.type) ? max : 1,
title: item?.name ?? currencySetting?.label
};
}

View file

@ -1,5 +1,3 @@
import { RefreshType, socketEvent } from '../../systemRegistration/socket.mjs';
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
export default class RerollDamageDialog extends HandlebarsApplicationMixin(ApplicationV2) {
@ -123,16 +121,8 @@ export default class RerollDamageDialog extends HandlebarsApplicationMixin(Appli
return acc;
}, {})
};
await this.message.update(update);
Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.TagTeamRoll });
await game.socket.emit(`system.${CONFIG.DH.id}`, {
action: socketEvent.Refresh,
data: {
refreshType: RefreshType.TagTeamRoll
}
});
await this.close();
}

File diff suppressed because it is too large Load diff

View file

@ -122,15 +122,14 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD {
async toggleClowncar(actors) {
const animationDuration = 500;
const activeTokens = actors.flatMap(member => member.getActiveTokens());
const scene = game.scenes.get(game.user.viewedScene);
/* getDependentTokens returns already removed tokens with id = null. Need to filter that until it's potentially fixed from Foundry */
const activeTokens = actors.flatMap(member => member.getDependentTokens({ scenes: scene }).filter(x => x._id));
const { x: actorX, y: actorY } = this.document;
if (activeTokens.length > 0) {
for (let token of activeTokens) {
await token.document.update(
{ x: actorX, y: actorY, alpha: 0 },
{ animation: { duration: animationDuration } }
);
setTimeout(() => token.document.delete(), animationDuration);
await token.update({ x: actorX, y: actorY, alpha: 0 }, { animation: { duration: animationDuration } });
setTimeout(() => token.delete(), animationDuration);
}
} else {
const activeScene = game.scenes.find(x => x.id === game.user.viewedScene);
@ -140,11 +139,16 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD {
tokenData.push(data.toObject());
}
const viewedLevel = game.scenes.get(game.user.viewedScene).levels.get(game.user.viewedLevel);
const elevation = this.actor.token?.elevation ?? viewedLevel.elevation.bottom;
const newTokens = await activeScene.createEmbeddedDocuments(
'Token',
tokenData.map(tokenData => ({
...tokenData,
alpha: 0,
level: viewedLevel,
elevation: elevation,
x: actorX,
y: actorY
}))

View file

@ -67,7 +67,7 @@ export default class DhCompanionLevelUp extends BaseLevelUp {
break;
case 'summary':
const levelKeys = Object.keys(this.levelup.levels);
const actorDamageDice = this.actor.system.attack.damage.parts[0].value.dice;
const actorDamageDice = this.actor.system.attack.damage.parts.hitPoints.value.dice;
const actorRange = this.actor.system.attack.range;
let achievementExperiences = [];

View file

@ -477,7 +477,7 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
const secondaryData = Object.keys(
foundry.utils.getProperty(this.levelup, `${target.dataset.path}.secondaryData`)
).reduce((acc, key) => {
acc[`-=${key}`] = null;
acc[key] = _del;
return acc;
}, {});
await this.levelup.updateSource({
@ -511,9 +511,9 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
const current = foundry.utils.getProperty(this.levelup, `${basePath}.${button.dataset.option}`);
if (Number(button.dataset.cost) > 1 || Object.keys(current).length === 1) {
// Simple handling that doesn't cover potential Custom LevelTiers.
update[`${basePath}.-=${button.dataset.option}`] = null;
update[`${basePath}.${button.dataset.option}`] = _del;
} else {
update[`${basePath}.${button.dataset.option}.-=${button.dataset.checkboxNr}`] = null;
update[`${basePath}.${button.dataset.option}.${button.dataset.checkboxNr}`] = _del;
}
} else {
if (this.levelup.levels[this.levelup.currentLevel].nrSelections.available < Number(button.dataset.cost)) {

View file

@ -62,7 +62,15 @@ export default class DhSceneConfigSettings extends foundry.applications.sheets.S
}
async _onDrop(event) {
event.stopPropagation();
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
if (data.type === 'Level') {
const level = await foundry.documents.Level.fromDropData(data);
if (level?.parent === this.document) return this._onSortLevel(event, level);
return;
}
const item = await foundry.utils.fromUuid(data.uuid);
if (item instanceof game.system.api.documents.DhpActor && item.type === 'environment') {
let sceneUuid = data.uuid;
@ -114,7 +122,7 @@ export default class DhSceneConfigSettings extends foundry.applications.sheets.S
for (const key of Object.keys(this.document._source.flags.daggerheart?.sceneEnvironments ?? {})) {
if (!submitData.flags.daggerheart.sceneEnvironments[key]) {
submitData.flags.daggerheart.sceneEnvironments[`-=${key}`] = null;
submitData.flags.daggerheart.sceneEnvironments[key] = _del;
}
}

View file

@ -118,8 +118,13 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
break;
case 'footer':
partContext.buttons = [
{ type: 'button', action: 'reset', icon: 'fa-solid fa-arrow-rotate-left', label: 'Reset' },
{ type: 'submit', icon: 'fa-solid fa-floppy-disk', label: 'Save Changes' }
{
type: 'button',
action: 'reset',
icon: 'fa-solid fa-arrow-rotate-left',
label: game.i18n.localize('SETTINGS.UI.ACTIONS.Reset')
},
{ type: 'submit', icon: 'fa-solid fa-floppy-disk', label: game.i18n.localize('EDITOR.Save') }
];
break;
}

View file

@ -298,7 +298,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
const isDowntime = ['shortRest', 'longRest'].includes(type);
const path = isDowntime ? `restMoves.${type}.moves` : `itemFeatures.${type}`;
await this.settings.updateSource({
[`${path}.-=${id}`]: null
[`${path}.${id}`]: _del
});
game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew, this.settings.toObject());
@ -322,7 +322,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
const fields = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).schema.fields;
const removeUpdate = Object.keys(this.settings.restMoves[target.dataset.type].moves).reduce((acc, key) => {
acc[`-=${key}`] = null;
acc[key] = _del;
return acc;
}, {});
@ -382,7 +382,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
[`itemFeatures.${target.dataset.type}`]: Object.keys(
this.settings.itemFeatures[target.dataset.type]
).reduce((acc, key) => {
acc[`-=${key}`] = null;
acc[key] = _del;
return acc;
}, {})
@ -455,12 +455,12 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
if (!confirmed) return;
await this.settings.updateSource({
[`domains.-=${this.selected.domain}`]: null
[`domains.${this.selected.domain}`]: _del
});
const currentSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew);
if (currentSettings.domains[this.selected.domain]) {
await currentSettings.updateSource({ [`domains.-=${this.selected.domain}`]: null });
await currentSettings.updateSource({ [`domains.${this.selected.domain}`]: _del });
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew, currentSettings);
}
@ -507,7 +507,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
static async deleteAdversaryType(_, target) {
const { key } = target.dataset;
await this.settings.updateSource({ [`adversaryTypes.-=${key}`]: null });
await this.settings.updateSource({ [`adversaryTypes.${key}`]: _del });
this.selected.adversaryType = this.selected.adversaryType === key ? null : this.selected.adversaryType;
this.render();
@ -563,7 +563,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
const { actorType, resourceKey } = target.dataset;
await this.settings.updateSource({
[`resources.${actorType}.resources.-=${resourceKey}`]: null
[`resources.${actorType}.resources.${resourceKey}`]: _del
});
game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew, this.settings.toObject());

View file

@ -3,7 +3,6 @@ export { default as ActionSettingsConfig } from './action-settings-config.mjs';
export { default as CharacterSettings } from './character-settings.mjs';
export { default as AdversarySettings } from './adversary-settings.mjs';
export { default as CompanionSettings } from './companion-settings.mjs';
export { default as SettingActiveEffectConfig } from './setting-active-effect-config.mjs';
export { default as SettingFeatureConfig } from './setting-feature-config.mjs';
export { default as EnvironmentSettings } from './environment-settings.mjs';
export { default as ActiveEffectConfig } from './activeEffectConfig.mjs';

View file

@ -1,3 +1,4 @@
import { getUnusedDamageTypes } from '../../helpers/utils.mjs';
import DaggerheartSheet from '../sheets/daggerheart-sheet.mjs';
const { ApplicationV2 } = foundry.applications.api;
@ -35,7 +36,9 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
editDoc: this.editDoc,
addTrigger: this.addTrigger,
removeTrigger: this.removeTrigger,
expandTrigger: this.expandTrigger
expandTrigger: this.expandTrigger,
addBeastformTraitBonus: this.addBeastformTraitBonus,
removeBeastformTraitBonus: this.removeBeastformTraitBonus
},
form: {
handler: this.updateForm,
@ -104,7 +107,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
}
};
static CLEAN_ARRAYS = ['damage.parts', 'cost', 'effects', 'summon'];
static CLEAN_ARRAYS = ['cost', 'effects', 'summon'];
_getTabs(tabs) {
for (const v of Object.values(tabs)) {
@ -153,8 +156,13 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
context.openSection = this.openSection;
context.tabs = this._getTabs(this.constructor.TABS);
context.config = CONFIG.DH;
if (this.action.damage?.hasOwnProperty('includeBase') && this.action.type === 'attack')
if (this.action.hasDamage) {
context.allDamageTypesUsed = !getUnusedDamageTypes(this.action.damage.parts).length;
if (this.action.damage.hasOwnProperty('includeBase') && this.action.type === 'attack')
context.hasBaseDamage = !!this.action.parent.attack;
}
context.costOptions = this.getCostOptions();
context.getRollTypeOptions = this.getRollTypeOptions();
context.disableOption = this.disableOption.bind(this);
@ -256,7 +264,9 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
key = event.target.closest('[data-key]').dataset.key;
if (!this.action[key]) return;
data[key].push(this.action.defaultValues[key] ?? {});
const value = key === 'areas' ? { name: this.action.item.name } : {};
data[key].push(this.action.defaultValues[key] ?? value);
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
}
@ -291,18 +301,64 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
static addDamage(_event) {
if (!this.action.damage.parts) return;
const data = this.action.toObject(),
part = {};
if (this.action.actor?.isNPC) part.value = { multiplier: 'flat' };
data.damage.parts.push(part);
const choices = getUnusedDamageTypes(this.action.damage.parts);
const content = new foundry.data.fields.StringField({
label: game.i18n.localize('Damage Type'),
choices,
required: true
}).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;
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 }
)
],
content: content,
rejectClose: false,
modal: false,
window: {
title: game.i18n.localize('Add Damage')
},
position: { width: 300 }
});
typeDialog.render(true);
}
static removeDamage(_event, button) {
if (!this.action.damage.parts) return;
const data = this.action.toObject(),
index = button.dataset.index;
data.damage.parts.splice(index, 1);
const data = this.action.toObject();
const key = button.dataset.key;
delete data.damage.parts[key];
data.damage.parts[`${key}`] = _del;
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
}
@ -360,6 +416,21 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
}
}
static async addBeastformTraitBonus() {
const data = this.action.toObject();
data.beastform.modifications.traitBonuses = [
...data.beastform.modifications.traitBonuses,
this.action.schema.fields.beastform.fields.modifications.fields.traitBonuses.element.getInitialValue()
];
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
}
static async removeBeastformTraitBonus(_event, button) {
const data = this.action.toObject();
data.beastform.modifications.traitBonuses.splice(button.dataset.index, 1);
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
}
updateSummonCount(event) {
event.stopPropagation();
const wrapper = event.target.closest('.summon-count-wrapper');

View file

@ -19,17 +19,19 @@ export default class DHActionConfig extends DHActionBaseConfig {
return context;
}
static async addEffect(_event) {
static async addEffect(event) {
const { areaIndex } = event.target.dataset;
if (!this.action.effects) return;
const effectData = this._addEffectData.bind(this)();
const data = this.action.toObject();
const [created] = await this.action.item.createEmbeddedDocuments('ActiveEffect', [effectData], {
render: false
});
data.effects.push({ _id: created._id });
const created = await this.action.item.createEmbeddedDocuments('ActiveEffect', [
game.system.api.data.activeEffects.BaseEffect.getDefaultObject({ transfer: false })
]);
if (areaIndex !== undefined) data.areas[areaIndex].effects.push(created[0]._id);
else data.effects.push({ _id: created[0]._id });
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
this.action.item.effects.get(created._id).sheet.render(true);
this.action.item.effects.get(created[0]._id).sheet.render(true);
}
/**
@ -52,9 +54,19 @@ export default class DHActionConfig extends DHActionBaseConfig {
static removeEffect(event, button) {
if (!this.action.effects) return;
const index = button.dataset.index,
const { areaIndex, index } = button.dataset;
let effectId = null;
if (areaIndex !== undefined) {
effectId = this.action.areas[areaIndex].effects[index];
const data = this.action.toObject();
data.areas[areaIndex].effects.splice(index, 1);
this.constructor.updateForm.call(this, null, null, { object: foundry.utils.flattenObject(data) });
} else {
effectId = this.action.effects[index]._id;
this.constructor.removeElement.bind(this)(event, button);
this.constructor.removeElement.call(this, event, button);
}
this.action.item.deleteEmbeddedDocuments('ActiveEffect', [effectId]);
}

View file

@ -31,21 +31,35 @@ export default class DHActionSettingsConfig extends DHActionBaseConfig {
}
static async addEffect(_event) {
const { areaIndex } = event.target.dataset;
if (!this.action.effects) return;
const effectData = game.system.api.data.activeEffects.BaseEffect.getDefaultObject();
const effectData = game.system.api.data.activeEffects.BaseEffect.getDefaultObject({ transfer: false });
const data = this.action.toObject();
this.sheetUpdate(data, effectData);
this.effects = [...this.effects, effectData];
data.effects.push({ _id: effectData.id });
if (areaIndex !== undefined) data.areas[areaIndex].effects.push(effectData.id);
else data.effects.push({ _id: effectData.id });
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
}
static removeEffect(event, button) {
if (!this.action.effects) return;
const index = button.dataset.index,
const { areaIndex, index } = button.dataset;
let effectId = null;
if (areaIndex !== undefined) {
effectId = this.action.areas[areaIndex].effects[index];
const data = this.action.toObject();
data.areas[areaIndex].effects.splice(index, 1);
this.constructor.updateForm.call(this, null, null, { object: foundry.utils.flattenObject(data) });
} else {
effectId = this.action.effects[index]._id;
this.constructor.removeElement.bind(this)(event, button);
this.constructor.removeElement.call(this, event, button);
}
this.sheetUpdate(
this.action.toObject(),
this.effects.find(x => x.id === effectId),
@ -55,7 +69,7 @@ export default class DHActionSettingsConfig extends DHActionBaseConfig {
static async editEffect(event) {
const id = event.target.closest('[data-effect-id]')?.dataset?.effectId;
const updatedEffect = await game.system.api.applications.sheetConfigs.SettingActiveEffectConfig.configure(
const updatedEffect = await game.system.api.applications.sheetConfigs.ActiveEffectConfig.configureSetting(
this.getEffectDetails(id)
);
if (!updatedEffect) return;

View file

@ -18,6 +18,7 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
settings: { template: 'systems/daggerheart/templates/sheets/activeEffect/settings.hbs' },
changes: {
template: 'systems/daggerheart/templates/sheets/activeEffect/changes.hbs',
templates: ['systems/daggerheart/templates/sheets/activeEffect/change.hbs'],
scrollable: ['ol[data-changes]']
},
footer: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-form-footer.hbs' }
@ -149,6 +150,18 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
minLength: 0
});
});
htmlElement
.querySelector('.stacking-change-checkbox')
?.addEventListener('change', this.stackingChangeToggle.bind(this));
htmlElement
.querySelector('.armor-change-checkbox')
?.addEventListener('change', this.armorChangeToggle.bind(this));
htmlElement
.querySelector('.armor-damage-thresholds-checkbox')
?.addEventListener('change', this.armorDamageThresholdToggle.bind(this));
}
async _prepareContext(options) {
@ -173,8 +186,166 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
}));
}
break;
case 'settings':
const groups = {
time: _loc('EFFECT.DURATION.UNITS.GROUPS.time'),
combat: _loc('EFFECT.DURATION.UNITS.GROUPS.combat')
};
partContext.durationUnits = CONST.ACTIVE_EFFECT_DURATION_UNITS.map(value => ({
value,
label: _loc(`EFFECT.DURATION.UNITS.${value}`),
group: CONST.ACTIVE_EFFECT_TIME_DURATION_UNITS.includes(value) ? groups.time : groups.combat
}));
break;
case 'changes':
const singleTypes = ['armor'];
const typedChanges = context.source.changes.reduce((acc, change, index) => {
if (singleTypes.includes(change.type)) {
acc[change.type] = { ...change, index };
}
return acc;
}, {});
partContext.changes = partContext.changes.filter(c => !!c);
partContext.typedChanges = typedChanges;
break;
}
return partContext;
}
stackingChangeToggle(event) {
const stackingFields = this.document.system.schema.fields.stacking.fields;
const systemData = {
stacking: event.target.checked
? { value: stackingFields.value.initial, max: stackingFields.max.initial }
: null
};
return this.submit({ updateData: { system: systemData } });
}
armorChangeToggle(event) {
if (event.target.checked) {
this.addArmorChange();
} else {
this.removeTypedChange(event.target.dataset.index);
}
}
/* Could be generalised if needed later */
addArmorChange() {
const submitData = this._processFormData(null, this.form, new FormDataExtended(this.form));
const changes = Object.values(submitData.system?.changes ?? {});
changes.push(game.system.api.data.activeEffects.changeTypes.armor.getInitialValue());
return this.submit({ updateData: { system: { changes } } });
}
removeTypedChange(indexString) {
const submitData = this._processFormData(null, this.form, new FormDataExtended(this.form));
const changes = Object.values(submitData.system.changes);
const index = Number(indexString);
changes.splice(index, 1);
return this.submit({ updateData: { system: { changes } } });
}
armorDamageThresholdToggle(event) {
const submitData = this._processFormData(null, this.form, new FormDataExtended(this.form));
const changes = Object.values(submitData.system?.changes ?? {});
const index = Number(event.target.dataset.index);
if (event.target.checked) {
changes[index].value.damageThresholds = { major: 0, severe: 0 };
} else {
changes[index].value.damageThresholds = null;
}
return this.submit({ updateData: { system: { changes } } });
}
/** @inheritdoc */
_renderChange(context) {
const { change, index, defaultPriority } = context;
if (!(change.type in CONFIG.DH.GENERAL.baseActiveEffectModes)) return null;
const changeTypesSchema = this.document.system.schema.fields.changes.element.types;
const fields = context.fields ?? (changeTypesSchema[change.type] ?? changeTypesSchema.add).fields;
if (typeof change.value !== 'string') change.value = JSON.stringify(change.value);
Object.assign(
change,
['key', 'type', 'value', 'priority'].reduce((paths, fieldName) => {
paths[`${fieldName}Path`] = `system.changes.${index}.${fieldName}`;
return paths;
}, {})
);
return (
game.system.api.documents.DhActiveEffect.CHANGE_TYPES[change.type].render?.(
change,
index,
defaultPriority
) ??
foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/sheets/activeEffect/change.hbs',
{
change,
index,
defaultPriority,
fields,
types: Object.keys(CONFIG.DH.GENERAL.baseActiveEffectModes).reduce((r, key) => {
r[key] = CONFIG.DH.GENERAL.baseActiveEffectModes[key].label;
return r;
}, {})
}
)
);
}
/** @inheritDoc */
_onChangeForm(_formConfig, event) {
if (foundry.utils.isElementInstanceOf(event.target, 'select') && event.target.name === 'system.duration.type') {
const durationSection = this.element.querySelector('.custom-duration-section');
if (event.target.value === 'custom') durationSection.classList.add('visible');
else durationSection.classList.remove('visible');
const durationDescription = this.element.querySelector('.duration-description');
if (event.target.value === 'temporary') durationDescription.classList.add('visible');
else durationDescription.classList.remove('visible');
}
}
/** @inheritDoc */
_processFormData(event, form, formData) {
const submitData = super._processFormData(event, form, formData);
if (submitData.start && !submitData.start.time) submitData.start.time = '0';
else if (!submitData) submitData.start = null;
return submitData;
}
/** @inheritDoc */
_processSubmitData(event, form, submitData, options) {
if (this.options.isSetting) {
// Settings should update source instead
this.document.updateSource(submitData);
this.render();
} else {
return super._processSubmitData(event, form, submitData, options);
}
}
/** Creates an active effect config for a setting */
static async configureSetting(effect, options = {}) {
const document = new CONFIG.ActiveEffect.documentClass({ ...foundry.utils.duplicate(effect), _id: effect.id });
return new Promise(resolve => {
const app = new this({ document, ...options, isSetting: true });
app.addEventListener(
'close',
() => {
const newEffect = app.document.toObject(true);
newEffect.id = newEffect._id;
delete newEffect._id;
resolve(newEffect);
},
{ once: true }
);
app.render({ force: true });
});
}
}

View file

@ -95,7 +95,7 @@ export default class DHAdversarySettings extends DHBaseActorSettings {
});
if (!confirmed) return;
await this.actor.update({ [`system.experiences.-=${target.dataset.experience}`]: null });
await this.actor.update({ [`system.experiences.${target.dataset.experience}`]: _del });
}
async _onDragStart(event) {

View file

@ -101,8 +101,8 @@ export default class DHCharacterSettings extends DHBaseActorSettings {
if (relinkAchievementData.length > 0) {
relinkAchievementData.forEach(data => {
updates[`system.levelData.levelups.${data.levelKey}.achievements.experiences.-=${data.experience}`] =
null;
updates[`system.levelData.levelups.${data.levelKey}.achievements.experiences.${data.experience}`] =
_del;
});
} else if (relinkSelectionData.length > 0) {
relinkSelectionData.forEach(data => {
@ -137,7 +137,7 @@ export default class DHCharacterSettings extends DHBaseActorSettings {
await this.actor.update({
...updates,
[`system.experiences.-=${target.dataset.experience}`]: null
[`system.experiences.${target.dataset.experience}`]: _del
});
}
}

View file

@ -117,6 +117,6 @@ export default class DHCompanionSettings extends DHBaseActorSettings {
});
if (!confirmed) return;
await this.actor.update({ [`system.experiences.-=${target.dataset.experience}`]: null });
await this.actor.update({ [`system.experiences.${target.dataset.experience}`]: _del });
}
}

View file

@ -68,9 +68,9 @@ export default class DHEnvironmentSettings extends DHBaseActorSettings {
*/
static async #addCategory() {
await this.actor.update({
[`system.potentialAdversaries.${foundry.utils.randomID()}.label`]: game.i18n.localize(
'DAGGERHEART.ACTORS.Environment.newAdversary'
)
[`system.potentialAdversaries.${foundry.utils.randomID()}`]: {
label: game.i18n.localize('DAGGERHEART.ACTORS.Environment.newAdversary')
}
});
}
@ -79,7 +79,7 @@ export default class DHEnvironmentSettings extends DHBaseActorSettings {
* @type {ApplicationClickAction}
*/
static async #removeCategory(_, target) {
await this.actor.update({ [`system.potentialAdversaries.-=${target.dataset.categoryId}`]: null });
await this.actor.update({ [`system.potentialAdversaries.${target.dataset.categoryId}`]: _del });
}
/**
@ -138,4 +138,8 @@ export default class DHEnvironmentSettings extends DHBaseActorSettings {
this.render();
}
}
async _onDropItem(event, item) {
console.log(item);
}
}

View file

@ -1,223 +0,0 @@
import autocomplete from 'autocompleter';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
export default class SettingActiveEffectConfig extends HandlebarsApplicationMixin(ApplicationV2) {
constructor(effect) {
super({});
this.effect = foundry.utils.deepClone(effect);
this.changeChoices = game.system.api.applications.sheetConfigs.ActiveEffectConfig.getChangeChoices();
}
static DEFAULT_OPTIONS = {
classes: ['daggerheart', 'sheet', 'dh-style', 'active-effect-config', 'standard-form'],
tag: 'form',
position: {
width: 560
},
form: {
submitOnChange: false,
closeOnSubmit: false,
handler: SettingActiveEffectConfig.#onSubmit
},
actions: {
editImage: SettingActiveEffectConfig.#editImage,
addChange: SettingActiveEffectConfig.#addChange,
deleteChange: SettingActiveEffectConfig.#deleteChange
}
};
static PARTS = {
header: { template: 'systems/daggerheart/templates/sheets/activeEffect/header.hbs' },
tabs: { template: 'templates/generic/tab-navigation.hbs' },
details: { template: 'systems/daggerheart/templates/sheets/activeEffect/details.hbs', scrollable: [''] },
settings: { template: 'systems/daggerheart/templates/sheets/activeEffect/settings.hbs' },
changes: {
template: 'systems/daggerheart/templates/sheets/activeEffect/changes.hbs',
scrollable: ['ol[data-changes]']
},
footer: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-form-footer.hbs' }
};
static TABS = {
sheet: {
tabs: [
{ id: 'details', icon: 'fa-solid fa-book' },
{ id: 'settings', icon: 'fa-solid fa-bars', label: 'DAGGERHEART.GENERAL.Tabs.settings' },
{ id: 'changes', icon: 'fa-solid fa-gears' }
],
initial: 'details',
labelPrefix: 'EFFECT.TABS'
}
};
/**@inheritdoc */
async _onFirstRender(context, options) {
await super._onFirstRender(context, options);
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.source = this.effect;
context.fields = game.system.api.documents.DhActiveEffect.schema.fields;
context.systemFields = game.system.api.data.activeEffects.BaseEffect._schema.fields;
return context;
}
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
const changeChoices = this.changeChoices;
htmlElement.querySelectorAll('.effect-change-input').forEach(element => {
autocomplete({
input: element,
fetch: function (text, update) {
if (!text) {
update(changeChoices);
} else {
text = text.toLowerCase();
var suggestions = changeChoices.filter(n => n.label.toLowerCase().includes(text));
update(suggestions);
}
},
render: function (item, search) {
const label = game.i18n.localize(item.label);
const matchIndex = label.toLowerCase().indexOf(search);
const beforeText = label.slice(0, matchIndex);
const matchText = label.slice(matchIndex, matchIndex + search.length);
const after = label.slice(matchIndex + search.length, label.length);
const element = document.createElement('li');
element.innerHTML =
`${beforeText}${matchText ? `<strong>${matchText}</strong>` : ''}${after}`.replaceAll(
' ',
'&nbsp;'
);
if (item.hint) {
element.dataset.tooltip = game.i18n.localize(item.hint);
}
return element;
},
renderGroup: function (label) {
const itemElement = document.createElement('div');
itemElement.textContent = game.i18n.localize(label);
return itemElement;
},
onSelect: function (item) {
element.value = `system.${item.value}`;
},
click: e => e.fetch(),
customize: function (_input, _inputRect, container) {
container.style.zIndex = foundry.applications.api.ApplicationV2._maxZ;
},
minLength: 0
});
});
}
async _preparePartContext(partId, context) {
if (partId in context.tabs) context.tab = context.tabs[partId];
switch (partId) {
case 'details':
context.statuses = CONFIG.statusEffects.map(s => ({ value: s.id, label: game.i18n.localize(s.name) }));
context.isActorEffect = false;
context.isItemEffect = true;
const useGeneric = game.settings.get(
CONFIG.DH.id,
CONFIG.DH.SETTINGS.gameSettings.appearance
).showGenericStatusEffects;
if (!useGeneric) {
context.statuses = [
...context.statuses,
Object.values(CONFIG.DH.GENERAL.conditions).map(status => ({
value: status.id,
label: game.i18n.localize(status.name)
}))
];
}
break;
case 'changes':
context.modes = Object.entries(CONST.ACTIVE_EFFECT_MODES).reduce((modes, [key, value]) => {
modes[value] = game.i18n.localize(`EFFECT.MODE_${key}`);
return modes;
}, {});
context.priorities = ActiveEffectConfig.DEFAULT_PRIORITIES;
break;
}
return context;
}
static async #onSubmit(_event, _form, formData) {
this.data = foundry.utils.expandObject(formData.object);
this.close();
}
/**
* Edit a Document image.
* @this {DocumentSheetV2}
* @type {ApplicationClickAction}
*/
static async #editImage(_event, target) {
if (target.nodeName !== 'IMG') {
throw new Error('The editImage action is available only for IMG elements.');
}
const attr = target.dataset.edit;
const current = foundry.utils.getProperty(this.effect, attr);
const fp = new FilePicker.implementation({
current,
type: 'image',
callback: path => (target.src = path),
position: {
top: this.position.top + 40,
left: this.position.left + 10
}
});
await fp.browse();
}
/**
* Add a new change to the effect's changes array.
* @this {ActiveEffectConfig}
* @type {ApplicationClickAction}
*/
static async #addChange() {
const { changes, ...rest } = foundry.utils.expandObject(new FormDataExtended(this.form).object);
const updatedChanges = Object.values(changes ?? {});
updatedChanges.push({});
this.effect = { ...rest, changes: updatedChanges };
this.render();
}
/**
* Delete a change from the effect's changes array.
* @this {ActiveEffectConfig}
* @type {ApplicationClickAction}
*/
static async #deleteChange(event) {
const submitData = foundry.utils.expandObject(new FormDataExtended(this.form).object);
const updatedChanges = Object.values(submitData.changes);
const row = event.target.closest('li');
const index = Number(row.dataset.index) || 0;
updatedChanges.splice(index, 1);
this.effect = { ...submitData, changes: updatedChanges };
this.render();
}
static async configure(effect, options = {}) {
return new Promise(resolve => {
const app = new this(effect, options);
app.addEventListener('close', () => resolve(app.data), { once: true });
app.render({ force: true });
});
}
}

View file

@ -147,7 +147,7 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App
const effectIndex = this.move.effects.findIndex(x => x.id === id);
const effect = this.move.effects[effectIndex];
const updatedEffect =
await game.system.api.applications.sheetConfigs.SettingActiveEffectConfig.configure(effect);
await game.system.api.applications.sheetConfigs.ActiveEffectConfig.configureSetting(effect);
if (!updatedEffect) return;
await this.updateMove({
@ -205,7 +205,7 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App
}
});
} else {
await this.updateMove({ [`${this.actionsPath}.-=${target.dataset.id}`]: null });
await this.updateMove({ [`${this.actionsPath}.${target.dataset.id}`]: _del });
}
this.render();

View file

@ -67,9 +67,9 @@ export default function DHTokenConfigMixin(Base) {
changes.height = tokenSize;
}
const deletions = { '-=actorId': null, '-=actorLink': null };
const mergeOptions = { inplace: false, performDeletions: true };
this._preview.updateSource(mergeObject(changes, deletions, mergeOptions));
// const deletions = { actorId: _del };
// const mergeOptions = { inplace: false, performDeletions: true, actorLink: false };
this._preview.updateSource(changes);
if (this._preview?.object?.destroyed === false) {
this._preview.object.initializeSources();

View file

@ -217,8 +217,8 @@ export default class AdversarySheet extends DHBaseActorSheet {
static #reactionRoll(event) {
const config = {
event,
title: `Reaction Roll: ${this.actor.name}`,
headerTitle: 'Adversary Reaction Roll',
title: game.i18n.localize('DAGGERHEART.GENERAL.reactionRoll'),
headerTitle: game.i18n.localize('DAGGERHEART.ACTORS.Adversary.adversaryReactionRoll.headerTitle'),
roll: {
type: 'trait'
},

View file

@ -1,10 +1,9 @@
import DHBaseActorSheet from '../api/base-actor.mjs';
import DhDeathMove from '../../dialogs/deathMove.mjs';
import { abilities } from '../../../config/actorConfig.mjs';
import { CharacterLevelup, LevelupViewMode } from '../../levelup/_module.mjs';
import DhCharacterCreation from '../../characterCreation/characterCreation.mjs';
import FilterMenu from '../../ux/filter-menu.mjs';
import { getDocFromElement, getDocFromElementSync } from '../../../helpers/utils.mjs';
import { getArmorSources, getDocFromElement, getDocFromElementSync } from '../../../helpers/utils.mjs';
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
@ -13,8 +12,6 @@ export default class CharacterSheet extends DHBaseActorSheet {
static DEFAULT_OPTIONS = {
classes: ['character'],
position: { width: 850, height: 800 },
/* Foundry adds disabled to all buttons and inputs if editPermission is missing. This is not desired. */
editPermission: CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER,
actions: {
toggleVault: CharacterSheet.#toggleVault,
rollAttribute: CharacterSheet.#rollAttribute,
@ -35,7 +32,8 @@ export default class CharacterSheet extends DHBaseActorSheet {
cancelBeastform: CharacterSheet.#cancelBeastform,
toggleResourceManagement: CharacterSheet.#toggleResourceManagement,
useDowntime: this.useDowntime,
viewParty: CharacterSheet.#viewParty
viewParty: CharacterSheet.#viewParty,
toggleArmorMangement: CharacterSheet.#toggleArmorManagement
},
window: {
resizable: true,
@ -68,7 +66,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
}
},
{
handler: CharacterSheet.#getEquipamentContextOptions,
handler: CharacterSheet.#getEquipmentContextOptions,
selector: '[data-item-uuid][data-type="armor"], [data-item-uuid][data-type="weapon"]',
options: {
parentClassHooks: false,
@ -170,6 +168,16 @@ export default class CharacterSheet extends DHBaseActorSheet {
return applicationOptions;
}
/** @inheritdoc */
_toggleDisabled(disabled) {
// Overriden to only disable text inputs by default.
// Everything else is done by checking @root.editable in the sheet
const form = this.form;
for (const input of form.querySelectorAll('input:not([type=search]), .editor.prosemirror')) {
input.disabled = disabled;
}
}
/** @inheritDoc */
async _onRender(context, options) {
await super._onRender(context, options);
@ -315,11 +323,11 @@ export default class CharacterSheet extends DHBaseActorSheet {
/**@type {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]} */
const options = [
{
name: 'toLoadout',
label: 'toLoadout',
icon: 'fa-solid fa-arrow-up',
condition: target => {
visible: target => {
const doc = getDocFromElementSync(target);
return doc && doc.system.inVault;
return doc?.isOwner && doc.system.inVault;
},
callback: async target => {
const doc = await getDocFromElement(target);
@ -329,11 +337,11 @@ export default class CharacterSheet extends DHBaseActorSheet {
}
},
{
name: 'recall',
label: 'recall',
icon: 'fa-solid fa-bolt-lightning',
condition: target => {
visible: target => {
const doc = getDocFromElementSync(target);
return doc && doc.system.inVault;
return doc?.isOwner && doc.system.inVault;
},
callback: async (target, event) => {
const doc = await getDocFromElement(target);
@ -368,17 +376,17 @@ export default class CharacterSheet extends DHBaseActorSheet {
}
},
{
name: 'toVault',
label: 'toVault',
icon: 'fa-solid fa-arrow-down',
condition: target => {
visible: target => {
const doc = getDocFromElementSync(target);
return doc && !doc.system.inVault;
return doc?.isOwner && !doc.system.inVault;
},
callback: async target => (await getDocFromElement(target)).update({ 'system.inVault': true })
}
].map(option => ({
...option,
name: `DAGGERHEART.APPLICATIONS.ContextMenu.${option.name}`,
label: `DAGGERHEART.APPLICATIONS.ContextMenu.${option.label}`,
icon: `<i class="${option.icon}"></i>`
}));
@ -391,29 +399,29 @@ export default class CharacterSheet extends DHBaseActorSheet {
* @this {CharacterSheet}
* @protected
*/
static #getEquipamentContextOptions() {
static #getEquipmentContextOptions() {
const options = [
{
name: 'equip',
label: 'equip',
icon: 'fa-solid fa-hands',
condition: target => {
visible: target => {
const doc = getDocFromElementSync(target);
return doc && !doc.system.equipped;
return doc.isOwner && doc && !doc.system.equipped;
},
callback: (target, event) => CharacterSheet.#toggleEquipItem.call(this, event, target)
},
{
name: 'unequip',
label: 'unequip',
icon: 'fa-solid fa-hands',
condition: target => {
visible: target => {
const doc = getDocFromElementSync(target);
return doc && doc.system.equipped;
return doc.isOwner && doc && doc.system.equipped;
},
callback: (target, event) => CharacterSheet.#toggleEquipItem.call(this, event, target)
}
].map(option => ({
...option,
name: `DAGGERHEART.APPLICATIONS.ContextMenu.${option.name}`,
label: `DAGGERHEART.APPLICATIONS.ContextMenu.${option.label}`,
icon: `<i class="${option.icon}"></i>`
}));
@ -639,12 +647,12 @@ export default class CharacterSheet extends DHBaseActorSheet {
}
async updateArmorMarks(event) {
const armor = this.document.system.armor;
if (!armor) return;
const inputValue = Number(event.currentTarget.value);
const { value, max } = this.document.system.armorScore;
const changeValue = Math.min(inputValue - value, max - value);
const maxMarks = this.document.system.armorScore;
const value = Math.min(Math.max(Number(event.currentTarget.value), 0), maxMarks);
await armor.update({ 'system.marks.value': value });
event.currentTarget.value = inputValue < 0 ? 0 : value + changeValue;
this.document.system.updateArmorValue({ value: changeValue });
}
/* -------------------------------------------- */
@ -720,35 +728,16 @@ export default class CharacterSheet extends DHBaseActorSheet {
* Rolls an attribute check based on the clicked button's dataset attribute.
* @type {ApplicationClickAction}
*/
static async #rollAttribute(event, button) {
const abilityLabel = game.i18n.localize(abilities[button.dataset.attribute].label);
const config = {
event: event,
title: `${game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll')}: ${this.actor.name}`,
headerTitle: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
ability: abilityLabel
}),
effects: await game.system.api.data.actions.actionsTypes.base.getEffects(this.document),
roll: {
trait: button.dataset.attribute,
type: 'trait'
},
hasRoll: true,
actionType: 'action',
headerTitle: `${game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll')}: ${this.actor.name}`,
title: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
ability: abilityLabel
})
};
const result = await this.document.diceRoll(config);
static async #rollAttribute(_event, button) {
const result = await this.document.rollTrait(button.dataset.attribute);
if (!result) return;
/* This could be avoided by baking config.costs into config.resourceUpdates. Didn't feel like messing with it at the time */
const costResources =
result.costs?.filter(x => x.enabled).map(cost => ({ ...cost, value: -cost.value, total: -cost.total })) ||
{};
config.resourceUpdates.addResources(costResources);
await config.resourceUpdates.updateResources();
result.resourceUpdates.addResources(costResources);
await result.resourceUpdates.updateResources();
}
//TODO: redo toggleEquipItem method
@ -823,10 +812,13 @@ export default class CharacterSheet extends DHBaseActorSheet {
* Toggles ArmorScore resource value.
* @type {ApplicationClickAction}
*/
static async #toggleArmor(_, button, element) {
const ArmorValue = Number.parseInt(button.dataset.value);
const newValue = this.document.system.armor.system.marks.value >= ArmorValue ? ArmorValue - 1 : ArmorValue;
await this.document.system.armor.update({ 'system.marks.value': newValue });
static async #toggleArmor(_, button, _element) {
const { value, max } = this.document.system.armorScore;
const inputValue = Number.parseInt(button.dataset.value);
const newValue = value >= inputValue ? inputValue - 1 : inputValue;
const changeValue = Math.min(newValue - value, max - value);
this.document.system.updateArmorValue({ value: changeValue });
}
/**
@ -952,6 +944,99 @@ export default class CharacterSheet extends DHBaseActorSheet {
});
}
static async #toggleArmorManagement(_event, target) {
const existingTooltip = document.body.querySelector('.locked-tooltip .armor-management-container');
if (existingTooltip) {
game.tooltip.dismissLockedTooltips();
return;
}
const armorSources = getArmorSources(this.document)
.filter(s => !s.disabled)
.toReversed()
.map(({ name, document, data }) => ({
...data,
uuid: document.uuid,
name
}));
if (!armorSources.length) return;
const useResourcePips = game.settings.get(
CONFIG.DH.id,
CONFIG.DH.SETTINGS.gameSettings.appearance
).useResourcePips;
const html = document.createElement('div');
html.innerHTML = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/armorManagement.hbs`,
{
sources: armorSources,
useResourcePips
}
);
game.tooltip.dismissLockedTooltips();
game.tooltip.activate(target, {
html,
locked: true,
cssClass: 'bordered-tooltip',
direction: 'DOWN'
});
html.querySelectorAll('.armor-slot').forEach(element => {
element.addEventListener('click', CharacterSheet.armorSourcePipUpdate);
});
}
static async armorSourceInput(event) {
const effect = await foundry.utils.fromUuid(event.target.dataset.uuid);
const value = Math.max(Math.min(Number.parseInt(event.target.value), effect.system.armorData.max), 0);
event.target.value = value;
const progressBar = event.target.closest('.status-bar.armor-slots').querySelector('progress');
progressBar.value = value;
}
/** Update specific armor source */
static async armorSourcePipUpdate(event) {
const target = event.target.closest('.armor-slot');
const { uuid, value } = target.dataset;
const document = await foundry.utils.fromUuid(uuid);
let inputValue = Number.parseInt(value);
let decreasing = false;
let newCurrent = 0;
if (document.type === 'armor') {
decreasing = document.system.armor.current >= inputValue;
newCurrent = decreasing ? inputValue - 1 : inputValue;
await document.update({ 'system.armor.current': newCurrent });
} else if (document.system.armorData) {
const { current } = document.system.armorData;
decreasing = current >= inputValue;
newCurrent = decreasing ? inputValue - 1 : inputValue;
const newChanges = document.system.changes.map(change => ({
...change,
value: change.type === 'armor' ? { ...change.value, current: newCurrent } : change.value
}));
await document.update({ 'system.changes': newChanges });
} else {
return;
}
const container = target.closest('.slot-bar');
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');
armorSlot.classList.add('fa-shield-halved');
} else if (!decreasing && index < newCurrent) {
armorSlot.classList.add('fa-shield');
armorSlot.classList.remove('fa-shield-halved');
}
}
}
static async #toggleResourceManagement(event, button) {
event.stopPropagation();
const existingTooltip = document.body.querySelector('.locked-tooltip .resource-management-container');
@ -985,7 +1070,6 @@ export default class CharacterSheet extends DHBaseActorSheet {
);
const target = button.closest('.resource-section');
game.tooltip.dismissLockedTooltips();
game.tooltip.activate(target, {
html,

View file

@ -1,10 +1,9 @@
import DHBaseActorSheet from '../api/base-actor.mjs';
import { getDocFromElement } from '../../../helpers/utils.mjs';
import { getDocFromElement, sortBy } from '../../../helpers/utils.mjs';
import { ItemBrowser } from '../../ui/itemBrowser.mjs';
import FilterMenu from '../../ux/filter-menu.mjs';
import DaggerheartMenu from '../../sidebar/tabs/daggerheartMenu.mjs';
import { socketEvent } from '../../../systemRegistration/socket.mjs';
import GroupRollDialog from '../../dialogs/group-roll-dialog.mjs';
import DhpActor from '../../../documents/actor.mjs';
export default class Party extends DHBaseActorSheet {
@ -18,13 +17,14 @@ export default class Party extends DHBaseActorSheet {
static DEFAULT_OPTIONS = {
classes: ['party'],
position: {
width: 550,
width: 600,
height: 900
},
window: {
resizable: true
},
actions: {
openDocument: Party.#openDocument,
deletePartyMember: Party.#deletePartyMember,
deleteItem: Party.#deleteItem,
toggleHope: Party.#toggleHope,
@ -35,9 +35,7 @@ export default class Party extends DHBaseActorSheet {
refeshActions: Party.#refeshActions,
triggerRest: Party.#triggerRest,
tagTeamRoll: Party.#tagTeamRoll,
groupRoll: Party.#groupRoll,
selectRefreshable: DaggerheartMenu.selectRefreshable,
refreshActors: DaggerheartMenu.refreshActors
groupRoll: Party.#groupRoll
},
dragDrop: [{ dragSelector: '[data-item-id]', dropSelector: null }]
};
@ -47,10 +45,6 @@ export default class Party extends DHBaseActorSheet {
header: { template: 'systems/daggerheart/templates/sheets/actors/party/header.hbs' },
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
partyMembers: { template: 'systems/daggerheart/templates/sheets/actors/party/party-members.hbs' },
resources: {
template: 'systems/daggerheart/templates/sheets/actors/party/resources.hbs',
scrollable: ['']
},
/* NOT YET IMPLEMENTED */
// projects: {
// template: 'systems/daggerheart/templates/sheets/actors/party/projects.hbs',
@ -68,7 +62,6 @@ export default class Party extends DHBaseActorSheet {
primary: {
tabs: [
{ id: 'partyMembers' },
{ id: 'resources' },
/* NOT YET IMPLEMENTED */
// { id: 'projects' },
{ id: 'inventory' },
@ -98,6 +91,8 @@ export default class Party extends DHBaseActorSheet {
case 'header':
await this._prepareHeaderContext(context, options);
break;
case 'partyMembers':
await this._prepareMembersContext(context, options);
case 'notes':
await this._prepareNotesContext(context, options);
break;
@ -120,6 +115,61 @@ export default class Party extends DHBaseActorSheet {
secrets: this.document.isOwner,
relativeTo: this.document
});
context.tagTeamActive = Boolean(this.document.system.tagTeam.initiator);
context.groupRollActive = Boolean(this.document.system.groupRoll.leader);
}
async _prepareMembersContext(context, _options) {
context.partyMembers = [];
const traits = ['agility', 'strength', 'finesse', 'instinct', 'presence', 'knowledge'];
for (const actor of this.document.system.partyMembers) {
const weapons = [];
if (actor.type === 'character') {
if (actor.system.usedUnarmed) {
weapons.push(actor.system.usedUnarmed);
}
const equipped = actor.items.filter(i => i.system.equipped && i.type === 'weapon');
weapons.push(...sortBy(equipped, i => (i.system.secondary ? 1 : 0)));
}
context.partyMembers.push({
uuid: actor.uuid,
img: actor.img,
name: actor.name,
subtitle: (() => {
if (!['character', 'companion'].includes(actor.type)) {
return game.i18n.format(`TYPES.Actor.${actor.type}`);
}
const { value: classItem, subclass } = actor.system.class ?? {};
const partner = actor.system.partner;
const ancestry = actor.system.ancestry;
const community = actor.system.community;
if (partner || (classItem && subclass && ancestry && community)) {
return game.i18n.format(`DAGGERHEART.ACTORS.Party.Subtitle.${actor.type}`, {
class: classItem?.name,
subclass: subclass?.name,
partner: partner?.name,
ancestry: ancestry?.name,
community: community?.name
});
}
})(),
type: actor.type,
resources: actor.system.resources,
armorScore: actor.system.armorScore,
damageThresholds: actor.system.damageThresholds,
evasion: actor.system.evasion,
difficulty: actor.system.difficulty,
traits: actor.system.traits
? traits.map(t => ({
label: game.i18n.localize(`DAGGERHEART.CONFIG.Traits.${t}.short`),
value: actor.system.traits[t].value
}))
: null,
weapons
});
}
}
/**
@ -150,6 +200,12 @@ export default class Party extends DHBaseActorSheet {
}
}
static async #openDocument(_, target) {
const uuid = target.dataset.uuid;
const document = await foundry.utils.fromUuid(uuid);
document?.sheet?.render(true);
}
/**
* Toggles a hope resource value.
* @type {ApplicationClickAction}
@ -190,11 +246,14 @@ export default class Party extends DHBaseActorSheet {
* Toggles a armor slot resource value.
* @type {ApplicationClickAction}
*/
static async #toggleArmorSlot(_, target, element) {
const armorItem = await foundry.utils.fromUuid(target.dataset.itemUuid);
const armorValue = Number.parseInt(target.dataset.value);
const newValue = armorItem.system.marks.value >= armorValue ? armorValue - 1 : armorValue;
await armorItem.update({ 'system.marks.value': newValue });
static async #toggleArmorSlot(_, target) {
const actor = await foundry.utils.fromUuid(target.dataset.actorId);
const { value, max } = actor.system.armorScore;
const inputValue = Number.parseInt(target.dataset.value);
const newValue = value >= inputValue ? inputValue - 1 : inputValue;
const changeValue = Math.min(newValue - value, max - value);
await actor.system.updateArmorValue({ value: changeValue });
this.render();
}
@ -229,7 +288,7 @@ export default class Party extends DHBaseActorSheet {
title: game.i18n.localize(`DAGGERHEART.APPLICATIONS.Downtime.${button.dataset.type}.title`),
icon: button.dataset.type === 'shortRest' ? 'fa-solid fa-utensils' : 'fa-solid fa-bed'
},
content: 'This will trigger a dialog to players make their downtime moves, are you sure?',
content: game.i18n.localize('DAGGERHEART.ACTORS.Party.triggerRestContent'),
classes: ['daggerheart', 'dialog', 'dh-style']
});
@ -255,17 +314,11 @@ export default class Party extends DHBaseActorSheet {
}
static async #tagTeamRoll() {
new game.system.api.applications.dialogs.TagTeamDialog(
this.document.system.partyMembers.filter(x => Party.DICE_ROLL_ACTOR_TYPES.includes(x.type))
).render({
force: true
});
new game.system.api.applications.dialogs.TagTeamDialog(this.document).render({ force: true });
}
static async #groupRoll(_params) {
new GroupRollDialog(
this.document.system.partyMembers.filter(x => Party.DICE_ROLL_ACTOR_TYPES.includes(x.type))
).render({ force: true });
new game.system.api.applications.dialogs.GroupRollDialog(this.document).render({ force: true });
}
/* -------------------------------------------- */
@ -427,25 +480,23 @@ export default class Party extends DHBaseActorSheet {
}
static async #deletePartyMember(event, target) {
const doc = await getDocFromElement(target.closest('.inventory-item'));
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.APPLICATIONS.DeleteConfirmation.title', {
type: game.i18n.localize('TYPES.Actor.adversary'),
title: game.i18n.format('DAGGERHEART.ACTORS.Party.RemoveConfirmation.title', {
name: doc.name
})
},
content: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.text', { 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 newMemberdList = currentMembers.filter(uuid => uuid !== doc.uuid);
await this.document.update({ 'system.partyMembers': newMemberdList });
const newMembersList = currentMembers.filter(uuid => uuid !== doc.uuid);
await this.document.update({ 'system.partyMembers': newMembersList });
}
static async #deleteItem(event, target) {

View file

@ -72,20 +72,15 @@ const typeSettingsMap = {
*/
export default function DHApplicationMixin(Base) {
class DHSheetV2 extends HandlebarsApplicationMixin(Base) {
#nonHeaderAttribution = ['environment', 'ancestry', 'community', 'domainCard'];
/**
* @param {DHSheetV2Configuration} [options={}]
*/
constructor(options = {}) {
super(options);
/**
* @type {foundry.applications.ux.DragDrop[]}
* @private
*/
this._dragDrop = this._createDragDropHandlers();
}
#nonHeaderAttribution = ['environment', 'ancestry', 'community', 'domainCard'];
/**
* The default options for the sheet.
* @type {DHSheetV2Configuration}
@ -177,7 +172,6 @@ export default function DHApplicationMixin(Base) {
/**@inheritdoc */
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
this._dragDrop.forEach(d => d.bind(htmlElement));
// Handle delta inputs
for (const deltaInput of htmlElement.querySelectorAll('input[data-allow-delta]')) {
@ -290,6 +284,16 @@ export default function DHApplicationMixin(Base) {
async _onRender(context, options) {
await super._onRender(context, options);
this._createTagifyElements(this.options.tagifyConfigs);
for (const d of this.options.dragDrop) {
new foundry.applications.ux.DragDrop.implementation({
...d,
callbacks: {
dragstart: this._onDragStart.bind(this),
drop: this._onDrop.bind(this)
}
}).bind(this.element);
}
}
/* -------------------------------------------- */
@ -350,21 +354,6 @@ export default function DHApplicationMixin(Base) {
/* Drag and Drop */
/* -------------------------------------------- */
/**
* Creates drag-drop handlers from the configured options.
* @returns {foundry.applications.ux.DragDrop[]}
* @private
*/
_createDragDropHandlers() {
return this.options.dragDrop.map(d => {
d.callbacks = {
dragstart: this._onDragStart.bind(this),
drop: this._onDrop.bind(this)
};
return new foundry.applications.ux.DragDrop.implementation(d);
});
}
/**
* Handle dragStart event.
* @param {DragEvent} event
@ -429,18 +418,18 @@ export default function DHApplicationMixin(Base) {
/**@type {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]} */
const options = [
{
name: 'disableEffect',
label: 'disableEffect',
icon: 'fa-solid fa-lightbulb',
condition: element => {
visible: element => {
const target = element.closest('[data-item-uuid]');
return !target.dataset.disabled && target.dataset.itemType !== 'beastform';
},
callback: async target => (await getDocFromElement(target)).update({ disabled: true })
},
{
name: 'enableEffect',
label: 'enableEffect',
icon: 'fa-regular fa-lightbulb',
condition: element => {
visible: element => {
const target = element.closest('[data-item-uuid]');
return target.dataset.disabled && target.dataset.itemType !== 'beastform';
},
@ -448,7 +437,7 @@ export default function DHApplicationMixin(Base) {
}
].map(option => ({
...option,
name: `DAGGERHEART.APPLICATIONS.ContextMenu.${option.name}`,
label: `DAGGERHEART.APPLICATIONS.ContextMenu.${option.label}`,
icon: `<i class="${option.icon}"></i>`
}));
@ -479,14 +468,14 @@ export default function DHApplicationMixin(Base) {
_getContextMenuCommonOptions({ usable = false, toChat = false, deletable = true }) {
const options = [
{
name: 'CONTROLS.CommonEdit',
label: 'CONTROLS.CommonEdit',
icon: 'fa-solid fa-pen-to-square',
condition: target => {
visible: target => {
const { dataset } = target.closest('[data-item-uuid]');
const doc = getDocFromElementSync(target);
return (
(!dataset.noCompendiumEdit && !doc) ||
(doc && (!doc?.hasOwnProperty('systemPath') || doc?.inCollection))
(doc?.isOwner && (!doc?.hasOwnProperty('systemPath') || doc?.inCollection))
);
},
callback: async target => (await getDocFromElement(target)).sheet.render({ force: true })
@ -495,11 +484,14 @@ export default function DHApplicationMixin(Base) {
if (usable) {
options.unshift({
name: 'DAGGERHEART.GENERAL.damage',
label: 'DAGGERHEART.GENERAL.damage',
icon: 'fa-solid fa-explosion',
condition: target => {
visible: target => {
const doc = getDocFromElementSync(target);
return doc?.system?.attack?.damage.parts.length || doc?.damage?.parts.length;
const hasDamage =
!foundry.utils.isEmpty(doc?.system?.attack?.damage.parts) ||
!foundry.utils.isEmpty(doc?.damage?.parts);
return doc?.isOwner && hasDamage;
},
callback: async (target, event) => {
const doc = await getDocFromElement(target),
@ -515,11 +507,11 @@ export default function DHApplicationMixin(Base) {
});
options.unshift({
name: 'DAGGERHEART.APPLICATIONS.ContextMenu.useItem',
label: 'DAGGERHEART.APPLICATIONS.ContextMenu.useItem',
icon: 'fa-solid fa-burst',
condition: target => {
visible: target => {
const doc = getDocFromElementSync(target);
return doc && !(doc.type === 'domainCard' && doc.system.inVault);
return doc?.isOwner && !(doc.type === 'domainCard' && doc.system.inVault);
},
callback: async (target, event) => (await getDocFromElement(target)).use(event)
});
@ -527,18 +519,19 @@ export default function DHApplicationMixin(Base) {
if (toChat)
options.push({
name: 'DAGGERHEART.APPLICATIONS.ContextMenu.sendToChat',
label: 'DAGGERHEART.APPLICATIONS.ContextMenu.sendToChat',
icon: 'fa-solid fa-message',
callback: async target => (await getDocFromElement(target)).toChat(this.document.uuid)
});
if (deletable)
options.push({
name: 'CONTROLS.CommonDelete',
label: 'CONTROLS.CommonDelete',
icon: 'fa-solid fa-trash',
condition: element => {
visible: element => {
const target = element.closest('[data-item-uuid]');
return target.dataset.itemType !== 'beastform';
const doc = getDocFromElementSync(target);
return doc?.isOwner && target.dataset.itemType !== 'beastform';
},
callback: async (target, event) => {
const doc = await getDocFromElement(target);
@ -652,12 +645,12 @@ export default function DHApplicationMixin(Base) {
buttons: [
{
action: 'create',
label: 'Create Item',
label: game.i18n.localize('DAGGERHEART.APPLICATIONS.CreateItemDialog.createItem'),
icon: 'fa-solid fa-plus'
},
{
action: 'browse',
label: 'Browse Compendium',
label: game.i18n.localize('DAGGERHEART.APPLICATIONS.CreateItemDialog.browseCompendium'),
icon: 'fa-solid fa-book'
}
]
@ -742,11 +735,13 @@ export default function DHApplicationMixin(Base) {
const cls =
type === 'action' ? game.system.api.models.actions.actionsTypes.base : getDocumentClass(documentClass);
const data = {
name: cls.defaultName({ type, parent }),
type,
system: systemData
};
if (inVault) data['system.inVault'] = true;
if (disabled) data.disabled = true;
if (type === 'domainCard' && parent?.system.domains?.length) {

View file

@ -73,7 +73,7 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
.hideAttribution;
// Prepare inventory data
if (['party', 'character'].includes(this.document.type)) {
if (this.document.system.metadata.hasInventory) {
context.inventory = {
currencies: {},
weapons: this.document.itemTypes.weapon.sort((a, b) => a.sort - b.sort),
@ -160,7 +160,7 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
inactives: []
};
for (const effect of this.actor.allApplicableEffects()) {
for (const effect of this.actor.allApplicableEffects({ noTransferArmor: true })) {
const list = effect.active ? context.effects.actives : context.effects.inactives;
list.push(effect);
}
@ -228,7 +228,6 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
'systems/daggerheart/templates/ui/chat/action.hbs',
systemData
),
title: game.i18n.localize('DAGGERHEART.ACTIONS.Config.displayInChat'),
speaker: cls.getSpeaker(),
flags: {
daggerheart: {
@ -284,11 +283,7 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
async _onDropItem(event, item) {
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
const originActor = item.actor;
if (
item.actor?.uuid === this.document.uuid ||
!originActor ||
!['character', 'party'].includes(this.document.type)
) {
if (!originActor || originActor.uuid === this.document.uuid || !this.document.system.metadata.hasInventory) {
return super._onDropItem(event, item);
}
@ -303,45 +298,77 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
);
}
if (item.system.metadata.isQuantifiable) {
const actorItem = originActor.items.get(data.originId);
const quantityTransfered = await game.system.api.applications.dialogs.ItemTransferDialog.configure({
// Perform the actual transfer, showing a dialog when doing it
const availableQuantity = Math.max(1, item.system.quantity);
const actorItem = originActor.items.get(data.originId) ?? item;
if (availableQuantity > 1) {
const quantityTransferred = await game.system.api.applications.dialogs.ItemTransferDialog.configure({
item,
targetActor: this.document
});
if (quantityTransfered) {
const existingItem = this.document.items.find(x => itemIsIdentical(x, item));
if (existingItem) {
await existingItem.update({
'system.quantity': existingItem.system.quantity + quantityTransfered
});
return this.#transferItem(actorItem, quantityTransferred);
} else {
const createData = item.toObject();
await this.document.createEmbeddedDocuments('Item', [
{
...createData,
system: {
...createData.system,
quantity: quantityTransfered
return this.#transferItem(actorItem, availableQuantity);
}
}
]);
}
if (quantityTransfered === actorItem.system.quantity) {
await originActor.deleteEmbeddedDocuments('Item', [data.originId]);
/**
* Helper to perform the actual transfer of an item to this actor, including stack/unstack logic based on target quantifiability.
* Make sure item is the actor item before calling this method or there will be issues
*/
async #transferItem(item, quantity) {
const originActor = item.actor;
const targetActor = this.document;
const allowStacking = targetActor.system.metadata.quantifiable?.includes(item.type);
const batch = [];
// First add/update the item to the target actor
const existing = allowStacking ? targetActor.items.find(x => itemIsIdentical(x, item)) : null;
if (existing) {
batch.push({
action: 'update',
documentName: 'Item',
parent: targetActor,
updates: [{ '_id': existing.id, 'system.quantity': existing.system.quantity + quantity }]
});
} else {
await actorItem.update({
'system.quantity': actorItem.system.quantity - quantityTransfered
const itemsToCreate = [];
if (allowStacking) {
itemsToCreate.push(foundry.utils.mergeObject(item.toObject(true), { system: { quantity } }));
} else {
const createData = new Array(Math.max(1, quantity))
.fill(0)
.map(() => foundry.utils.mergeObject(item.toObject(), { system: { quantity: 1 } }));
itemsToCreate.push(...createData);
}
batch.push({
action: 'create',
documentName: 'Item',
parent: targetActor,
data: itemsToCreate
});
}
}
// Remove the item from the original actor (by either deleting it, or updating its quantity)
if (quantity >= item.system.quantity) {
batch.push({
action: 'delete',
documentName: 'Item',
parent: originActor,
ids: [item.id]
});
} else {
await this.document.createEmbeddedDocuments('Item', [item.toObject()]);
await originActor.deleteEmbeddedDocuments('Item', [data.originId]);
}
batch.push({
action: 'update',
documentName: 'Item',
parent: originActor,
updates: [{ '_id': item.id, 'system.quantity': item.system.quantity - quantity }]
});
}
return foundry.documents.modifyBatch(batch);
}
/**

View file

@ -31,11 +31,12 @@ export default class AncestrySheet extends DHHeritageSheet {
if (data.type === 'ActiveEffect') return super._onDrop(event);
const target = event.target.closest('fieldset.drop-section');
if (target) {
const typeField =
this.document.system[target.dataset.type === 'primary' ? 'primaryFeature' : 'secondaryFeature'];
if (!typeField) {
super._onDrop(event);
}
}
}
}

View file

@ -47,6 +47,15 @@ export default class ArmorSheet extends ItemAttachmentSheet(DHBaseItemSheet) {
return context;
}
async updateArmorEffect(event) {
const value = Number.parseInt(event.target.value);
const armorEffect = this.document.system.armorEffect;
if (Number.isNaN(value) || !armorEffect) return;
await armorEffect.system.armorChange.updateArmorMax(value);
this.render();
}
/**
* Callback function used by `tagifyElement`.
* @param {Array<Object>} selectedOptions - The currently selected tag objects.

View file

@ -102,7 +102,7 @@ export default class BeastformSheet extends DHBaseItemSheet {
async advantageOnRemove(event) {
await this.document.update({
[`system.advantageOn.-=${event.detail.data.value}`]: null
[`system.advantageOn.${event.detail.data.value}`]: _del
});
}
}

View file

@ -31,7 +31,7 @@ export default class FeatureSheet extends DHBaseItemSheet {
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
}
};
//Might be wrong location but testing out if here is okay.
//Might be wrong location but testing out if here is okay.
/**@override */
async _prepareContext(options) {
const context = await super._prepareContext(options);

View file

@ -108,14 +108,15 @@ export default class DhRollTableSheet extends foundry.applications.sheets.RollTa
getSystemFlagUpdate() {
const deleteUpdate = Object.keys(this.document._source.flags.daggerheart?.altFormula ?? {}).reduce(
(acc, formulaKey) => {
if (!this.daggerheartFlag.altFormula[formulaKey]) acc.altFormula[`-=${formulaKey}`] = null;
if (!this.daggerheartFlag.altFormula[formulaKey]) acc.altFormula[formulaKey] = _del;
return acc;
},
{ altFormula: {} }
);
return { ['flags.daggerheart']: foundry.utils.mergeObject(this.daggerheartFlag.toObject(), deleteUpdate) };
const flagData = this.daggerheartFlag.toObject();
return { ...flagData, altFormula: { ...flagData.altFormula, ...deleteUpdate.altFormula } };
}
static async #addFormula() {
@ -127,7 +128,7 @@ export default class DhRollTableSheet extends foundry.applications.sheets.RollTa
static async #removeFormula(_event, target) {
await this.daggerheartFlag.updateSource({
[`altFormula.-=${target.dataset.key}`]: null
[`altFormula.${target.dataset.key}`]: _del
});
this.render({ internalRefresh: true });
}

View file

@ -1,52 +1,19 @@
export default class DhSidebar extends foundry.applications.sidebar.Sidebar {
/** @override */
static TABS = {
chat: {
documentName: 'ChatMessage'
},
combat: {
documentName: 'Combat'
},
scenes: {
documentName: 'Scene',
gmOnly: true
},
actors: {
documentName: 'Actor'
},
items: {
documentName: 'Item'
},
journal: {
documentName: 'JournalEntry',
tooltip: 'SIDEBAR.TabJournal'
},
tables: {
documentName: 'RollTable'
},
cards: {
documentName: 'Cards'
},
macros: {
documentName: 'Macro'
},
playlists: {
documentName: 'Playlist'
},
compendium: {
tooltip: 'SIDEBAR.TabCompendium',
icon: 'fa-solid fa-book-atlas'
},
static buildTabs() {
const { settings, ...tabs } = super.TABS;
return {
...tabs,
daggerheartMenu: {
tooltip: 'DAGGERHEART.UI.Sidebar.daggerheartMenu.title',
img: 'systems/daggerheart/assets/logos/FoundryBorneLogoWhite.svg',
gmOnly: true
},
settings: {
tooltip: 'SIDEBAR.TabSettings',
icon: 'fa-solid fa-gears'
}
settings
};
}
/** @override */
static TABS = DhSidebar.buildTabs();
/** @override */
static PARTS = {

View file

@ -46,10 +46,11 @@ export default class DhActorDirectory extends foundry.applications.sidebar.tabs.
_getEntryContextOptions() {
const options = super._getEntryContextOptions();
options.push({
name: 'DAGGERHEART.UI.Sidebar.actorDirectory.duplicateToNewTier',
options.push(
{
label: 'DAGGERHEART.UI.Sidebar.actorDirectory.duplicateToNewTier',
icon: `<i class="fa-solid fa-arrow-trend-up" inert></i>`,
condition: li => {
visible: li => {
const actor = game.actors.get(li.dataset.entryId);
return actor?.type === 'adversary' && actor.system.type !== 'social';
},
@ -76,7 +77,7 @@ export default class DhActorDirectory extends foundry.applications.sidebar.tabs.
window: { title: 'DAGGERHEART.UI.Sidebar.actorDirectory.pickTierTitle' },
content,
ok: {
label: 'Create Adversary',
label: 'DAGGERHEART.UI.Sidebar.actorDirectory.createAdversary',
callback: (event, button, dialog) => Number(button.form.elements.tier.value)
}
});
@ -89,7 +90,23 @@ export default class DhActorDirectory extends foundry.applications.sidebar.tabs.
ui.notifications.info(`Tier ${tier} ${actor.name} created`);
}
}
});
},
{
label: 'DAGGERHEART.UI.Sidebar.actorDirectory.activateParty',
icon: `<i class="fa-regular fa-square"></i>`,
visible: li => {
const actor = game.actors.get(li.dataset.entryId);
return actor && actor.type === 'party' && !actor.system.active;
},
callback: async li => {
const actor = game.actors.get(li.dataset.entryId);
if (!actor) throw new Error('Unexpected missing actor');
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty, actor.id);
ui.actors.render();
}
}
);
return options;
}

View file

@ -31,7 +31,8 @@ export default class DaggerheartMenu extends HandlebarsApplicationMixin(Abstract
},
actions: {
selectRefreshable: DaggerheartMenu.#selectRefreshable,
refreshActors: DaggerheartMenu.#refreshActors
refreshActors: DaggerheartMenu.#refreshActors,
createFallCollisionDamage: DaggerheartMenu.#createFallCollisionDamage
}
};
@ -50,6 +51,7 @@ export default class DaggerheartMenu extends HandlebarsApplicationMixin(Abstract
const context = await super._prepareContext(options);
context.refreshables = this.refreshSelections;
context.disableRefresh = Object.values(this.refreshSelections).every(x => !x.selected);
context.fallAndCollision = CONFIG.DH.GENERAL.fallAndCollisionDamage;
return context;
}
@ -71,4 +73,22 @@ export default class DaggerheartMenu extends HandlebarsApplicationMixin(Abstract
this.refreshSelections = DaggerheartMenu.defaultRefreshSelections();
this.render();
}
static async #createFallCollisionDamage(_event, button) {
const data = CONFIG.DH.GENERAL.fallAndCollisionDamage[button.dataset.key];
const roll = new Roll(data.damageFormula);
await roll.evaluate();
/* class BaseRoll needed to get rendered by foundryRoll.hbs */
const rollJSON = roll.toJSON();
rollJSON.class = 'BaseRoll';
foundry.documents.ChatMessage.implementation.create({
title: game.i18n.localize(data.chatTitle),
author: game.user.id,
speaker: foundry.documents.ChatMessage.implementation.getSpeaker(),
rolls: [rollJSON],
sound: CONFIG.sounds.dice
});
}
}

View file

@ -7,3 +7,4 @@ export { default as DhFearTracker } from './fearTracker.mjs';
export { default as DhHotbar } from './hotbar.mjs';
export { default as DhSceneNavigation } from './sceneNavigation.mjs';
export { ItemBrowser } from './itemBrowser.mjs';
export { default as DhProgress } from './progress.mjs';

View file

@ -1,5 +1,6 @@
import { abilities } from '../../config/actorConfig.mjs';
import { emitAsGM, GMUpdateEvent, RefreshType, socketEvent } from '../../systemRegistration/socket.mjs';
import { enrichedDualityRoll } from '../../enrichers/DualityRollEnricher.mjs';
import { enrichedFateRoll, getFateTypeData } from '../../enrichers/FateRollEnricher.mjs';
import { getCommandTarget, rollCommandToJSON } from '../../helpers/utils.mjs';
export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLog {
constructor(options) {
@ -21,26 +22,91 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
classes: ['daggerheart']
};
static CHAT_COMMANDS = {
...super.CHAT_COMMANDS,
dr: {
rgx: /^(?:\/dr)((?:\s)[^]*)?/,
fn: (_, match) => {
const argString = match[1]?.trim();
const result = argString ? rollCommandToJSON(argString) : { result: {} };
if (!result) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.dualityParsing'));
return false;
}
const { result: rollCommand, flavor } = result;
const reaction = rollCommand.reaction;
const traitValue = rollCommand.trait?.toLowerCase();
const advantage = rollCommand.advantage
? CONFIG.DH.ACTIONS.advantageState.advantage.value
: rollCommand.disadvantage
? CONFIG.DH.ACTIONS.advantageState.disadvantage.value
: undefined;
const difficulty = rollCommand.difficulty;
const grantResources = rollCommand.grantResources;
const target = getCommandTarget({ allowNull: true });
const title =
(flavor ?? traitValue)
? game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
ability: game.i18n.localize(SYSTEM.ACTOR.abilities[traitValue].label)
})
: game.i18n.localize('DAGGERHEART.GENERAL.duality');
enrichedDualityRoll({
reaction,
traitValue,
target,
difficulty,
title,
label: game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll'),
actionType: null,
advantage,
grantResources
});
return false;
}
},
fr: {
rgx: /^(?:\/fr)((?:\s)[^]*)?/,
fn: (_, match) => {
const argString = match[1]?.trim();
const result = argString ? rollCommandToJSON(argString) : { result: {} };
if (!result) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateParsing'));
return false;
}
const { result: rollCommand, flavor } = result;
const fateTypeData = getFateTypeData(rollCommand?.type);
if (!fateTypeData)
return ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
const { value: fateType, label: fateTypeLabel } = fateTypeData;
const target = getCommandTarget({ allowNull: true });
const title = flavor ?? game.i18n.localize('DAGGERHEART.GENERAL.fateRoll');
enrichedFateRoll({
target,
title,
label: fateTypeLabel,
fateType
});
return false;
}
}
};
_getEntryContextOptions() {
return [
...super._getEntryContextOptions(),
// {
// name: 'Reroll',
// icon: '<i class="fa-solid fa-dice"></i>',
// condition: li => {
// const message = game.messages.get(li.dataset.messageId);
// return (game.user.isGM || message.isAuthor) && message.rolls.length > 0;
// },
// callback: li => {
// const message = game.messages.get(li.dataset.messageId);
// new game.system.api.applications.dialogs.RerollDialog(message).render({ force: true });
// }
// },
{
name: game.i18n.localize('DAGGERHEART.UI.ChatLog.rerollDamage'),
label: 'DAGGERHEART.UI.ChatLog.rerollDamage',
icon: '<i class="fa-solid fa-dice"></i>',
condition: li => {
visible: li => {
const message = game.messages.get(li.dataset.messageId);
const hasRolledDamage = message.system.hasDamage
? Object.keys(message.system.damage).length > 0
@ -69,18 +135,6 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
html.querySelectorAll('.reroll-button').forEach(element =>
element.addEventListener('click', event => this.rerollEvent(event, message))
);
html.querySelectorAll('.group-roll-button').forEach(element =>
element.addEventListener('click', event => this.groupRollButton(event, message))
);
html.querySelectorAll('.group-roll-reroll').forEach(element =>
element.addEventListener('click', event => this.groupRollReroll(event, message))
);
html.querySelectorAll('.group-roll-success').forEach(element =>
element.addEventListener('click', event => this.groupRollSuccessEvent(event, message))
);
html.querySelectorAll('.group-roll-header-expand-section').forEach(element =>
element.addEventListener('click', this.groupRollExpandSection)
);
html.querySelectorAll('.risk-it-all-button').forEach(element =>
element.addEventListener('click', event => this.riskItAllClearStressAndHitPoints(event, data))
);
@ -175,7 +229,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
action.use(event);
}
async rerollEvent(event, message) {
async rerollEvent(event, messageData) {
event.stopPropagation();
if (!event.shiftKey) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
@ -187,206 +241,41 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
if (!confirmed) return;
}
const message = game.messages.get(messageData._id);
const target = event.target.closest('[data-die-index]');
if (target.dataset.type === 'damage') {
game.system.api.dice.DamageRoll.reroll(target, message);
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
}
});
} else {
let originalRoll_parsed = message.rolls.map(roll => JSON.parse(roll))[0];
const rollClass =
game.system.api.dice[
message.type === 'dualityRoll'
? 'DualityRoll'
: target.dataset.type === 'damage'
? 'DHRoll'
: 'D20Roll'
];
if (!game.modules.get('dice-so-nice')?.active) foundry.audio.AudioHelper.play({ src: CONFIG.sounds.dice });
const { newRoll, parsedRoll } = await rollClass.reroll(originalRoll_parsed, target, message);
await game.messages.get(message._id).update({
'system.roll': newRoll,
'rolls': [parsedRoll]
});
Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.TagTeamRoll });
await game.socket.emit(`system.${CONFIG.DH.id}`, {
action: socketEvent.Refresh,
data: {
refreshType: RefreshType.TagTeamRoll
const rerollDice = message.system.roll.dice[target.dataset.dieIndex];
await rerollDice.reroll(`/r1=${rerollDice.total}`, {
liveRoll: {
roll: message.system.roll,
actor: message.system.actionActor,
isReaction: message.system.roll.options.actionType === 'reaction'
}
});
}
}
async groupRollButton(event, message) {
const path = event.currentTarget.dataset.path;
const isLeader = path === 'leader';
const { actor: actorData, trait } = foundry.utils.getProperty(message.system, path);
const actor = game.actors.get(actorData._id);
if (!actor) {
return ui.notifications.error(
game.i18n.format('DAGGERHEART.UI.Notifications.documentIsMissing', {
documentType: game.i18n.localize('TYPES.Actor.character')
})
);
}
if (!actor.testUserPermission(game.user, 'OWNER')) {
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.noActorOwnership'));
}
const traitLabel = game.i18n.localize(abilities[trait].label);
const config = {
event: event,
title: `${game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll')}: ${actor.name}`,
headerTitle: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
ability: traitLabel
}),
roll: {
trait: trait,
advantage: 0,
modifiers: [{ label: traitLabel, value: actor.system.traits[trait].value }]
},
hasRoll: true,
skips: {
createMessage: true,
resources: !isLeader,
updateCountdowns: !isLeader
}
};
const result = await actor.diceRoll({
...config,
headerTitle: `${game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll')}: ${actor.name}`,
title: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
ability: traitLabel
})
await message.update({
rolls: [message.system.roll.toJSON()]
});
if (!result) return;
const newMessageData = foundry.utils.deepClone(message.system);
foundry.utils.setProperty(newMessageData, `${path}.result`, result.roll);
const renderData = { system: new game.system.api.models.chatMessages.config.groupRoll(newMessageData) };
const updatedContent = await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/ui/chat/groupRoll.hbs',
{ ...renderData, user: game.user }
);
const mess = game.messages.get(message._id);
await emitAsGM(
GMUpdateEvent.UpdateDocument,
mess.update.bind(mess),
{
...renderData,
content: updatedContent
},
mess.uuid
);
}
async groupRollReroll(event, message) {
const path = event.currentTarget.dataset.path;
const { actor: actorData, trait } = foundry.utils.getProperty(message.system, path);
const actor = game.actors.get(actorData._id);
if (!actor.testUserPermission(game.user, 'OWNER')) {
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.noActorOwnership'));
}
const traitLabel = game.i18n.localize(abilities[trait].label);
const config = {
event: event,
title: `${game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll')}: ${actor.name}`,
headerTitle: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
ability: traitLabel
}),
roll: {
trait: trait,
advantage: 0,
modifiers: [{ label: traitLabel, value: actor.system.traits[trait].value }]
},
hasRoll: true,
skips: {
createMessage: true,
updateCountdowns: true
}
};
const result = await actor.diceRoll({
...config,
headerTitle: `${game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll')}: ${actor.name}`,
title: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
ability: traitLabel
})
});
const newMessageData = foundry.utils.deepClone(message.system);
foundry.utils.setProperty(newMessageData, `${path}.result`, { ...result.roll, rerolled: true });
const renderData = { system: new game.system.api.models.chatMessages.config.groupRoll(newMessageData) };
const updatedContent = await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/ui/chat/groupRoll.hbs',
{ ...renderData, user: game.user }
);
const mess = game.messages.get(message._id);
await emitAsGM(
GMUpdateEvent.UpdateDocument,
mess.update.bind(mess),
{
...renderData,
content: updatedContent
},
mess.uuid
);
}
async groupRollSuccessEvent(event, message) {
if (!game.user.isGM) {
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.gmOnly'));
}
const { path, success } = event.currentTarget.dataset;
const { actor: actorData } = foundry.utils.getProperty(message.system, path);
const actor = game.actors.get(actorData._id);
if (!actor.testUserPermission(game.user, 'OWNER')) {
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.noActorOwnership'));
}
const newMessageData = foundry.utils.deepClone(message.system);
foundry.utils.setProperty(newMessageData, `${path}.manualSuccess`, Boolean(success));
const renderData = { system: new game.system.api.models.chatMessages.config.groupRoll(newMessageData) };
const updatedContent = await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/ui/chat/groupRoll.hbs',
{ ...renderData, user: game.user }
);
const mess = game.messages.get(message._id);
await emitAsGM(
GMUpdateEvent.UpdateDocument,
mess.update.bind(mess),
{
...renderData,
content: updatedContent
},
mess.uuid
);
}
async groupRollExpandSection(event) {
event.target
.closest('.group-roll-header-expand-section')
.querySelectorAll('i')
.forEach(element => {
element.classList.toggle('fa-angle-up');
element.classList.toggle('fa-angle-down');
});
event.target.closest('.group-roll-section').querySelector('.group-roll-content').classList.toggle('closed');
}
async riskItAllClearStressAndHitPoints(event, data) {

View file

@ -1,4 +1,6 @@
import { AdversaryBPPerEncounter } from '../../config/encounterConfig.mjs';
import { expireActiveEffects } from '../../helpers/utils.mjs';
import { clearPreviousSpotlight } from '../../macros/spotlightCombatant.mjs';
export default class DhCombatTracker extends foundry.applications.sidebar.tabs.CombatTracker {
static DEFAULT_OPTIONS = {
@ -82,15 +84,15 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
_getCombatContextOptions() {
return [
{
name: 'COMBAT.ClearMovementHistories',
label: 'COMBAT.ClearMovementHistories',
icon: '<i class="fa-solid fa-shoe-prints"></i>',
condition: () => game.user.isGM && this.viewed?.combatants.size > 0,
visible: () => game.user.isGM && this.viewed?.combatants.size > 0,
callback: () => this.viewed.clearMovementHistories()
},
{
name: 'COMBAT.Delete',
label: 'COMBAT.Delete',
icon: '<i class="fa-solid fa-trash"></i>',
condition: () => game.user.isGM && !!this.viewed,
visible: () => game.user.isGM && !!this.viewed,
callback: () => this.viewed.endCombat()
}
];
@ -149,13 +151,13 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
}
async setCombatantSpotlight(combatantId) {
const combatant = this.viewed.combatants.get(combatantId);
const update = {
system: {
'spotlight.requesting': false,
'spotlight.requestOrderIndex': 0
}
};
const combatant = this.viewed.combatants.get(combatantId);
const toggleTurn = this.viewed.combatants.contents
.sort(this.viewed._sortCombatants)
@ -177,6 +179,8 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
if (autoPoints) {
update.system.actionTokens = Math.max(combatant.system.actionTokens - 1, 0);
}
if (combatant.actor) expireActiveEffects(combatant.actor, [CONFIG.DH.GENERAL.activeEffectDurations.act.id]);
}
await this.viewed.update({
@ -184,6 +188,14 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
round: this.viewed.round + 1
});
await combatant.update(update);
if (combatant.token) clearPreviousSpotlight();
}
async clearTurn() {
await this.viewed.update({
turn: null,
round: this.viewed.round + 1
});
}
static async requestSpotlight(_, target) {

View file

@ -233,6 +233,6 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
}
if (this.editingCountdowns.has(countdownId)) this.editingCountdowns.delete(countdownId);
this.updateSetting({ [`countdowns.-=${countdownId}`]: null });
this.updateSetting({ [`countdowns.${countdownId}`]: _del });
}
}

View file

@ -52,10 +52,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
}
};
get element() {
return document.body.querySelector('.daggerheart.dh-style.countdowns');
}
/**@inheritdoc */
async _renderFrame(options) {
const frame = await super._renderFrame(options);
@ -68,6 +64,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
const header = frame.querySelector('.window-header');
header.querySelector('button[data-action="close"]').remove();
header.querySelector('button[data-action="toggleControls"]').remove();
if (game.user.isGM) {
const editTooltip = game.i18n.localize('DAGGERHEART.APPLICATIONS.CountdownEdit.editTitle');
@ -140,6 +137,8 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
}
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
@ -278,9 +277,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
return acc;
}, {})
};
await emitAsGM(GMUpdateEvent.UpdateCountdowns,
DhCountdowns.gmSetSetting.bind(settings),
settings, null, {
await emitAsGM(GMUpdateEvent.UpdateCountdowns, DhCountdowns.gmSetSetting.bind(settings), settings, null, {
refreshType: RefreshType.Countdown
});
}

View file

@ -1,3 +1,4 @@
import { getIconVisibleActiveEffects } from '../../helpers/utils.mjs';
import { RefreshType } from '../../systemRegistration/socket.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
@ -48,11 +49,9 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
if (this.element) {
this.element.querySelectorAll('.effect-container a').forEach(element => {
element.addEventListener('contextmenu', this.removeEffect.bind(this));
});
for (const element of this.element?.querySelectorAll('.effect-container a') ?? []) {
element.addEventListener('click', e => this.#onClickEffect(e));
element.addEventListener('contextmenu', e => this.#onClickEffect(e, -1));
}
}
@ -72,7 +71,7 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
? game.user.character
: null
: canvas.tokens.controlled[0].actor;
return actor?.getActiveEffects() ?? [];
return getIconVisibleActiveEffects(actor?.getActiveEffects() ?? []);
};
toggleHidden(token, focused) {
@ -86,11 +85,21 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
this.render();
}
async removeEffect(event) {
async #onClickEffect(event, delta = 1) {
const element = event.target.closest('.effect-container');
const effects = DhEffectsDisplay.getTokenEffects();
const effect = effects.find(x => x.id === element.dataset.effectId);
if (!effect || (delta >= 0 && !effect.system.stacking)) {
return;
}
const maxValue = effect.system.stacking?.max ?? Infinity;
const newValue = Math.clamp((effect.system.stacking?.value ?? 1) + delta, 0, maxValue);
if (newValue > 0) {
await effect.update({ 'system.stacking.value': newValue });
} else {
await effect.delete();
}
this.render();
}

View file

@ -22,7 +22,7 @@ export default class FearTracker extends HandlebarsApplicationMixin(ApplicationV
tag: 'div',
window: {
frame: true,
title: 'Fear',
title: 'DAGGERHEART.GENERAL.fear',
positioned: true,
resizable: true,
minimizable: false

View file

@ -37,7 +37,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
tag: 'div',
window: {
frame: true,
title: 'Compendium Browser',
title: 'DAGGERHEART.UI.ItemBrowser.windowTitle',
icon: 'fa-solid fa-book-atlas',
positioned: true,
resizable: true
@ -207,8 +207,23 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
label: game.i18n.localize(col.label)
}));
const splitPath = folderId?.split('.') ?? [];
const { pathLabels } = splitPath.reduce(
(acc, curr) => {
acc.currentPath = !acc.currentPath ? curr : [acc.currentPath, curr].join('.');
if (curr === 'folder') return acc;
const label = foundry.utils.getProperty(this.config, acc.currentPath)?.label;
if (label) acc.pathLabels.push(game.i18n.localize(label));
return acc;
},
{ pathLabels: [], currentPath: '' }
);
this.selectedMenu = {
path: folderId?.split('.') ?? [],
path: splitPath,
pathLabels: pathLabels,
data: {
...folderData,
columns: columns
@ -568,7 +583,9 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
const { itemUuid } = event.target.closest('[data-item-uuid]').dataset,
item = await foundry.utils.fromUuid(itemUuid),
dragData = item.toDragData();
event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
event.dataTransfer.setDragImage(event.target.querySelector('img'), 0, 0);
}
_canDragStart() {

View file

@ -0,0 +1,27 @@
export default class DhProgress {
#notification;
constructor({ max, label = '' }) {
this.max = max;
this.label = label;
this.#notification = ui.notifications.info(this.label, { progress: true });
}
updateMax(newMax) {
this.max = newMax;
}
advance({ by = 1, label = this.label } = {}) {
if (this.value === this.max) return;
this.value = (this.value ?? 0) + Math.abs(by);
this.#notification.update({ message: label, pct: this.value / this.max });
}
close({ label = '' } = {}) {
this.#notification.update({ message: label, pct: 1 });
}
static createMigrationProgress(max = 0) {
return new DhProgress({ max, label: game.i18n.localize('DAGGERHEART.UI.Progress.migrationLabel') });
}
}

View file

@ -31,7 +31,7 @@ export default class DhSceneNavigation extends foundry.applications.ui.SceneNavi
const environments = daggerheartInfo.sceneEnvironments.filter(
x => x && x.testUserPermission(game.user, 'LIMITED')
);
const hasEnvironments = environments.length > 0 && x.isView;
const hasEnvironments = environments.length > 0 && x.active;
return {
...x,
hasEnvironments,
@ -39,9 +39,10 @@ export default class DhSceneNavigation extends foundry.applications.ui.SceneNavi
environments: environments
};
});
context.scenes.active = extendScenes(context.scenes.active);
context.scenes.inactive = extendScenes(context.scenes.inactive);
context.scenes.viewed = context.scenes.viewed ? extendScenes([context.scenes.viewed])[0] : null;
return context;
}

View file

@ -1,97 +1,4 @@
/**
* @typedef ContextMenuEntry
* @property {string} name The context menu label. Can be localized.
* @property {string} [icon] A string containing an HTML icon element for the menu item.
* @property {string} [classes] Additional CSS classes to apply to this menu item.
* @property {string} [group] An identifier for a group this entry belongs to.
* @property {ContextMenuJQueryCallback} callback The function to call when the menu item is clicked.
* @property {ContextMenuCondition|boolean} [condition] A function to call or boolean value to determine if this entry
* appears in the menu.
*/
/**
* @callback ContextMenuCondition
* @param {jQuery|HTMLElement} html The element of the context menu entry.
* @returns {boolean} Whether the entry should be rendered in the context menu.
*/
/**
* @callback ContextMenuCallback
* @param {HTMLElement} target The element that the context menu has been triggered for.
* @returns {unknown}
*/
/**
* @callback ContextMenuJQueryCallback
* @param {HTMLElement|jQuery} target The element that the context menu has been triggered for. Will
* either be a jQuery object or an HTMLElement instance, depending
* on how the ContextMenu was configured.
* @returns {unknown}
*/
/**
* @typedef ContextMenuOptions
* @property {string} [eventName="contextmenu"] Optionally override the triggering event which can spawn the menu. If
* the menu is using fixed positioning, this event must be a MouseEvent.
* @property {ContextMenuCallback} [onOpen] A function to call when the context menu is opened.
* @property {ContextMenuCallback} [onClose] A function to call when the context menu is closed.
* @property {boolean} [fixed=false] If true, the context menu is given a fixed position rather than being
* injected into the target.
* @property {boolean} [jQuery=true] If true, callbacks will be passed jQuery objects instead of HTMLElement
* instances.
*/
/**
* @typedef ContextMenuRenderOptions
* @property {Event} [event] The event that triggered the context menu opening.
* @property {boolean} [animate=true] Animate the context menu opening.
*/
/**
* A subclass of ContextMenu.
* @extends {foundry.applications.ux.ContextMenu}
*/
export default class DHContextMenu extends foundry.applications.ux.ContextMenu {
/**
* @param {HTMLElement|jQuery} container - The HTML element that contains the context menu targets.
* @param {string} selector - A CSS selector which activates the context menu.
* @param {ContextMenuEntry[]} menuItems - An Array of entries to display in the menu
* @param {ContextMenuOptions} [options] - Additional options to configure the context menu.
*/
constructor(container, selector, menuItems, options) {
super(container, selector, menuItems, options);
/** @deprecated since v13 until v15 */
this.#jQuery = options.jQuery;
}
/**
* Whether to pass jQuery objects or HTMLElement instances to callback.
* @type {boolean}
*/
#jQuery;
/**@inheritdoc */
activateListeners(menu) {
menu.addEventListener('click', this.#onClickItem.bind(this));
}
/**
* Handle click events on context menu items.
* @param {PointerEvent} event The click event
*/
#onClickItem(event) {
event.preventDefault();
event.stopPropagation();
const element = event.target.closest('.context-item');
if (!element) return;
const item = this.menuItems.find(i => i.element === element);
item?.callback(this.#jQuery ? $(this.target) : this.target, event);
this.close();
}
/* -------------------------------------------- */
/**
* Trigger a context menu event in response to a normal click on a additional options button.
* @param {PointerEvent} event
@ -99,8 +6,11 @@ export default class DHContextMenu extends foundry.applications.ux.ContextMenu {
static triggerContextMenu(event, altSelector) {
event.preventDefault();
event.stopPropagation();
const { clientX, clientY } = event;
const selector = altSelector ?? '[data-item-uuid]';
if (ui.context?.selector === selector) return;
const { clientX, clientY } = event;
const target = event.target.closest(selector) ?? event.currentTarget.closest(selector);
target?.dispatchEvent(
new PointerEvent('contextmenu', {

View file

@ -188,7 +188,7 @@ export default class FilterMenu extends foundry.applications.ux.ContextMenu {
}));
const damageTypeFilter = Object.values(CONFIG.DH.GENERAL.damageTypes).map(({ id, abbreviation }) => ({
group: 'Damage Type', //TODO localize
group: game.i18n.localize('DAGGERHEART.GENERAL.damageType'),
name: game.i18n.localize(abbreviation),
filter: {
field: 'system.damage.type',

View file

@ -1,5 +1,6 @@
export { default as DhMeasuredTemplate } from './measuredTemplate.mjs';
export { default as DhRuler } from './ruler.mjs';
export { default as DhTemplateLayer } from './templateLayer.mjs';
export { default as DhRegion } from './region.mjs';
export { default as DhRegionLayer } from './regionLayer.mjs';
export { default as DhTokenPlaceable } from './token.mjs';
export { default as DhTokenRuler } from './tokenRuler.mjs';

View file

@ -18,7 +18,7 @@ export default class DhMeasuredTemplate extends foundry.canvas.placeables.Measur
static getRangeLabels(distanceValue, settings) {
let result = { distance: distanceValue, units: '' };
if (!settings.enabled) return result;
if (!settings.enabled || !canvas.scene) return result;
const sceneRangeMeasurement = canvas.scene.flags.daggerheart?.rangeMeasurement;
const { disable, custom } = CONFIG.DH.GENERAL.sceneRangeMeasurementSetting;

View file

@ -0,0 +1,12 @@
import DhMeasuredTemplate from './measuredTemplate.mjs';
export default class DhRegion extends foundry.canvas.placeables.Region {
/**@inheritdoc */
_formatMeasuredDistance(distance) {
const range = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).rangeMeasurement;
if (!range.enabled) return super._formatMeasuredDistance(distance);
const { distance: resultDistance, units } = DhMeasuredTemplate.getRangeLabels(distance, range);
return `${resultDistance} ${units}`;
}
}

View file

@ -0,0 +1,155 @@
export default class DhRegionLayer extends foundry.canvas.layers.RegionLayer {
static prepareSceneControls() {
const sc = foundry.applications.ui.SceneControls;
const { tools, ...rest } = super.prepareSceneControls();
return {
...rest,
tools: {
select: tools.select,
templateMode: tools.templateMode,
rectangle: tools.rectangle,
circle: tools.circle,
ellipse: tools.ellipse,
cone: tools.cone,
inFront: {
name: 'inFront',
order: 7,
title: 'CONTROLS.inFront',
icon: 'fa-solid fa-eye',
toolclip: {
src: 'toolclips/tools/measure-cone.webm',
heading: 'CONTROLS.inFront',
items: sc.buildToolclipItems(['create', 'move', 'edit', 'hide', 'delete', 'rotate'])
}
},
ring: { ...tools.ring, order: 8 },
line: { ...tools.line, order: 9 },
emanation: { ...tools.emanation, order: 10 },
polygon: { ...tools.polygon, order: 11 },
hole: { ...tools.hole, order: 12 },
snap: { ...tools.snap, order: 13 },
clear: { ...tools.clear, order: 14 }
}
};
}
/** @inheritDoc */
_isCreationToolActive() {
return this.active && (game.activeTool === 'inFront' || game.activeTool in foundry.data.BaseShapeData.TYPES);
}
_createDragShapeData(event) {
const hole = ui.controls.controls[this.options.name].tools.hole?.active ?? false;
if (game.activeTool === 'inFront') return { type: 'cone', x: 0, y: 0, radius: 0, angle: 180, hole };
const shape = super._createDragShapeData(event);
const token =
shape?.type === 'emanation' && shape.base?.type === 'token'
? this.#findTokenInBounds(event.interactionData.origin)
: null;
if (token) {
shape.base.width = token.width;
shape.base.height = token.height;
event.interactionData.origin = token.getCenterPoint();
}
return shape;
}
async placeRegion(data, options = {}) {
const preConfirm = ({ _event, document, _create, _options }) => {
const shape = document.shapes[0];
const isEmanation = shape.type === 'emanation';
if (isEmanation) {
const token = this.#findTokenInBounds(shape.base.origin);
if (!token) return options.preConfirm?.() ?? true;
const shapeData = shape.toObject();
document.updateSource({
shapes: [
{
...shapeData,
base: {
...shapeData.base,
height: token.height,
width: token.width,
x: token.x,
y: token.y
}
}
]
});
}
return options?.preConfirm?.() ?? true;
};
super.placeRegion(data, { ...options, preConfirm });
}
/** Searches for token at origin point, returning null if there are no tokens or multiple overlapping tokens */
#findTokenInBounds(origin) {
const { x, y } = origin;
const gridSize = canvas.grid.size;
const inBounds = canvas.scene.tokens.filter(t => {
return x.between(t.x, t.x + t.width * gridSize) && y.between(t.y, t.y + t.height * gridSize);
});
return inBounds.length === 1 ? inBounds[0] : null;
}
static getTemplateShape({ type, angle, range, direction } = {}) {
const { line, rectangle, inFront, cone, circle, emanation } = CONFIG.DH.GENERAL.templateTypes;
/* Length calculation */
const { grid, distance } = CONFIG.Scene.documentClass.schema.fields.grid.fields;
const sceneGridSize = canvas.scene?.grid.size ?? grid.size.initial;
const sceneGridDistance = canvas.scene?.grid.distance ?? distance.getInitialValue();
const dimensionConstant = sceneGridSize / sceneGridDistance;
const settings = canvas.scene?.rangeSettings;
const rangeNumber = Number(range);
const length = (!Number.isNaN(rangeNumber) ? rangeNumber : settings ? settings[range] : 0) * dimensionConstant;
/*----*/
const shapeData = {
...canvas.mousePosition,
type: type,
direction: direction ?? 0
};
switch (type) {
case rectangle.id:
shapeData.width = length;
shapeData.height = length;
break;
case line.id:
shapeData.length = length;
shapeData.width = 5 * dimensionConstant;
break;
case cone.id:
shapeData.angle = angle ?? CONFIG.MeasuredTemplate.defaults.angle;
shapeData.radius = length;
break;
case inFront.id:
shapeData.angle = '180';
shapeData.radius = length;
shapeData.type = cone.id;
break;
case circle.id:
shapeData.radius = length;
break;
case emanation.id:
shapeData.radius = length;
shapeData.base = {
type: 'token',
x: 0,
y: 0,
width: 1,
height: 1,
shape: game.canvas.grid.isHexagonal ? CONST.TOKEN_SHAPES.ELLIPSE_1 : CONST.TOKEN_SHAPES.RECTANGLE_1
};
break;
}
return shapeData;
}
}

View file

@ -1,116 +0,0 @@
export default class DhTemplateLayer extends foundry.canvas.layers.TemplateLayer {
static prepareSceneControls() {
const sc = foundry.applications.ui.SceneControls;
return {
name: 'templates',
order: 2,
title: 'CONTROLS.GroupMeasure',
icon: 'fa-solid fa-ruler-combined',
visible: game.user.can('TEMPLATE_CREATE'),
onChange: (event, active) => {
if (active) canvas.templates.activate();
},
onToolChange: () => canvas.templates.setAllRenderFlags({ refreshState: true }),
tools: {
circle: {
name: 'circle',
order: 1,
title: 'CONTROLS.MeasureCircle',
icon: 'fa-regular fa-circle',
toolclip: {
src: 'toolclips/tools/measure-circle.webm',
heading: 'CONTROLS.MeasureCircle',
items: sc.buildToolclipItems(['create', 'move', 'edit', 'hide', 'delete'])
}
},
cone: {
name: 'cone',
order: 2,
title: 'CONTROLS.MeasureCone',
icon: 'fa-solid fa-angle-left',
toolclip: {
src: 'toolclips/tools/measure-cone.webm',
heading: 'CONTROLS.MeasureCone',
items: sc.buildToolclipItems(['create', 'move', 'edit', 'hide', 'delete', 'rotate'])
}
},
inFront: {
name: 'inFront',
order: 3,
title: 'CONTROLS.inFront',
icon: 'fa-solid fa-eye',
toolclip: {
src: 'toolclips/tools/measure-cone.webm',
heading: 'CONTROLS.inFront',
items: sc.buildToolclipItems(['create', 'move', 'edit', 'hide', 'delete', 'rotate'])
}
},
rect: {
name: 'rect',
order: 4,
title: 'CONTROLS.MeasureRect',
icon: 'fa-regular fa-square',
toolclip: {
src: 'toolclips/tools/measure-rect.webm',
heading: 'CONTROLS.MeasureRect',
items: sc.buildToolclipItems(['create', 'move', 'edit', 'hide', 'delete', 'rotate'])
}
},
ray: {
name: 'ray',
order: 5,
title: 'CONTROLS.MeasureRay',
icon: 'fa-solid fa-up-down',
toolclip: {
src: 'toolclips/tools/measure-ray.webm',
heading: 'CONTROLS.MeasureRay',
items: sc.buildToolclipItems(['create', 'move', 'edit', 'hide', 'delete', 'rotate'])
}
},
clear: {
name: 'clear',
order: 6,
title: 'CONTROLS.MeasureClear',
icon: 'fa-solid fa-trash',
visible: game.user.isGM,
onChange: () => canvas.templates.deleteAll(),
button: true
}
},
activeTool: 'circle'
};
}
_onDragLeftStart(event) {
const interaction = event.interactionData;
// Snap the origin to the grid
if (!event.shiftKey) interaction.origin = this.getSnappedPoint(interaction.origin);
// Create a pending MeasuredTemplateDocument
const tool = game.activeTool === 'inFront' ? 'cone' : game.activeTool;
const previewData = {
user: game.user.id,
t: tool,
x: interaction.origin.x,
y: interaction.origin.y,
sort: Math.max(this.getMaxSort() + 1, 0),
distance: 1,
direction: 0,
fillColor: game.user.color || '#FF0000',
hidden: event.altKey
};
const defaults = CONFIG.MeasuredTemplate.defaults;
if (game.activeTool === 'cone') previewData.angle = defaults.angle;
else if (game.activeTool === 'inFront') previewData.angle = 180;
else if (game.activeTool === 'ray') previewData.width = defaults.width * canvas.dimensions.distance;
const cls = foundry.utils.getDocumentClass('MeasuredTemplate');
const doc = new cls(previewData, { parent: canvas.scene });
// Create a preview MeasuredTemplate object
const template = new this.constructor.placeableClass(doc);
doc._object = template;
interaction.preview = this.preview.addChild(template);
template.draw();
}
}

View file

@ -1,3 +1,4 @@
import { getIconVisibleActiveEffects } from '../../helpers/utils.mjs';
import DhMeasuredTemplate from './measuredTemplate.mjs';
export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
@ -9,6 +10,36 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
this.previewHelp ||= this.addChild(this.#drawPreviewHelp());
}
/**@inheritdoc */
_refreshTurnMarker() {
// Should a Turn Marker be active?
const { turnMarker } = this.document;
const markersEnabled =
CONFIG.Combat.settings.turnMarker.enabled && turnMarker.mode !== CONST.TOKEN_TURN_MARKER_MODES.DISABLED;
const spotlighted = game.settings
.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.SpotlightTracker)
.spotlightedTokens.has(this.document.uuid);
const turnIsSet = typeof game.combat?.turn === 'number';
const isTurn = game.combat?.combatant?.tokenId === this.id;
const markerActive = markersEnabled && turnIsSet ? isTurn : spotlighted;
// Activate a Turn Marker
if (markerActive) {
if (!this.turnMarker)
this.turnMarker = this.addChildAt(new foundry.canvas.placeables.tokens.TokenTurnMarker(this), 0);
canvas.tokens.turnMarkers.add(this);
this.turnMarker.draw();
}
// Remove a Turn Marker
else if (this.turnMarker) {
canvas.tokens.turnMarkers.delete(this);
this.turnMarker.destroy();
this.turnMarker = null;
}
}
/** @inheritDoc */
async _drawEffects() {
this.effects.renderable = false;
@ -20,7 +51,7 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
this.effects.overlay = null;
// Categorize effects
const activeEffects = this.actor?.getActiveEffects() ?? [];
const activeEffects = getIconVisibleActiveEffects(Array.from(this.actor?.allApplicableEffects() ?? []));
const overlayEffect = activeEffects.findLast(e => e.img && e.getFlag?.('core', 'overlay'));
// Draw effects
@ -29,8 +60,8 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
if (!effect.img) continue;
const promise =
effect === overlayEffect
? this._drawOverlay(effect.img, effect.tint)
: this._drawEffect(effect.img, effect.tint);
? this._drawOverlay(effect.img, effect.tint, effect)
: this._drawEffect(effect.img, effect.tint, effect);
promises.push(
promise.then(e => {
if (e) e.zIndex = i;
@ -44,6 +75,39 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
this.renderFlags.set({ refreshEffects: true });
}
/**@inheritdoc */
async _drawEffect(src, tint, effect) {
if (!src) return;
const tex = await foundry.canvas.loadTexture(src, { fallback: 'icons/svg/hazard.svg' });
const icon = new PIXI.Sprite(tex);
icon.tint = tint ?? 0xffffff;
if (effect.system.stacking?.value > 1) {
const stackOverlay = new PIXI.Text(effect.system.stacking.value, {
fill: '#f3c267',
stroke: '#000000',
fontSize: 96,
strokeThickness: 4
});
const nrDigits = Math.floor(Math.log10(effect.system.stacking.value)) + 1;
stackOverlay.y = -8;
/* This does not account for 1:s being much less wide than other digits. I don't think it's desired however as it makes it look jumpy */
stackOverlay.x = icon.width - 8 - nrDigits * 56;
stackOverlay.anchor.set(0, 0);
icon.addChild(stackOverlay);
}
return this.effects.addChild(icon);
}
async _drawOverlay(src, tint, effect) {
const icon = await this._drawEffect(src, tint, effect);
if (icon) icon.alpha = 0.8;
this.effects.overlay = icon ?? null;
return icon;
}
/**
* Returns the distance from this token to another token object.
* This value is corrected to handle alternate token sizes and other grid types

View file

@ -1,16 +1 @@
export default class DhTokenLayer extends foundry.canvas.layers.TokenLayer {
async _createPreview(createData, options) {
if (options.actor) {
const tokenSizes = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).tokenSizes;
if (options.actor?.system.metadata.usesSize) {
const tokenSize = tokenSizes[options.actor.system.size];
if (tokenSize && options.actor.system.size !== CONFIG.DH.ACTOR.tokenSize.custom.id) {
createData.width = tokenSize;
createData.height = tokenSize;
}
}
}
return super._createPreview(createData, options);
}
}
export default class DhTokenLayer extends foundry.canvas.layers.TokenLayer {}

View file

@ -115,3 +115,10 @@ export const advantageState = {
value: 1
}
};
export const areaTypes = {
placed: {
id: 'placed',
label: 'Placed Area'
}
};

View file

@ -70,10 +70,40 @@ export const range = {
}
};
export const groupAttackRange = {
melee: range.melee,
veryClose: range.veryClose,
close: range.close,
far: range.far,
veryFar: range.veryFar
};
/* circle|cone|rect|ray used to be CONST.MEASURED_TEMPLATE_TYPES. Hardcoded for now */
export const templateTypes = {
...CONST.MEASURED_TEMPLATE_TYPES,
EMANATION: 'emanation',
INFRONT: 'inFront'
circle: {
id: 'circle',
label: 'Circle'
},
cone: {
id: 'cone',
label: 'Cone'
},
rectangle: {
id: 'rectangle',
label: 'Rectangle'
},
line: {
id: 'line',
label: 'Line'
},
emanation: {
id: 'emanation',
label: 'Emanation'
},
inFront: {
id: 'inFront',
label: 'In Front'
}
};
export const rangeInclusion = {
@ -241,8 +271,8 @@ export const defaultRestOptions = {
type: 'friendly'
},
damage: {
parts: [
{
parts: {
hitPoints: {
applyTo: healingTypes.hitPoints.id,
value: {
custom: {
@ -251,7 +281,7 @@ export const defaultRestOptions = {
}
}
}
]
}
}
}
},
@ -275,8 +305,8 @@ export const defaultRestOptions = {
type: 'self'
},
damage: {
parts: [
{
parts: {
stress: {
applyTo: healingTypes.stress.id,
value: {
custom: {
@ -285,7 +315,7 @@ export const defaultRestOptions = {
}
}
}
]
}
}
}
},
@ -310,8 +340,8 @@ export const defaultRestOptions = {
type: 'friendly'
},
damage: {
parts: [
{
parts: {
armor: {
applyTo: healingTypes.armor.id,
value: {
custom: {
@ -320,7 +350,7 @@ export const defaultRestOptions = {
}
}
}
]
}
}
}
},
@ -344,8 +374,8 @@ export const defaultRestOptions = {
type: 'self'
},
damage: {
parts: [
{
parts: {
hope: {
applyTo: healingTypes.hope.id,
value: {
custom: {
@ -354,7 +384,7 @@ export const defaultRestOptions = {
}
}
}
]
}
}
},
prepareWithFriends: {
@ -368,8 +398,8 @@ export const defaultRestOptions = {
type: 'self'
},
damage: {
parts: [
{
parts: {
hope: {
applyTo: healingTypes.hope.id,
value: {
custom: {
@ -378,7 +408,7 @@ export const defaultRestOptions = {
}
}
}
]
}
}
}
},
@ -405,8 +435,8 @@ export const defaultRestOptions = {
type: 'friendly'
},
damage: {
parts: [
{
parts: {
hitPoints: {
applyTo: healingTypes.hitPoints.id,
value: {
custom: {
@ -415,7 +445,7 @@ export const defaultRestOptions = {
}
}
}
]
}
}
}
},
@ -439,8 +469,8 @@ export const defaultRestOptions = {
type: 'self'
},
damage: {
parts: [
{
parts: {
stress: {
applyTo: healingTypes.stress.id,
value: {
custom: {
@ -449,7 +479,7 @@ export const defaultRestOptions = {
}
}
}
]
}
}
}
},
@ -474,17 +504,17 @@ export const defaultRestOptions = {
type: 'friendly'
},
damage: {
parts: [
{
parts: {
armor: {
applyTo: healingTypes.armor.id,
value: {
custom: {
enabled: true,
formula: '@system.armorScore'
formula: '@system.armorScore.max'
}
}
}
}
]
}
}
},
@ -508,8 +538,8 @@ export const defaultRestOptions = {
type: 'self'
},
damage: {
parts: [
{
parts: {
hope: {
applyTo: healingTypes.hope.id,
value: {
custom: {
@ -518,7 +548,7 @@ export const defaultRestOptions = {
}
}
}
]
}
}
},
prepareWithFriends: {
@ -532,8 +562,8 @@ export const defaultRestOptions = {
type: 'self'
},
damage: {
parts: [
{
parts: {
hope: {
applyTo: healingTypes.hope.id,
value: {
custom: {
@ -542,7 +572,7 @@ export const defaultRestOptions = {
}
}
}
]
}
}
}
},
@ -704,14 +734,14 @@ const getDiceSoNiceSFX = sfxOptions => {
if (sfxOptions.critical && criticalAnimationData.class) {
return {
specialEffect: criticalAnimationData.class,
options: {}
options: { ...criticalAnimationData.options }
};
}
if (sfxOptions.higher && sfxOptions.data.higher) {
return {
specialEffect: sfxOptions.data.higher.class,
options: {}
options: { ...sfxOptions.data.higher.options }
};
}
@ -943,14 +973,155 @@ export const countdownAppMode = {
export const sceneRangeMeasurementSetting = {
disable: {
id: 'disable',
label: 'Disable Daggerheart Range Measurement'
label: 'DAGGERHEART.CONFIG.SceneRangeMeasurementTypes.disable'
},
default: {
id: 'default',
label: 'Default'
label: 'DAGGERHEART.CONFIG.SceneRangeMeasurementTypes.default'
},
custom: {
id: 'custom',
label: 'Custom'
label: 'DAGGERHEART.CONFIG.SceneRangeMeasurementTypes.custom'
}
};
export const tagTeamRollTypes = {
trait: {
id: 'trait',
label: 'DAGGERHEART.CONFIG.TagTeamRollTypes.trait'
},
ability: {
id: 'ability',
label: 'DAGGERHEART.CONFIG.TagTeamRollTypes.ability'
},
damageAbility: {
id: 'damageAbility',
label: 'DAGGERHEART.CONFIG.TagTeamRollTypes.damageAbility'
}
};
export const baseActiveEffectModes = {
custom: {
id: 'custom',
priority: 0,
label: 'EFFECT.CHANGES.TYPES.custom'
},
multiply: {
id: 'multiply',
priority: 10,
label: 'EFFECT.CHANGES.TYPES.multiply'
},
add: {
id: 'add',
priority: 20,
label: 'EFFECT.CHANGES.TYPES.add'
},
subtract: {
id: 'subtract',
priority: 20,
label: 'EFFECT.CHANGES.TYPES.subtract'
},
downgrade: {
id: 'downgrade',
priority: 30,
label: 'EFFECT.CHANGES.TYPES.downgrade'
},
upgrade: {
id: 'upgrade',
priority: 40,
label: 'EFFECT.CHANGES.TYPES.upgrade'
},
override: {
id: 'override',
priority: 50,
label: 'EFFECT.CHANGES.TYPES.override'
}
};
export const activeEffectModes = {
armor: {
id: 'armor',
priority: 20,
label: 'TYPES.ActiveEffect.armor'
},
...baseActiveEffectModes
};
export const activeEffectArmorInteraction = {
none: { id: 'none', label: 'DAGGERHEART.CONFIG.ArmorInteraction.none.label' },
active: { id: 'active', label: 'DAGGERHEART.CONFIG.ArmorInteraction.active.label' },
inactive: { id: 'inactive', label: 'DAGGERHEART.CONFIG.ArmorInteraction.inactive.label' }
};
export const activeEffectDurations = {
temporary: {
id: 'temporary',
label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.temporary'
},
act: {
id: 'act',
label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.act'
},
scene: {
id: 'scene',
label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.scene'
},
shortRest: {
id: 'shortRest',
label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.shortRest'
},
longRest: {
id: 'longRest',
label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.longRest'
},
session: {
id: 'session',
label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.session'
},
custom: {
id: 'custom',
label: 'DAGGERHEART.CONFIG.ActiveEffectDuration.custom'
}
};
export const fallAndCollisionDamage = {
veryClose: {
id: 'veryClose',
label: 'DAGGERHEART.CONFIG.fallAndCollision.veryClose.label',
chatTitle: 'DAGGERHEART.CONFIG.fallAndCollision.veryClose.chatTitle',
damageFormula: '1d10 + 3'
},
close: {
id: 'veryClose',
label: 'DAGGERHEART.CONFIG.fallAndCollision.close.label',
chatTitle: 'DAGGERHEART.CONFIG.fallAndCollision.close.chatTitle',
damageFormula: '1d20 + 5'
},
far: {
id: 'veryClose',
label: 'DAGGERHEART.CONFIG.fallAndCollision.far.label',
chatTitle: 'DAGGERHEART.CONFIG.fallAndCollision.far.chatTitle',
damageFormula: '1d100 + 15'
},
collision: {
id: 'veryClose',
label: 'DAGGERHEART.CONFIG.fallAndCollision.collision.label',
chatTitle: 'DAGGERHEART.CONFIG.fallAndCollision.collision.chatTitle',
damageFormula: '1d20 + 5'
}
};
export const simpleDispositions = {
[-1]: {
id: -1,
label: 'TOKEN.DISPOSITION.HOSTILE'
},
[0]: {
id: 0,
label: 'TOKEN.DISPOSITION.NEUTRAL'
},
[1]: {
id: 1,
label: 'TOKEN.DISPOSITION.FRIENDLY'
}
};

View file

@ -1,4 +1,6 @@
export const hooksConfig = {
effectDisplayToggle: 'DHEffectDisplayToggle',
lockedTooltipDismissed: 'DHLockedTooltipDismissed'
lockedTooltipDismissed: 'DHLockedTooltipDismissed',
tagTeamStart: 'DHTagTeamRollStart',
groupRollStart: 'DHGroupRollStart'
};

View file

@ -7,7 +7,12 @@ export const typeConfig = {
},
{
key: 'system.type',
label: 'DAGGERHEART.GENERAL.type'
label: 'DAGGERHEART.GENERAL.type',
format: type => {
if (!type) return '-';
return CONFIG.DH.ACTOR.allAdversaryTypes()[type].label;
}
}
],
filters: [
@ -69,12 +74,18 @@ export const typeConfig = {
columns: [
{
key: 'type',
label: 'DAGGERHEART.GENERAL.type'
label: 'DAGGERHEART.GENERAL.type',
format: type => (type ? `TYPES.Item.${type}` : '-')
},
{
key: 'system.secondary',
label: 'DAGGERHEART.UI.ItemBrowser.subtype',
format: isSecondary => (isSecondary ? 'secondary' : isSecondary === false ? 'primary' : '-')
format: isSecondary =>
isSecondary
? 'DAGGERHEART.ITEMS.Weapon.secondaryWeapon.short'
: isSecondary === false
? 'DAGGERHEART.ITEMS.Weapon.primaryWeapon.short'
: '-'
},
{
key: 'system.tier',
@ -94,8 +105,8 @@ export const typeConfig = {
key: 'system.secondary',
label: 'DAGGERHEART.UI.ItemBrowser.subtype',
choices: [
{ value: false, label: 'DAGGERHEART.ITEMS.Weapon.primaryWeapon' },
{ value: true, label: 'DAGGERHEART.ITEMS.Weapon.secondaryWeapon' }
{ value: false, label: 'DAGGERHEART.ITEMS.Weapon.primaryWeapon.full' },
{ value: true, label: 'DAGGERHEART.ITEMS.Weapon.secondaryWeapon.full' }
]
},
{
@ -253,11 +264,13 @@ export const typeConfig = {
columns: [
{
key: 'system.type',
label: 'DAGGERHEART.GENERAL.type'
label: 'DAGGERHEART.GENERAL.type',
format: type => (type ? `DAGGERHEART.CONFIG.DomainCardTypes.${type}` : '-')
},
{
key: 'system.domain',
label: 'DAGGERHEART.GENERAL.Domain.single'
label: 'DAGGERHEART.GENERAL.Domain.single',
format: domain => (domain ? CONFIG.DH.DOMAIN.allDomains()[domain].label : '-')
},
{
key: 'system.level',
@ -318,7 +331,14 @@ export const typeConfig = {
},
{
key: 'system.domains',
label: 'DAGGERHEART.GENERAL.Domain.plural'
label: 'DAGGERHEART.GENERAL.Domain.plural',
format: domains => {
const config = CONFIG.DH.DOMAIN.allDomains();
return domains
.map(x => (x ? game.i18n.localize(config[x].label) : null))
.filter(x => x)
.join(', ');
}
}
],
filters: [
@ -362,18 +382,19 @@ export const typeConfig = {
columns: [
{
key: 'system.linkedClass',
label: 'Class',
label: 'TYPES.Item.class',
format: linkedClass => linkedClass?.name ?? 'DAGGERHEART.UI.ItemBrowser.missing'
},
{
key: 'system.spellcastingTrait',
label: 'DAGGERHEART.ITEMS.Subclass.spellcastingTrait'
label: 'DAGGERHEART.ITEMS.Subclass.spellcastingTrait',
format: trait => (trait ? `DAGGERHEART.CONFIG.Traits.${trait}.name` : '-')
}
],
filters: [
{
key: 'system.linkedClass.uuid',
label: 'Class',
label: 'TYPES.Item.class',
choices: items => {
const list = items
.filter(item => item.system.linkedClass)
@ -397,7 +418,8 @@ export const typeConfig = {
},
{
key: 'system.mainTrait',
label: 'DAGGERHEART.GENERAL.Trait.single'
label: 'DAGGERHEART.GENERAL.Trait.single',
format: trait => (trait ? `DAGGERHEART.CONFIG.Traits.${trait}.name` : '-')
}
],
filters: [

View file

@ -14,8 +14,8 @@ export const armorFeatures = {
type: 'hostile'
},
damage: {
parts: [
{
parts: {
stress: {
applyTo: 'stress',
value: {
custom: {
@ -24,7 +24,7 @@ export const armorFeatures = {
}
}
}
]
}
}
}
]
@ -489,15 +489,18 @@ export const weaponFeatures = {
description: 'DAGGERHEART.CONFIG.WeaponFeature.barrier.effects.barrier.description',
img: 'icons/skills/melee/shield-block-bash-blue.webp',
changes: [
{
key: 'system.armorScore',
mode: 2,
value: 'ITEM.@system.tier + 1'
},
{
key: 'system.evasion',
mode: 2,
value: '-1'
},
{
key: 'Armor',
type: 'armor',
typeData: {
type: 'armor',
max: 'ITEM.@system.tier + 1'
}
}
]
}
@ -732,8 +735,8 @@ export const weaponFeatures = {
type: 'hostile'
},
damage: {
parts: [
{
parts: {
stress: {
applyTo: 'stress',
value: {
custom: {
@ -742,7 +745,7 @@ export const weaponFeatures = {
}
}
}
]
}
}
}
],
@ -789,11 +792,6 @@ export const weaponFeatures = {
description: 'DAGGERHEART.CONFIG.WeaponFeature.doubleDuty.effects.doubleDuty.description',
img: 'icons/skills/melee/sword-shield-stylized-white.webp',
changes: [
{
key: 'system.armorScore',
mode: 2,
value: '1'
},
{
key: 'system.bonuses.damage.primaryWeapon.bonus',
mode: 2,
@ -808,6 +806,22 @@ export const weaponFeatures = {
type: 'withinRange'
}
}
},
{
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: 'Armor',
type: 'armor',
value: 0,
typeData: {
type: 'armor',
max: 1
}
}
]
}
]
},
@ -914,8 +928,8 @@ export const weaponFeatures = {
type: 'self'
},
damage: {
parts: [
{
parts: {
hitPoints: {
applyTo: 'hitPoints',
value: {
custom: {
@ -924,7 +938,7 @@ export const weaponFeatures = {
}
}
}
]
}
}
}
]
@ -1191,9 +1205,13 @@ export const weaponFeatures = {
img: 'icons/skills/melee/shield-block-gray-orange.webp',
changes: [
{
key: 'system.armorScore',
mode: 2,
value: 'ITEM.@system.tier'
key: 'Armor',
type: 'armor',
value: 0,
typeData: {
type: 'armor',
max: 'ITEM.@system.tier'
}
}
]
}

View file

@ -1,3 +1,8 @@
export const keybindings = {
spotlight: 'DHSpotlight',
partySheet: 'DHPartySheet'
};
export const menu = {
Automation: {
Name: 'GameSettingsAutomation',
@ -34,26 +39,23 @@ export const gameSettings = {
LevelTiers: 'LevelTiers',
Countdowns: 'Countdowns',
LastMigrationVersion: 'LastMigrationVersion',
TagTeamRoll: 'TagTeamRoll',
SpotlightRequestQueue: 'SpotlightRequestQueue',
CompendiumBrowserSettings: 'CompendiumBrowserSettings'
CompendiumBrowserSettings: 'CompendiumBrowserSettings',
SpotlightTracker: 'SpotlightTracker',
ActiveParty: 'ActiveParty'
};
export const actionAutomationChoices = {
never: {
id: 'never',
label: 'Never'
label: 'DAGGERHEART.CONFIG.ActionAutomationChoices.never'
},
showDialog: {
id: 'showDialog',
label: 'Show Dialog only'
label: 'DAGGERHEART.CONFIG.ActionAutomationChoices.showDialog'
},
// npcOnly: {
// id: "npcOnly",
// label: "Always for non-characters"
// },
always: {
id: 'always',
label: 'Always'
label: 'DAGGERHEART.CONFIG.ActionAutomationChoices.always'
}
};

View file

@ -1,9 +1,11 @@
export { default as DhCombat } from './combat.mjs';
export { default as DhCombatant } from './combatant.mjs';
export { default as DhTagTeamRoll } from './tagTeamRoll.mjs';
export { default as DhRollTable } from './rollTable.mjs';
export { default as RegisteredTriggers } from './registeredTriggers.mjs';
export { default as CompendiumBrowserSettings } from './compendiumBrowserSettings.mjs';
export { default as TagTeamData } from './tagTeamData.mjs';
export { default as GroupRollData } from './groupRollData.mjs';
export { default as SpotlightTracker } from './spotlightTracker.mjs';
export * as countdowns from './countdowns.mjs';
export * as actions from './action/_module.mjs';
@ -13,3 +15,4 @@ export * as chatMessages from './chat-message/_modules.mjs';
export * as fields from './fields/_module.mjs';
export * as items from './item/_module.mjs';
export * as scenes from './scene/_module.mjs';
export * as regionBehaviors from './regionBehavior/_module.mjs';

View file

@ -13,7 +13,7 @@ export default class DHAttackAction extends DHDamageAction {
if (!!this.item?.system?.attack) {
if (this.damage.includeBase) {
const baseDamage = this.getParentDamage();
this.damage.parts.unshift(new DHDamageData(baseDamage));
this.damage.parts.hitPoints = new DHDamageData(baseDamage);
}
if (this.roll.useDefault) {
this.roll.trait = this.item.system.attack.roll.trait;
@ -26,23 +26,23 @@ export default class DHAttackAction extends DHDamageAction {
return {
value: {
multiplier: 'prof',
dice: this.item?.system?.attack.damage.parts[0].value.dice,
bonus: this.item?.system?.attack.damage.parts[0].value.bonus ?? 0
dice: this.item?.system?.attack.damage.parts.hitPoints.value.dice,
bonus: this.item?.system?.attack.damage.parts.hitPoints.value.bonus ?? 0
},
type: this.item?.system?.attack.damage.parts[0].type,
type: this.item?.system?.attack.damage.parts.hitPoints.type,
base: true
};
}
get damageFormula() {
const hitPointsPart = this.damage.parts.find(x => x.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id);
const hitPointsPart = this.damage.parts.hitPoints;
if (!hitPointsPart) return '0';
return hitPointsPart.value.getFormula();
}
get altDamageFormula() {
const hitPointsPart = this.damage.parts.find(x => x.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id);
const hitPointsPart = this.damage.parts.hitPoints;
if (!hitPointsPart) return '0';
return hitPointsPart.valueAlt.getFormula();
@ -50,9 +50,8 @@ export default class DHAttackAction extends DHDamageAction {
async use(event, options) {
const result = await super.use(event, options);
if (!result.message) return;
if (result.message.system.action.roll?.type === 'attack') {
if (result?.message?.system.action?.roll?.type === 'attack') {
const { updateCountdowns } = game.system.api.applications.ui.DhCountdowns;
await updateCountdowns(CONFIG.DH.GENERAL.countdownProgressionTypes.characterAttack.id);
}

View file

@ -15,7 +15,7 @@ const fields = foundry.data.fields;
*/
export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel) {
static extraSchemas = ['cost', 'uses', 'range'];
static extraSchemas = ['areas', 'cost', 'uses', 'range'];
/** @inheritDoc */
static defineSchema() {
@ -110,6 +110,11 @@ 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 */
get isOwner() {
return this.item?.isOwner ?? true;
}
/**
* Return Item the action is attached too.
*/
@ -143,6 +148,12 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
: null;
}
/** Returns true if the action is usable */
get usable() {
const actor = this.actor;
return this.isOwner && actor?.type === 'character';
}
static getRollType(parent) {
return 'trait';
}
@ -207,10 +218,10 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
* @param {Event} event Event from the button used to trigger the Action
* @returns {object}
*/
async use(event) {
async use(event, configOptions = {}) {
if (!this.actor) throw new Error("An Action can't be used outside of an Actor context.");
let config = this.prepareConfig(event);
let config = this.prepareConfig(event, configOptions);
if (!config) return;
config.effects = await game.system.api.data.actions.actionsTypes.base.getEffects(this.actor, this.item);
@ -231,7 +242,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
if (Hooks.call(`${CONFIG.DH.id}.postUseAction`, this, config) === false) return;
if (this.chatDisplay && !config.actionChatMessageHandled) await this.toChat();
if (this.chatDisplay && !config.skips.createMessage && !config.actionChatMessageHandled) await this.toChat();
return config;
}
@ -241,7 +252,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
* @param {Event} event Event from the button used to trigger the Action
* @returns {object}
*/
prepareBaseConfig(event) {
prepareBaseConfig(event, configOptions = {}) {
const isActor = this.item instanceof CONFIG.Actor.documentClass;
const actionTitle = game.i18n.localize(this.name);
const itemTitle = isActor || this.item.name === actionTitle ? '' : `${this.item.name} - `;
@ -264,13 +275,42 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
hasSave: this.hasSave,
onSave: this.save?.damageMod,
isDirect: !!this.damage?.direct,
selectedRollMode: game.settings.get('core', 'rollMode'),
selectedMessageMode: game.settings.get('core', 'messageMode'),
data: this.getRollData(),
evaluate: this.hasRoll,
resourceUpdates: new ResourceUpdateMap(this.actor),
targetUuid: this.targetUuid
targetUuid: this.targetUuid,
...configOptions,
skips: {
resources: false,
triggers: false,
createMessage: false,
updateCountdowns: false,
reaction: false,
...(configOptions.skips ?? {})
}
};
if (this.damage) {
config.isDirect = this.damage.direct;
const groupAttackTokens = this.damage.groupAttack
? game.system.api.fields.ActionFields.DamageField.getGroupAttackTokens(
this.actor.id,
this.damage.groupAttack
)
: null;
config.damageOptions = {
groupAttack: this.damage.groupAttack
? {
numAttackers: Math.max(groupAttackTokens.length, 1),
range: this.damage.groupAttack
}
: null
};
}
DHBaseAction.applyKeybindings(config);
return config;
}
@ -280,8 +320,8 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
* @param {Event} event Event from the button used to trigger the Action
* @returns {object}
*/
prepareConfig(event) {
const config = this.prepareBaseConfig(event);
prepareConfig(event, configOptions = {}) {
const config = this.prepareBaseConfig(event, configOptions);
for (const clsField of Object.values(this.schema.fields)) {
if (clsField?.prepareConfig) if (clsField.prepareConfig.call(this, config) === false) return false;
}
@ -297,7 +337,8 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
static async getEffects(actor, effectParent) {
if (!actor) return [];
return Array.from(await actor.allApplicableEffects()).filter(effect => {
return Array.from(await actor.allApplicableEffects({ noTransferArmor: true, noSelfArmor: true })).filter(
effect => {
/* Effects on weapons only ever apply for the weapon itself */
if (effect.parent.type === 'weapon') {
/* Unless they're secondary - then they apply only to other primary weapons */
@ -307,7 +348,8 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
}
return !effect.isSuppressed;
});
}
);
}
/**
@ -326,6 +368,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
* @param {boolean} successCost
*/
async consume(config, successCost = false) {
config.resourceUpdates = new ResourceUpdateMap(config.actionActor);
await this.workflow.get('cost')?.execute(config, successCost);
await this.workflow.get('uses')?.execute(config, successCost);
@ -354,11 +397,11 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
}
get hasDamage() {
return this.damage?.parts?.length && this.type !== 'healing';
return Boolean(Object.keys(this.damage?.parts ?? {}).length) && this.type !== 'healing';
}
get hasHealing() {
return this.damage?.parts?.length && this.type === 'healing';
return Boolean(Object.keys(this.damage?.parts ?? {}).length) && this.type === 'healing';
}
get hasSave() {
@ -378,6 +421,15 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
return tags;
}
static migrateData(source) {
if (source.damage?.parts && Array.isArray(source.damage.parts)) {
source.damage.parts = source.damage.parts.reduce((acc, part) => {
acc[part.applyTo] = part;
return acc;
}, {});
}
}
}
export class ResourceUpdateMap extends Map {

View file

@ -2,84 +2,4 @@ import DHBaseAction from './baseAction.mjs';
export default class DhBeastformAction extends DHBaseAction {
static extraSchemas = [...super.extraSchemas, 'beastform'];
/* async use(event, options) {
const beastformConfig = this.prepareBeastformConfig();
const abort = await this.handleActiveTransformations();
if (abort) return;
const calcCosts = game.system.api.fields.ActionFields.CostField.calcCosts.call(this, this.cost);
const hasCost = game.system.api.fields.ActionFields.CostField.hasCost.call(this, calcCosts);
if (!hasCost) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.insufficientResources'));
return;
}
const { selected, evolved, hybrid } = await BeastformDialog.configure(beastformConfig, this.item);
if (!selected) return;
const result = await super.use(event, options);
if (!result) return;
await this.transform(selected, evolved, hybrid);
}
prepareBeastformConfig(config) {
const settingsTiers = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers).tiers;
const actorLevel = this.actor.system.levelData.level.current;
const actorTier =
Object.values(settingsTiers).find(
tier => actorLevel >= tier.levels.start && actorLevel <= tier.levels.end
) ?? 1;
return {
tierLimit: this.beastform.tierAccess.exact ?? actorTier
};
}
async transform(selectedForm, evolvedData, hybridData) {
const formData = evolvedData?.form ? evolvedData.form.toObject() : selectedForm.toObject();
const beastformEffect = formData.effects.find(x => x.type === 'beastform');
if (!beastformEffect) {
ui.notifications.error('DAGGERHEART.UI.Notifications.beastformMissingEffect');
return;
}
if (evolvedData?.form) {
const evolvedForm = selectedForm.effects.find(x => x.type === 'beastform');
if (!evolvedForm) {
ui.notifications.error('DAGGERHEART.UI.Notifications.beastformMissingEffect');
return;
}
beastformEffect.changes = [...beastformEffect.changes, ...evolvedForm.changes];
formData.system.features = [...formData.system.features, ...selectedForm.system.features.map(x => x.uuid)];
}
if (selectedForm.system.beastformType === CONFIG.DH.ITEM.beastformTypes.hybrid.id) {
formData.system.advantageOn = Object.values(hybridData.advantages).reduce((advantages, formCategory) => {
Object.keys(formCategory).forEach(advantageKey => {
advantages[advantageKey] = formCategory[advantageKey];
});
return advantages;
}, {});
formData.system.features = [
...formData.system.features,
...Object.values(hybridData.features).flatMap(x => Object.keys(x))
];
}
this.actor.createEmbeddedDocuments('Item', [formData]);
}
async handleActiveTransformations() {
const beastformEffects = this.actor.effects.filter(x => x.type === 'beastform');
const existingEffects = beastformEffects.length > 0;
await this.actor.deleteEmbeddedDocuments(
'ActiveEffect',
beastformEffects.map(x => x.id)
);
return existingEffects;
} */
}

View file

@ -1,6 +1,7 @@
import BaseEffect from './baseEffect.mjs';
import BeastformEffect from './beastformEffect.mjs';
import HordeEffect from './hordeEffect.mjs';
export { changeTypes, changeEffects } from './changeTypes/_module.mjs';
export { BaseEffect, BeastformEffect, HordeEffect };

View file

@ -12,11 +12,50 @@
* "Anything that uses another data model value as its value": +1 - Effects that increase traits have to be calculated first at Base priority. (EX: Raise evasion by half your agility)
*/
export default class BaseEffect extends foundry.abstract.TypeDataModel {
import { getScrollTextData } from '../../helpers/utils.mjs';
import { changeTypes } from './_module.mjs';
export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
static defineSchema() {
const fields = foundry.data.fields;
const baseChanges = Object.keys(CONFIG.DH.GENERAL.baseActiveEffectModes).reduce((r, type) => {
r[type] = new fields.SchemaField({
key: new fields.StringField({ required: true }),
type: new fields.StringField({
required: true,
choices: [type],
initial: type,
validate: BaseEffect.#validateType
}),
value: new fields.AnyField({
required: true,
nullable: true,
serializable: true,
initial: ''
}),
phase: new fields.StringField({ required: true, blank: false, initial: 'initial' }),
priority: new fields.NumberField()
});
return r;
}, {});
return {
...super.defineSchema(),
changes: new fields.ArrayField(
new fields.TypedSchemaField(
{ ...changeTypes, ...baseChanges },
{ initial: baseChanges.add.getInitialValue() }
)
),
duration: new fields.SchemaField({
type: new fields.StringField({
choices: CONFIG.DH.GENERAL.activeEffectDurations,
blank: true,
label: 'DAGGERHEART.GENERAL.type'
}),
description: new fields.HTMLField({ label: 'DAGGERHEART.GENERAL.description' })
}),
rangeDependence: new fields.SchemaField({
enabled: new fields.BooleanField({
required: true,
@ -41,17 +80,71 @@ export default class BaseEffect extends foundry.abstract.TypeDataModel {
initial: CONFIG.DH.GENERAL.range.melee.id,
label: 'DAGGERHEART.GENERAL.range'
})
})
}),
stacking: new fields.SchemaField(
{
value: new fields.NumberField({
initial: 1,
min: 1,
integer: true,
nullable: false,
label: 'DAGGERHEART.GENERAL.value'
}),
max: new fields.NumberField({ integer: true, label: 'DAGGERHEART.GENERAL.max' })
},
{ nullable: true, initial: null }
),
targetDispositions: new fields.SetField(
new fields.NumberField({
choices: CONFIG.DH.GENERAL.simpleDispositions
}),
{ label: 'DAGGERHEART.ACTIVEEFFECT.Config.targetDispositions' }
)
};
}
static getDefaultObject() {
/**
* Validate that an {@link EffectChangeData#type} string is well-formed.
* @param {string} type The string to be validated
* @returns {true}
* @throws {Error} An error if the type string is malformed
*/
static #validateType(type) {
if (type.length < 3) throw new Error('must be at least three characters long');
if (!/^custom\.-?\d+$/.test(type) && !type.split('.').every(s => /^[a-z0-9]+$/i.test(s))) {
throw new Error(
'A change type must either be a sequence of dot-delimited, alpha-numeric substrings or of the form' +
' "custom.{number}"'
);
}
return true;
}
get isSuppressed() {
for (const change of this.changes) {
if (change.isSuppressed) return true;
}
}
get armorChange() {
return this.changes.find(x => x.type === CONFIG.DH.GENERAL.activeEffectModes.armor.id);
}
get armorData() {
const armorChange = this.armorChange;
if (!armorChange) return null;
return armorChange.getArmorData();
}
static getDefaultObject(options = { transfer: true }) {
return {
name: 'New Effect',
id: foundry.utils.randomID(),
disabled: false,
img: 'icons/magic/life/heart-cross-blue.webp',
description: '',
transfer: options.transfer,
statuses: [],
changes: [],
system: {
@ -64,4 +157,32 @@ export default class BaseEffect extends foundry.abstract.TypeDataModel {
}
};
}
async _preUpdate(changed, options, userId) {
const allowed = await super._preUpdate(changed, options, userId);
if (allowed === false) return false;
const autoSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
if (
autoSettings.resourceScrollTexts &&
this.parent.actor?.type === 'character' &&
this.parent.actor.system.resources.armor
) {
const armorEffect = changed.system?.changes?.find(x => x.type === 'armor');
const newArmorTotal =
armorEffect?.value?.current + (this.parent.actor.system.armor?.system?.armor?.current ?? 0);
if (armorEffect && newArmorTotal !== this.parent.actor.system.armorScore.value) {
const armorData = getScrollTextData(this.parent.actor, { value: newArmorTotal }, 'armor');
options.scrollingTextData = [armorData];
}
}
}
_onUpdate(changed, options, userId) {
super._onUpdate(changed, options, userId);
if (this.parent.actor && options.scrollingTextData)
this.parent.actor.queueScrollText(options.scrollingTextData);
}
}

View file

@ -5,6 +5,7 @@ export default class BeastformEffect extends BaseEffect {
static defineSchema() {
const fields = foundry.data.fields;
return {
...super.defineSchema(),
characterTokenData: new fields.SchemaField({
usesDynamicToken: new fields.BooleanField({ initial: false }),
tokenImg: new fields.FilePathField({
@ -24,7 +25,7 @@ export default class BeastformEffect extends BaseEffect {
width: new fields.NumberField({ integer: false, nullable: true })
})
}),
advantageOn: new fields.ArrayField(new fields.StringField()),
advantageOn: new fields.TypedObjectField(new fields.SchemaField({ value: new fields.StringField() })),
featureIds: new fields.ArrayField(new fields.StringField()),
effectIds: new fields.ArrayField(new fields.StringField())
};
@ -99,7 +100,7 @@ export default class BeastformEffect extends BaseEffect {
token.flags.daggerheart?.beastformSubjectTexture ?? this.characterTokenData.tokenRingImg
}
},
'flags.daggerheart': { '-=beastformTokenImg': null, '-=beastformSubjectTexture': null }
'flags.daggerheart': { beastformTokenImg: _del, beastformSubjectTexture: _del }
};
};

View file

@ -0,0 +1,9 @@
import Armor from './armor.mjs';
export const changeEffects = {
armor: Armor.changeEffect
};
export const changeTypes = {
armor: Armor
};

View file

@ -0,0 +1,209 @@
import { itemAbleRollParse } from '../../../helpers/utils.mjs';
const fields = foundry.data.fields;
export default class ArmorChange extends foundry.abstract.DataModel {
static defineSchema() {
return {
type: new fields.StringField({ required: true, choices: ['armor'], initial: 'armor' }),
priority: new fields.NumberField(),
phase: new fields.StringField({ required: true, blank: false, initial: 'initial' }),
value: new fields.SchemaField({
current: new fields.NumberField({ integer: true, min: 0, initial: 0 }),
max: new fields.StringField({
required: true,
nullable: false,
initial: '1',
label: 'DAGGERHEART.GENERAL.max'
}),
damageThresholds: new fields.SchemaField(
{
major: new fields.StringField({
initial: '0',
label: 'DAGGERHEART.GENERAL.DamageThresholds.majorThreshold'
}),
severe: new fields.StringField({
initial: '0',
label: 'DAGGERHEART.GENERAL.DamageThresholds.severeThreshold'
})
},
{ nullable: true, initial: null }
),
interaction: new fields.StringField({
required: true,
choices: CONFIG.DH.GENERAL.activeEffectArmorInteraction,
initial: CONFIG.DH.GENERAL.activeEffectArmorInteraction.none.id,
label: 'DAGGERHEART.EFFECTS.ChangeTypes.armor.FIELDS.interaction.label',
hint: 'DAGGERHEART.EFFECTS.ChangeTypes.armor.FIELDS.interaction.hint'
})
})
};
}
static changeEffect = {
label: 'Armor',
defaultPriority: 20,
handler: (actor, change, _options, _field, replacementData) => {
const baseParsedMax = itemAbleRollParse(change.value.max, actor, change.effect.parent);
const parsedMax = new Roll(baseParsedMax).evaluateSync().total;
game.system.api.documents.DhActiveEffect.applyChange(
actor,
{
...change,
key: 'system.armorScore.value',
type: CONFIG.DH.GENERAL.activeEffectModes.add.id,
value: change.value.current
},
replacementData
);
game.system.api.documents.DhActiveEffect.applyChange(
actor,
{
...change,
key: 'system.armorScore.max',
type: CONFIG.DH.GENERAL.activeEffectModes.add.id,
value: parsedMax
},
replacementData
);
if (change.value.damageThresholds) {
const getThresholdValue = value => {
const parsed = itemAbleRollParse(value, actor, change.effect.parent);
const roll = new Roll(parsed).evaluateSync();
return roll ? (roll.isDeterministic ? roll.total : null) : null;
};
const major = getThresholdValue(change.value.damageThresholds.major);
const severe = getThresholdValue(change.value.damageThresholds.severe);
if (major) {
game.system.api.documents.DhActiveEffect.applyChange(
actor,
{
...change,
key: 'system.damageThresholds.major',
type: CONFIG.DH.GENERAL.activeEffectModes.add.id,
priority: 50,
value: major
},
replacementData
);
}
if (severe) {
game.system.api.documents.DhActiveEffect.applyChange(
actor,
{
...change,
key: 'system.damageThresholds.severe',
type: CONFIG.DH.GENERAL.activeEffectModes.add.id,
priority: 50,
value: severe
},
replacementData
);
}
}
return {};
},
render: null
};
get isSuppressed() {
if (!this.parent.parent?.actor) return false;
switch (this.value.interaction) {
case CONFIG.DH.GENERAL.activeEffectArmorInteraction.active.id:
return !this.parent.parent?.actor.system.armor;
case CONFIG.DH.GENERAL.activeEffectArmorInteraction.inactive.id:
return Boolean(this.parent.parent?.actor.system.armor);
default:
return false;
}
}
static getInitialValue() {
return {
type: CONFIG.DH.GENERAL.activeEffectModes.armor.id,
value: {
current: 0,
max: 0
},
phase: 'initial',
priority: 20
};
}
static getDefaultArmorEffect() {
return {
name: game.i18n.localize('DAGGERHEART.EFFECTS.ChangeTypes.armor.newArmorEffect'),
img: 'icons/equipment/chest/breastplate-helmet-metal.webp',
system: {
changes: [ArmorChange.getInitialValue()]
}
};
}
/* Helpers */
getArmorData() {
const actor = this.parent.parent?.actor?.type === 'character' ? this.parent.parent.actor : null;
const maxParse = actor ? itemAbleRollParse(this.value.max, actor, this.parent.parent.parent) : null;
const maxRoll = maxParse ? new Roll(maxParse).evaluateSync() : null;
const maxEvaluated = maxRoll ? (maxRoll.isDeterministic ? maxRoll.total : null) : null;
return {
current: this.value.current,
max: maxEvaluated ?? this.value.max
};
}
async updateArmorMax(newMax) {
const newChanges = [
...this.parent.changes.map(change => ({
...change,
value:
change.type === 'armor'
? {
...change.value,
current: Math.min(change.value.current, newMax),
max: newMax
}
: change.value
}))
];
await this.parent.parent.update({ 'system.changes': newChanges });
}
static orderEffectsForAutoChange(armorEffects, increasing) {
const getEffectWeight = effect => {
switch (effect.parent.type) {
case 'class':
case 'subclass':
case 'ancestry':
case 'community':
case 'feature':
case 'domainCard':
return 2;
case 'armor':
return 3;
case 'loot':
case 'consumable':
return 4;
case 'weapon':
return 5;
case 'character':
return 6;
default:
return 1;
}
};
return armorEffects
.filter(x => !x.disabled && !x.isSuppressed)
.sort((a, b) =>
increasing ? getEffectWeight(b) - getEffectWeight(a) : getEffectWeight(a) - getEffectWeight(b)
);
}
}

View file

@ -85,14 +85,14 @@ export default class DhpAdversary extends DhCreature {
type: 'attack'
},
damage: {
parts: [
{
parts: {
hitPoints: {
type: ['physical'],
value: {
multiplier: 'flat'
}
}
]
}
}
}
}),
@ -133,7 +133,7 @@ export default class DhpAdversary extends DhCreature {
}
isItemValid(source) {
return source.type === 'feature';
return super.isItemValid(source) || source.type === 'feature';
}
async _preUpdate(changes, options, user) {
@ -265,12 +265,12 @@ export default class DhpAdversary extends DhCreature {
}
// Update damage in item actions
for (const action of Object.values(item.system.actions)) {
if (!action.damage) continue;
// Parse damage, and convert all formula matches in the descriptions to the new damage
for (const action of Object.values(item.system.actions)) {
try {
const result = this.#adjustActionDamage(action, { ...damageMeta, type: 'action' });
if (!result) continue;
for (const { previousFormula, formula } of Object.values(result)) {
const oldFormulaRegexp = new RegExp(
previousFormula.replace(' ', '').replace('+', '(?:\\s)?\\+(?:\\s)?')
@ -372,16 +372,14 @@ export default class DhpAdversary extends DhCreature {
/**
* 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
* @returns the converted formula and value as a simplified term, or null if it doesn't deal HP damage
*/
#adjustActionDamage(action, damageMeta) {
// The current algorithm only returns a value if there is a single damage part
const hpDamageParts = action.damage.parts.filter(d => d.applyTo === 'hitPoints');
if (hpDamageParts.length !== 1) throw new Error('incorrect number of hp parts');
if (!action.damage?.parts.hitPoints) return null;
const result = {};
for (const property of ['value', 'valueAlt']) {
const data = hpDamageParts[0][property];
const data = action.damage.parts.hitPoints[property];
const previousFormula = data.custom.enabled
? data.custom.formula
: [data.flatMultiplier ? `${data.flatMultiplier}${data.dice}` : 0, data.bonus ?? 0]

View file

@ -107,7 +107,8 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
hasResistances: true,
hasAttribution: false,
hasLimitedView: true,
usesSize: false
usesSize: false,
hasInventory: false
};
}
@ -168,6 +169,11 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
/* -------------------------------------------- */
isItemValid(source) {
const inventoryTypes = ['weapon', 'armor', 'consumable', 'loot'];
return this.metadata.hasInventory && inventoryTypes.includes(source.type);
}
/**
* Obtain a data object used to evaluate any dice rolls associated with this Item Type
* @param {object} [options] - Options which modify the getRollData method.
@ -189,21 +195,6 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
return true;
}
async _preDelete() {
/* Clear all partyMembers from tagTeam setting.*/
/* Revisit this when tagTeam is improved for many parties */
if (this.parent.parties.size > 0) {
const tagTeam = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll);
await tagTeam.updateSource({
initiator: this.parent.id === tagTeam.initiator ? null : tagTeam.initiator,
members: Object.keys(tagTeam.members).find(x => x === this.parent.id)
? { [`-=${this.parent.id}`]: null }
: {}
});
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll, tagTeam);
}
}
async _preUpdate(changes, options, userId) {
const allowed = await super._preUpdate(changes, options, userId);
if (allowed === false) return;

View file

@ -3,9 +3,10 @@ import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
import DhLevelData from '../levelData.mjs';
import { commonActorRules } from './base.mjs';
import DhCreature from './creature.mjs';
import { attributeField, stressDamageReductionRule, bonusField } from '../fields/actorField.mjs';
import { attributeField, stressDamageReductionRule, bonusField, GoldField } from '../fields/actorField.mjs';
import { ActionField } from '../fields/actionField.mjs';
import DHCharacterSettings from '../../applications/sheets-configs/character-settings.mjs';
import { getArmorSources } from '../../helpers/utils.mjs';
export default class DhCharacter extends DhCreature {
/**@override */
@ -17,7 +18,9 @@ export default class DhCharacter extends DhCreature {
label: 'TYPES.Actor.character',
type: 'character',
settingSheet: DHCharacterSettings,
isNPC: false
isNPC: false,
hasInventory: true,
quantifiable: ['loot', 'consumable']
});
}
@ -41,17 +44,16 @@ export default class DhCharacter extends DhCreature {
label: 'DAGGERHEART.GENERAL.proficiency'
}),
evasion: new fields.NumberField({ initial: 0, integer: true, label: 'DAGGERHEART.GENERAL.evasion' }),
armorScore: new fields.NumberField({ integer: true, initial: 0, label: 'DAGGERHEART.GENERAL.armorScore' }),
damageThresholds: new fields.SchemaField({
severe: new fields.NumberField({
integer: true,
initial: 0,
label: 'DAGGERHEART.GENERAL.DamageThresholds.severeThreshold'
}),
major: new fields.NumberField({
integer: true,
initial: 0,
label: 'DAGGERHEART.GENERAL.DamageThresholds.majorThreshold'
}),
severe: new fields.NumberField({
integer: true,
initial: 0,
label: 'DAGGERHEART.GENERAL.DamageThresholds.severeThreshold'
})
}),
experiences: new fields.TypedObjectField(
@ -62,12 +64,7 @@ export default class DhCharacter extends DhCreature {
core: new fields.BooleanField({ initial: false })
})
),
gold: new fields.SchemaField({
coins: new fields.NumberField({ initial: 0, integer: true }),
handfuls: new fields.NumberField({ initial: 1, integer: true }),
bags: new fields.NumberField({ initial: 0, integer: true }),
chests: new fields.NumberField({ initial: 0, integer: true })
}),
gold: new GoldField(),
scars: new fields.NumberField({ initial: 0, integer: true, label: 'DAGGERHEART.GENERAL.scars' }),
biography: new fields.SchemaField({
background: new fields.HTMLField(),
@ -96,8 +93,8 @@ export default class DhCharacter extends DhCreature {
trait: 'strength'
},
damage: {
parts: [
{
parts: {
hitPoints: {
type: ['physical'],
value: {
custom: {
@ -106,7 +103,7 @@ export default class DhCharacter extends DhCreature {
}
}
}
]
}
}
}
}),
@ -153,7 +150,6 @@ export default class DhCharacter extends DhCreature {
shortMoves: new fields.NumberField({
required: true,
integer: true,
min: 0,
initial: 0,
label: 'DAGGERHEART.GENERAL.Bonuses.rest.shortRest.shortRestMoves.label',
hint: 'DAGGERHEART.GENERAL.Bonuses.rest.shortRest.shortRestMoves.hint'
@ -161,7 +157,6 @@ export default class DhCharacter extends DhCreature {
longMoves: new fields.NumberField({
required: true,
integer: true,
min: 0,
initial: 0,
label: 'DAGGERHEART.GENERAL.Bonuses.rest.shortRest.longRestMoves.label',
hint: 'DAGGERHEART.GENERAL.Bonuses.rest.shortRest.longRestMoves.hint'
@ -171,7 +166,6 @@ export default class DhCharacter extends DhCreature {
shortMoves: new fields.NumberField({
required: true,
integer: true,
min: 0,
initial: 0,
label: 'DAGGERHEART.GENERAL.Bonuses.rest.longRest.shortRestMoves.label',
hint: 'DAGGERHEART.GENERAL.Bonuses.rest.longRest.shortRestMoves.hint'
@ -179,7 +173,6 @@ export default class DhCharacter extends DhCreature {
longMoves: new fields.NumberField({
required: true,
integer: true,
min: 0,
initial: 0,
label: 'DAGGERHEART.GENERAL.Bonuses.rest.longRest.longRestMoves.label',
hint: 'DAGGERHEART.GENERAL.Bonuses.rest.longRest.longRestMoves.hint'
@ -293,6 +286,22 @@ export default class DhCharacter extends DhCreature {
guaranteedCritical: new fields.BooleanField({
label: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.label',
hint: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.hint'
}),
defaultAdvantageDice: new fields.NumberField({
nullable: true,
required: true,
integer: true,
choices: CONFIG.DH.GENERAL.dieFaces,
initial: null,
label: 'DAGGERHEART.ACTORS.Character.defaultAdvantageDice'
}),
defaultDisadvantageDice: new fields.NumberField({
nullable: true,
required: true,
integer: true,
choices: CONFIG.DH.GENERAL.dieFaces,
initial: null,
label: 'DAGGERHEART.ACTORS.Character.defaultDisadvantageDice'
})
})
})
@ -438,6 +447,11 @@ export default class DhCharacter extends DhCreature {
return attack;
}
/* All items are valid on characters */
isItemValid() {
return true;
}
/** @inheritDoc */
isItemAvailable(item) {
if (!super.isItemAvailable(this)) return false;
@ -465,6 +479,101 @@ export default class DhCharacter extends DhCreature {
}
}
async updateArmorValue({ value: armorChange = 0, clear = false }) {
if (armorChange === 0 && !clear) return;
const increasing = armorChange >= 0;
let remainingChange = Math.abs(armorChange);
const orderedSources = getArmorSources(this.parent).filter(s => !s.disabled);
const handleArmorData = (embeddedUpdates, doc, armorData) => {
let usedArmorChange = 0;
if (clear) {
usedArmorChange -= armorData.current;
} else {
if (increasing) {
const remainingArmor = armorData.max - armorData.current;
usedArmorChange = Math.min(remainingChange, remainingArmor);
remainingChange -= usedArmorChange;
} else {
const changeChange = Math.min(armorData.current, remainingChange);
usedArmorChange -= changeChange;
remainingChange -= changeChange;
}
}
if (!usedArmorChange) return usedArmorChange;
else {
if (!embeddedUpdates[doc.id]) embeddedUpdates[doc.id] = { doc: doc, updates: [] };
return usedArmorChange;
}
};
const armorUpdates = [];
const effectUpdates = [];
for (const { document: armorSource } of orderedSources) {
const usedArmorChange = handleArmorData(
armorSource.type === 'armor' ? armorUpdates : effectUpdates,
armorSource.parent,
armorSource.type === 'armor' ? armorSource.system.armor : armorSource.system.armorData
);
if (!usedArmorChange) continue;
if (armorSource.type === 'armor') {
armorUpdates[armorSource.parent.id].updates.push({
'_id': armorSource.id,
'system.armor.current': armorSource.system.armor.current + usedArmorChange
});
} else {
effectUpdates[armorSource.parent.id].updates.push({
'_id': armorSource.id,
'system.changes': armorSource.system.changes.map(change => ({
...change,
value:
change.type === 'armor'
? {
...change.value,
current: armorSource.system.armorChange.value.current + usedArmorChange
}
: change.value
}))
});
}
if (remainingChange === 0 && !clear) break;
}
const armorUpdateValues = Object.values(armorUpdates);
for (const [index, { doc, updates }] of armorUpdateValues.entries())
await doc.updateEmbeddedDocuments('Item', updates, { render: index === armorUpdateValues.length - 1 });
const effectUpdateValues = Object.values(effectUpdates);
for (const [index, { doc, updates }] of effectUpdateValues.entries())
await doc.updateEmbeddedDocuments('ActiveEffect', updates, {
render: index === effectUpdateValues.length - 1
});
}
async updateArmorEffectValue({ uuid, value }) {
const source = await foundry.utils.fromUuid(uuid);
if (source.type === 'armor') {
await source.update({
'system.armor.current': source.system.armor.current + value
});
} else {
const effectValue = source.system.armorChange.value;
await source.update({
'system.changes': [
{
...source.system.armorChange,
value: { ...effectValue, current: effectValue.current + value }
}
]
});
}
}
get sheetLists() {
const ancestryFeatures = [],
communityFeatures = [],
@ -588,6 +697,10 @@ export default class DhCharacter extends DhCreature {
prepareBaseData() {
super.prepareBaseData();
this.armorScore = {
max: this.armor?.system.armor.max ?? 0,
value: this.armor?.system.armor.current ?? 0
};
this.evasion += this.class.value?.system?.evasion ?? 0;
const currentLevel = this.levelData.level.current;
@ -637,15 +750,22 @@ export default class DhCharacter extends DhCreature {
}
}
const armor = this.armor;
this.armorScore = armor ? armor.system.baseScore : 0;
/* Armor and ArmorEffects can set a Base Damage Threshold. Characters only gain level*2 bonus to severe if this is not present */
const severeThresholdMulitplier =
this.armor ||
this.parent.appliedEffects.some(x =>
x.system.changes.some(x => x.type === 'armor' && x.value.damageThresholds)
)
? 1
: 2;
this.damageThresholds = {
major: armor
? armor.system.baseThresholds.major + this.levelData.level.current
major: this.armor
? this.armor.system.baseThresholds.major + this.levelData.level.current
: this.levelData.level.current,
severe: armor
? armor.system.baseThresholds.severe + this.levelData.level.current
: this.levelData.level.current * 2
severe: this.armor
? this.armor.system.baseThresholds.severe + this.levelData.level.current
: this.levelData.level.current * severeThresholdMulitplier
};
const globalHopeMax = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxHope;
@ -660,7 +780,6 @@ export default class DhCharacter extends DhCreature {
prepareDerivedData() {
super.prepareDerivedData();
let baseHope = this.resources.hope.value;
if (this.companion) {
for (let levelKey in this.companion.system.levelData.levelups) {
const level = this.companion.system.levelData.levelups[levelKey];
@ -675,17 +794,15 @@ export default class DhCharacter extends DhCreature {
}
this.resources.hope.max -= this.scars;
this.resources.hope.value = Math.min(baseHope, this.resources.hope.max);
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
this.resources.armor = {
...this.armorScore,
label: 'DAGGERHEART.GENERAL.armor',
value: this.armor?.system?.marks?.value ?? 0,
max: this.armorScore,
isReversed: true
};
this.attack.damage.parts[0].value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`;
this.attack.damage.parts.hitPoints.value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`;
}
getRollData() {

View file

@ -61,6 +61,24 @@ export default class DhCompanion extends DhCreature {
initial: false,
label: 'DAGGERHEART.GENERAL.Rules.conditionImmunities.vulnerable'
})
}),
roll: new fields.SchemaField({
defaultAdvantageDice: new fields.NumberField({
nullable: true,
required: true,
integer: true,
choices: CONFIG.DH.GENERAL.dieFaces,
initial: null,
label: 'DAGGERHEART.ACTORS.Character.defaultAdvantageDice'
}),
defaultDisadvantageDice: new fields.NumberField({
nullable: true,
required: true,
integer: true,
choices: CONFIG.DH.GENERAL.dieFaces,
initial: null,
label: 'DAGGERHEART.ACTORS.Character.defaultDisadvantageDice'
})
})
}),
attack: new ActionField({
@ -81,15 +99,15 @@ export default class DhCompanion extends DhCreature {
bonus: 0
},
damage: {
parts: [
{
parts: {
hitPoints: {
type: ['physical'],
value: {
dice: 'd6',
multiplier: 'prof'
}
}
]
}
}
}
}),
@ -118,10 +136,6 @@ export default class DhCompanion extends DhCreature {
return this.levelupChoicesLeft > 0;
}
isItemValid() {
return false;
}
prepareBaseData() {
super.prepareBaseData();
this.attack.roll.bonus = this.partner?.system?.spellcastModifier ?? 0;
@ -135,7 +149,9 @@ export default class DhCompanion extends DhCreature {
break;
case 'vicious':
if (selection.data[0] === 'damage') {
this.attack.damage.parts[0].value.dice = adjustDice(this.attack.damage.parts[0].value.dice);
this.attack.damage.parts.hitPoints.value.dice = adjustDice(
this.attack.damage.parts.hitPoints.value.dice
);
} else {
this.attack.range = adjustRange(this.attack.range).id;
}

View file

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

View file

@ -56,7 +56,7 @@ export default class DhEnvironment extends BaseDataActor {
}
isItemValid(source) {
return source.type === 'feature';
return super.isItemValid(source) || source.type === 'feature';
}
_onUpdate(changes, options, userId) {
@ -75,10 +75,6 @@ export default class DhEnvironment extends BaseDataActor {
);
scene.update({ 'flags.daggerheart.sceneEnvironments': newSceneEnvironments }).then(() => {
Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.Scene });
game.socket.emit(`system.${CONFIG.DH.id}`, {
action: socketEvent.Refresh,
data: { refreshType: RefreshType.TagTeamRoll }
});
});
}
}

View file

@ -1,7 +1,18 @@
import BaseDataActor from './base.mjs';
import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayField.mjs';
import TagTeamData from '../tagTeamData.mjs';
import GroupRollData from '../groupRollData.mjs';
import { GoldField } from '../fields/actorField.mjs';
export default class DhParty extends BaseDataActor {
/** @inheritdoc */
static get metadata() {
return foundry.utils.mergeObject(super.metadata, {
hasInventory: true,
quantifiable: ['weapon', 'armor', 'loot', 'consumable']
});
}
/**@inheritdoc */
static defineSchema() {
const fields = foundry.data.fields;
@ -9,15 +20,16 @@ export default class DhParty extends BaseDataActor {
...super.defineSchema(),
partyMembers: new ForeignDocumentUUIDArrayField({ type: 'Actor' }, { prune: true }),
notes: new fields.HTMLField(),
gold: new fields.SchemaField({
coins: new fields.NumberField({ initial: 0, integer: true }),
handfuls: new fields.NumberField({ initial: 1, integer: true }),
bags: new fields.NumberField({ initial: 0, integer: true }),
chests: new fields.NumberField({ initial: 0, integer: true })
})
gold: new GoldField(),
tagTeam: new fields.EmbeddedDataField(TagTeamData),
groupRoll: new fields.EmbeddedDataField(GroupRollData)
};
}
get active() {
return game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty) === this.parent.id;
}
/* -------------------------------------------- */
/**@inheritdoc */
@ -25,10 +37,6 @@ export default class DhParty extends BaseDataActor {
/* -------------------------------------------- */
isItemValid(source) {
return ['weapon', 'armor', 'consumable', 'loot'].includes(source.type);
}
prepareBaseData() {
super.prepareBaseData();
@ -40,21 +48,14 @@ export default class DhParty extends BaseDataActor {
}
}
async _preDelete() {
/* Clear all partyMembers from tagTeam setting.*/
/* Revisit this when tagTeam is improved for many parties */
const tagTeam = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll);
await tagTeam.updateSource({
initiator: this.partyMembers.some(x => x.id === tagTeam.initiator) ? null : tagTeam.initiator,
members: Object.keys(tagTeam.members).reduce((acc, key) => {
if (this.partyMembers.find(x => x.id === key)) {
acc[`-=${key}`] = null;
}
_onCreate(data, options, userId) {
super._onCreate(data, options, userId);
return acc;
}, {})
if (game.user.isActiveGM && !game.actors.party) {
game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty, this.parent.id).then(_ => {
ui.actors.render();
});
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll, tagTeam);
}
}
_onDelete(options, userId) {
@ -64,5 +65,11 @@ export default class DhParty extends BaseDataActor {
for (const member of this.partyMembers) {
member?.parties?.delete(this.parent);
}
// If this *was* the active party, delete it. We can't use game.actors.party as this actor was already deleted
const isWorldActor = !this.parent?.parent && !this.parent.compendium;
const activePartyId = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty);
if (isWorldActor && this.id === activePartyId)
game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty, null);
}
}

View file

@ -1,6 +1,5 @@
import DHAbilityUse from './abilityUse.mjs';
import DHActorRoll from './actorRoll.mjs';
import DHGroupRoll from './groupRoll.mjs';
import DHSystemMessage from './systemMessage.mjs';
export const config = {
@ -9,6 +8,5 @@ export const config = {
damageRoll: DHActorRoll,
dualityRoll: DHActorRoll,
fateRoll: DHActorRoll,
groupRoll: DHGroupRoll,
systemMessage: DHSystemMessage
};

View file

@ -7,26 +7,31 @@ export default class DHAbilityUse extends foundry.abstract.TypeDataModel {
img: new fields.StringField({}),
name: new fields.StringField({}),
description: new fields.StringField({}),
actions: new fields.ArrayField(
new fields.ObjectField({
name: new fields.StringField({}),
damage: new fields.SchemaField({
type: new fields.StringField({}),
value: new fields.StringField({})
}),
healing: new fields.SchemaField({
type: new fields.StringField({}),
value: new fields.StringField({})
}),
cost: new fields.SchemaField({
type: new fields.StringField({}),
value: new fields.NumberField({})
}),
target: new fields.SchemaField({
type: new fields.StringField({ nullable: true })
source: new fields.SchemaField({
actor: new fields.StringField(),
item: new fields.StringField(),
action: new fields.StringField()
})
})
)
};
}
get actionActor() {
if (!this.source.actor) return null;
return fromUuidSync(this.source.actor);
}
get actionItem() {
const actionActor = this.actionActor;
if (!actionActor || !this.source.item) return null;
const item = actionActor.items.get(this.source.item);
return item ? item.system.actions?.find(a => a.id === this.source.action) : null;
}
get action() {
const { actionItem: itemAction } = this;
if (!this.source.action) return null;
if (itemAction) return itemAction;
return null;
}
}

View file

@ -32,7 +32,6 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
return {
title: new fields.StringField(),
actionDescription: new fields.HTMLField(),
roll: new fields.ObjectField(),
targets: targetsField(),
hasRoll: new fields.BooleanField({ initial: false }),
hasDamage: new fields.BooleanField({ initial: false }),
@ -41,7 +40,6 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
hasSave: new fields.BooleanField({ initial: false }),
hasTarget: new fields.BooleanField({ initial: false }),
isDirect: new fields.BooleanField({ initial: false }),
isCritical: new fields.BooleanField({ initial: false }),
onSave: new fields.StringField(),
source: new fields.SchemaField({
actor: new fields.StringField(),
@ -50,11 +48,25 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
action: new fields.StringField()
}),
damage: new fields.ObjectField(),
damageOptions: new fields.ObjectField(),
costs: new fields.ArrayField(new fields.ObjectField()),
successConsumed: new fields.BooleanField({ initial: false })
};
}
get roll() {
switch (this.parent.type) {
case 'adversaryRoll':
return this.parent.rolls.find(x => x instanceof game.system.api.dice.D20Roll);
case 'dualityRoll':
return this.parent.rolls.find(x => x instanceof game.system.api.dice.DualityRoll);
case 'fateRoll':
return this.parent.rolls.find(x => x instanceof game.system.api.dice.FateRoll);
}
return null;
}
get actionActor() {
if (!this.source.actor) return null;
return fromUuidSync(this.source.actor);

View file

@ -1,39 +0,0 @@
import { abilities } from '../../config/actorConfig.mjs';
export default class DHGroupRoll extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
leader: new fields.EmbeddedDataField(GroupRollMemberField),
members: new fields.ArrayField(new fields.EmbeddedDataField(GroupRollMemberField))
};
}
get totalModifier() {
return this.members.reduce((acc, m) => {
if (m.manualSuccess === null) return acc;
return acc + (m.manualSuccess ? 1 : -1);
}, 0);
}
}
class GroupRollMemberField extends foundry.abstract.DataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
actor: new fields.ObjectField(),
trait: new fields.StringField({ choices: abilities }),
difficulty: new fields.StringField(),
result: new fields.ObjectField({ nullable: true, initial: null }),
manualSuccess: new fields.BooleanField({ nullable: true, initial: null })
};
}
/* Can be expanded if we handle automation of success/failure */
get success() {
return manualSuccess;
}
}

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