Compare commits

..

46 Commits

Author SHA1 Message Date
uberwald 3b0d4e032e fix: cache results.length before explosion loop to prevent double-count
Release Creation / build (release) Successful in 50s
Pushing explosion dice to DieTerm.results made the for loop
condition (j < results.length) grow mid-iteration, re-processing
the explosion result as a normal die. This produced spurious
entries like `1D6 → 4` alongside the correct `1D6-1 → 3`.

Fixes prompt() (for loop) and rollSpellDamageToMessage()
(for...of) by caching result count / snapshotting the array
before iterating.
2026-06-16 19:34:13 +02:00
uberwald 539841c4ff fix: push explosion dice to DieTerm results so DSN displays them
Explosion rolls were evaluated as separate Roll instances but never
added to the original DieTerm's results array. Dice So Nice reads
DieTerm.results to render 3D dice, so explosions were invisible.

Now each explosion result is pushed into the DieTerm's results array
({result, active:true}), letting DSN render explosion dice in the
correct chronological order alongside the main die.

Applies to prompt(), promptRangedDefense(), promptRangedAttack(),
and rollSpellDamageToMessage().
2026-06-16 19:29:07 +02:00
uberwald ffba37b59e Fix D30 management, again 2026-06-14 23:00:39 +02:00
uberwald 1a7585e1f6 fix: merge saving_throws D30 table into arcane_spell_defense
Release Creation / build (release) Successful in 49s
saving_throws was redundant — all saves in this system are
vs spells. Removed SAVING_THROWS constant; all save rollType
lookups use ARCANE_SPELL_DEFENSE. D30=1 arcane_spell_defense
blank (no special result). Added miracle types to ARCANE_SPELL_ATTACK
mapping so they get D30 results instead of null.
2026-06-14 22:57:41 +02:00
uberwald b567c8bbea Fix D30 management, again
Release Creation / build (release) Successful in 48s
2026-06-13 23:15:22 +02:00
uberwald 60b351f50d Fix spell save/defense again
Release Creation / build (release) Successful in 45s
2026-06-13 21:06:18 +02:00
uberwald ace726a1fc fix: use try/finally for spellDefense cleanup instead of delete
Release Creation / build (release) Successful in 47s
delete on game.lethalFantasy.spellDefense was breaking roll flow
on Foundry's proxied game object.  Use try/finally with
assignment to false instead, which is safe on any object type.

Initialize saveSpell local var from one-shot flag so D30
chart lookup correctly uses arcane_spell_defense for spell saves
without requiring user to click the pre-checked checkbox.
2026-06-13 16:51:52 +02:00
uberwald 67499bc199 fix: add missing arcane_spell_defense entry for D30=1
Release Creation / build (release) Successful in 49s
User spec lists D30=1 as 'Possible Spell Calamity or Catastrophe'
for Arcane Spell Defense but it was missing from the table.
2026-06-13 16:29:54 +02:00
uberwald 7eae95cbbd fix: use arcane spell defense D30 chart for spell saves
Release Creation / build (release) Successful in 43s
Bug: saveSpell local var initialized to false (line 142), while
dialog checkbox was pre-checked via dialogContext.saveSpell =
game.lethalFantasy.spellDefense.  If user didn't click the checkbox,
D30 call used SAVING_THROWS chart instead of ARCANE_SPELL_DEFENSE.

Also: game.lethalFantasy.spellDefense was set true before spell
defense rolls but never cleared, leaking to subsequent non-spell saves.

Fix: initialize saveSpell from the one-shot flag and delete it
immediately.  Dialog context now uses the local saveSpell variable
instead of re-reading the deleted flag.
2026-06-13 15:22:34 +02:00
uberwald 1b53bf9152 fix: resolve hud actor from hud.token not render context param
Release Creation / build (release) Successful in 41s
V2 renderTokenHUD passes (hud, html, data) where data is a render
context object — not a TokenDocument.  data.actor was undefined,
and data?.token?.actor was also undefined.  Use hud.token.actor
(or hud.object.actor) instead, which is the real PlaceableObject
with proper actor resolution.

Also fix html.find() → html.querySelector() for V2 HTMLElement.
2026-06-12 19:01:54 +02:00
uberwald 2570bf707e fix: prevent duplicate cross-client defense dialog, clear bleed on heal
- Only send attackBoosted socket when attackerHandledBonus || attackerHasNonGMOwner
  (GM→player: hook handles it, no socket needed; PC→PC: socket needed)
- Clear bleeding wounds when HP restored via token HUD heal buttons
2026-06-12 17:23:39 +02:00
uberwald cbeaaeec99 Final fixes and code review checks
Release Creation / build (release) Successful in 39s
2026-06-12 08:19:42 +02:00
uberwald 37badf2619 fix: attack/defense cross-client reaction flow
- C1: Stop D30 auto-roll on non-primary clients (caused divergence)
- C2: defenderOwner fallback to GM for monster defenders
- C3: Fix tie outcome in handleAttackBoosted (>= not >)
- C5: Convert handleAttackBoosted to while-loop (multi-reaction)
- C4/C6: shouldCreateMessage cross-client guard
- M2: Coordinate main flow defender dialog vs socket handler
- M3: Fresh grit/luck reads each socket handler iteration
- M4: Include defenseD30message in socket payload + re-process
- M5: Communicate attackerHandledBonus in socket payload
- i18n: Add missing COMBAT.* keys, fix weapon.hbs label localize
- d30_results_tables: Fix string typo
2026-06-12 02:51:59 +02:00
uberwald 5839616863 chore: add pushLDBtoYML/pullYMLtoLDB scripts, gitignore packs_src 2026-06-12 01:56:19 +02:00
uberwald 89298490ef fix: pre-check 'Save against spell' checkbox in template when saveSpell is true 2026-06-12 01:56:03 +02:00
uberwald bb42de19bd REmove unused file 2026-06-11 23:05:55 +02:00
uberwald 53f9c33419 chore: gitignore LevelDB internal files, stop tracking auto-generated LDB bookkeeping
Release Creation / build (release) Successful in 46s
2026-06-11 23:00:45 +02:00
uberwald 06eba5f835 fix: show spell tier dialog on character sheet cast; duplicate rollTarget to prevent Item mutation 2026-06-11 22:56:54 +02:00
uberwald 46fa2d15a3 fix: allow defender to react when attacker boosts past defense via cross-client socket 2026-06-11 22:41:54 +02:00
uberwald 8aae7bada0 fix: pre-check 'Save against spell' checkbox when defense originates from spell attack 2026-06-11 22:17:37 +02:00
uberwald ceb62bca3f fix: add missing class lethal-luck-grit-hud to template so JS selector matches 2026-06-11 22:03:56 +02:00
uberwald 110ac65ba5 fix: replace hardcoded French bleeding notifications with i18n keys 2026-06-11 21:50:19 +02:00
uberwald 9b75fd4d96 feat: combat-tracker-driven bleeding (HP loss per wound per round) 2026-06-11 21:49:35 +02:00
uberwald 141d6048e0 Fix triple damage issue 2026-06-11 21:32:26 +02:00
uberwald ea7acf6bf8 Fix hp < 0 and D30 with D20 bonus roll 2026-06-11 20:48:46 +02:00
uberwald c20750caa7 Minor fixes regarding rolls and chat messages
Release Creation / build (release) Successful in 48s
2026-06-10 20:17:45 +02:00
uberwald ce630feb51 feat: D30 combat effects, spell tiers, small damage removal, token HUD luck/grit
- Replace Knockback with Internal Injury on D30 (5, 10, 15); remove Shield Bash from D30 counter-attacks
- Eliminate small weapon damage: keep only medium damage labelled Damage in sheets, rolls, and chat
- D30 bonus dice (20, 27, 30) auto-resolved before grit/luck/shield decisions; choice dialogs for special strikes
- D30 combat effects: bleeding wounds, damage ×2/×3 before DR, DR ×2/×3 with component picker dialog
- Add hp.wounds to monster schema for bleeding support
- Show Save against spell? checkbox for all save rolls (not just magic users)
- Fix mulligan restart: persistent D30 process flags prevent double-application and allow both sides to react
- For Dice So Nice, show main roll animation before explosion dice for correct ordering
- Spell tier selection: force Standard/Overpowered choice at cast time, tier-specific aether cost, only chosen damage button shown
- Add +1/−1 luck and grit controls to Token HUD
- Fix inconsistent indentation, remove duplicate i18n key, remove unused includesShield return
2026-06-10 07:53:51 +02:00
uberwald b35b684d50 NEgative values for HP and weapon bonuses 2026-06-06 16:11:36 +02:00
uberwald f6fb0b68b8 Fix spell rolls again
Release Creation / build (release) Successful in 47s
2026-05-25 20:41:00 +02:00
uberwald e45edd60c4 FIx spell order and dual rollll for spell damages
Release Creation / build (release) Successful in 1m6s
2026-05-25 12:29:39 +02:00
uberwald d389a85a9f Fix ranged attacks again
Release Creation / build (release) Successful in 43s
2026-05-24 09:42:07 +02:00
uberwald c217490a5b Fix ranged attacks again
Release Creation / build (release) Has been cancelled
2026-05-24 09:41:06 +02:00
uberwald 38eb1a8d3d Add ranged actions for monsters
Release Creation / build (release) Successful in 54s
2026-05-23 19:10:10 +02:00
uberwald 4724cdf2bb VArious fixes for rolls and ranged attacks
Release Creation / build (release) Successful in 44s
2026-05-23 09:08:16 +02:00
uberwald 6d06c8ddad Various fixes for spell and ranged attacks 2026-05-23 00:21:05 +02:00
uberwald 2770774aa3 Various fixes for spell and ranged attacks 2026-05-23 00:11:58 +02:00
uberwald e417b61625 Spells fixe
Release Creation / build (release) Successful in 46s
2026-05-20 23:17:07 +02:00
uberwald 9a8d580ef6 Other fixes for damage buttons from chat
Release Creation / build (release) Successful in 53s
2026-05-20 10:53:46 +02:00
uberwald 9ccb0f90f0 Other fixes for damage buttons from chat 2026-05-20 10:53:22 +02:00
uberwald 6cf0880ad3 Enhance spell damage and messages content
Release Creation / build (release) Successful in 44s
2026-05-19 10:52:03 +02:00
uberwald 96306623e5 UPdate and fixes for roll in combats
Release Creation / build (release) Successful in 43s
2026-05-18 20:26:39 +02:00
uberwald 7279cd752d Fix initiative again
Release Creation / build (release) Successful in 43s
2026-05-18 07:58:28 +02:00
uberwald db3e8b5d35 Improve init for monsters and some fixwes around shields
Release Creation / build (release) Successful in 48s
2026-05-17 13:22:29 +02:00
uberwald 54421e4a83 MAnage spell/miracle spending points and favor/disfavor for shield rolls
Release Creation / build (release) Successful in 43s
2026-05-10 17:49:53 +02:00
uberwald ac44419b7a Corredction sur attack ranged 2026-05-03 15:12:25 +02:00
uberwald a3fc0a42b9 Corredction sur attack ranged
Release Creation / build (release) Successful in 1m19s
2026-05-03 10:06:44 +02:00
77 changed files with 3177 additions and 1213 deletions
+1
View File
@@ -0,0 +1 @@
packs/** filter=lfs diff=lfs merge=lfs -text
+3 -3
View File
@@ -57,7 +57,7 @@ jobs:
token: ${{ secrets.FOUNDRY_PUBLISH_KEY }} token: ${{ secrets.FOUNDRY_PUBLISH_KEY }}
id: "fvtt-lethal-fantasy" id: "fvtt-lethal-fantasy"
version: ${{github.event.release.tag_name}} version: ${{github.event.release.tag_name}}
manifest: "https://www.uberwald.me/gitea/${{gitea.repository}}/releases/download/${{github.event.release.tag_name}}/system.json" manifest: "https://www.uberwald.me/gitea/uberwald/fvtt-lethal-fantasy/releases/download/latest/system.json"
notes: "https://www.uberwald.me/gitea/public/fvtt-lethal-fantasy/raw/branch/main/changelog.md" notes: "https://www.uberwald.me/gitea/public/fvtt-lethal-fantasy/raw/branch/main/changelog.md"
compatibility-minimum: "13" compatibility-minimum: "14"
compatibility-verified: "13" compatibility-verified: "14"
+11
View File
@@ -9,3 +9,14 @@ node_modules/
.history .history
.github/ .github/
# LevelDB internals (auto-generated, churn on every open)
packs-system/**/*.log
packs-system/**/LOG
packs-system/**/LOG.old
packs-system/**/CURRENT
packs-system/**/LOCK
packs-system/**/MANIFEST-*
# YAML source for pack round-trip
packs_src/
+6
View File
@@ -0,0 +1,6 @@
{
"cSpell.words": [
"biodata",
"LETHALFANTASY"
]
}
+105
View File
@@ -0,0 +1,105 @@
# Lethal Fantasy FoundryVTT System — Session Context
## Current Goal
Fix Grit/Luck defense reaction dialog UX (stacking dialogs, multiple clicks, revert on close) and cross-client sync of defense bonuses.
## Accomplished
### Pass 1 — Critical Issues
- **Telemetry removed**: `ClassCounter`, `registerWorldCount`, orphaned `worldKey` setting deleted from system.json
- **globalThis side effects**: `globalThis.SYSTEM`, `globalThis.pendingDefenses` moved from top-level to `init` hook
- **console.log → log()**: All runtime console.log replaced with `log()` helper guarded by `lethalFantasy.debug` setting
- **Stale Tenebris refs**: `macros.mjs``TENEBRIS.Label.jet``LETHALFANTASY.Label.jet`, `TENEBRIS.Manager.*``LETHALFANTASY.Label.*`, `tenebris.macro` flag → `lethalFantasy.macro`
### Pass 2 — V1/V2 Mixing, Fire-and-Forget
- **V1 sheet registrations removed**: `foundry.appv1.sheets.*` in system.json
- **V1 `activateListeners`/jQuery**: removed dead `defaultOptions`, V1 tab code from `combat.mjs`
- **V2 API paths**: `FilePicker` → V2, `TextEditor.getDragEventData` → V2, `item.sheet.render(true)``render({force:true})`, `super._onRender()``super._onRender(context, options)`, `token._id``token.id`
- **Fire-and-forget Promises**: All `actor.update()`, `ChatMessage.create()`, `prepareRoll()`, `prepareMonsterRoll()`, socket handler calls now awaited
- **Misnamed class**: `LethalFantasySkill``LethalFantasyWeapon`; added missing `WEAPON_TYPE` import; fixed `weaponCategory`
### Pass 3 — Code Review Fixes
- **Duplicated dialogs**: Per-element `.rollable`/`.wound-data` bindings moved to `_onRender` (V2 destroys/recreates DOM each render); `_activateListeners` reverted
- **renderChatMessage reverted**: V2 hook `renderChatMessage` passes jQuery html, `querySelectorAll` fails; kept `renderChatMessageHTML`
- **Roll actions broken**: Fixed `async` base-actor-sheet methods; `_onRender` bindings for rollable elements restored
- **Token HUD guard**: `html.querySelector()``html.find().length` (html is jQuery object)
- **All review awaits confirmed**: `showDefenseRequest`/`socket` handlers all awaited
## Defense Dialog Investigation — Status
### Symptom (user process)
1. Monster (GM) attacks player — hits
2. Player uses Grit/Luck to boost defense
3. Defense now beats attack — reports new result
4. Dialog **stays open** — Grit/Luck/bonus dice options still visible
5. Closing dialog (Continue or X) causes "rolls vanish" — reverts to original result
### Root Cause Found — Duplicate cross-client processing (FIXED)
When monster (GM) attacks player, the `createChatMessage` hook fires on **both** clients:
```
Player's client: GM's client:
defense msg created defense msg synced
↓ ↓
hook fires (line 557) hook fires (line 557)
isPrimaryController(defender)=true isPrimaryController(defender)=false
↓ ↓
Defense dialog A shows Defense dialog skipped
Player spends Grit Cross-client code (line 1009):
defenseRoll=10→16 isPrimaryController(attacker)=true
While loop exits defenderOwner=player (≠GM)
Comparison: "miss" ↓
**Sends attackBoosted with ORIGINAL
defenseRoll=10 (stale!)**
Player receives socket → handleAttackBoosted
→ Defense dialog B shows with OLD values
→ When closed, comparison: "hit" (overwrites!)
```
Player sees **two** dialogs (A then B). Dialog B uses unboosted values, so closing/ignoring it produces a stale "hit" result that overwrites the correct "miss."
### Fix
`lethal-fantasy.mjs:1016` — only send `attackBoosted` socket when `attackerHandledBonus || attackerHasNonGMOwner`. Guards against stale-socket overwrite for GM→player combat (where hook-based processing works without socket), while preserving socket delegation for PC→PC cross-client (where `attackerIsCrossClient` suppresses the hook-based processing on the defender's client).
Before:
```js
if (defenderOwner && defenderOwner.id !== game.user.id) {
game.socket.emit(`system.${SYSTEM.id}`, { type: "attackBoosted", ... })
return
}
```
After:
```js
if (defenderOwner && defenderOwner.id !== game.user.id) {
if (attackerHandledBonus || attackerHasNonGMOwner) {
game.socket.emit(`system.${SYSTEM.id}`, { type: "attackBoosted", ... })
}
return
}
```
### Same-Client Path
Code pattern is identical between attack and defense dialogs — both use `await DialogV2.wait({rejectClose:false})` in a while loop. Same-client defense works correctly because no duplicate socket messages arrive.
### Other Findings
- `offerGritLuckBonus` (`utils.mjs:1121`) is dead code — never called
- `promptCombatBonusDie` (`utils.mjs:975`) is correct — DialogV2 resolves to callback return value, not `action`
- Cross-client `handleAttackBoosted` (`utils.mjs:291`) still uses `else if` chain without `continue` — functionally correct but differs from same-client pattern
### Code Paths
| Flow | File | Line |
|------|------|------|
| Same-client attack | `lethal-fantasy.mjs` | 918-1004 |
| Same-client defense | `lethal-fantasy.mjs` | 697-870 |
| Cross-client defense | `module/utils.mjs` | 291-445 |
| Cross-client socket guard | `lethal-fantasy.mjs` | 1006-1037 |
| Attack Grit offer | `module/utils.mjs` | 1210-1290 |
### Key Files
- `lethal-fantasy.mjs` — Main system hooks, same-client attack/defense reactions
- `module/utils.mjs` — Cross-client defense flow, bonus dialogs, compareAttackDefense
- `module/documents/actor.mjs``prepareRoll()` entry point
- `module/documents/roll.mjs` — Roll resolution pipeline
+186 -32
View File
@@ -529,16 +529,16 @@ i.lethalfantasy {
} }
.lethalfantasy .tab.character-combat .main-div .combat-details .combat-detail .armor-hp { .lethalfantasy .tab.character-combat .main-div .combat-details .combat-detail .armor-hp {
margin-right: 4px; margin-right: 4px;
min-width: 10rem; min-width: 11rem;
max-width: 10rem; max-width: 11rem;
} }
.lethalfantasy .tab.character-combat .main-div .combat-details .combat-detail .armor-hp .name { .lethalfantasy .tab.character-combat .main-div .combat-details .combat-detail .armor-hp .name {
min-width: 6rem; min-width: 6rem;
max-width: 6rem; max-width: 6rem;
} }
.lethalfantasy .tab.character-combat .main-div .combat-details .combat-detail .armor-hp .input { .lethalfantasy .tab.character-combat .main-div .combat-details .combat-detail .armor-hp .input {
min-width: 2.5rem; min-width: 3.5rem;
max-width: 2.5rem; max-width: 3.5rem;
} }
.lethalfantasy .tab.character-combat .main-div .combat-details .combat-detail .granted { .lethalfantasy .tab.character-combat .main-div .combat-details .combat-detail .granted {
min-width: 8rem; min-width: 8rem;
@@ -2027,9 +2027,12 @@ i.lethalfantasy {
background: #4a4940 !important; background: #4a4940 !important;
color: #ffffff !important; color: #ffffff !important;
} }
.lethalfantasy .grit-luck-dialog {
color: var(--color-text-dark-primary, #191813);
}
.lethalfantasy .grit-luck-dialog .combat-status { .lethalfantasy .grit-luck-dialog .combat-status {
padding: 12px; padding: 12px;
background: linear-gradient(to bottom, rgba(42, 41, 32, 0.8) 0%, rgba(26, 25, 16, 0.9) 100%); background: linear-gradient(to bottom, rgba(42, 41, 32, 0.88) 0%, rgba(26, 25, 16, 0.95) 100%);
border: 1px solid rgba(212, 175, 55, 0.5); border: 1px solid rgba(212, 175, 55, 0.5);
border-radius: 6px; border-radius: 6px;
margin-bottom: 16px; margin-bottom: 16px;
@@ -2049,11 +2052,25 @@ i.lethalfantasy {
margin-top: 8px; margin-top: 8px;
} }
.lethalfantasy .grit-luck-dialog .offer-text { .lethalfantasy .grit-luck-dialog .offer-text {
color: #f0e6d2; color: var(--color-text-dark-primary, #191813);
font-size: calc(var(--font-size-standard) * 1); font-size: calc(var(--font-size-standard) * 1);
text-align: center; text-align: center;
font-weight: 600; font-weight: 600;
margin: 0 0 8px 0;
}
.lethalfantasy .grit-luck-dialog .shield-warning {
color: #7a4000;
background: rgba(255, 160, 0, 0.12);
border: 1px solid rgba(255, 160, 0, 0.4);
border-radius: 5px;
font-size: calc(var(--font-size-standard) * 0.88);
padding: 6px 10px;
margin: 0; margin: 0;
text-align: center;
}
.lethalfantasy .grit-luck-dialog .shield-warning i {
color: #c07000;
margin-right: 5px;
} }
.lethalfantasy .attack-result { .lethalfantasy .attack-result {
padding: 16px; padding: 16px;
@@ -2144,31 +2161,66 @@ i.lethalfantasy {
color: #d4af37; color: #d4af37;
} }
.lethalfantasy .attack-result .attack-result-damage { .lethalfantasy .attack-result .attack-result-damage {
display: flex; display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 8px; gap: 8px;
justify-content: center; }
.lethalfantasy .attack-result .attack-result-damage.single-btn {
grid-template-columns: 1fr;
max-width: 280px;
margin: 0 auto;
}
.lethalfantasy .attack-result .attack-result-damage.spell-damage {
grid-template-columns: 1fr;
width: 100%;
} }
.lethalfantasy .attack-result .attack-result-damage .roll-damage-btn { .lethalfantasy .attack-result .attack-result-damage .roll-damage-btn {
padding: 10px 16px; padding: 10px 14px;
background: linear-gradient(to bottom, #8b0000 0%, #660000 100%); background: linear-gradient(to bottom, #8b0000 0%, #660000 100%);
border: 1px solid #ff0000; border: 1px solid #4b0000;
border-radius: 6px; border-radius: 6px;
color: #f0e6d2; color: #f0e6d2;
font-weight: 600; font-weight: 600;
font-size: calc(var(--font-size-standard) * 0.9);
text-align: center;
white-space: nowrap;
cursor: pointer; cursor: pointer;
transition: all 0.2s ease; transition: all 0.2s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
position: relative;
overflow: hidden;
}
.lethalfantasy .attack-result .attack-result-damage .roll-damage-btn::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
transition: left 0.5s;
}
.lethalfantasy .attack-result .attack-result-damage .roll-damage-btn:hover::before {
left: 100%;
}
.lethalfantasy .attack-result .attack-result-damage .roll-damage-btn i {
font-size: calc(var(--font-size-standard) * 1.1);
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
flex-shrink: 0;
} }
.lethalfantasy .attack-result .attack-result-damage .roll-damage-btn:hover { .lethalfantasy .attack-result .attack-result-damage .roll-damage-btn:hover {
background: linear-gradient(to bottom, #a00000 0%, #7b0000 100%); background: linear-gradient(to bottom, #a00000 0%, #7b0000 100%);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
transform: translateY(-2px); transform: translateY(-2px);
border-color: #5b0000;
} }
.lethalfantasy .attack-result .attack-result-damage .roll-damage-btn:active { .lethalfantasy .attack-result .attack-result-damage .roll-damage-btn:active {
transform: translateY(0); transform: translateY(0);
} box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 3px rgba(0, 0, 0, 0.3);
.lethalfantasy .attack-result .attack-result-damage .roll-damage-btn i {
margin-right: 6px;
} }
.lethalfantasy .equipment-content { .lethalfantasy .equipment-content {
font-family: var(--font-primary); font-family: var(--font-primary);
@@ -2634,6 +2686,21 @@ i.lethalfantasy {
max-width: 8rem; max-width: 8rem;
margin-left: 1rem; margin-left: 1rem;
} }
.dialog-warning {
margin: 0.4rem 0.2rem 0.2rem;
padding: 0.35rem 0.5rem;
border-left: 3px solid #c8941a;
background: rgba(200, 148, 26, 0.12);
border-radius: 3px;
font-family: var(--font-secondary);
font-size: calc(var(--font-size-standard) * 0.9);
color: #7a5400;
line-height: 1.4;
}
.dialog-warning i {
color: #c8941a;
margin-right: 0.4rem;
}
.lethalfantasy.dice-roll, .lethalfantasy.dice-roll,
.fvtt-lethal-fantasy.dice-roll, .fvtt-lethal-fantasy.dice-roll,
.message.lethalfantasy.dice-roll, .message.lethalfantasy.dice-roll,
@@ -3213,16 +3280,10 @@ i.lethalfantasy {
.message.lethalfantasy.dice-roll .damage-buttons .damage-buttons-grid, .message.lethalfantasy.dice-roll .damage-buttons .damage-buttons-grid,
.message.fvtt-lethal-fantasy.dice-roll .damage-buttons .damage-buttons-grid { .message.fvtt-lethal-fantasy.dice-roll .damage-buttons .damage-buttons-grid {
display: grid; display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 8px;
}
.lethalfantasy.dice-roll .damage-buttons .damage-buttons-grid.monster-damage,
.fvtt-lethal-fantasy.dice-roll .damage-buttons .damage-buttons-grid.monster-damage,
.message.lethalfantasy.dice-roll .damage-buttons .damage-buttons-grid.monster-damage,
.message.fvtt-lethal-fantasy.dice-roll .damage-buttons .damage-buttons-grid.monster-damage {
grid-template-columns: 1fr; grid-template-columns: 1fr;
max-width: 280px; max-width: 280px;
margin: 0 auto; margin: 0 auto;
gap: 8px;
} }
.lethalfantasy.dice-roll .damage-buttons .damage-buttons-grid .damage-roll-btn, .lethalfantasy.dice-roll .damage-buttons .damage-buttons-grid .damage-roll-btn,
.fvtt-lethal-fantasy.dice-roll .damage-buttons .damage-buttons-grid .damage-roll-btn, .fvtt-lethal-fantasy.dice-roll .damage-buttons .damage-buttons-grid .damage-roll-btn,
@@ -3482,6 +3543,7 @@ i.lethalfantasy {
display: grid; display: grid;
grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(2, 1fr);
gap: 8px; gap: 8px;
justify-items: center;
} }
.lethalfantasy.dice-roll .d30-message, .lethalfantasy.dice-roll .d30-message,
.fvtt-lethal-fantasy.dice-roll .d30-message, .fvtt-lethal-fantasy.dice-roll .d30-message,
@@ -3928,35 +3990,74 @@ i.lethalfantasy {
} }
.message .attack-result .attack-result-damage, .message .attack-result .attack-result-damage,
.attack-result .attack-result-damage { .attack-result .attack-result-damage {
display: flex; display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 8px; gap: 8px;
justify-content: center; }
.message .attack-result .attack-result-damage.single-btn,
.attack-result .attack-result-damage.single-btn {
grid-template-columns: 1fr;
max-width: 280px;
margin: 0 auto;
}
.message .attack-result .attack-result-damage.spell-damage,
.attack-result .attack-result-damage.spell-damage {
grid-template-columns: 1fr;
width: 100%;
} }
.message .attack-result .attack-result-damage .roll-damage-btn, .message .attack-result .attack-result-damage .roll-damage-btn,
.attack-result .attack-result-damage .roll-damage-btn { .attack-result .attack-result-damage .roll-damage-btn {
padding: 10px 16px; padding: 10px 14px;
background: linear-gradient(to bottom, #8b0000 0%, #660000 100%); background: linear-gradient(to bottom, #8b0000 0%, #660000 100%);
border: 1px solid #ff0000; border: 1px solid #4b0000;
border-radius: 6px; border-radius: 6px;
color: #f0e6d2; color: #f0e6d2;
font-weight: 600; font-weight: 600;
font-size: calc(var(--font-size-standard) * 0.9);
text-align: center;
white-space: nowrap;
cursor: pointer; cursor: pointer;
transition: all 0.2s ease; transition: all 0.2s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
position: relative;
overflow: hidden;
}
.message .attack-result .attack-result-damage .roll-damage-btn::before,
.attack-result .attack-result-damage .roll-damage-btn::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
transition: left 0.5s;
}
.message .attack-result .attack-result-damage .roll-damage-btn:hover::before,
.attack-result .attack-result-damage .roll-damage-btn:hover::before {
left: 100%;
}
.message .attack-result .attack-result-damage .roll-damage-btn i,
.attack-result .attack-result-damage .roll-damage-btn i {
font-size: calc(var(--font-size-standard) * 1.1);
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
flex-shrink: 0;
} }
.message .attack-result .attack-result-damage .roll-damage-btn:hover, .message .attack-result .attack-result-damage .roll-damage-btn:hover,
.attack-result .attack-result-damage .roll-damage-btn:hover { .attack-result .attack-result-damage .roll-damage-btn:hover {
background: linear-gradient(to bottom, #a00000 0%, #7b0000 100%); background: linear-gradient(to bottom, #a00000 0%, #7b0000 100%);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
transform: translateY(-2px); transform: translateY(-2px);
border-color: #5b0000;
} }
.message .attack-result .attack-result-damage .roll-damage-btn:active, .message .attack-result .attack-result-damage .roll-damage-btn:active,
.attack-result .attack-result-damage .roll-damage-btn:active { .attack-result .attack-result-damage .roll-damage-btn:active {
transform: translateY(0); transform: translateY(0);
} box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 3px rgba(0, 0, 0, 0.3);
.message .attack-result .attack-result-damage .roll-damage-btn i,
.attack-result .attack-result-damage .roll-damage-btn i {
margin-right: 6px;
} }
#token-hud .hp-loss-wrap { #token-hud .hp-loss-wrap {
position: absolute; position: absolute;
@@ -4033,6 +4134,59 @@ i.lethalfantasy {
padding-left: 8px; padding-left: 8px;
font-size: 0.9rem; font-size: 0.9rem;
} }
/* Luck/Grit Styles */
#token-hud .luck-grit-wrap {
position: absolute;
left: 75px;
display: none;
top: 50%;
width: 80px;
text-align: start;
background: rgba(0, 0, 0, 0.8);
border: 1px solid rgba(139, 69, 19, 0.5);
border-radius: 4px;
padding: 4px 6px;
transform: translate(-100%, -50%);
}
#token-hud .luck-grit-hud-active {
display: block;
}
#token-hud .luck-grit-hud-disabled {
display: none;
}
#token-hud .luck-grit-row {
display: flex;
align-items: center;
gap: 4px;
margin: 2px 0;
}
#token-hud .luck-grit-label {
flex: 1;
color: #c9b896;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
}
#token-hud .luck-grit-btn {
width: 28px;
height: 22px;
padding: 0;
background: rgba(139, 69, 19, 0.25);
border: 1px solid rgba(139, 69, 19, 0.4);
border-radius: 3px;
color: #d4c5a9;
font-size: 12px;
font-weight: 700;
cursor: pointer;
line-height: 1;
display: flex;
align-items: center;
justify-content: center;
}
#token-hud .luck-grit-btn:hover {
background: rgba(139, 69, 19, 0.5);
border-color: rgba(139, 69, 19, 0.7);
}
/* -------------------------------------------------- */ /* -------------------------------------------------- */
/* Dice Tray — injected into the Foundry chat sidebar */ /* Dice Tray — injected into the Foundry chat sidebar */
/* -------------------------------------------------- */ /* -------------------------------------------------- */
+103 -8
View File
@@ -1,8 +1,32 @@
{ {
"COMBAT": { "COMBAT": {
"Begin": "Begin Combat",
"Create": "Create Encounter",
"Delete": "Delete Encounter",
"Encounter": "Encounter",
"EncounterNext": "Next Encounter",
"EncounterPrevious": "Previous Encounter",
"End": "End Combat",
"InitiativeReset": "Reset Initiative",
"InitiativeRoll": "Roll Initiative",
"InitiativeScore": "Initiative Score",
"NavLabel": "Combat Tracker Navigation",
"None": "None",
"NotStarted": "Not Started",
"PanToCombatant": "Pan to Combatant",
"PingCombatant": "Ping Combatant",
"RollAll": "Roll All",
"RollNPC": "Roll NPCs",
"Round": "Second {round}", "Round": "Second {round}",
"RoundNext": "Next second",
"RoundPrev": "Previous second",
"Rounds": "Seconds", "Rounds": "Seconds",
"RoundNext": "Next second" "Settings": "Combat Settings",
"ToggleDead": "Toggle Dead",
"ToggleVis": "Toggle Visible",
"TurnEnd": "End Turn",
"TurnNext": "Next Turn",
"TurnPrev": "Previous Turn"
}, },
"LETHALFANTASY": { "LETHALFANTASY": {
"Armor": { "Armor": {
@@ -382,7 +406,7 @@
"rollProgressionCount": "Roll progression count", "rollProgressionCount": "Roll progression count",
"rollProgressionDice": "Roll progression/Lethargy dice", "rollProgressionDice": "Roll progression/Lethargy dice",
"earned": "Earned", "earned": "Earned",
"divinityPoints": "Divinity points", "divinityPoints": "Grace",
"aetherPoints": "Aether points", "aetherPoints": "Aether points",
"attacks": "Attacks", "attacks": "Attacks",
"attackMode": "Attack Mode", "attackMode": "Attack Mode",
@@ -471,6 +495,8 @@
"range": "Range", "range": "Range",
"rangeDefenseDialog": "Ranged defense dialog", "rangeDefenseDialog": "Ranged defense dialog",
"rangeDefenseRoll": "Ranged defense roll", "rangeDefenseRoll": "Ranged defense roll",
"rangeAttackDialog": "Ranged attack dialog",
"rangeAttackRoll": "Ranged attack roll",
"rangedAttackDefense": "Ranged attack defense", "rangedAttackDefense": "Ranged attack defense",
"resource": "Resource", "resource": "Resource",
"resources": "Resources", "resources": "Resources",
@@ -503,11 +529,42 @@
"monster-defense": "Monster defense", "monster-defense": "Monster defense",
"weapons": "Weapons", "weapons": "Weapons",
"wis": "WIS", "wis": "WIS",
"weapon-damage-medium": "Weapon damage medium",
"weapon-damage-small": "Weapon damage small",
"combatProgressionStart": "Combat start threshold", "combatProgressionStart": "Combat start threshold",
"miracle": "Miracle", "miracle": "Miracle",
"titleStandard": "Standard Roll" "titleStandard": "Standard Roll",
"privateRoll": "Private Roll",
"current": "Current",
"max": "Max",
"speed": "Speed",
"bonuses": "Bonuses",
"handToHandAttacks": "Hand To Hand Attacks",
"beyondSkill": "Beyond Skill",
"letItFly": "Let It Fly!",
"class": "Class",
"mortal": "Mortal",
"alignment": "Alignment",
"age": "Age",
"height": "Height",
"weight": "Weight",
"eyes": "Eyes",
"hair": "Hair",
"magicUser": "Magic User",
"clericUser": "Cleric User",
"lastHdRoll": "Last HD roll",
"naturalDR": "Natural DR",
"magicalDR": "Magical DR",
"saveBonus": "Save bonus (1/5 levels)",
"spellBonus": "Spell bonus (1/5 levels)",
"miracleBonus": "Miracle bonus (1/5 levels)",
"devPointsTotal": "Dev. Points (Total)",
"devPointsRem": "Dev. Points (Rem.)",
"length": "Length",
"vision": "Vision",
"damageType": "Damage Type",
"components": "Components",
"coverRanged": "Cover vs ranged attacks",
"standing": "Standing",
"crouching": "Crouching"
}, },
"Miracle": { "Miracle": {
"FIELDS": { "FIELDS": {
@@ -563,6 +620,15 @@
}, },
"savingThrow": { "savingThrow": {
"label": "Saving throw" "label": "Saving throw"
},
"damageDiceOverpowered": {
"label": "Overpowered Damage Dice"
},
"damageDiceOverpowered2": {
"label": "Overpowered 2 Damage Dice"
},
"damageDice": {
"label": "Damage Dice"
} }
} }
}, },
@@ -582,7 +648,9 @@
"messageLethargyKO": "{spellName} : Lethargy still ongoing ... ( dice result : {roll} )", "messageLethargyKO": "{spellName} : Lethargy still ongoing ... ( dice result : {roll} )",
"messageProgressionKO": "{name} can't attack this second.", "messageProgressionKO": "{name} can't attack this second.",
"messageProgressionOKMonster": "{name} can attack this second with {weapon}.", "messageProgressionOKMonster": "{name} can attack this second with {weapon}.",
"messageProgressionKOMonster": "{name} can't attack this second (dice result {roll})." "messageProgressionKOMonster": "{name} can't attack this second (dice result {roll}).",
"bleedingCombatEnd": "Bleeding active out of combat: {names}",
"bleedingCombatStart": "Bleeding still active on: {names}"
}, },
"Opponent": { "Opponent": {
"FIELDS": {} "FIELDS": {}
@@ -684,7 +752,8 @@
"label": "Min" "label": "Min"
} }
} }
} },
"autoDestruction": "Auto-Destruction"
}, },
"Skill": { "Skill": {
"Category": { "Category": {
@@ -783,6 +852,12 @@
"cost": { "cost": {
"label": "Cost" "label": "Cost"
}, },
"costOverpowered": {
"label": "Cost (Overpowered)"
},
"costOverpowered2": {
"label": "Cost (Overpowered 2)"
},
"description": { "description": {
"label": "Description" "label": "Description"
}, },
@@ -809,6 +884,12 @@
}, },
"damageDice": { "damageDice": {
"label": "Damage dice" "label": "Damage dice"
},
"damageDiceOverpowered": {
"label": "Overpowered Damage Dice"
},
"damageDiceOverpowered2": {
"label": "Overpowered 2 Damage Dice"
} }
}, },
"Range": { "Range": {
@@ -843,7 +924,9 @@
} }
} }
}, },
"Warning": {}, "Warning": {
"defenseShieldOrder": "To avoid a hit without using the shield, roll Grit or Luck first — then roll the shield."
},
"Weapon": { "Weapon": {
"FIELDS": { "FIELDS": {
"isAgile": { "isAgile": {
@@ -988,6 +1071,18 @@
"diceResult": "Dice result", "diceResult": "Dice result",
"progressionCount": "Progression count:" "progressionCount": "Progression count:"
}, },
"Combat": {
"RollMonsters": "Roll Monsters",
"monstersNotRolledTitle": "Monsters Not Rolled",
"monstersNotRolledMsg": "Monsters have not rolled this second. Proceed anyway?",
"proceedYes": "Proceed",
"proceedNo": "Cancel",
"spellDRDialogTitle": "Spell Damage — Apply DR?",
"spellDRDialogMsg": "Enter a damage reduction value to subtract, or click No DR to apply full damage.",
"spellDRLabel": "DR:",
"spellNoDR": "No DR",
"spellApplyDR": "Apply DR"
},
"EquipmentCategories": { "EquipmentCategories": {
"ClassKit": "Class Kit", "ClassKit": "Class Kit",
"Clothing": "Clothing", "Clothing": "Clothing",
+649 -196
View File
File diff suppressed because it is too large Load Diff
+68 -50
View File
@@ -18,62 +18,44 @@ export class LethalFantasyCombatTracker extends foundry.applications.sidebar.tab
actions: { actions: {
initiativePlus: LethalFantasyCombatTracker.#initiativePlus, initiativePlus: LethalFantasyCombatTracker.#initiativePlus,
initiativeMinus: LethalFantasyCombatTracker.#initiativeMinus, initiativeMinus: LethalFantasyCombatTracker.#initiativeMinus,
rollMonsterProgression: LethalFantasyCombatTracker.#rollMonsterProgression,
}, },
}); });
async _prepareContext(options) { async _prepareContext(options) {
let data = await super._prepareContext(options); let data = await super._prepareContext(options);
console?.log("Combat Tracker Data", data); log("Combat Tracker Data", data);
/*for (let u of data.turns) { /*for (let u of data.turns) {
let c = game.combat.combatants.get(u.id); let c = game.combat.combatants.get(u.id);
u.progressionCount = c.system.progressionCount u.progressionCount = c.system.progressionCount
u.isMonster = c.actor.type === "monster" u.isMonster = c.actor.type === "monster"
} }
console.log("Combat Data", data);*/ log("Combat Data", data);*/
return data; return data;
} }
static #initiativePlus(ev) { static async #initiativePlus(ev) {
ev.preventDefault(); ev.preventDefault();
let cId = ev.target.closest(".combatant").dataset.combatantId; let cId = ev.target.closest(".combatant").dataset.combatantId;
let c = game.combat.combatants.get(cId); let c = game.combat.combatants.get(cId);
c.update({ 'initiative': c.initiative + 1 }); await c.update({ 'initiative': c.initiative + 1 });
console.log("Initiative Plus");
} }
static #initiativeMinus(ev) { static async #initiativeMinus(ev) {
ev.preventDefault(); ev.preventDefault();
let cId = ev.target.closest(".combatant").dataset.combatantId; let cId = ev.target.closest(".combatant").dataset.combatantId;
let c = game.combat.combatants.get(cId); let c = game.combat.combatants.get(cId);
let newInit = Math.max(c.initiative - 1, 0); let newInit = Math.max(c.initiative - 1, 0);
c.update({ 'initiative': newInit }); await c.update({ 'initiative': newInit });
} }
activateListeners(html) { /**
super.activateListeners(html); * Roll progression dice for all monster combatants that are eligible this round.
// Display Combat settings * @param {Event} ev Click event.
html.find(".initiative-plus").click(ev => { */
static async #rollMonsterProgression(ev) {
ev.preventDefault(); ev.preventDefault();
let cId = ev.currentTarget.closest(".combatant").dataset.combatantId; await game.combat.rollMonsterProgression();
let c = game.combat.combatants.get(cId);
c.update({ 'initiative': c.initiative + 1 });
});
html.find(".initiative-minus").click(ev => {
ev.preventDefault();
let cId = ev.currentTarget.closest(".combatant").dataset.combatantId;
let c = game.combat.combatants.get(cId);
c.update({ 'initiative': c.initiative - 1 });
console.log("Initiative Minus");
});
}
/* -------------------------------------------- */
static get defaultOptions() {
let path = "systems/fvtt-lethal-fantasy/templates/combat-tracker.hbs";
return foundry.utils.mergeObject(super.defaultOptions, {
template: path,
});
} }
} }
@@ -84,7 +66,7 @@ export class LethalFantasyCombat extends Combat {
* @returns {Combatant[]} * @returns {Combatant[]}
*/ */
setupTurns() { setupTurns() {
console?.log("Setup Turns...."); log("Setup Turns....");
this.turns ||= []; this.turns ||= [];
// Determine the turn order and the current turn // Determine the turn order and the current turn
@@ -109,18 +91,12 @@ export class LethalFantasyCombat extends Combat {
} }
async rollInitiative(ids, options) { async rollInitiative(ids, options) {
console.log("%%%%%%%%% Roll Initiative", ids, options);
ids = typeof ids === "string" ? [ids] : ids; ids = typeof ids === "string" ? [ids] : ids;
let messages = [];
let rollMode = game.settings.get("core", "rollMode");
let updates = [];
for (let cId of ids) { for (let cId of ids) {
const c = this.combatants.get(cId); const c = this.combatants.get(cId);
const playerOwner = game.users.find(u => u.active && !u.isGM && u.character?.id === c.actor.id); const playerOwner = game.users.find(u => u.active && !u.isGM && u.character?.id === c.actor.id);
if (game.user.isGM && playerOwner) { if (game.user.isGM && playerOwner) {
console.log("Rolling initiative for", c.actor.name);
game.socket.emit(`system.${SYSTEM.id}`, { type: "rollInitiative", userId: playerOwner.id, actorId: c.actor.id, combatId: this.id, combatantId: c.id }); game.socket.emit(`system.${SYSTEM.id}`, { type: "rollInitiative", userId: playerOwner.id, actorId: c.actor.id, combatId: this.id, combatantId: c.id });
} else { } else {
await c.actor.system.rollInitiative(this.id, c.id); await c.actor.system.rollInitiative(this.id, c.id);
@@ -130,19 +106,49 @@ export class LethalFantasyCombat extends Combat {
return this; return this;
} }
resetProgression(cId) { /** Roll progression dice for all eligible monster combatants this round. Called manually by the GM. */
let c = this.combatants.get(cId); async rollMonsterProgression() {
c.update({ 'system.progressionCount': 0 }); const currentRound = this.round;
const monsters = this.combatants.filter(c => c.actor?.type === "monster" && !c.isDefeated);
if (monsters.length === 0) {
ui.notifications.warn("No monsters in combat.");
return;
} }
setCasting(cId) { let rolled = 0;
let c = this.combatants.get(cId); for (let c of monsters) {
c.setFlag(SYSTEM.id, "casting", true); if (c.initiative !== null && currentRound >= c.initiative) {
await c.actor.system.rollProgressionDice(this.id, c.id);
rolled++;
}
} }
resetCasting(cId) { if (rolled === 0) {
const earliest = monsters.reduce((min, c) => (c.initiative !== null && c.initiative < min) ? c.initiative : min, Infinity);
if (earliest === Infinity) {
ui.notifications.warn("Monsters have no initiative set. Roll initiative first.");
} else {
ui.notifications.info(`No monsters act yet — earliest monster initiative is ${earliest} (current round: ${currentRound}).`);
}
} else {
this._monsterProgressionRolledRound = currentRound;
}
}
async resetProgression(cId) {
let c = this.combatants.get(cId); let c = this.combatants.get(cId);
c.setFlag(SYSTEM.id, "casting", false); await c.update({ 'system.progressionCount': 0 });
}
async setCasting(cId) {
let c = this.combatants.get(cId);
await c.setFlag(SYSTEM.id, "casting", true);
}
async resetCasting(cId) {
let c = this.combatants.get(cId);
await c.setFlag(SYSTEM.id, "casting", false);
} }
isCasting(cId) { isCasting(cId) {
@@ -151,15 +157,12 @@ export class LethalFantasyCombat extends Combat {
} }
async nextTurn() { async nextTurn() {
console.log("NEXT TURN");
let turn = this.turn ?? -1; let turn = this.turn ?? -1;
let skipDefeated = this.settings.skipDefeated; let skipDefeated = this.settings.skipDefeated;
// Determine the next turn number // Determine the next turn number
let next = null; let next = null;
for (let [i, t] of this.turns.entries()) { for (let [i, t] of this.turns.entries()) {
console.log("Turn", t);
if (i <= turn) continue; if (i <= turn) continue;
if (skipDefeated && t.isDefeated) continue; if (skipDefeated && t.isDefeated) continue;
next = i; next = i;
@@ -183,7 +186,6 @@ export class LethalFantasyCombat extends Combat {
this.turnsDone = false this.turnsDone = false
let turn = this.turn === null ? null : 0; // Preserve the fact that it's no-one's turn currently. let turn = this.turn === null ? null : 0; // Preserve the fact that it's no-one's turn currently.
console.log("ROUND", this);
let advanceTime = Math.max(this.turns.length - this.turn, 0) * CONFIG.time.turnTime; let advanceTime = Math.max(this.turns.length - this.turn, 0) * CONFIG.time.turnTime;
advanceTime += CONFIG.time.roundTime; advanceTime += CONFIG.time.roundTime;
@@ -201,8 +203,24 @@ export class LethalFantasyCombat extends Combat {
return this; return this;
} }
// Warn if eligible monsters have not rolled progression dice this round
const eligibleMonsters = this.combatants.filter(
c => c.actor?.type === "monster" && !c.isDefeated && c.initiative !== null && this.round >= c.initiative
);
if (eligibleMonsters.length > 0 && this._monsterProgressionRolledRound !== this.round) {
const proceed = await foundry.applications.api.DialogV2.confirm({
window: { title: game.i18n.localize("LETHALFANTASY.Combat.monstersNotRolledTitle") },
content: `<p>${game.i18n.localize("LETHALFANTASY.Combat.monstersNotRolledMsg")}</p>`,
yes: { label: game.i18n.localize("LETHALFANTASY.Combat.proceedYes") },
no: { label: game.i18n.localize("LETHALFANTASY.Combat.proceedNo") },
rejectClose: false,
});
if (!proceed) return this;
}
for (let c of this.combatants) { for (let c of this.combatants) {
if (nextRound >= c.initiative) { if (nextRound >= c.initiative) {
if (c.actor.type === "monster") continue; // Monsters roll manually via the "Roll Monsters" button
const playerOwner = game.users.find(u => u.active && !u.isGM && u.character?.id === c.actor.id); const playerOwner = game.users.find(u => u.active && !u.isGM && u.character?.id === c.actor.id);
if (game.user.isGM && playerOwner) { if (game.user.isGM && playerOwner) {
game.socket.emit(`system.${SYSTEM.id}`, { type: "rollProgressionDice", userId: playerOwner.id, progressionCount: c.system.progressionCount + 1, actorId: c.actor.id, combatId: this.id, combatantId: c.id }); game.socket.emit(`system.${SYSTEM.id}`, { type: "rollProgressionDice", userId: playerOwner.id, progressionCount: c.system.progressionCount + 1, actorId: c.actor.id, combatId: this.id, combatantId: c.id });
+4 -1
View File
@@ -142,11 +142,14 @@ export async function rollFreeDie(dieType, count = 1, explode = false) {
` `
const rollMode = game.settings.get("core", "rollMode") const rollMode = game.settings.get("core", "rollMode")
// Normalize old-style rollMode keys (v12/v13) to new-style (v14), fallback to "public"
const modeMap = { publicroll: "public", gmroll: "gm", blindroll: "blind", selfroll: "self" }
const mode = modeMap[rollMode] ?? rollMode ?? "public"
const msgData = { const msgData = {
speaker: ChatMessage.getSpeaker(), speaker: ChatMessage.getSpeaker(),
content, content,
sound: CONFIG.sounds.dice, sound: CONFIG.sounds.dice,
mode,
} }
ChatMessage.applyRollMode(msgData, rollMode)
await ChatMessage.create(msgData) await ChatMessage.create(msgData)
} }
@@ -78,7 +78,6 @@ export default class LethalFantasyActorSheet extends HandlebarsApplicationMixin(
/** @override */ /** @override */
_onRender(context, options) { _onRender(context, options) {
this.#dragDrop.forEach((d) => d.bind(this.element)) this.#dragDrop.forEach((d) => d.bind(this.element))
// Add listeners to rollable elements
const rollables = this.element.querySelectorAll(".rollable") const rollables = this.element.querySelectorAll(".rollable")
rollables.forEach((d) => d.addEventListener("click", this._onRoll.bind(this))) rollables.forEach((d) => d.addEventListener("click", this._onRoll.bind(this)))
} }
@@ -234,12 +233,12 @@ export default class LethalFantasyActorSheet extends HandlebarsApplicationMixin(
const attr = target.dataset.edit const attr = target.dataset.edit
const current = foundry.utils.getProperty(this.document, attr) const current = foundry.utils.getProperty(this.document, attr)
const { img } = this.document.constructor.getDefaultArtwork?.(this.document.toObject()) ?? {} const { img } = this.document.constructor.getDefaultArtwork?.(this.document.toObject()) ?? {}
const fp = new FilePicker({ const fp = new foundry.applications.ux.FilePicker.implementation({
current, current,
type: "image", type: "image",
redirectToRoot: img ? [img] : [], redirectToRoot: img ? [img] : [],
callback: (path) => { callback: async (path) => {
this.document.update({ [attr]: path }) await this.document.update({ [attr]: path })
}, },
top: this.position.top + 40, top: this.position.top + 40,
left: this.position.left + 10, left: this.position.left + 10,
@@ -261,7 +260,7 @@ export default class LethalFantasyActorSheet extends HandlebarsApplicationMixin(
item = await fromUuid(uuid) item = await fromUuid(uuid)
if (!item) item = this.document.items.get(id) if (!item) item = this.document.items.get(id)
if (!item) return if (!item) return
item.sheet.render(true) item.sheet.render({ force: true })
} }
/** /**
@@ -284,8 +283,8 @@ export default class LethalFantasyActorSheet extends HandlebarsApplicationMixin(
* @private * @private
* @static * @static
*/ */
static #onCreateSpell(event, target) { static async #onCreateSpell(event, target) {
const item = this.document.createEmbeddedDocuments("Item", [{ name: "Nouveau sortilège", type: "spell" }]) await this.document.createEmbeddedDocuments("Item", [{ name: "Nouveau sortilège", type: "spell" }])
} }
// #endregion // #endregion
@@ -177,12 +177,12 @@ export default class LethalFantasyItemSheet extends HandlebarsApplicationMixin(f
const attr = target.dataset.edit const attr = target.dataset.edit
const current = foundry.utils.getProperty(this.document, attr) const current = foundry.utils.getProperty(this.document, attr)
const { img } = this.document.constructor.getDefaultArtwork?.(this.document.toObject()) ?? {} const { img } = this.document.constructor.getDefaultArtwork?.(this.document.toObject()) ?? {}
const fp = new FilePicker({ const fp = new foundry.applications.ux.FilePicker.implementation({
current, current,
type: "image", type: "image",
redirectToRoot: img ? [img] : [], redirectToRoot: img ? [img] : [],
callback: (path) => { callback: async (path) => {
this.document.update({ [attr]: path }) await this.document.update({ [attr]: path })
}, },
top: this.position.top + 40, top: this.position.top + 40,
left: this.position.left + 10, left: this.position.left + 10,
+97 -23
View File
@@ -22,6 +22,7 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
divinityPointsMinus: LethalFantasyCharacterSheet.#onDivinityPointsMinus, divinityPointsMinus: LethalFantasyCharacterSheet.#onDivinityPointsMinus,
aetherPointsPlus: LethalFantasyCharacterSheet.#onAetherPointsPlus, aetherPointsPlus: LethalFantasyCharacterSheet.#onAetherPointsPlus,
aetherPointsMinus: LethalFantasyCharacterSheet.#onAetherPointsMinus, aetherPointsMinus: LethalFantasyCharacterSheet.#onAetherPointsMinus,
rollSpellDamage: LethalFantasyCharacterSheet.#onRollSpellDamage,
}, },
} }
@@ -70,10 +71,10 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
biography: { id: "biography", group: "sheet", icon: "fa-solid fa-book", label: "LETHALFANTASY.Label.biography" }, biography: { id: "biography", group: "sheet", icon: "fa-solid fa-book", label: "LETHALFANTASY.Label.biography" },
} }
if (this.actor.system.biodata.magicUser) { if (this.actor.system.biodata.magicUser) {
tabs.spells = { id: "spells", group: "sheet", icon: "fa-sharp-duotone fa-solid fa-wand-magic-sparkles", label: "LETHALFANTASY.Label.spells" } tabs.spells = { id: "spells", group: "sheet", icon: "fa-solid fa-wand-magic-sparkles", label: "LETHALFANTASY.Label.spells" }
} }
if (this.actor.system.biodata.clericUser) { if (this.actor.system.biodata.clericUser) {
tabs.miracles = { id: "miracles", group: "sheet", icon: "fa-sharp-duotone fa-solid fa-hands-praying", label: "LETHALFANTASY.Label.miracles" } tabs.miracles = { id: "miracles", group: "sheet", icon: "fa-solid fa-hands-praying", label: "LETHALFANTASY.Label.miracles" }
} }
for (const v of Object.values(tabs)) { for (const v of Object.values(tabs)) {
v.active = this.tabGroups[v.group] === v.id v.active = this.tabGroups[v.group] === v.id
@@ -172,61 +173,132 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
}) })
if (!roll) return null if (!roll) return null
await roll.toMessage({}, { rollMode: roll.options.rollMode }) await roll.toMessage({}, { messageMode: roll.options.rollMode })
} }
static async #onRollInitiative(event, target) { static async #onRollInitiative(event, target) {
await this.document.system.rollInitiative() await this.document.system.rollInitiative()
} }
static #onArmorHitPointsPlus(event, target) { static async #onArmorHitPointsPlus(event, target) {
let armorHP = this.actor.system.combat.armorHitPoints let armorHP = this.actor.system.combat.armorHitPoints
armorHP += 1 armorHP += 1
this.actor.update({ "system.combat.armorHitPoints": armorHP }) await this.actor.update({ "system.combat.armorHitPoints": armorHP })
} }
static #onArmorHitPointsMinus(event, target) { static async #onArmorHitPointsMinus(event, target) {
let armorHP = this.actor.system.combat.armorHitPoints let armorHP = this.actor.system.combat.armorHitPoints
armorHP -= 1 armorHP -= 1
this.actor.update({ "system.combat.armorHitPoints": Math.max(armorHP, 0) }) await this.actor.update({ "system.combat.armorHitPoints": Math.max(armorHP, 0) })
} }
static #onDivinityPointsPlus(event, target) { static async #onDivinityPointsPlus(event, target) {
let points = this.actor.system.divinityPoints.value let points = this.actor.system.divinityPoints.value
points += 1 points += 1
points = Math.min(points, this.actor.system.divinityPoints.max) points = Math.min(points, this.actor.system.divinityPoints.max)
this.actor.update({ "system.divinityPoints.value": points }) await this.actor.update({ "system.divinityPoints.value": points })
} }
static #onDivinityPointsMinus(event, target) { static async #onDivinityPointsMinus(event, target) {
let points = this.actor.system.divinityPoints.value let points = this.actor.system.divinityPoints.value
points -= 1 points -= 1
points = Math.max(points, 0) points = Math.max(points, 0)
this.actor.update({ "system.divinityPoints.value": points }) await this.actor.update({ "system.divinityPoints.value": points })
} }
static #onAetherPointsPlus(event, target) { static async #onAetherPointsPlus(event, target) {
let points = this.actor.system.aetherPoints.value let points = this.actor.system.aetherPoints.value
points += 1 points += 1
points = Math.min(points, this.actor.system.aetherPoints.max) points = Math.min(points, this.actor.system.aetherPoints.max)
this.actor.update({ "system.aetherPoints.value": points }) await this.actor.update({ "system.aetherPoints.value": points })
} }
static #onAetherPointsMinus(event, target) { static async #onAetherPointsMinus(event, target) {
let points = this.actor.system.aetherPoints.value let points = this.actor.system.aetherPoints.value
points -= 1 points -= 1
points = Math.max(points, 0) points = Math.max(points, 0)
this.actor.update({ "system.aetherPoints.value": points }) await this.actor.update({ "system.aetherPoints.value": points })
}
/**
* Handles spell damage roll from the spell sheet tab.
* Shows a DR dialog then rolls the appropriate damage formula.
* @param {PointerEvent} event
* @param {HTMLElement} target
*/
static async #onRollSpellDamage(event, target) {
if (this.isEditMode) return
const itemId = target.dataset.itemId
const tier = target.dataset.damageTier
const spell = this.actor.items.get(itemId)
if (!spell) return
const formulaMap = {
standard: spell.system.damageDice,
overpowered: spell.system.damageDiceOverpowered,
overpowered2: spell.system.damageDiceOverpowered2,
}
const formula = formulaMap[tier]
if (!formula) return
const manualDR = await foundry.applications.api.DialogV2.wait({
window: { title: game.i18n.localize("LETHALFANTASY.Combat.spellDRDialogTitle") },
classes: ["lethalfantasy"],
position: { width: 320 },
content: `<div style="padding:0.5rem 0">
<p style="margin-bottom:0.6rem">${game.i18n.localize("LETHALFANTASY.Combat.spellDRDialogMsg")}</p>
<div style="display:flex;align-items:center;gap:0.5rem">
<label style="font-weight:bold">${game.i18n.localize("LETHALFANTASY.Combat.spellDRLabel")}</label>
<input type="number" name="manualDr" value="0" min="0" style="width:5rem"/>
</div>
</div>`,
buttons: [
{
action: "noDR",
type: "button",
label: game.i18n.localize("LETHALFANTASY.Combat.spellNoDR"),
icon: "fa-solid fa-wand-magic-sparkles",
callback: () => 0
},
{
action: "applyDR",
type: "button",
label: game.i18n.localize("LETHALFANTASY.Combat.spellApplyDR"),
icon: "fa-solid fa-shield",
callback: (event, button) => Number(button.form?.elements?.manualDr?.value) || 0
},
{
action: "cancel",
type: "button",
label: game.i18n.localize("LETHALFANTASY.Combat.proceedNo"),
callback: () => "cancel"
}
],
rejectClose: false
})
if (manualDR === null || manualDR === "cancel") return
const rollOpts = {
type: "spell-damage",
rollType: "spell-damage",
rollName: `${spell.name}${formula}`,
isDamage: true,
rollData: { isDamage: true },
manualDR,
actorId: this.actor.id,
actorName: this.actor.name,
actorImage: this.actor.img
}
await LethalFantasyRoll.rollSpellDamageToMessage(formula, rollOpts)
} }
static #onCreateEquipment(event, target) { static #onCreateEquipment(event, target) {
} }
_onRender(context, options) { _onRender(context, options) {
// Inputs with class `item-quantity`
const woundDescription = this.element.querySelectorAll('.wound-data') const woundDescription = this.element.querySelectorAll('.wound-data')
for (const input of woundDescription) { for (const input of woundDescription) {
input.addEventListener("change", (e) => { input.addEventListener("change", async (e) => {
e.preventDefault(); e.preventDefault();
e.stopImmediatePropagation(); e.stopImmediatePropagation();
const newValue = e.currentTarget.value const newValue = e.currentTarget.value
@@ -234,11 +306,11 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
const fieldName = e.currentTarget.dataset.name const fieldName = e.currentTarget.dataset.name
let tab = foundry.utils.duplicate(this.actor.system.hp.wounds) let tab = foundry.utils.duplicate(this.actor.system.hp.wounds)
tab[index][fieldName] = newValue tab[index][fieldName] = newValue
console.log(tab, index, fieldName, newValue) log(tab, index, fieldName, newValue)
this.actor.update({ "system.hp.wounds": tab }); await this.actor.update({ "system.hp.wounds": tab });
}) })
} }
super._onRender(); super._onRender(context, options);
} }
@@ -259,9 +331,11 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
async _onRoll(event, target) { async _onRoll(event, target) {
if (this.isEditMode) return if (this.isEditMode) return
const rollType = event.target.dataset.rollType const el = event.currentTarget
let rollKey = event.target.dataset.rollKey; const rollType = el.dataset.rollType
let rollDice = event.target.dataset?.rollDice; if (!rollType) return
let rollKey = el.dataset.rollKey
let rollDice = el.dataset.rollDice
this.actor.prepareRoll(rollType, rollKey, rollDice) this.actor.prepareRoll(rollType, rollKey, rollDice)
+5 -3
View File
@@ -91,7 +91,7 @@ export default class LethalFantasyMonsterSheet extends LethalFantasyActorSheet {
*/ */
async _onDrop(event) { async _onDrop(event) {
if (!this.isEditable || !this.isEditMode) return if (!this.isEditable || !this.isEditMode) return
const data = TextEditor.getDragEventData(event) const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event)
// Handle different data types // Handle different data types
switch (data.type) { switch (data.type) {
@@ -111,11 +111,13 @@ export default class LethalFantasyMonsterSheet extends LethalFantasyActorSheet {
}) })
if (!roll) return null if (!roll) return null
await roll.toMessage({}, { rollMode: roll.options.rollMode }) await roll.toMessage({}, { messageMode: roll.options.rollMode })
} }
static async #onRollInitiative(event, target) { static async #onRollInitiative(event, target) {
await this.document.system.rollInitiative(event, target) const combat = game.combat
const combatant = combat?.combatants.find(c => c.actorId === this.document.id)
await this.document.system.rollInitiative(combat?.id, combatant?.id)
} }
getBestWeaponClassSkill(skills, rollType, multiplier = 1.0) { getBestWeaponClassSkill(skills, rollType, multiplier = 1.0) {
+88 -89
View File
@@ -73,20 +73,6 @@
], ],
"description": "Possible Lethal or Vital Magical Strike or Add D20E to Spell Attack" "description": "Possible Lethal or Vital Magical Strike or Add D20E to Spell Attack"
}, },
"arcane_spell_defense": {
"type": "choice",
"choices": [
{
"type": "spell_calamity"
},
{
"type": "bonus_dice",
"dice": "D20E",
"target": "spell_defense"
}
],
"description": "Possible Spell Catastrophe or adds D20E to Spell Defense"
},
"skill_rolls": { "skill_rolls": {
"type": "skill_auto_success", "type": "skill_auto_success",
"description": "Skill Succeeds Regardless of Opposing Roll" "description": "Skill Succeeds Regardless of Opposing Roll"
@@ -108,6 +94,20 @@
} }
], ],
"description": "Possible Flawless or Legendary Defense or Add D20E to Defense" "description": "Possible Flawless or Legendary Defense or Add D20E to Defense"
},
"arcane_spell_defense": {
"type": "choice",
"choices": [
{
"type": "spell_calamity"
},
{
"type": "bonus_dice",
"dice": "D20E",
"target": "spell_defense"
}
],
"description": "Possible Spell Catastrophe or adds D20E to Spell Defense"
} }
}, },
"29": { "29": {
@@ -131,11 +131,6 @@
"amount": 1, "amount": 1,
"description": "Gain 1 Grit" "description": "Gain 1 Grit"
}, },
"arcane_spell_defense": {
"type": "gain_grit",
"amount": 1,
"description": "Gain 1 Grit"
},
"skill_rolls": { "skill_rolls": {
"type": "gain_grit", "type": "gain_grit",
"amount": 1, "amount": 1,
@@ -145,6 +140,11 @@
"type": "gain_grit", "type": "gain_grit",
"amount": 1, "amount": 1,
"description": "Gain 1 Grit" "description": "Gain 1 Grit"
},
"arcane_spell_defense": {
"type": "gain_grit",
"amount": 1,
"description": "Gain 1 Grit"
} }
}, },
"28": { "28": {
@@ -175,16 +175,16 @@
"type": "no_lethargy", "type": "no_lethargy",
"description": "No Spell Lethargy the Aether Approves of Characters Efforts" "description": "No Spell Lethargy the Aether Approves of Characters Efforts"
}, },
"ranged_defense": {
"type": "luck_die",
"scope": "combat",
"description": "Granted 1 Luck dice for Use in This Combat Only"
},
"arcane_spell_defense": { "arcane_spell_defense": {
"type": "flash_of_pain", "type": "flash_of_pain",
"duration_dice": "1D6E", "duration_dice": "1D6E",
"target": "caster", "target": "caster",
"description": "Caster Suffers Severe pain and will be under a flash of pain for 1D6E seconds" "description": "Caster Suffers Severe pain and will be under a flash of pain for 1D6E seconds"
},
"ranged_defense": {
"type": "luck_die",
"scope": "combat",
"description": "Granted 1 Luck dice for Use in This Combat Only"
} }
}, },
"26": { "26": {
@@ -224,12 +224,6 @@
"target": "defender", "target": "defender",
"description": "Magical Damage inflicts Flash of pain 1D6E seconds" "description": "Magical Damage inflicts Flash of pain 1D6E seconds"
}, },
"arcane_spell_defense": {
"type": "flash_of_pain",
"duration_dice": "1D6E",
"target": "caster",
"description": "Caster Suffers Severe pain and will be under a flash of pain for 1D6E seconds"
},
"skill_rolls": { "skill_rolls": {
"type": "bonus_dice", "type": "bonus_dice",
"dice": "D6", "dice": "D6",
@@ -239,6 +233,12 @@
"ranged_defense": { "ranged_defense": {
"type": "recover_pain", "type": "recover_pain",
"description": "Defender Recovers or ignores any flash of pain" "description": "Defender Recovers or ignores any flash of pain"
},
"arcane_spell_defense": {
"type": "flash_of_pain",
"duration_dice": "1D6E",
"target": "caster",
"description": "Caster Suffers Severe pain and will be under a flash of pain for 1D6E seconds"
} }
}, },
"20": { "20": {
@@ -310,23 +310,6 @@
], ],
"description": "Possible Vicious Application of a Magical Attack or add D12 to attack" "description": "Possible Vicious Application of a Magical Attack or add D12 to attack"
}, },
"arcane_spell_defense": {
"type": "choice",
"choices": [
{
"type": "special_defense",
"options": [
"perfect_spell"
]
},
{
"type": "bonus_dice",
"dice": "D12",
"target": "spell_defense"
}
],
"description": "Possible 20/20 Spell defense that Saves Against Any Magical Attack Except a Lethal Magical Strike or add D12 to defense"
},
"skill_rolls": { "skill_rolls": {
"type": "bonus_flat", "type": "bonus_flat",
"amount": 20, "amount": 20,
@@ -349,6 +332,23 @@
} }
], ],
"description": "Possible 20/20 defense that avoids Any Attack Except a Lethal Strike or adds D12 to defense" "description": "Possible 20/20 defense that avoids Any Attack Except a Lethal Strike or adds D12 to defense"
},
"arcane_spell_defense": {
"type": "choice",
"choices": [
{
"type": "special_defense",
"options": [
"perfect_spell"
]
},
{
"type": "bonus_dice",
"dice": "D12",
"target": "spell_defense"
}
],
"description": "Possible 20/20 Spell defense that Saves Against Any Magical Attack Except a Lethal Magical Strike or add D12 to spell defense"
} }
}, },
"15": { "15": {
@@ -359,10 +359,10 @@
"type": "bleed" "type": "bleed"
}, },
{ {
"type": "knockback" "type": "internal_injury"
} }
], ],
"description": "Bleed, Knock-back on Hit" "description": "Bleed, Internal Injury on Hit"
}, },
"ranged_attack": { "ranged_attack": {
"type": "bleed", "type": "bleed",
@@ -372,10 +372,9 @@
"type": "counter_attack", "type": "counter_attack",
"options": [ "options": [
"kick", "kick",
"punch", "punch"
"shield_bash"
], ],
"description": "Kick, Punch or Shield Bash" "description": "Kick or Punch"
}, },
"skill_rolls": { "skill_rolls": {
"type": "bonus_flat", "type": "bonus_flat",
@@ -387,10 +386,9 @@
"type": "counter_attack", "type": "counter_attack",
"options": [ "options": [
"kick", "kick",
"punch", "punch"
"shield_bash"
], ],
"description": "Kick, Punch or Shield Bash" "description": "Kick or Punch"
} }
}, },
"13": {}, "13": {},
@@ -398,7 +396,7 @@
"melee_attack": { "melee_attack": {
"type": "flurry", "type": "flurry",
"condition": "hit_or_miss", "condition": "hit_or_miss",
"description": "Flurry Attack or Hit to Miss" "description": "Flurry Attack on Hit or Miss"
}, },
"ranged_attack": { "ranged_attack": {
"type": "double_damage_dice", "type": "double_damage_dice",
@@ -413,10 +411,10 @@
"type": "bleed" "type": "bleed"
}, },
{ {
"type": "knockback" "type": "internal_injury"
} }
], ],
"description": "Bleed, Knock-back on Hit" "description": "Bleed, Internal Injury on Hit"
}, },
"ranged_attack": { "ranged_attack": {
"type": "bleed", "type": "bleed",
@@ -426,10 +424,9 @@
"type": "counter_attack", "type": "counter_attack",
"options": [ "options": [
"kick", "kick",
"punch", "punch"
"shield_bash"
], ],
"description": "Kick, Punch or Shield Bash" "description": "Kick or Punch"
}, },
"skill_rolls": { "skill_rolls": {
"type": "bonus_flat", "type": "bonus_flat",
@@ -441,10 +438,9 @@
"type": "counter_attack", "type": "counter_attack",
"options": [ "options": [
"kick", "kick",
"punch", "punch"
"shield_bash"
], ],
"description": "Kick, Punch or Shield Bash" "description": "Kick or Punch"
} }
}, },
"8": { "8": {
@@ -464,10 +460,6 @@
"type": "mulligan", "type": "mulligan",
"description": "Mulligan, Can Re-Roll This Spell Attack" "description": "Mulligan, Can Re-Roll This Spell Attack"
}, },
"arcane_spell_defense": {
"type": "mulligan",
"description": "Mulligan, Can Re-Roll This Spell Defense"
},
"skill_rolls": { "skill_rolls": {
"type": "mulligan", "type": "mulligan",
"description": "Mulligan, Can Re-Roll This Skill roll" "description": "Mulligan, Can Re-Roll This Skill roll"
@@ -475,6 +467,10 @@
"ranged_defense": { "ranged_defense": {
"type": "mulligan", "type": "mulligan",
"description": "Mulligan, Can Choose to Re-Roll This Defense" "description": "Mulligan, Can Choose to Re-Roll This Defense"
},
"arcane_spell_defense": {
"type": "mulligan",
"description": "Mulligan, Can Re-Roll This Spell Defense"
} }
}, },
"7": { "7": {
@@ -496,10 +492,10 @@
"type": "bleed" "type": "bleed"
}, },
{ {
"type": "knockback" "type": "internal_injury"
} }
], ],
"description": "Bleed, Knock-back on Hit" "description": "Bleed, Internal Injury on Hit"
}, },
"ranged_attack": { "ranged_attack": {
"type": "bleed", "type": "bleed",
@@ -509,10 +505,9 @@
"type": "counter_attack", "type": "counter_attack",
"options": [ "options": [
"kick", "kick",
"punch", "punch"
"shield_bash"
], ],
"description": "Kick, Punch, or Shield Bash" "description": "Kick or Punch"
}, },
"skill_rolls": { "skill_rolls": {
"type": "bonus_flat", "type": "bonus_flat",
@@ -524,10 +519,9 @@
"type": "counter_attack", "type": "counter_attack",
"options": [ "options": [
"kick", "kick",
"punch", "punch"
"shield_bash"
], ],
"description": "Kick, Punch, or Shield Bash" "description": "Kick or Punch"
} }
}, },
"3": { "3": {
@@ -552,17 +546,17 @@
"multiplier": 3, "multiplier": 3,
"description": "Triple Damage on Spell Damage" "description": "Triple Damage on Spell Damage"
}, },
"arcane_spell_defense": {
"type": "bonus_dice",
"dice": "D12",
"target": "spell_defense",
"description": "D12 Added to Spell Defense Modifier"
},
"ranged_defense": { "ranged_defense": {
"type": "dr_multiplier", "type": "dr_multiplier",
"multiplier": 3, "multiplier": 3,
"includes_shield": true, "includes_shield": true,
"description": "DR Tripled including Shield" "description": "DR Tripled including Shield"
},
"arcane_spell_defense": {
"type": "bonus_dice",
"dice": "D12",
"target": "spell_defense",
"description": "D12 Added to Spell Defense Modifier"
} }
}, },
"2": { "2": {
@@ -587,17 +581,17 @@
"multiplier": 2, "multiplier": 2,
"description": "Double Damage on Spell Damage" "description": "Double Damage on Spell Damage"
}, },
"arcane_spell_defense": {
"type": "bonus_dice",
"dice": "D6",
"target": "spell_defense",
"description": "D6 Added to Spell Defense Modifier"
},
"ranged_defense": { "ranged_defense": {
"type": "dr_multiplier", "type": "dr_multiplier",
"multiplier": 2, "multiplier": 2,
"includes_shield": true, "includes_shield": true,
"description": "DR Doubled including Shield" "description": "DR Doubled including Shield"
},
"arcane_spell_defense": {
"type": "bonus_dice",
"dice": "D6",
"target": "spell_defense",
"description": "D6 Added to Spell Defense Modifier"
} }
}, },
"1": { "1": {
@@ -608,7 +602,12 @@
}, },
"arcane_spell_attack": { "arcane_spell_attack": {
"type": "spell_calamity", "type": "spell_calamity",
"description": "Possible Spell Calamity or Catastrophe" "description": "A possible spell calamity has occurred"
},
"melee_attack": {
"type": "fumble",
"detail": "melee_fumble",
"description": "Possible Fumble"
} }
} }
}, },
+9 -1
View File
@@ -85,11 +85,18 @@ export const RANGE_CHOICES = {
"pointblank": { label: "Point Blank (Special)", value: "pointblank" }, "pointblank": { label: "Point Blank (Special)", value: "pointblank" },
"short": { label: "Short (+0)", value: "0" }, "short": { label: "Short (+0)", value: "0" },
"medium": { label: "Medium (Red +5)", value: "+5" }, "medium": { label: "Medium (Red +5)", value: "+5" },
"long": { label: "Long (Purle +7)", value: "+7" }, "long": { label: "Long (Purple +7)", value: "+7" },
"extreme": { label: "Extreme (Grey +9)", value: "+9" }, "extreme": { label: "Extreme (Grey +9)", value: "+9" },
"beyondskill": { label: "Beyond Skill (Blue +11)", value: "beyondskill" } "beyondskill": { label: "Beyond Skill (Blue +11)", value: "beyondskill" }
} }
export const ATTACKER_MOVEMENT_CHOICES = {
"none": { label: "None / Stationary (D20E Favor)", favor: true, value: "2D20kh" },
"walk": { label: "Walk (D20E)", value: "D20" },
"incombat": { label: "In Combat (D20E)", value: "D20" },
"run": { label: "Jog/Run/Sprint (D20E Disfavor)", disfavor: true, value: "2D20kl" }
}
export const ATTACKER_AIM_CHOICES = { export const ATTACKER_AIM_CHOICES = {
"simple": { label: "Simple (+0)", value: "0" }, "simple": { label: "Simple (+0)", value: "0" },
"careful": { label: "Careful (Red +5)", value: "+4" }, "careful": { label: "Careful (Red +5)", value: "+4" },
@@ -321,6 +328,7 @@ export const SYSTEM = {
RANGE_CHOICES, RANGE_CHOICES,
FAVOR_CHOICES, FAVOR_CHOICES,
ATTACKER_AIM_CHOICES, ATTACKER_AIM_CHOICES,
ATTACKER_MOVEMENT_CHOICES,
MORTAL_CHOICES, MORTAL_CHOICES,
SPELL_CRITICAL, SPELL_CRITICAL,
MIRACLE_TYPES, MIRACLE_TYPES,
+71 -17
View File
@@ -72,23 +72,32 @@ export default class LethalFantasyActor extends Actor {
/* *************************************************/ /* *************************************************/
async applyDamage(hpLoss) { async applyDamage(hpLoss) {
let hp = this.system.hp.value + hpLoss let hp = this.system.hp.value + hpLoss
if (hp < 0) { await this.update({ "system.hp.value": hp })
hp = 0
} }
this.update({ "system.hp.value": hp })
/* *************************************************/
getNaturalDR() {
if (this.type === "monster") {
return Number(this.system.hp?.damageResistance) || 0
}
return Number(this.system.biodata?.naturalDR) || 0
}
/* *************************************************/
getMagicDR() {
if (this.type === "monster") return 0
return Number(this.system.biodata?.magicDR) || 0
} }
/* *************************************************/ /* *************************************************/
computeDamageReduction() { computeDamageReduction() {
// Pour les monstres, utiliser hp.damageResistance et combat.damageReduction
if (this.type === "monster") { if (this.type === "monster") {
let hpDR = Number(this.system.hp?.damageResistance) || 0 let hpDR = this.getNaturalDR()
let combatDR = Number(this.system.combat?.damageReduction) || 0 let combatDR = Number(this.system.combat?.damageReduction) || 0
return hpDR + combatDR return hpDR + combatDR
} }
// Pour les personnages, utiliser biodata et items let naturalDR = this.getNaturalDR()
let naturalDR = Number(this.system.biodata?.naturalDR) || 0 let magicDR = this.getMagicDR()
let magicDR = Number(this.system.biodata?.magicDR) || 0
let armorDR = this.getArmorDR() let armorDR = this.getArmorDR()
return naturalDR + magicDR + armorDR return naturalDR + magicDR + armorDR
} }
@@ -153,8 +162,8 @@ export default class LethalFantasyActor extends Actor {
} }
/* *************************************************/ /* *************************************************/
async prepareRoll(rollType, rollKey, rollDice, defenderId, defenderTokenId, extraShieldDr = 0) { async prepareRoll(rollType, rollKey, rollDice, defenderId, defenderTokenId, extraShieldDr = 0, d30Effects = {}) {
console.log("Preparing roll", rollType, rollKey, rollDice, defenderId) log("Preparing roll", rollType, rollKey, rollDice, defenderId)
let rollTarget let rollTarget
switch (rollType) { switch (rollType) {
case "granted": case "granted":
@@ -196,8 +205,53 @@ export default class LethalFantasyActor extends Actor {
case "spell-power": case "spell-power":
case "miracle-attack": case "miracle-attack":
case "miracle-power": case "miracle-power":
rollTarget = this.items.find((i) => (i.type === "miracle" || i.type == "spell") && i.id === rollKey) rollTarget = foundry.utils.duplicate(this.items.find((i) => (i.type === "miracle" || i.type == "spell") && i.id === rollKey))
rollTarget.rollKey = rollKey rollTarget.rollKey = rollKey
// Read damage tier from combatant currentAction if available
const activeCombatant = game.combat?.combatants?.find(c => c.actorId === this.id)
const currentAction = activeCombatant?.getFlag(SYSTEM.id, "currentAction")
let damageTier = currentAction?.damageTier
// No tier from combat action — prompt the user if multiple tiers exist
if (!damageTier) {
const tierMap = { standard: "damageDice", overpowered: "damageDiceOverpowered", overpowered2: "damageDiceOverpowered2" }
const available = Object.entries(tierMap).filter(([k, v]) => rollTarget.system?.[v])
if (available.length > 1) {
const buttons = available.map(([id]) => ({
action: id,
type: "button",
label: id.charAt(0).toUpperCase() + id.slice(1),
callback: () => id,
}))
damageTier = await foundry.applications.api.DialogV2.wait({
window: { title: "Choose spell tier" },
classes: ["lethalfantasy"],
content: `<p>Select the power level for <strong>${rollTarget.name}</strong>:</p>`,
buttons,
rejectClose: false,
}) || "standard"
} else {
damageTier = "standard"
}
}
rollTarget.damageTier = damageTier
if (rollType === "spell-attack" || rollType === "spell-power") {
const tierCostMap = { standard: "cost", overpowered: "costOverpowered", overpowered2: "costOverpowered2" }
const costField = tierCostMap[damageTier] || "cost"
const cost = Number(rollTarget.system?.[costField]) || 0
const currentAether = Number(this.system.aetherPoints?.value) || 0
if (cost > currentAether) {
ui.notifications.warn(`${this.name} cannot cast ${rollTarget.name}: insufficient Aether (needs ${cost}, has ${currentAether}).`)
return
}
}
if (rollType === "miracle-attack" || rollType === "miracle-power") {
const cost = Number(rollTarget.system?.level) || 0
const currentGrace = Number(this.system.divinityPoints?.value) || 0
if (cost > currentGrace) {
ui.notifications.warn(`${this.name} cannot invoke ${rollTarget.name}: insufficient Grace (needs ${cost}, has ${currentGrace}).`)
return
}
}
break break
case "shield-roll": { case "shield-roll": {
rollTarget = this.items.find((i) => i.type === "shield" && i.id === rollKey) rollTarget = this.items.find((i) => i.type === "shield" && i.id === rollKey)
@@ -206,8 +260,7 @@ export default class LethalFantasyActor extends Actor {
rollTarget.rollKey = rollKey rollTarget.rollKey = rollKey
} }
break; break;
case "weapon-damage-small": case "weapon-damage":
case "weapon-damage-medium":
case "weapon-attack": case "weapon-attack":
case "weapon-defense": { case "weapon-defense": {
let weapon = this.items.find((i) => i.type === "weapon" && i.id === rollKey) let weapon = this.items.find((i) => i.type === "weapon" && i.id === rollKey)
@@ -245,9 +298,10 @@ export default class LethalFantasyActor extends Actor {
weapon: weapon, weapon: weapon,
weaponSkillModifier: skill.weaponSkillModifier, weaponSkillModifier: skill.weaponSkillModifier,
rollKey: rollKey, rollKey: rollKey,
combat: foundry.utils.duplicate(this.system.combat) combat: foundry.utils.duplicate(this.system.combat),
isRangedAttack: weapon.system.weaponType === "ranged"
} }
if (rollType === "weapon-damage-small" || rollType === "weapon-damage-medium") { if (rollType === "weapon-damage") {
rollTarget.grantedDice = this.system.granted.damageDice rollTarget.grantedDice = this.system.granted.damageDice
} }
if (rollType === "weapon-attack") { if (rollType === "weapon-attack") {
@@ -263,14 +317,14 @@ export default class LethalFantasyActor extends Actor {
break break
default: default:
ui.notifications.error(game.i18n.localize("LETHALFANTASY.Notifications.rollTypeNotFound") + String(rollType)) ui.notifications.error(game.i18n.localize("LETHALFANTASY.Notifications.rollTypeNotFound") + String(rollType))
break return
} }
// In all cases // In all cases
rollTarget.magicUser = this.system.biodata.magicUser rollTarget.magicUser = this.system.biodata.magicUser
rollTarget.actorModifiers = foundry.utils.duplicate(this.system.modifiers) rollTarget.actorModifiers = foundry.utils.duplicate(this.system.modifiers)
rollTarget.actorLevel = this.system.biodata.level rollTarget.actorLevel = this.system.biodata.level
await this.system.roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr) await this.system.roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr, d30Effects)
} }
} }
+16 -10
View File
@@ -1,3 +1,5 @@
import { log } from "../utils.mjs"
/** /**
* Classe pour gérer les résultats du D30 dans Lethal Fantasy * Classe pour gérer les résultats du D30 dans Lethal Fantasy
*/ */
@@ -40,7 +42,7 @@ export default class D30Roll {
this.resultsTable = data.d30_dice_results this.resultsTable = data.d30_dice_results
this.definitions = data.definitions this.definitions = data.definitions
console.log("D30Roll | D30 results table loaded successfully") log("D30Roll | D30 results table loaded successfully")
} catch (error) { } catch (error) {
console.error("D30Roll | Error loading D30 table:", error) console.error("D30Roll | Error loading D30 table:", error)
ui.notifications.error("Unable to load D30 results table") ui.notifications.error("Unable to load D30 results table")
@@ -111,17 +113,16 @@ export default class D30Roll {
if (externalType === "weapon-attack") { if (externalType === "weapon-attack") {
if (!weapon) { if (!weapon) {
console.warn("D30Roll | Weapon object required for weapon-attack type") console.warn("D30Roll | Weapon object required for weapon-attack type")
return this.ROLL_TYPES.MELEE_ATTACK // Default to melee // Fall through to use options.isRanged if available, otherwise default melee
} }
return weapon.system?.weaponType === "ranged" return (options.isRanged || weapon?.system?.weaponType === "ranged")
? this.ROLL_TYPES.RANGED_ATTACK ? this.ROLL_TYPES.RANGED_ATTACK
: this.ROLL_TYPES.MELEE_ATTACK : this.ROLL_TYPES.MELEE_ATTACK
} }
// Monster attacks - default to melee // Monster attacks - check options.isRanged (set from rollTarget.attackMode) or weapon type
if (externalType === "monster-attack") { if (externalType === "monster-attack") {
// Check if weapon object has range information if (options.isRanged || weapon?.system?.weaponType === "ranged") {
if (weapon?.system?.weaponType === "ranged") {
return this.ROLL_TYPES.RANGED_ATTACK return this.ROLL_TYPES.RANGED_ATTACK
} }
return this.ROLL_TYPES.MELEE_ATTACK return this.ROLL_TYPES.MELEE_ATTACK
@@ -132,17 +133,22 @@ export default class D30Roll {
return options.isRanged ? this.ROLL_TYPES.RANGED_DEFENSE : this.ROLL_TYPES.MELEE_DEFENSE return options.isRanged ? this.ROLL_TYPES.RANGED_DEFENSE : this.ROLL_TYPES.MELEE_DEFENSE
} }
// Spell types // Spell/Miracle types
if (externalType === "spell-attack" || externalType === "spell" || externalType === "spell-power") { if (externalType === "spell-attack" || externalType === "spell" || externalType === "spell-power"
|| externalType === "miracle-attack" || externalType === "miracle" || externalType === "miracle-power") {
return this.ROLL_TYPES.ARCANE_SPELL_ATTACK return this.ROLL_TYPES.ARCANE_SPELL_ATTACK
} }
// Skill types // Skill types
if (externalType === "skill" || externalType === "monster-skill" || if (externalType === "skill" || externalType === "monster-skill" || externalType === "challenge") {
externalType === "save" || externalType === "challenge") {
return this.ROLL_TYPES.SKILL_ROLLS return this.ROLL_TYPES.SKILL_ROLLS
} }
// Saving throw types
if (externalType === "save") {
return this.ROLL_TYPES.ARCANE_SPELL_DEFENSE
}
// If no match, return null // If no match, return null
console.warn(`D30Roll | Unknown external roll type: ${externalType}`) console.warn(`D30Roll | Unknown external roll type: ${externalType}`)
return null return null
+332 -73
View File
@@ -127,6 +127,7 @@ export default class LethalFantasyRoll extends Roll {
* @returns {Promise<Object|null>} The roll result or null if the dialog was cancelled. * @returns {Promise<Object|null>} The roll result or null if the dialog was cancelled.
*/ */
static async prompt(options = {}) { static async prompt(options = {}) {
try {
let dice = "1D20" let dice = "1D20"
let maxValue = 20 let maxValue = 20
let baseFormula = "1D20" let baseFormula = "1D20"
@@ -139,7 +140,7 @@ export default class LethalFantasyRoll extends Roll {
let hasGrantedDice = false let hasGrantedDice = false
let pointBlank = false let pointBlank = false
let letItFly = false let letItFly = false
let saveSpell = false let saveSpell = game.lethalFantasy?.spellDefense ?? false
let beyondSkill = false let beyondSkill = false
let hasStaticModifier = false let hasStaticModifier = false
let hasExplode = true let hasExplode = true
@@ -237,6 +238,7 @@ export default class LethalFantasyRoll extends Roll {
baseFormula = "D20" baseFormula = "D20"
hasModifier = true hasModifier = true
hasChangeDice = false hasChangeDice = false
hasFavor = true
options.rollTarget.value = options.rollTarget.actorModifiers.levelSpellModifier + options.rollTarget.actorModifiers.intSpellModifier options.rollTarget.value = options.rollTarget.actorModifiers.levelSpellModifier + options.rollTarget.actorModifiers.intSpellModifier
options.rollTarget.charModifier = options.rollTarget.actorModifiers.intSpellModifier options.rollTarget.charModifier = options.rollTarget.actorModifiers.intSpellModifier
hasStaticModifier = options.rollType === "spell-power" hasStaticModifier = options.rollType === "spell-power"
@@ -253,6 +255,7 @@ export default class LethalFantasyRoll extends Roll {
dice = "1D20" dice = "1D20"
baseFormula = "D20" baseFormula = "D20"
hasChangeDice = false hasChangeDice = false
hasFavor = true
options.rollTarget.value = options.rollTarget.actorModifiers.levelMiracleModifier + options.rollTarget.actorModifiers.chaMiracleModifier options.rollTarget.value = options.rollTarget.actorModifiers.levelMiracleModifier + options.rollTarget.actorModifiers.chaMiracleModifier
options.rollTarget.charModifier = options.rollTarget.actorModifiers.chaMiracleModifier options.rollTarget.charModifier = options.rollTarget.actorModifiers.chaMiracleModifier
hasStaticModifier = options.rollType === "miracle-power" hasStaticModifier = options.rollType === "miracle-power"
@@ -272,6 +275,7 @@ export default class LethalFantasyRoll extends Roll {
hasChangeDice = false hasChangeDice = false
hasMaxValue = false hasMaxValue = false
hasExplode = false hasExplode = false
hasFavor = true
options.rollTarget.value = 0 options.rollTarget.value = 0
} else if (options.rollType.includes("weapon-damage")) { } else if (options.rollType.includes("weapon-damage")) {
@@ -282,13 +286,7 @@ export default class LethalFantasyRoll extends Roll {
let damageBonus = (options.rollTarget.weapon.system.applyStrengthDamageBonus) ? options.rollTarget.combat.damageModifier : 0 let damageBonus = (options.rollTarget.weapon.system.applyStrengthDamageBonus) ? options.rollTarget.combat.damageModifier : 0
options.rollTarget.value = damageBonus + options.rollTarget.weaponSkillModifier + options.rollTarget.weapon.system.bonuses.damageBonus options.rollTarget.value = damageBonus + options.rollTarget.weaponSkillModifier + options.rollTarget.weapon.system.bonuses.damageBonus
options.rollTarget.charModifier = damageBonus options.rollTarget.charModifier = damageBonus
if (options.rollType.includes("small")) {
options.damageSmall = true
dice = options.rollTarget.weapon.system.damage.damageS
} else {
options.damageMedium = true
dice = options.rollTarget.weapon.system.damage.damageM dice = options.rollTarget.weapon.system.damage.damageM
}
if (/NE$/i.test(dice)) { if (/NE$/i.test(dice)) {
hasMaxValue = false hasMaxValue = false
hasExplode = false hasExplode = false
@@ -319,8 +317,8 @@ export default class LethalFantasyRoll extends Roll {
hasModifier = false hasModifier = false
} }
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)])) const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes);
console.log("Roll mode", rollModes)
const fieldRollMode = new foundry.data.fields.StringField({ const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes, choices: rollModes,
@@ -335,6 +333,10 @@ export default class LethalFantasyRoll extends Roll {
let modifier = "+0" let modifier = "+0"
let targetName let targetName
// True for any ranged attack: PC weapon (ranged type) or monster attack (ranged mode)
const isRangedAttack = (options.rollType === "weapon-attack" && options.rollTarget?.weapon?.system?.weaponType === "ranged")
|| (options.rollType === "monster-attack" && options.rollTarget?.attackMode === "ranged")
let dialogContext = { let dialogContext = {
rollType: options.rollType, rollType: options.rollType,
rollTarget: options.rollTarget, rollTarget: options.rollTarget,
@@ -357,9 +359,10 @@ export default class LethalFantasyRoll extends Roll {
dice, dice,
hasTarget: options.hasTarget, hasTarget: options.hasTarget,
modifier, modifier,
saveSpell: false, saveSpell,
favor: "none", favor: "none",
targetName targetName,
isRangedAttack
} }
let rollContext let rollContext
if (options.rollContext) { if (options.rollContext) {
@@ -369,7 +372,9 @@ export default class LethalFantasyRoll extends Roll {
beyondSkill = !!rollContext.beyondSkill beyondSkill = !!rollContext.beyondSkill
letItFly = !!rollContext.letItFly letItFly = !!rollContext.letItFly
saveSpell = !!rollContext.saveSpell saveSpell = !!rollContext.saveSpell
rollContext.visibility ||= rollContext.rollMode || game.settings.get("core", "rollMode") const _rawMode = rollContext.rollMode || game.settings.get("core", "rollMode")
const _modeMap = { publicroll: "public", gmroll: "gm", blindroll: "blind", selfroll: "self" }
rollContext.visibility ||= _modeMap[_rawMode] ?? _rawMode ?? "public"
rollContext.modifier ||= modifier rollContext.modifier ||= modifier
rollContext.favor ||= "none" rollContext.favor ||= "none"
rollContext.changeDice ||= `${dice}` rollContext.changeDice ||= `${dice}`
@@ -386,10 +391,12 @@ export default class LethalFantasyRoll extends Roll {
position, position,
buttons: [ buttons: [
{ {
action: "roll",
type: "button",
label: label, label: label,
callback: (event, button, dialog) => { callback: (event, button, dialog) => {
console.log("Roll context", event, button, dialog) log("Roll context", event, button, dialog)
let position = dialog.position let position = dialog?.position
game.user.setFlag(SYSTEM.id, "roll-dialog-pos", foundry.utils.duplicate(position)) game.user.setFlag(SYSTEM.id, "roll-dialog-pos", foundry.utils.duplicate(position))
const output = Array.from(button.form.elements).reduce((obj, input) => { const output = Array.from(button.form.elements).reduce((obj, input) => {
if (input.name) obj[input.name] = input.value if (input.name) obj[input.name] = input.value
@@ -400,22 +407,22 @@ export default class LethalFantasyRoll extends Roll {
}, },
], ],
actions: { actions: {
"selectGranted": (event, button, dialog) => { "selectGranted": (event, button) => {
hasGrantedDice = event.target.checked hasGrantedDice = event.target.checked
}, },
"selectBeyondSkill": (event, button, dialog) => { "selectBeyondSkill": (event, button) => {
beyondSkill = button.checked beyondSkill = button.checked
}, },
"selectPointBlank": (event, button, dialog) => { "selectPointBlank": (event, button) => {
pointBlank = button.checked pointBlank = button.checked
}, },
"selectLetItFly": (event, button, dialog) => { "selectLetItFly": (event, button) => {
letItFly = button.checked letItFly = button.checked
}, },
"saveSpellCheck": (event, button, dialog) => { "saveSpellCheck": (event, button) => {
saveSpell = button.checked saveSpell = button.checked
}, },
"gotoToken": (event, button, dialog) => { "gotoToken": (event, button) => {
let tokenId = $(button).data("tokenId") let tokenId = $(button).data("tokenId")
let token = canvas.tokens?.get(tokenId) let token = canvas.tokens?.get(tokenId)
if (token) { if (token) {
@@ -431,7 +438,7 @@ export default class LethalFantasyRoll extends Roll {
// If the user cancels the dialog, exit // If the user cancels the dialog, exit
if (rollContext === null) return if (rollContext === null) return
console.log("rollContext", rollContext, hasGrantedDice) log("rollContext", rollContext, hasGrantedDice)
rollContext.saveSpell = saveSpell // Update fucking flag rollContext.saveSpell = saveSpell // Update fucking flag
let fullModifier = 0 let fullModifier = 0
@@ -440,7 +447,7 @@ export default class LethalFantasyRoll extends Roll {
if (hasModifier) { if (hasModifier) {
let bonus = Number(options.rollTarget.value) let bonus = Number(options.rollTarget.value)
fullModifier = rollContext.modifier === "" ? 0 : parseInt(rollContext.modifier, 10) + bonus fullModifier = rollContext.modifier === "" ? 0 : parseInt(rollContext.modifier, 10) + bonus
fullModifier += (rollContext.saveSpell) ? options.rollTarget.actorModifiers.saveModifier : 0 fullModifier += (rollContext.saveSpell) ? (options.rollTarget.actorModifiers?.saveModifier ?? 0) : 0
if (Number(rollContext.attackerAim) > 0) { if (Number(rollContext.attackerAim) > 0) {
fullModifier += Number(rollContext.attackerAim) fullModifier += Number(rollContext.attackerAim)
} }
@@ -519,8 +526,6 @@ export default class LethalFantasyRoll extends Roll {
rollMode: rollContext.visibility, rollMode: rollContext.visibility,
hasTarget: options.hasTarget, hasTarget: options.hasTarget,
isDamage: options.isDamage, isDamage: options.isDamage,
damageSmall: options.damageSmall,
damageMedium: options.damageMedium,
pointBlank, pointBlank,
beyondSkill, beyondSkill,
letItFly, letItFly,
@@ -550,7 +555,7 @@ export default class LethalFantasyRoll extends Roll {
if (rollContext.favor === "favor") { if (rollContext.favor === "favor") {
rollFavor = new this(baseFormula, options.data, rollData) rollFavor = new this(baseFormula, options.data, rollData)
await rollFavor.evaluate() await rollFavor.evaluate()
console.log("Rolling with favor", rollFavor) log("Rolling with favor", rollFavor)
if (game?.dice3d) { if (game?.dice3d) {
game.dice3d.showForRoll(rollFavor, game.user, true) game.dice3d.showForRoll(rollFavor, game.user, true)
} }
@@ -589,12 +594,17 @@ export default class LethalFantasyRoll extends Roll {
} }
options.D30result = rollD30.total options.D30result = rollD30.total
// Récupérer le message D30 correspondant // Compute isRanged for D30: covers defense (isRangedDefense), monster ranged attacks (attackMode),
// and PC weapon attacks (isRangedAttack or weaponType)
const isRangedForD30 = options.isRangedDefense
|| options.rollTarget?.attackMode === "ranged"
|| options.rollTarget?.isRangedAttack === true
|| options.rollTarget?.weapon?.system?.weaponType === "ranged"
const d30Message = D30Roll.getResult( const d30Message = D30Roll.getResult(
rollD30.total, rollD30.total,
options.rollType, options.rollType,
options.rollTarget?.weapon, options.rollTarget?.weapon,
{ isRanged: options.isRangedDefense } { isRanged: isRangedForD30, isSpellSave: saveSpell }
) )
options.D30message = d30Message options.D30message = d30Message
} }
@@ -606,19 +616,20 @@ export default class LethalFantasyRoll extends Roll {
let singleDice = `1D${maxValue}` let singleDice = `1D${maxValue}`
for (let i = 0; i < rollBase.dice.length; i++) { for (let i = 0; i < rollBase.dice.length; i++) {
for (let j = 0; j < rollBase.dice[i].results.length; j++) { const dieResults = rollBase.dice[i].results
let diceResult = rollBase.dice[i].results[j].result const resultCount = dieResults.length
for (let j = 0; j < resultCount; j++) {
let diceResult = dieResults[j].result
diceResults.push({ dice: `${singleDice.toUpperCase()}`, value: diceResult }) diceResults.push({ dice: `${singleDice.toUpperCase()}`, value: diceResult })
diceSum += diceResult diceSum += diceResult
if (hasMaxValue) { if (hasMaxValue) {
while (diceResult === maxValue) { while (diceResult === maxValue) {
let r = await new Roll(baseFormula).evaluate() let r = await new Roll(baseFormula).evaluate()
if (game?.dice3d) {
await game.dice3d.showForRoll(r, game.user, true)
}
diceResult = r.dice[0].results[0].result diceResult = r.dice[0].results[0].result
diceResults.push({ dice: `${singleDice.toUpperCase()}-1`, value: diceResult - 1 }) diceResults.push({ dice: `${singleDice.toUpperCase()}-1`, value: diceResult - 1 })
diceSum += (diceResult - 1) diceSum += (diceResult - 1)
// Add to DieTerm results so DSN/Foundry display shows explosion dice
dieResults.push({ result: diceResult, active: true })
} }
} }
} }
@@ -658,6 +669,10 @@ export default class LethalFantasyRoll extends Roll {
rollBase.options.defenderId = options.defenderId rollBase.options.defenderId = options.defenderId
rollBase.options.defenderTokenId = options.defenderTokenId rollBase.options.defenderTokenId = options.defenderTokenId
rollBase.options.extraShieldDr = options.extraShieldDr || 0 rollBase.options.extraShieldDr = options.extraShieldDr || 0
rollBase.options.damageTier = options.damageTier || "standard"
rollBase.options.d30Bleed = options.d30Bleed || false
rollBase.options.d30DamageMultiplier = options.d30DamageMultiplier || 1
rollBase.options.d30DrMultiplier = options.d30DrMultiplier || 1
/** /**
* A hook event that fires after the roll has been made. * A hook event that fires after the roll has been made.
@@ -671,11 +686,15 @@ export default class LethalFantasyRoll extends Roll {
if (Hooks.call("fvtt-lethal-fantasy.Roll", options, rollData, rollBase) === false) return if (Hooks.call("fvtt-lethal-fantasy.Roll", options, rollData, rollBase) === false) return
return rollBase return rollBase
} finally {
// Clear one-shot flag so it doesn't leak to subsequent non-spell saves
if (game.lethalFantasy) game.lethalFantasy.spellDefense = false
}
} }
/* ***********************************************************/ /* ***********************************************************/
static async promptInitiative(options = {}) { static async promptInitiative(options = {}) {
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)])) const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
const fieldRollMode = new foundry.data.fields.StringField({ const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes, choices: rollModes,
blank: false, blank: false,
@@ -706,8 +725,10 @@ export default class LethalFantasyRoll extends Roll {
content, content,
buttons: [ buttons: [
{ {
action: "initiative",
type: "button",
label: label, label: label,
callback: (event, button, dialog) => { callback: (event, button) => {
const output = Array.from(button.form.elements).reduce((obj, input) => { const output = Array.from(button.form.elements).reduce((obj, input) => {
if (input.name) obj[input.name] = input.value if (input.name) obj[input.name] = input.value
return obj return obj
@@ -729,7 +750,7 @@ export default class LethalFantasyRoll extends Roll {
let initRoll = new Roll(formula, options.data) let initRoll = new Roll(formula, options.data)
await initRoll.evaluate() await initRoll.evaluate()
let msg = await initRoll.toMessage({ flavor: `Initiative for ${options.actorName}` }, { rollMode: rollContext.visibility }) let msg = await initRoll.toMessage({ flavor: `Initiative for ${options.actorName}` }, { messageMode: rollContext.visibility })
if (game?.dice3d && initRoll.dice?.length) { if (game?.dice3d && initRoll.dice?.length) {
await game.dice3d.waitFor3DAnimationByMessageID(msg.id) await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
} }
@@ -743,7 +764,7 @@ export default class LethalFantasyRoll extends Roll {
/* ***********************************************************/ /* ***********************************************************/
static async promptCombatAction(options = {}) { static async promptCombatAction(options = {}) {
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)])) const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
const fieldRollMode = new foundry.data.fields.StringField({ const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes, choices: rollModes,
blank: false, blank: false,
@@ -772,10 +793,20 @@ export default class LethalFantasyRoll extends Roll {
let buttons = [] let buttons = []
if (currentAction) { if (currentAction) {
if (currentAction.type === "weapon") { if (currentAction.type === "weapon") {
let weaponLabel = "Roll progression dice"
if (currentAction.rangedMode) {
// Compute loading count from the speed formula (e.g. "3+1d6" → load=3)
const speedStr = currentAction.system?.speed?.[currentAction.rangedMode] ?? ""
const rangedLoad = currentAction.rangedLoad ?? (Number(speedStr.split("+")[0]) || 0)
if (rangedLoad > 0 && !currentAction.weaponLoaded) {
weaponLabel = "Load weapon"
}
}
buttons.push({ buttons.push({
action: "roll", action: "roll",
label: "Roll progression dice", type: "button",
callback: (event, button, dialog) => { label: weaponLabel,
callback: (event, button) => {
let pos = $('#combat-action-dialog').position() let pos = $('#combat-action-dialog').position()
game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", pos) game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", pos)
return "rollProgressionDice" return "rollProgressionDice"
@@ -800,8 +831,9 @@ export default class LethalFantasyRoll extends Roll {
} }
buttons.push({ buttons.push({
action: "roll", action: "roll",
type: "button",
label: label, label: label,
callback: (event, button, dialog) => { callback: (event, button) => {
let pos = $('#combat-action-dialog').position() let pos = $('#combat-action-dialog').position()
game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", foundry.utils.duplicate(pos)) game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", foundry.utils.duplicate(pos))
return "rollLethargyDice" return "rollLethargyDice"
@@ -811,8 +843,9 @@ export default class LethalFantasyRoll extends Roll {
} else { } else {
buttons.push({ buttons.push({
action: "roll", action: "roll",
type: "button",
label: "Select action", label: "Select action",
callback: (event, button, dialog) => { callback: (event, button) => {
let pos = $('#combat-action-dialog').position() let pos = $('#combat-action-dialog').position()
game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", foundry.utils.duplicate(pos)) game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", foundry.utils.duplicate(pos))
const output = Array.from(button.form.elements).reduce((obj, input) => { const output = Array.from(button.form.elements).reduce((obj, input) => {
@@ -826,8 +859,9 @@ export default class LethalFantasyRoll extends Roll {
} }
buttons.push({ buttons.push({
action: "cancel", action: "cancel",
type: "button",
label: "Other action, not listed here", label: "Other action, not listed here",
callback: (event, button, dialog) => { callback: (event, button) => {
let pos = $('#combat-action-dialog').position() let pos = $('#combat-action-dialog').position()
game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", foundry.utils.duplicate(pos)) game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", foundry.utils.duplicate(pos))
return null; return null;
@@ -844,12 +878,12 @@ export default class LethalFantasyRoll extends Roll {
rejectClose: false // Click on Close button will not launch an error rejectClose: false // Click on Close button will not launch an error
}) })
console.log("RollContext", dialogContext, rollContext) log("RollContext", dialogContext, rollContext)
// If action is cancelled, exit // If action is cancelled, exit
if (rollContext === null || rollContext === "cancel") { if (rollContext === null || rollContext === "cancel") {
await combatant.setFlag(SYSTEM.id, "currentAction", "") await combatant.setFlag(SYSTEM.id, "currentAction", "")
let message = `${combatant.name} : Other action, progression reset` let message = `${combatant.name} : Other action, progression reset`
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) }) await ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
return return
} }
@@ -879,12 +913,36 @@ export default class LethalFantasyRoll extends Roll {
actionItem.progressionCount = firstActionTaken ? 1 : (combatant.actor.system.combat?.combatProgressionStart ?? 1) actionItem.progressionCount = firstActionTaken ? 1 : (combatant.actor.system.combat?.combatProgressionStart ?? 1)
if (!firstActionTaken) await combatant.setFlag(SYSTEM.id, "firstActionTaken", true) if (!firstActionTaken) await combatant.setFlag(SYSTEM.id, "firstActionTaken", true)
actionItem.rangedMode = rangedMode actionItem.rangedMode = rangedMode
// If this is a spell/miracle with multiple damage tiers, prompt tier choice
if (actionItem.system?.damageDice) {
const tiers = [
{ id: "standard", label: "Standard", dice: actionItem.system.damageDice },
{ id: "overpowered", label: "Overpowered", dice: actionItem.system.damageDiceOverpowered },
{ id: "overpowered2", label: "Overpowered 2", dice: actionItem.system.damageDiceOverpowered2 },
].filter(t => t.dice)
if (tiers.length > 1) {
const tierChoice = await foundry.applications.api.DialogV2.wait({
window: { title: "Choose Damage Tier" },
classes: ["lethalfantasy"],
content: `<div class="grit-luck-dialog"><p><strong>${selectedItem.name}</strong> has multiple damage tiers.</p><p>Choose which damage to use when the attack lands:</p></div>`,
buttons: tiers.map(t => ({
action: t.id,
type: "button",
label: `${t.label} (${t.dice.toUpperCase()})`,
icon: "fa-solid fa-wand-magic-sparkles",
callback: () => t.id
})),
rejectClose: false
})
actionItem.damageTier = tierChoice || "standard"
}
}
actionItem.castingTime = 1 actionItem.castingTime = 1
actionItem.spellStatus = "castingTime" actionItem.spellStatus = "castingTime"
// Set the flag on the combatant // Set the flag on the combatant
await combatant.setFlag(SYSTEM.id, "currentAction", actionItem) await combatant.setFlag(SYSTEM.id, "currentAction", actionItem)
let message = `${combatant.name} action : ${selectedItem.name}, start rolling progression dice or casting time` let message = `${combatant.name} action : ${selectedItem.name}, start rolling progression dice or casting time`
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) }) await ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
rollContext = (actionItem.type === "weapon") ? "rollProgressionDice" : "rollLethargyDice" // Set the roll context to rollProgressionDice rollContext = (actionItem.type === "weapon") ? "rollProgressionDice" : "rollLethargyDice" // Set the roll context to rollProgressionDice
currentAction = actionItem currentAction = actionItem
} }
@@ -895,13 +953,14 @@ export default class LethalFantasyRoll extends Roll {
let time = currentAction.type === "spell" ? currentAction.system.castingTime : currentAction.system.prayerTime let time = currentAction.type === "spell" ? currentAction.system.castingTime : currentAction.system.prayerTime
if (currentAction.castingTime < time) { if (currentAction.castingTime < time) {
let message = `Casting time : ${currentAction.name}, count : ${currentAction.castingTime}/${time}` let message = `Casting time : ${currentAction.name}, count : ${currentAction.castingTime}/${time}`
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) }) await ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
currentAction.castingTime += 1 currentAction.castingTime += 1
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction)) await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
return return
} else { } else {
let message = `Spell/Miracle ${currentAction.name} ready to be cast on next second !` // Last counting second — announce ready and transition immediately (no extra second consumed)
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) }) let message = `Casting time : ${currentAction.name}, count : ${time}/${time} — ready to cast next second !`
await ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
currentAction.castingTime = 1 currentAction.castingTime = 1
currentAction.spellStatus = "toBeCasted" currentAction.spellStatus = "toBeCasted"
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction)) await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
@@ -941,7 +1000,7 @@ export default class LethalFantasyRoll extends Roll {
isLethargy: true isLethargy: true
} }
) )
ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) }) await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
// Update the combatant progression count // Update the combatant progression count
await combatant.setFlag(SYSTEM.id, "currentAction", "") await combatant.setFlag(SYSTEM.id, "currentAction", "")
// Display the action selection window again // Display the action selection window again
@@ -961,7 +1020,7 @@ export default class LethalFantasyRoll extends Roll {
isLethargy: true isLethargy: true
} }
) )
ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) }) await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
} }
} }
} }
@@ -973,18 +1032,18 @@ export default class LethalFantasyRoll extends Roll {
let split = toSplit.split("+") let split = toSplit.split("+")
currentAction.rangedLoad = Number(split[0]) || 0 currentAction.rangedLoad = Number(split[0]) || 0
formula = split[1] formula = split[1]
console.log("Ranged Mode", currentAction.rangedMode, currentAction.rangedLoad, formula) log("Ranged Mode", currentAction.rangedMode, currentAction.rangedLoad, formula)
} }
// Range weapon loading // Range weapon loading
if (!currentAction.weaponLoaded && currentAction.rangedLoad) { if (!currentAction.weaponLoaded && currentAction.rangedLoad) {
if (currentAction.progressionCount <= currentAction.rangedLoad) { if (currentAction.progressionCount < currentAction.rangedLoad) {
let message = `Ranged weapon ${currentAction.name} is loading, loading count : ${currentAction.progressionCount}/${currentAction.rangedLoad}` let message = `Ranged weapon ${currentAction.name} is loading, loading count : ${currentAction.progressionCount}/${currentAction.rangedLoad}`
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) }) await ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
currentAction.progressionCount += 1 currentAction.progressionCount += 1
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction)) await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
} else { } else {
let message = `Ranged weapon ${currentAction.name} is loaded !` let message = `Ranged weapon ${currentAction.name} is loaded !`
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) }) await ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
currentAction.weaponLoaded = true currentAction.weaponLoaded = true
currentAction.progressionCount = 1 currentAction.progressionCount = 1
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction)) await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
@@ -1000,7 +1059,7 @@ export default class LethalFantasyRoll extends Roll {
let max = roll.dice[0].faces - 1 let max = roll.dice[0].faces - 1
max = Math.min(currentAction.progressionCount, max) max = Math.min(currentAction.progressionCount, max)
let msg = await roll.toMessage({ flavor: `Progression Roll for ${currentAction.name}, progression count : ${currentAction.progressionCount}/${max}` }, { rollMode: rollContext.visibility }) let msg = await roll.toMessage({ flavor: `Progression Roll for ${currentAction.name}, progression count : ${currentAction.progressionCount}/${max}` }, { messageMode: rollContext.visibility })
if (game?.dice3d) { if (game?.dice3d) {
await game.dice3d.waitFor3DAnimationByMessageID(msg.id) await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
} }
@@ -1016,13 +1075,13 @@ export default class LethalFantasyRoll extends Roll {
rollResult: roll.total rollResult: roll.total
} }
) )
ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) }) await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
await combatant.setFlag(SYSTEM.id, "currentAction", "") await combatant.setFlag(SYSTEM.id, "currentAction", "")
combatant.actor.prepareRoll(currentAction.type === "weapon" ? "weapon-attack" : "spell-attack", currentAction._id) combatant.actor.prepareRoll(currentAction.type === "weapon" ? "weapon-attack" : "spell-attack", currentAction._id)
} else { } else {
// Notify that the player cannot act now with a chat message // Notify that the player cannot act now with a chat message
currentAction.progressionCount += 1 currentAction.progressionCount += 1
combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction)) await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
const messageContent = await foundry.applications.handlebars.renderTemplate( const messageContent = await foundry.applications.handlebars.renderTemplate(
"systems/fvtt-lethal-fantasy/templates/progression-message.hbs", "systems/fvtt-lethal-fantasy/templates/progression-message.hbs",
{ {
@@ -1033,7 +1092,7 @@ export default class LethalFantasyRoll extends Roll {
progressionCount: currentAction.progressionCount progressionCount: currentAction.progressionCount
} }
) )
ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) }) await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
} }
} }
} }
@@ -1042,7 +1101,7 @@ export default class LethalFantasyRoll extends Roll {
/* ***********************************************************/ /* ***********************************************************/
static async promptRangedDefense(options = {}) { static async promptRangedDefense(options = {}) {
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes); const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes);
const fieldRollMode = new foundry.data.fields.StringField({ const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes, choices: rollModes,
blank: false, blank: false,
@@ -1073,8 +1132,10 @@ export default class LethalFantasyRoll extends Roll {
content, content,
buttons: [ buttons: [
{ {
action: "rangeDefense",
type: "button",
label: label, label: label,
callback: (event, button, dialog) => { callback: (event, button) => {
const output = Array.from(button.form.elements).reduce((obj, input) => { const output = Array.from(button.form.elements).reduce((obj, input) => {
if (input.name) obj[input.name] = input.value if (input.name) obj[input.name] = input.value
return obj return obj
@@ -1089,7 +1150,7 @@ export default class LethalFantasyRoll extends Roll {
// If the user cancels the dialog, exit // If the user cancels the dialog, exit
if (rollContext === null) return if (rollContext === null) return
console.log("RollContext", rollContext) log("RollContext", rollContext)
// Add disfavor/favor option if point blank range // Add disfavor/favor option if point blank range
if (rollContext.range === "pointblank") { if (rollContext.range === "pointblank") {
rollContext.movement = rollContext.movement.replace("kh", "") rollContext.movement = rollContext.movement.replace("kh", "")
@@ -1123,6 +1184,8 @@ export default class LethalFantasyRoll extends Roll {
options = { ...options, ...rollContext } options = { ...options, ...rollContext }
options.rollName = "Ranged Defense" options.rollName = "Ranged Defense"
options.rollType = "weapon-defense" options.rollType = "weapon-defense"
options.type = options.rollType // Required: this.type reads options.type
options.rollMode = rollContext.visibility // Required: callers pass roll.options.rollMode to toMessage
const rollBase = new this(rollContext.movement, options.data, rollData) const rollBase = new this(rollContext.movement, options.data, rollData)
const rollModifier = new Roll(modifierFormula, options.data, rollData) const rollModifier = new Roll(modifierFormula, options.data, rollData)
@@ -1155,6 +1218,7 @@ export default class LethalFantasyRoll extends Roll {
diceResult = r.dice[0].results[0].result diceResult = r.dice[0].results[0].result
diceResults.push({ dice: `${dice.toUpperCase()}-1`, value: diceResult - 1 }) diceResults.push({ dice: `${dice.toUpperCase()}-1`, value: diceResult - 1 })
diceSum += (diceResult - 1) diceSum += (diceResult - 1)
rollBase.dice[0].results.push({ result: diceResult, active: true })
} }
if (fullModifier !== 0) { if (fullModifier !== 0) {
diceResults.push({ dice: `${rollModifier.formula.toUpperCase()}`, value: rollModifier.total }) diceResults.push({ dice: `${rollModifier.formula.toUpperCase()}`, value: rollModifier.total })
@@ -1190,6 +1254,164 @@ export default class LethalFantasyRoll extends Roll {
return rollBase return rollBase
} }
/**
* Prompts the GM for ranged attack context (movement, range, target size, aim) when a monster
* attacks with a ranged weapon, then evaluates an exploding D20 attack roll with the resulting modifiers.
*
* @param {Object} options Options for the roll.
* @param {string} options.actorId The attacker actor ID.
* @param {string} options.actorName The attacker actor name.
* @param {Object} options.rollTarget The rollTarget containing attackModifier and related data.
* @returns {Promise<LethalFantasyRoll|null>} The resulting roll, or null if cancelled.
*/
static async promptRangedAttack(options = {}) {
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes)
const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes,
blank: false,
default: "public",
})
let dialogContext = {
attackerMovementChoices: SYSTEM.ATTACKER_MOVEMENT_CHOICES,
rangeChoices: SYSTEM.RANGE_CHOICES,
sizeChoices: SYSTEM.SIZE_CHOICES,
attackerAimChoices: SYSTEM.ATTACKER_AIM_CHOICES,
movement: "none",
range: "short",
size: "+5",
attackerAim: "simple",
fieldRollMode,
rollModes
}
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/range-attack-dialog.hbs", dialogContext)
const label = game.i18n.localize("LETHALFANTASY.Label.rangeAttackRoll")
const rollContext = await foundry.applications.api.DialogV2.wait({
window: { title: "Ranged Attack" },
classes: ["lethalfantasy"],
content,
buttons: [
{
action: "rangedAttack",
type: "button",
label,
callback: (event, button) => {
const output = Array.from(button.form.elements).reduce((obj, input) => {
if (input.name) obj[input.name] = input.value
return obj
}, {})
return output
},
},
],
rejectClose: false
})
if (rollContext === null) return null
// Handle pointblank: attacker at point blank gets favor (standing still easier to aim)
if (rollContext.range === "pointblank") {
rollContext.movement = rollContext.movement.replace("kh", "")
rollContext.movement = rollContext.movement.replace("kl", "")
rollContext.movement += "kh" // Favor for attacker at point blank
rollContext.range = "0"
}
// Handle beyondskill: extreme range gives disfavor to attacker
if (rollContext.range === "beyondskill") {
rollContext.movement = rollContext.movement.replace("kh", "")
rollContext.movement = rollContext.movement.replace("kl", "")
rollContext.movement += "kl" // Disfavor for attacker beyond skill range
rollContext.range = "+11"
}
// Compute contextual penalty: range + target_size, reduced by aim bonus and attack modifier
const attackModifier = options.rollTarget?.attackModifier ?? 0
const contextualPenalty = Number(rollContext.range) + Number(rollContext.size)
const aimBonus = Number(rollContext.attackerAim || 0)
const fullModifier = contextualPenalty - aimBonus - attackModifier
let modifierFormula
if (fullModifier === 0) {
modifierFormula = "0"
} else {
const modAbs = Math.abs(fullModifier)
modifierFormula = `D${modAbs + 1} -1`
}
const rollData = { ...rollContext }
options = { ...options, ...rollContext }
options.rollName = "Ranged Attack"
options.rollType = options.rollType || "monster-attack"
options.type = options.rollType // Required: this.type reads options.type, used to build weaponDamageOptions in toHTML
options.rollMode = rollContext.visibility // Required: callers pass roll.options.rollMode to toMessage
options.isRangedAttack = true
const rollBase = new this(rollContext.movement, options.data, rollData)
const rollModifier = new Roll(modifierFormula, options.data, rollData)
rollModifier.evaluate()
await rollBase.evaluate()
const rollD30 = await new Roll("1D30").evaluate()
options.D30result = rollD30.total
options.D30message = D30Roll.getResult(rollD30.total, options.rollType, undefined, { isRanged: true })
// Determine favor from dice formula
let badResult = 0
if (rollContext.movement.includes("kh")) {
rollData.favor = "favor"
badResult = Math.min(rollBase.terms[0].results[0].result, rollBase.terms[0].results[1]?.result || 20)
}
if (rollContext.movement.includes("kl")) {
rollData.favor = "disfavor"
badResult = Math.max(rollBase.terms[0].results[0].result, rollBase.terms[0].results[1]?.result || 1)
}
const dice = rollContext.movement
const maxValue = 20
let rollTotal = -1
let diceResults = []
let diceResult = rollBase.dice[0].results[0].result
diceResults.push({ dice: `${dice.toUpperCase()}`, value: diceResult })
let diceSum = diceResult
// Exploding dice
while (diceResult === maxValue) {
const r = await new Roll(dice).evaluate()
diceResult = r.dice[0].results[0].result
diceResults.push({ dice: `${dice.toUpperCase()}-1`, value: diceResult - 1 })
diceSum += (diceResult - 1)
rollBase.dice[0].results.push({ result: diceResult, active: true })
}
if (fullModifier !== 0) {
diceResults.push({ dice: `${rollModifier.formula.toUpperCase()}`, value: rollModifier.total })
if (fullModifier > 0) {
// Net penalty: subtract from roll
rollTotal = Math.max(diceSum - rollModifier.total, 0)
} else {
// Net bonus: add to roll
rollTotal = diceSum + rollModifier.total
}
} else {
rollTotal = diceSum
}
rollBase.options = { ...rollBase.options, ...options }
rollBase.options.resultType = undefined
rollBase.options.rollTotal = rollTotal
rollBase.options.diceResults = diceResults
rollBase.options.rollTarget = options.rollTarget
rollBase.options.titleFormula = `1D20E + ${modifierFormula}`
rollBase.options.D30result = options.D30result
rollBase.options.D30message = options.D30message
rollBase.options.rollName = "Ranged Attack"
rollBase.options.badResult = badResult
rollBase.options.rollData = foundry.utils.duplicate(rollData)
return rollBase
}
/** /**
* Creates a title based on the given type. * Creates a title based on the given type.
* *
@@ -1210,10 +1432,8 @@ export default class LethalFantasyRoll extends Roll {
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-attack")}` return `${game.i18n.localize("LETHALFANTASY.Label.weapon-attack")}`
case "weapon-defense": case "weapon-defense":
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-defense")}` return `${game.i18n.localize("LETHALFANTASY.Label.weapon-defense")}`
case "weapon-damage-small": case "weapon-damage":
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-damage-small")}` return `${game.i18n.localize("LETHALFANTASY.Label.weapon-damage")}`
case "weapon-damage-medium":
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-damage-medium")}`
case "spell": case "spell":
case "spell-attack": case "spell-attack":
case "spell-power": case "spell-power":
@@ -1230,7 +1450,7 @@ export default class LethalFantasyRoll extends Roll {
/** @override */ /** @override */
async render(chatOptions = {}) { async render(chatOptions = {}) {
let chatData = await this._getChatCardData(chatOptions.isPrivate) let chatData = await this._getChatCardData(chatOptions.isPrivate)
console.log("ChatData", chatData) log("ChatData", chatData)
return await foundry.applications.handlebars.renderTemplate(this.constructor.CHAT_TEMPLATE, chatData) return await foundry.applications.handlebars.renderTemplate(this.constructor.CHAT_TEMPLATE, chatData)
} }
@@ -1268,16 +1488,15 @@ export default class LethalFantasyRoll extends Roll {
// Récupérer les informations de l'arme pour les attaques réussies // Récupérer les informations de l'arme pour les attaques réussies
let weaponDamageOptions = null let weaponDamageOptions = null
console.log("Roll type:", this.type, "rollTarget:", this.rollTarget, "Has weapon:", !!this.rollTarget?.weapon) log("Roll type:", this.type, "rollTarget:", this.rollTarget, "Has weapon:", !!this.rollTarget?.weapon)
if (this.type === "weapon-attack" && this.rollTarget?.weapon) { if (this.type === "weapon-attack" && this.rollTarget?.weapon) {
const weapon = this.rollTarget.weapon const weapon = this.rollTarget.weapon
weaponDamageOptions = { weaponDamageOptions = {
weaponId: weapon._id || weapon.id, weaponId: weapon.id,
weaponName: weapon.name, weaponName: weapon.name,
damageS: weapon.system?.damage?.damageS,
damageM: weapon.system?.damage?.damageM damageM: weapon.system?.damage?.damageM
} }
console.log("Weapon damage options:", weaponDamageOptions) log("Weapon damage options:", weaponDamageOptions)
} else if (this.type === "monster-attack" && this.rollTarget) { } else if (this.type === "monster-attack" && this.rollTarget) {
weaponDamageOptions = { weaponDamageOptions = {
weaponId: this.rollTarget.rollKey, weaponId: this.rollTarget.rollKey,
@@ -1286,7 +1505,7 @@ export default class LethalFantasyRoll extends Roll {
damageModifier: this.rollTarget.damageModifier, damageModifier: this.rollTarget.damageModifier,
isMonster: true isMonster: true
} }
console.log("Monster damage options:", weaponDamageOptions) log("Monster damage options:", weaponDamageOptions)
} }
const cardData = { const cardData = {
@@ -1331,11 +1550,11 @@ export default class LethalFantasyRoll extends Roll {
* *
* @param {Object} [messageData={}] Additional data to include in the message. * @param {Object} [messageData={}] Additional data to include in the message.
* @param {Object} options Options for message creation. * @param {Object} options Options for message creation.
* @param {string} options.rollMode The mode of the roll (e.g., public, private). * @param {string} options.messageMode The mode of the roll (e.g., public, private).
* @param {boolean} [options.create=true] Whether to create the message. * @param {boolean} [options.create=true] Whether to create the message.
* @returns {Promise} - A promise that resolves when the message is created. * @returns {Promise} - A promise that resolves when the message is created.
*/ */
async toMessage(messageData = {}, { rollMode, create = true } = {}) { async toMessage(messageData = {}, { messageMode, create = true } = {}) {
return await super.toMessage( return await super.toMessage(
{ {
isSave: this.isSave, isSave: this.isSave,
@@ -1353,8 +1572,48 @@ export default class LethalFantasyRoll extends Roll {
rollData: this.rollData, rollData: this.rollData,
...messageData, ...messageData,
}, },
{ rollMode, create }, { messageMode, create },
) )
} }
/**
* Evaluate a spell/miracle damage formula with per-die explosion, then post to chat.
* Explosion dice are shown manually via showForRoll; the main roll is shown automatically
* by toMessage() (which triggers Dice So Nice via its createChatMessage hook).
* Append "NE" to the formula to disable explosion.
*
* @param {string} formula Dice formula, e.g. "1d8", "2d6", "1d8NE"
* @param {Object} rollOpts Options for LethalFantasyRoll (rollType, actorId, defenderId, etc.)
* @returns {Promise<ChatMessage>}
*/
static async rollSpellDamageToMessage(formula, rollOpts) {
const roll = new LethalFantasyRoll(formula, {}, rollOpts)
await roll.evaluate()
const shouldExplode = !/NE$/i.test(formula)
const diceResults = []
let diceSum = 0
for (const term of roll.dice) {
const singleDice = `1D${term.faces}`
const termResults = Array.from(term.results)
for (const r of termResults) {
let diceResult = r.result
diceResults.push({ dice: singleDice.toUpperCase(), value: diceResult })
diceSum += diceResult
if (shouldExplode && term.faces > 0) {
while (diceResult === term.faces) {
const xr = await new Roll(singleDice).evaluate()
// Optional chaining guards against unexpected roll structure
diceResult = xr.dice?.[0]?.results?.[0]?.result ?? (term.faces - 1)
diceResults.push({ dice: `${singleDice.toUpperCase()}-1`, value: diceResult - 1 })
diceSum += (diceResult - 1)
term.results.push({ result: diceResult, active: true })
}
}
}
}
roll.options.diceResults = diceResults
roll.options.rollTotal = diceSum
return roll.toMessage()
}
} }
+5 -5
View File
@@ -32,20 +32,20 @@ export class Macros {
dropData.rollType === "save" dropData.rollType === "save"
? `game.actors.get('${dropData.actorId}').system.roll('${dropData.rollType}', '${dropData.rollTarget}', '=');` ? `game.actors.get('${dropData.actorId}').system.roll('${dropData.rollType}', '${dropData.rollTarget}', '=');`
: `game.actors.get('${dropData.actorId}').system.roll('${dropData.rollType}', '${dropData.rollTarget}');` : `game.actors.get('${dropData.actorId}').system.roll('${dropData.rollType}', '${dropData.rollTarget}');`
const rollName = `${game.i18n.localize("TENEBRIS.Label.jet")} ${game.i18n.localize(`TENEBRIS.Manager.${dropData.rollTarget}`)}` const rollName = `${game.i18n.localize("LETHALFANTASY.Label.jet")} ${game.i18n.localize(`LETHALFANTASY.Label.${dropData.rollTarget}`)}`
this.createMacro(slot, rollName, rollCommand, "icons/svg/d20-grey.svg") this.createMacro(slot, rollName, rollCommand, "icons/svg/d20-grey.svg")
break break
case "rollDamage": case "rollDamage":
const weapon = game.actors.get(dropData.actorId).items.get(dropData.rollTarget) const weapon = game.actors.get(dropData.actorId).items.get(dropData.rollTarget)
const rollDamageCommand = `game.actors.get('${dropData.actorId}').system.roll('${dropData.rollType}', '${dropData.rollTarget}');` const rollDamageCommand = `game.actors.get('${dropData.actorId}').system.roll('${dropData.rollType}', '${dropData.rollTarget}');`
const rollDamageName = `${game.i18n.localize("TENEBRIS.Label.jet")} ${weapon.name}` const rollDamageName = `${game.i18n.localize("LETHALFANTASY.Label.jet")} ${weapon.name}`
this.createMacro(slot, rollDamageName, rollDamageCommand, weapon.img) this.createMacro(slot, rollDamageName, rollDamageCommand, weapon.img)
break break
case "rollAttack": case "rollAttack":
const rollAttackCommand = `game.actors.get('${dropData.actorId}').system.roll('${dropData.rollValue}', '${dropData.rollTarget}');` const rollAttackCommand = `game.actors.get('${dropData.actorId}').system.roll('${dropData.rollValue}', '${dropData.rollTarget}');`
const rollAttackName = `${game.i18n.localize("TENEBRIS.Label.jet")} ${dropData.rollTarget}` const rollAttackName = `${game.i18n.localize("LETHALFANTASY.Label.jet")} ${dropData.rollTarget}`
this.createMacro(slot, rollAttackName, rollAttackCommand, "icons/svg/d20-grey.svg") this.createMacro(slot, rollAttackName, rollAttackCommand, "icons/svg/d20-grey.svg")
break break
@@ -57,7 +57,7 @@ export class Macros {
/** /**
* Create a macro * Create a macro
* All macros are flaged with a tenebris.macro flag at true * All macros are flaged with a lethalFantasy.macro flag at true
* @param {*} slot * @param {*} slot
* @param {*} name * @param {*} name
* @param {*} command * @param {*} command
@@ -72,7 +72,7 @@ export class Macros {
type: "script", type: "script",
img: img, img: img,
command: command, command: command,
flags: { "tenebris.macro": true }, flags: { "lethalFantasy.macro": true },
}, },
{ displaySheet: false }, { displaySheet: false },
) )
+14 -5
View File
@@ -65,7 +65,7 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
} }
schema.hp = new fields.SchemaField({ schema.hp = new fields.SchemaField({
value: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }), value: new fields.NumberField({ ...requiredInteger, initial: 1 }),
max: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }), max: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }),
painDamage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), painDamage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
wounds: new fields.ArrayField(new fields.SchemaField(woundFieldSchema), { wounds: new fields.ArrayField(new fields.SchemaField(woundFieldSchema), {
@@ -281,7 +281,7 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
* @param {"="|"+"|"++"|"-"|"--"} rollAdvantage If there is an avantage (+), a disadvantage (-), a double advantage (++), a double disadvantage (--) or a normal roll (=). * @param {"="|"+"|"++"|"-"|"--"} rollAdvantage If there is an avantage (+), a disadvantage (-), a double advantage (++), a double disadvantage (--) or a normal roll (=).
* @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled. * @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled.
*/ */
async roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr = 0) { async roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr = 0, d30Effects = {}) {
const hasTarget = false const hasTarget = false
let roll = await LethalFantasyRoll.prompt({ let roll = await LethalFantasyRoll.prompt({
rollType, rollType,
@@ -293,11 +293,15 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
target: false, target: false,
defenderId, defenderId,
defenderTokenId, defenderTokenId,
extraShieldDr extraShieldDr,
damageTier: rollTarget.damageTier || "standard",
d30Bleed: d30Effects.d30Bleed || false,
d30DamageMultiplier: d30Effects.d30DamageMultiplier || 1,
d30DrMultiplier: d30Effects.d30DrMultiplier || 1
}) })
if (!roll) return null if (!roll) return null
await roll.toMessage({}, { rollMode: roll.options.rollMode }) await roll.toMessage({}, { messageMode: roll.options.rollMode })
} }
async rollInitiative(combatId = undefined, combatantId = undefined) { async rollInitiative(combatId = undefined, combatantId = undefined) {
@@ -318,7 +322,7 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
}) })
if (!roll) return null if (!roll) return null
await roll.toMessage({}, { rollMode: roll.options.rollMode }) await roll.toMessage({}, { messageMode: roll.options.rollMode })
} }
async rollProgressionDice(combatId, combatantId, rollProgressionCount) { async rollProgressionDice(combatId, combatantId, rollProgressionCount) {
@@ -356,6 +360,11 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
} }
} }
if (weaponsChoices.length === 0) {
ui.notifications.warn(`${this.parent.name} has no weapons or spells available for combat. Add a weapon to the character sheet first.`)
return
}
let roll = await LethalFantasyRoll.promptCombatAction({ let roll = await LethalFantasyRoll.promptCombatAction({
actorId: this.parent.id, actorId: this.parent.id,
actorName: this.parent.name, actorName: this.parent.name,
+3
View File
@@ -35,6 +35,9 @@ export default class LethalFantasyMiracle extends foundry.abstract.TypeDataModel
schema.attackRoll = new fields.StringField({ required: true, initial: "" }) schema.attackRoll = new fields.StringField({ required: true, initial: "" })
schema.powerRoll = new fields.StringField({ required: true, initial: "" }) schema.powerRoll = new fields.StringField({ required: true, initial: "" })
schema.damageDice = new fields.StringField({ required: false, initial: "" })
schema.damageDiceOverpowered = new fields.StringField({ required: false, initial: "" })
schema.damageDiceOverpowered2 = new fields.StringField({ required: false, initial: "" })
return schema return schema
} }
+53 -16
View File
@@ -56,10 +56,28 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
}, {}), }, {}),
) )
const woundFieldSchema = {
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
duration: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
description: new fields.StringField({ initial: "", required: false, nullable: true }),
}
schema.hp = new fields.SchemaField({ schema.hp = new fields.SchemaField({
value: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }), value: new fields.NumberField({ ...requiredInteger, initial: 1 }),
average: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }), average: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }),
max: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }), max: new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 }),
wounds: new fields.ArrayField(new fields.SchemaField(woundFieldSchema), {
initial: [
{ description: "", value: 0, duration: 0 },
{ description: "", value: 0, duration: 0 },
{ description: "", value: 0, duration: 0 },
{ description: "", value: 0, duration: 0 },
{ description: "", value: 0, duration: 0 },
{ description: "", value: 0, duration: 0 },
{ description: "", value: 0, duration: 0 },
{ description: "", value: 0, duration: 0 }
], min: 8
}),
damageResistance: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), damageResistance: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
painDamage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }) painDamage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
}) })
@@ -164,8 +182,24 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
* @param {"="|"+"|"++"|"-"|"--"} rollAdvantage If there is an avantage (+), a disadvantage (-), a double advantage (++), a double disadvantage (--) or a normal roll (=). * @param {"="|"+"|"++"|"-"|"--"} rollAdvantage If there is an avantage (+), a disadvantage (-), a double advantage (++), a double disadvantage (--) or a normal roll (=).
* @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled. * @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled.
*/ */
async roll(rollType, rollTarget, defenderId = undefined, defenderTokenId = undefined, extraShieldDr = 0) { async roll(rollType, rollTarget, defenderId = undefined, defenderTokenId = undefined, extraShieldDr = 0, d30Effects = {}) {
const hasTarget = false const hasTarget = false
// Ranged monster defense uses the ranged defense dialog (movement, range, size modifiers)
if (rollType === "monster-defense" && rollTarget?.isRangedDefense === true) {
let roll = await LethalFantasyRoll.promptRangedDefense({
actorId: this.parent.id,
actorName: this.parent.name,
actorImage: this.parent.img,
rollTarget,
defenderId,
defenderTokenId,
})
if (!roll) return null
await roll.toMessage({}, { messageMode: roll.options.rollMode })
return
}
let roll = await LethalFantasyRoll.prompt({ let roll = await LethalFantasyRoll.prompt({
rollType, rollType,
rollTarget, rollTarget,
@@ -176,14 +210,18 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
target: false, target: false,
defenderId, defenderId,
defenderTokenId, defenderTokenId,
extraShieldDr extraShieldDr,
damageTier: rollTarget.damageTier || "standard",
d30Bleed: d30Effects.d30Bleed || false,
d30DamageMultiplier: d30Effects.d30DamageMultiplier || 1,
d30DrMultiplier: d30Effects.d30DrMultiplier || 1
}) })
if (!roll) return null if (!roll) return null
await roll.toMessage({}, { rollMode: roll.options.rollMode }) await roll.toMessage({}, { messageMode: roll.options.rollMode })
} }
async prepareMonsterRoll(rollType, rollKey, rollDice = undefined, tokenId = undefined, damageModifier = undefined, defenderId = undefined, defenderTokenId = undefined, extraShieldDr = 0) { async prepareMonsterRoll(rollType, rollKey, rollDice = undefined, tokenId = undefined, damageModifier = undefined, defenderId = undefined, defenderTokenId = undefined, extraShieldDr = 0, d30Effects = {}) {
let rollTarget let rollTarget
switch (rollType) { switch (rollType) {
case "monster-attack": case "monster-attack":
@@ -192,6 +230,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
const attacksSet = this.attackMode === "ranged" ? this.rangedAttacks : this.attacks const attacksSet = this.attackMode === "ranged" ? this.rangedAttacks : this.attacks
rollTarget = foundry.utils.duplicate(attacksSet[rollKey]) rollTarget = foundry.utils.duplicate(attacksSet[rollKey])
rollTarget.rollKey = rollKey rollTarget.rollKey = rollKey
rollTarget.attackMode = this.attackMode
if (rollType === "monster-defense") { if (rollType === "monster-defense") {
rollTarget.isRangedDefense = game.lethalFantasy?.nextDefenseData?.isRanged ?? false rollTarget.isRangedDefense = game.lethalFantasy?.nextDefenseData?.isRanged ?? false
} }
@@ -232,11 +271,10 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
await roll.toMessage({ await roll.toMessage({
flavor, flavor,
speaker: ChatMessage.getSpeaker({ actor: this.parent }) speaker: ChatMessage.getSpeaker({ actor: this.parent })
}) }, { messageMode: roll.options.rollMode ?? game.settings.get("core", "rollMode") })
return return
} }
case "weapon-damage-small": case "weapon-damage":
case "weapon-damage-medium":
case "weapon-attack": case "weapon-attack":
case "weapon-defense": { case "weapon-defense": {
let weapon = this.actor.items.find((i) => i.type === "weapon" && i.id === rollKey) let weapon = this.actor.items.find((i) => i.type === "weapon" && i.id === rollKey)
@@ -269,7 +307,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
return return
} }
rollTarget = skill rollTarget = skill
rollTarget.weapon = weapon rollTarget.weapon = foundry.utils.duplicate(weapon)
rollTarget.weaponSkillModifier = skill.weaponSkillModifier rollTarget.weaponSkillModifier = skill.weaponSkillModifier
rollTarget.rollKey = rollKey rollTarget.rollKey = rollKey
rollTarget.combat = foundry.utils.duplicate(this.combat) rollTarget.combat = foundry.utils.duplicate(this.combat)
@@ -283,8 +321,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
// In all cases // In all cases
if (rollTarget) { if (rollTarget) {
rollTarget.tokenId = tokenId rollTarget.tokenId = tokenId
console.log(rollTarget) await this.roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr, d30Effects)
await this.roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr)
} }
} }
@@ -304,7 +341,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
}) })
if (!roll) return null if (!roll) return null
await roll.toMessage({}, { rollMode: roll.options.rollMode }) await roll.toMessage({}, { messageMode: roll.options.rollMode })
} }
async rollProgressionDice(combatId, combatantId) { async rollProgressionDice(combatId, combatantId) {
@@ -316,7 +353,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
return return
} }
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes) const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes)
const fieldRollMode = new foundry.data.fields.StringField({ const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes, choices: rollModes,
blank: false, blank: false,
@@ -346,7 +383,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
rollResult: roll.total rollResult: roll.total
} }
) )
ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: this.parent }) }) await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: this.parent }) })
let token = combatant?.token let token = combatant?.token
this.prepareMonsterRoll("monster-attack", key, undefined, token?.id) this.prepareMonsterRoll("monster-attack", key, undefined, token?.id)
if (token?.object) { if (token?.object) {
@@ -370,7 +407,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
rollResult: roll.total rollResult: roll.total
} }
) )
ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: this.parent }) }) await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: this.parent }) })
let token = combatant?.token let token = combatant?.token
this.prepareMonsterRoll("monster-attack-hth", key, undefined, token?.id) this.prepareMonsterRoll("monster-attack-hth", key, undefined, token?.id)
if (token?.object) { if (token?.object) {
@@ -389,7 +426,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
rollResult: roll.total rollResult: roll.total
} }
) )
ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: this.parent }) }) await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: this.parent }) })
} }
} }
+4
View File
@@ -19,6 +19,8 @@ export default class LethalFantasySpell extends foundry.abstract.TypeDataModel {
}) })
schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }) schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.costOverpowered = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.costOverpowered2 = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.memorized = new fields.BooleanField({ required: true, initial: false }) schema.memorized = new fields.BooleanField({ required: true, initial: false })
schema.components = new fields.SchemaField({ schema.components = new fields.SchemaField({
@@ -40,6 +42,8 @@ export default class LethalFantasySpell extends foundry.abstract.TypeDataModel {
schema.attackRoll = new fields.StringField({ required: true, initial: "" }) schema.attackRoll = new fields.StringField({ required: true, initial: "" })
schema.powerRoll = new fields.StringField({ required: true, initial: "" }) schema.powerRoll = new fields.StringField({ required: true, initial: "" })
schema.damageDice = new fields.StringField({ required: false, initial: "" }) schema.damageDice = new fields.StringField({ required: false, initial: "" })
schema.damageDiceOverpowered = new fields.StringField({ required: false, initial: "" })
schema.damageDiceOverpowered2 = new fields.StringField({ required: false, initial: "" })
return schema return schema
} }
+6 -5
View File
@@ -1,6 +1,7 @@
import { SYSTEM } from "../config/system.mjs" import { SYSTEM } from "../config/system.mjs"
import { WEAPON_TYPE } from "../config/weapon.mjs"
export default class LethalFantasySkill extends foundry.abstract.TypeDataModel { export default class LethalFantasyWeapon extends foundry.abstract.TypeDataModel {
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields const fields = foundry.data.fields
const schema = {} const schema = {}
@@ -45,9 +46,9 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
}) })
schema.bonuses = new fields.SchemaField({ schema.bonuses = new fields.SchemaField({
attackBonus: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }), attackBonus: new fields.NumberField({ ...requiredInteger, required: true, initial: 0 }),
damageBonus: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }), damageBonus: new fields.NumberField({ ...requiredInteger, required: true, initial: 0 }),
defenseBonus: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }) defenseBonus: new fields.NumberField({ ...requiredInteger, required: true, initial: 0 })
}) })
schema.encLoad = new fields.NumberField({ required: true, initial: 0, min: 0 }) schema.encLoad = new fields.NumberField({ required: true, initial: 0, min: 0 })
@@ -62,7 +63,7 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Weapon"] static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Weapon"]
get weaponCategory() { get weaponCategory() {
return game.i18n.localize(CATEGORY[this.weaponType].label) return game.i18n.localize(WEAPON_TYPE[this.weaponType] || this.weaponType)
} }
} }
+574 -66
View File
@@ -1,8 +1,9 @@
import { SYSTEM } from "./config/system.mjs" import { SYSTEM } from "./config/system.mjs"
// Map temporaire pour stocker les données d'attaque en attente de défense export function log(...args) {
if (!globalThis.pendingDefenses) { if (game?.settings?.get(game.system.id, "debug")) {
globalThis.pendingDefenses = new Map() console.log(...args)
}
} }
export default class LethalFantasyUtils { export default class LethalFantasyUtils {
@@ -27,7 +28,12 @@ export default class LethalFantasyUtils {
/* -------------------------------------------- */ /* -------------------------------------------- */
static setHookListeners() { static setHookListeners() {
Hooks.on('renderTokenHUD', async (hud, html, token) => { Hooks.on('renderTokenHUD', async (hud, html, data) => {
if (html.querySelector(".lethal-hp-loss-hud")) return
// The token/actor is on the HUD application instance, not the third param.
// hud.token / hud.object gives the Token (PlaceableObject), which has .actor.
const hudActor = hud.token?.actor ?? hud.object?.actor
if (!hudActor) return
// HP Loss Button (existing) // HP Loss Button (existing)
const lossHPButton = await foundry.applications.handlebars.renderTemplate('systems/fvtt-lethal-fantasy/templates/loss-hp-hud.hbs', {}) const lossHPButton = await foundry.applications.handlebars.renderTemplate('systems/fvtt-lethal-fantasy/templates/loss-hp-hud.hbs', {})
$(html).find('div.left').append(lossHPButton); $(html).find('div.left').append(lossHPButton);
@@ -50,21 +56,16 @@ export default class LethalFantasyUtils {
$(html).find('.hp-loss-wrap')[2].classList.add('hp-loss-hud-disabled'); $(html).find('.hp-loss-wrap')[2].classList.add('hp-loss-hud-disabled');
} }
}) })
$(html).find('.loss-hp-hud-click').click((event) => { $(html).find('.loss-hp-hud-click').click(async (event) => {
event.preventDefault(); event.preventDefault();
let hpLoss = event.currentTarget.dataset.hpValue; let hpLoss = event.currentTarget.dataset.hpValue;
if (token) { await hudActor.applyDamage(Number(hpLoss));
let tokenFull = canvas.tokens.placeables.find(t => t.id === token._id);
console.log(tokenFull, token)
let actor = tokenFull.actor;
actor.applyDamage(Number(hpLoss));
$(html).find('.hp-loss-wrap')[0].classList.remove('hp-loss-hud-active'); $(html).find('.hp-loss-wrap')[0].classList.remove('hp-loss-hud-active');
$(html).find('.hp-loss-wrap')[0].classList.add('hp-loss-hud-disabled'); $(html).find('.hp-loss-wrap')[0].classList.add('hp-loss-hud-disabled');
$(html).find('.hp-loss-wrap')[1].classList.remove('hp-loss-hud-active'); $(html).find('.hp-loss-wrap')[1].classList.remove('hp-loss-hud-active');
$(html).find('.hp-loss-wrap')[1].classList.add('hp-loss-hud-disabled'); $(html).find('.hp-loss-wrap')[1].classList.add('hp-loss-hud-disabled');
$(html).find('.hp-loss-wrap')[2].classList.remove('hp-loss-hud-active'); $(html).find('.hp-loss-wrap')[2].classList.remove('hp-loss-hud-active');
$(html).find('.hp-loss-wrap')[2].classList.add('hp-loss-hud-disabled'); $(html).find('.hp-loss-wrap')[2].classList.add('hp-loss-hud-disabled');
}
}) })
// HP Gain Button (new) // HP Gain Button (new)
@@ -89,28 +90,59 @@ export default class LethalFantasyUtils {
$(html).find('.hp-gain-wrap')[2].classList.add('hp-gain-hud-disabled'); $(html).find('.hp-gain-wrap')[2].classList.add('hp-gain-hud-disabled');
} }
}) })
$(html).find('.gain-hp-hud-click').click((event) => { $(html).find('.gain-hp-hud-click').click(async (event) => {
event.preventDefault(); event.preventDefault();
let hpGain = event.currentTarget.dataset.hpValue; let hpGain = event.currentTarget.dataset.hpValue;
if (token) { await hudActor.applyDamage(Number(hpGain)); // Positive value to add HP
let tokenFull = canvas.tokens.placeables.find(t => t.id === token._id); // Clear bleeding wounds on heal — regardless of heal amount, any
console.log(tokenFull, token) // healing is enough to stop bleeding (field dressing / magic / rest).
let actor = tokenFull.actor; const wounds = foundry.utils.duplicate(hudActor.system.hp.wounds || [])
actor.applyDamage(Number(hpGain)); // Positive value to add HP const hadBleeding = wounds.some(w => w.description === "Bleeding")
if (hadBleeding) {
await hudActor.update({
"system.hp.wounds": wounds.map(w =>
w.description === "Bleeding" ? { value: 0, duration: 0 } : w
)
})
}
$(html).find('.hp-gain-wrap')[0].classList.remove('hp-gain-hud-active'); $(html).find('.hp-gain-wrap')[0].classList.remove('hp-gain-hud-active');
$(html).find('.hp-gain-wrap')[0].classList.add('hp-gain-hud-disabled'); $(html).find('.hp-gain-wrap')[0].classList.add('hp-gain-hud-disabled');
$(html).find('.hp-gain-wrap')[1].classList.remove('hp-gain-hud-active'); $(html).find('.hp-gain-wrap')[1].classList.remove('hp-gain-hud-active');
$(html).find('.hp-gain-wrap')[1].classList.add('hp-gain-hud-disabled'); $(html).find('.hp-gain-wrap')[1].classList.add('hp-gain-hud-disabled');
$(html).find('.hp-gain-wrap')[2].classList.remove('hp-gain-hud-active'); $(html).find('.hp-gain-wrap')[2].classList.remove('hp-gain-hud-active');
$(html).find('.hp-gain-wrap')[2].classList.add('hp-gain-hud-disabled'); $(html).find('.hp-gain-wrap')[2].classList.add('hp-gain-hud-disabled');
})
// Luck/Grit Buttons
const luckGritButton = await foundry.applications.handlebars.renderTemplate('systems/fvtt-lethal-fantasy/templates/luck-grit-hud.hbs', {})
$(html).find('div.left').append(luckGritButton);
$(html).find('.lethal-luck-grit-hud').click((event) => {
event.preventDefault();
let wrap = $(html).find('.luck-grit-wrap')[0]
if (wrap.classList.contains("luck-grit-hud-disabled")) {
wrap.classList.add('luck-grit-hud-active');
wrap.classList.remove('luck-grit-hud-disabled');
} else {
wrap.classList.remove('luck-grit-hud-active');
wrap.classList.add('luck-grit-hud-disabled');
} }
}) })
$(html).find('.luck-grit-btn').click(async (event) => {
event.preventDefault();
const resource = event.currentTarget.dataset.resource;
const amount = Number(event.currentTarget.dataset.amount);
const current = Number(foundry.utils.getProperty(hudActor.system, `${resource}.current`)) || 0;
const newValue = Math.max(0, current + amount);
await hudActor.update({ [`system.${resource}.current`]: newValue });
$(html).find('.luck-grit-wrap')[0].classList.remove('luck-grit-hud-active');
$(html).find('.luck-grit-wrap')[0].classList.add('luck-grit-hud-disabled');
})
}) })
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static handleSocketEvent(msg = {}) { static async handleSocketEvent(msg = {}) {
console.log(`handleSocketEvent !`, msg) log(`handleSocketEvent !`, msg)
let actor let actor
switch (msg.type) { switch (msg.type) {
case "applyDamage": case "applyDamage":
@@ -120,18 +152,18 @@ export default class LethalFantasyUtils {
? canvas.tokens?.placeables?.find(t => t.id === msg.tokenId)?.actor ? canvas.tokens?.placeables?.find(t => t.id === msg.tokenId)?.actor
: (game.combat?.combatants?.find(c => c.actorId === msg.actorId)?.actor : (game.combat?.combatants?.find(c => c.actorId === msg.actorId)?.actor
?? game.actors.get(msg.actorId)) ?? game.actors.get(msg.actorId))
if (actor) actor.applyDamage(msg.damage) if (actor) await actor.applyDamage(msg.damage)
} }
break break
case "rollInitiative": case "rollInitiative":
if (msg.userId && msg.userId !== game.user.id) break if (msg.userId && msg.userId !== game.user.id) break
actor = game.actors.get(msg.actorId) actor = game.actors.get(msg.actorId)
actor.system.rollInitiative(msg.combatId, msg.combatantId) await actor.system.rollInitiative(msg.combatId, msg.combatantId)
break break
case "rollProgressionDice": case "rollProgressionDice":
if (msg.userId && msg.userId !== game.user.id) break if (msg.userId && msg.userId !== game.user.id) break
actor = game.actors.get(msg.actorId) actor = game.actors.get(msg.actorId)
actor.system.rollProgressionDice(msg.combatId, msg.combatantId, msg.rollProgressionCount) await actor.system.rollProgressionDice(msg.combatId, msg.combatantId, msg.rollProgressionCount)
break break
case "requestDefense": case "requestDefense":
// Vérifier si le message est destiné à cet utilisateur // Vérifier si le message est destiné à cet utilisateur
@@ -145,6 +177,26 @@ export default class LethalFantasyUtils {
LethalFantasyUtils.handleAttackerGritOffer(msg) LethalFantasyUtils.handleAttackerGritOffer(msg)
} }
break break
case "applyBleeding":
if (game.user.isGM) {
actor = msg.tokenId
? canvas.tokens?.placeables?.find(t => t.id === msg.tokenId)?.actor
: game.actors.get(msg.actorId)
if (actor && actor.system.hp?.wounds && msg.damage > 0) {
const wounds = foundry.utils.duplicate(actor.system.hp.wounds)
const slot = wounds.findIndex(w => !w.value && !w.duration)
if (slot !== -1) {
wounds[slot] = { value: msg.damage, duration: msg.damage, description: "Bleeding" }
await actor.update({ "system.hp.wounds": wounds })
}
}
}
break
case "attackBoosted":
if (msg.userId === game.user.id) {
LethalFantasyUtils.handleAttackBoosted(msg)
}
break
} }
} }
@@ -182,6 +234,225 @@ export default class LethalFantasyUtils {
}) })
} }
/* -------------------------------------------- */
static async handleAttackBoosted(msg) {
const {
attackerName, attackerId, defenderName, defenderId, defenderTokenId,
attackerHandledBonus, attackRollFinal, defenseRoll, attackWeaponId, attackRollType, attackRollKey,
shieldDamageReduction: initialShieldDR,
d30Bleed, d30DamageMultiplier, d30DrMultiplier,
damageTier, attackD30message, defenseD30message,
hasShield, shieldLabel, shieldFormula, shieldDr, canAdHocShield
} = msg
const defender = game.actors.get(defenderId)
if (!defender) return
let updatedDefenseRoll = defenseRoll
let shieldBlocked = false
let shieldReaction = null
let canShieldReact = hasShield
let canAdHoc = canAdHocShield
// ── D30 bonus dice (defense) — resolved before grit/luck/shield ───────
let defenseDrMultiplier = null
if (defenseD30message && defender) {
const d30Result = await LethalFantasyUtils.processD30BonusDice(defenseD30message, "defense", null, defender, true)
if (d30Result.modifier) {
updatedDefenseRoll += d30Result.modifier
if (d30Result.modifier > 0) {
await ChatMessage.create({
content: `<p><strong>${defenderName}</strong> gains <strong>+${d30Result.modifier}</strong> from D30 bonus die for defense.</p>`,
speaker: ChatMessage.getSpeaker({ actor: defender })
})
}
}
if (d30Result.specialEffect === "auto") {
updatedDefenseRoll = attackRollFinal + 1
await ChatMessage.create({
content: `<p><strong>${defenderName}</strong> uses <strong>${d30Result.specialName || "Special Defense"}</strong> from D30 — defense automatically succeeds!</p>`,
speaker: ChatMessage.getSpeaker({ actor: defender })
})
}
if (d30Result.specialEffect === "flag") {
await ChatMessage.create({
content: `<p>D30 — <strong>${d30Result.specialName || "Special Effect"}</strong> triggered for ${defenderName}!</p>`,
speaker: ChatMessage.getSpeaker({ actor: defender })
})
}
if (d30Result.specialEffect === "drMultiplier") {
defenseDrMultiplier = d30Result.multiplier
await ChatMessage.create({
content: `<p>D30 — Defense grants <strong>x${d30Result.multiplier} DR</strong> (choose which DR types to multiply when damage is applied)</p>`,
speaker: ChatMessage.getSpeaker({ actor: defender })
})
}
}
// Show the defense reaction dialog — while-loop for multiple reactions
if (defender) {
while (updatedDefenseRoll < attackRollFinal) {
const currentGrit = Number(defender.system?.grit?.current) || 0
const currentLuck = Number(defender.system?.luck?.current) || 0
const buttons = []
if (currentGrit > 0) {
buttons.push({
action: "grit",
type: "button",
label: `Spend 1 Grit (+1D6) [${currentGrit} left]`,
icon: "fa-solid fa-fist-raised",
callback: () => "grit"
})
}
if (currentLuck > 0) {
buttons.push({
action: "luck",
type: "button",
label: `Spend 1 Luck (+1D6) [${currentLuck} left]`,
icon: "fa-solid fa-clover",
callback: () => "luck"
})
}
buttons.push({
action: "bonusDie",
type: "button",
label: "Add bonus die",
icon: "fa-solid fa-dice",
callback: () => "bonusDie"
})
if (canShieldReact) {
buttons.push({
action: "shieldReact",
type: "button",
label: `Roll shield (${shieldLabel})`,
icon: "fa-solid fa-shield",
callback: () => "shieldReact"
})
} else if (canAdHoc) {
buttons.push({
action: "adHocShield",
type: "button",
label: "Roll ad-hoc shield (choose dice + DR)",
icon: "fa-solid fa-shield-halved",
callback: () => "adHocShield"
})
}
buttons.push({
action: "continue",
type: "button",
label: "Continue (no defense bonus)",
icon: "fa-solid fa-forward",
callback: () => "continue"
})
const choice = await foundry.applications.api.DialogV2.wait({
window: { title: "Defense reactions — attack boosted" },
classes: ["lethalfantasy"],
content: `
<div class="grit-luck-dialog">
<div class="combat-status">
<p><strong>${attackerName}</strong> boosted attack to <strong>${attackRollFinal}</strong></p>
<p><strong>${defenderName}</strong> currently has <strong>${updatedDefenseRoll}</strong></p>
</div>
<p class="offer-text">The attack was boosted! Choose how to improve the defense.</p>
</div>
`,
buttons,
rejectClose: false
})
if (!choice || choice === "continue") break
if (choice === "grit") {
const bonusRoll = await LethalFantasyUtils.rollBonusDie("1d6", defender,
total => `<p><strong>${defenderName}</strong> spends 1 Grit and rolls <strong>${total}</strong> for defense.</p>`)
updatedDefenseRoll += bonusRoll
await defender.update({ "system.grit.current": currentGrit - 1 })
} else if (choice === "luck") {
const bonusRoll = await LethalFantasyUtils.rollBonusDie("1d6", defender,
total => `<p><strong>${defenderName}</strong> spends 1 Luck and rolls <strong>${total}</strong> for defense.</p>`)
updatedDefenseRoll += bonusRoll
await defender.update({ "system.luck.current": currentLuck - 1 })
} else if (choice === "bonusDie") {
const bonusDie = await LethalFantasyUtils.promptCombatBonusDie(defenderName, "attack", updatedDefenseRoll, attackRollFinal)
if (bonusDie) {
const bonusRoll = await LethalFantasyUtils.rollBonusDie(bonusDie, defender,
(total, formula) => `<p><strong>${defenderName}</strong> adds <strong>${formula.toUpperCase()}</strong> and rolls <strong>${total}</strong> for defense.</p>`)
updatedDefenseRoll += bonusRoll
}
} else if (choice === "shieldReact" && canShieldReact) {
const shieldBonus = await LethalFantasyUtils.rollBonusDie(shieldFormula, defender)
const newDefenseTotal = updatedDefenseRoll + shieldBonus
updatedDefenseRoll = newDefenseTotal
canShieldReact = false
if (newDefenseTotal >= attackRollFinal) {
shieldBlocked = true
shieldReaction = { damageReduction: shieldDr, label: shieldLabel, bonus: shieldBonus }
await ChatMessage.create({
content: `<p><strong>${defenderName}</strong> rolls <strong>${shieldLabel}</strong> and adds <strong>${shieldBonus}</strong> to defense (${newDefenseTotal}${attackRollFinal}). <strong>Shield blocked the attack!</strong> Both armor DR and shield DR <strong>${shieldDr}</strong> will apply to damage.</p>`,
speaker: ChatMessage.getSpeaker({ actor: defender })
})
} else {
await ChatMessage.create({
content: `<p><strong>${defenderName}</strong> rolls <strong>${shieldLabel}</strong> and adds <strong>${shieldBonus}</strong> to defense (${newDefenseTotal} < ${attackRollFinal}). Shield did not block — normal hit, armor DR only.</p>`,
speaker: ChatMessage.getSpeaker({ actor: defender })
})
}
} else if (choice === "adHocShield" && canAdHoc) {
const adHoc = await LethalFantasyUtils.promptAdHocShield(defenderName, attackRollFinal, updatedDefenseRoll)
if (adHoc) {
const shieldBonus = await LethalFantasyUtils.rollBonusDie(adHoc.formula, defender)
const newDefenseTotal = updatedDefenseRoll + shieldBonus
updatedDefenseRoll = newDefenseTotal
canShieldReact = false
canAdHoc = false
if (newDefenseTotal >= attackRollFinal) {
shieldBlocked = true
shieldReaction = { damageReduction: adHoc.damageReduction, label: `${adHoc.formula.toUpperCase()} shield`, bonus: shieldBonus }
await ChatMessage.create({
content: `<p><strong>${defenderName}</strong> rolls <strong>${adHoc.formula.toUpperCase()}</strong> shield and adds <strong>${shieldBonus}</strong> to defense (${newDefenseTotal}${attackRollFinal}). <strong>Shield blocked the attack!</strong> Both armor DR and shield DR <strong>${adHoc.damageReduction}</strong> will apply to damage.</p>`,
speaker: ChatMessage.getSpeaker({ actor: defender })
})
} else {
await ChatMessage.create({
content: `<p><strong>${defenderName}</strong> rolls <strong>${adHoc.formula.toUpperCase()}</strong> shield and adds <strong>${shieldBonus}</strong> to defense (${newDefenseTotal} < ${attackRollFinal}). Shield did not block — normal hit, armor DR only.</p>`,
speaker: ChatMessage.getSpeaker({ actor: defender })
})
}
}
}
}
}
const finalShieldDR = shieldBlocked ? (shieldReaction?.damageReduction || 0) : 0
const outcome = shieldBlocked ? "shielded-hit" : (updatedDefenseRoll >= attackRollFinal ? "miss" : "hit")
await LethalFantasyUtils.compareAttackDefense({
attackerName,
attackerId,
attackRoll: attackRollFinal,
attackWeaponId,
attackRollType,
attackRollKey,
defenderName,
defenderId,
defenderTokenId,
defenseRoll: updatedDefenseRoll,
outcome,
shieldDamageReduction: finalShieldDR,
d30Bleed: d30Bleed || "",
d30DamageMultiplier: d30DamageMultiplier || 1,
d30DrMultiplier: (d30DrMultiplier != null && d30DrMultiplier !== 1) ? d30DrMultiplier : (defenseDrMultiplier ?? d30DrMultiplier ?? 1),
damageTier: damageTier || "standard",
attackD30message
})
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static async showDefenseRequest(msg) { static async showDefenseRequest(msg) {
const attackerName = msg.attackerName const attackerName = msg.attackerName
@@ -235,7 +506,7 @@ export default class LethalFantasyUtils {
const isMonster = defender.type === "monster" const isMonster = defender.type === "monster"
console.log(`[LF] showDefenseRequest | attackRollType=${attackRollType} isMonster=${isMonster} defender=${defender?.name}`) log(`[LF] showDefenseRequest | attackRollType=${attackRollType} isMonster=${isMonster} defender=${defender?.name}`)
// Spell/miracle attacks use saving throws instead of weapon defense // Spell/miracle attacks use saving throws instead of weapon defense
const isSpellAttack = attackRollType === "spell-attack" || attackRollType === "miracle-attack" const isSpellAttack = attackRollType === "spell-attack" || attackRollType === "miracle-attack"
@@ -269,6 +540,7 @@ export default class LethalFantasyUtils {
buttons: [ buttons: [
{ {
action: "rollSave", action: "rollSave",
type: "button",
label: "Roll Save", label: "Roll Save",
icon: "fa-solid fa-person-running", icon: "fa-solid fa-person-running",
callback: (event, button) => button.form.elements.saveKey.value, callback: (event, button) => button.form.elements.saveKey.value,
@@ -279,6 +551,7 @@ export default class LethalFantasyUtils {
if (result) { if (result) {
game.lethalFantasy = game.lethalFantasy || {} game.lethalFantasy = game.lethalFantasy || {}
game.lethalFantasy.spellDefense = true // pré-cocher "Save against spell" dans le dialog
game.lethalFantasy.nextDefenseData = { game.lethalFantasy.nextDefenseData = {
attackerId, attackerId,
attackRoll, attackRoll,
@@ -290,13 +563,15 @@ export default class LethalFantasyUtils {
attackD30result, attackD30result,
attackD30message, attackD30message,
attackRerollContext, attackRerollContext,
attackNaturalRoll: msg.attackNaturalRoll,
damageTier: msg.damageTier,
defenderId: defender.id, defenderId: defender.id,
defenderTokenId defenderTokenId
} }
if (isMonster) { if (isMonster) {
defender.system.prepareMonsterRoll("save", result) await defender.system.prepareMonsterRoll("save", result)
} else { } else {
defender.prepareRoll("save", result) await defender.prepareRoll("save", result)
} }
} }
return return
@@ -324,7 +599,7 @@ export default class LethalFantasyUtils {
<p>Attack roll: <strong>${attackRoll}</strong></p> <p>Attack roll: <strong>${attackRoll}</strong></p>
</div> </div>
<div class="weapon-selection"> <div class="weapon-selection">
<label for="defense-attack">Choose your defense attack:</label> <label for="defense-attack">Choose your defense weapon:</label>
<select id="defense-attack" name="attackKey" style="width: 100%; margin-top: 8px;"> <select id="defense-attack" name="attackKey" style="width: 100%; margin-top: 8px;">
${attacksHTML} ${attacksHTML}
</select> </select>
@@ -339,6 +614,8 @@ export default class LethalFantasyUtils {
content, content,
buttons: [ buttons: [
{ {
action: "rangeDefense",
type: "button",
label: "Roll Defense", label: "Roll Defense",
icon: "fa-solid fa-shield", icon: "fa-solid fa-shield",
callback: (event, button, dialog) => { callback: (event, button, dialog) => {
@@ -365,12 +642,14 @@ export default class LethalFantasyUtils {
attackD30result, attackD30result,
attackD30message, attackD30message,
attackRerollContext, attackRerollContext,
attackNaturalRoll: msg.attackNaturalRoll,
damageTier: msg.damageTier,
defenderId: defender.id, defenderId: defender.id,
defenderTokenId, defenderTokenId,
isRanged: msg.isRanged isRanged: msg.isRanged
} }
defender.system.prepareMonsterRoll("monster-defense", result) await defender.system.prepareMonsterRoll("monster-defense", result)
} }
return return
} }
@@ -397,11 +676,12 @@ export default class LethalFantasyUtils {
attackD30result, attackD30result,
attackD30message, attackD30message,
attackRerollContext, attackRerollContext,
damageTier: msg.damageTier,
defenderId: defender.id, defenderId: defender.id,
defenderTokenId, defenderTokenId,
isRanged: true isRanged: true
} }
await roll.toMessage({}, { rollMode: roll.options.rollMode }) await roll.toMessage({}, { messageMode: roll.options.rollMode })
} }
return return
} }
@@ -443,6 +723,8 @@ export default class LethalFantasyUtils {
content, content,
buttons: [ buttons: [
{ {
action: "defenseRoll",
type: "button",
label: "Roll Defense", label: "Roll Defense",
icon: "fa-solid fa-shield", icon: "fa-solid fa-shield",
callback: (event, button, dialog) => { callback: (event, button, dialog) => {
@@ -469,14 +751,16 @@ export default class LethalFantasyUtils {
attackD30result, attackD30result,
attackD30message, attackD30message,
attackRerollContext, attackRerollContext,
attackNaturalRoll: msg.attackNaturalRoll,
damageTier: msg.damageTier,
defenderId: defender.id, defenderId: defender.id,
defenderTokenId, defenderTokenId,
isRanged: msg.isRanged isRanged: msg.isRanged
} }
console.log("Storing defense data for character:", defender.id) log("Storing defense data for character:", defender.id)
defender.prepareRoll("weapon-defense", result) await defender.prepareRoll("weapon-defense", result)
} }
} }
@@ -485,6 +769,190 @@ export default class LethalFantasyUtils {
return d30Message?.type === "mulligan" return d30Message?.type === "mulligan"
} }
/* -------------------------------------------- */
/**
* Process D30 bonus dice for attack or defense.
* Rolls and applies bonus dice BEFORE grit/luck/shield decisions.
* For `choice` type results (D30=20, 30), shows dialog to choose between bonus dice and special effect.
* For `bonus_dice` type results (D30=27, 2, 3), auto-rolls the dice.
* @param {Object|null} d30Message The D30 result object
* @param {"attack"|"defense"} side Whether processing the attack or defense side
* @param {number|null} naturalRoll The natural D20 roll (for special strike type detection)
* @param {Object} actor The actor (for dice3d display)
* @returns {Promise<{modifier: number, specialEffect: string|null, specialName: string|null}>}
*/
static async processD30BonusDice(d30Message, side, naturalRoll = null, actor = null, canDialog = true) {
if (!d30Message) return { modifier: 0, specialEffect: null, specialName: null }
const validTargets = side === "attack" ? ["attack", "spell_attack"] : ["defense", "spell_defense"]
// ── Simple bonus_dice type ── auto-roll if target matches
if (d30Message.type === "bonus_dice") {
if (!validTargets.includes(d30Message.target)) return { modifier: 0, specialEffect: null, specialName: null }
const modifier = await this._rollD30BonusDie(d30Message.dice, actor, !canDialog)
return { modifier, specialEffect: null, specialName: null }
}
// ── Choice type ── present all options to the player
if (d30Message.type === "choice") {
// If we can't show dialogs (wrong client), skip — the primary client
// will communicate its choice result via socket. Auto-rolling here
// would give a different modifier on each client, causing divergence.
if (!canDialog) {
return { modifier: 0, specialEffect: null, specialName: null }
}
const buttons = d30Message.choices.map(c => {
let label
let icon
if (c.type === "bonus_dice") {
label = `Roll ${c.dice.toUpperCase()} and add to ${side}`
icon = "fa-solid fa-dice"
} else if (c.type === "special_strike") {
label = this._buildSpecialLabel(c, naturalRoll)
icon = "fa-solid fa-star"
} else if (c.type === "special_defense") {
label = this._buildSpecialLabel(c, naturalRoll)
icon = "fa-solid fa-shield-halved"
} else {
label = c.type.replace(/_/g, " ").replace(/\b\w/g, l => l.toUpperCase())
icon = "fa-solid fa-question"
}
return {
action: c.type,
type: "button",
label,
icon,
callback: () => c
}
})
const choice = await foundry.applications.api.DialogV2.wait({
window: { title: "D30 Special — Choose Effect" },
classes: ["lethalfantasy"],
content: `
<div class="grit-luck-dialog">
<p><strong>D30 result:</strong> ${d30Message.description}</p>
<p>Choose how to use this result:</p>
</div>
`,
buttons,
rejectClose: false
})
if (!choice) return { modifier: 0, specialEffect: null, specialName: null }
if (choice.type === "bonus_dice") {
const modifier = await this._rollD30BonusDie(choice.dice, actor)
return { modifier, specialEffect: null, specialName: null }
}
if (choice.type === "special_strike" || choice.type === "special_defense") {
return { modifier: 0, specialEffect: "auto", specialName: this._buildSpecialName(choice, naturalRoll) }
}
// Non-standard choice (spell_calamity, etc.) — report it
return { modifier: 0, specialEffect: "flag", specialName: choice.type }
}
// ── Combo type (bleed / internal injury) — flag for wound creation
if (d30Message.type === "combo") {
const hasBleed = d30Message.effects?.some(e => e.type === "bleed" || e.type === "internal_injury")
if (hasBleed) {
return { modifier: 0, specialEffect: "bleed", specialName: "Bleeding/Internal Injury" }
}
}
// ── Damage multiplier type (2x/3x damage before DR)
if (d30Message.type === "damage_multiplier") {
return { modifier: 0, specialEffect: "damageMultiplier", specialName: `x${d30Message.multiplier} Damage`, multiplier: d30Message.multiplier }
}
// ── DR multiplier type (2x/3x DR including shield)
if (d30Message.type === "dr_multiplier") {
return { modifier: 0, specialEffect: "drMultiplier", specialName: `x${d30Message.multiplier} DR`, multiplier: d30Message.multiplier }
}
return { modifier: 0, specialEffect: null, specialName: null }
}
/* -------------------------------------------- */
/**
* Roll a D30 bonus die and show with 3D dice if available.
* @param {string} formula Dice formula (e.g. "D6", "D12", "D20E")
* @param {Object} actor Actor for chat message speaker
* @returns {Promise<number>} The roll total
*/
static async _rollD30BonusDie(formula, actor, silent = false) {
const cleaned = formula.replace(/NE$/i, "").replace("E", "")
const roll = new Roll(cleaned)
await roll.evaluate()
if (game?.dice3d) {
await game.dice3d.showForRoll(roll, game.user, true)
}
if (!silent) {
await ChatMessage.create({
content: `<p>D30 bonus: rolled <strong>${cleaned.toUpperCase()}</strong> = <strong>${roll.total}</strong></p>`,
speaker: ChatMessage.getSpeaker({ actor })
})
}
return roll.total
}
/* -------------------------------------------- */
/**
* Build a human-readable label for a special strike/defense choice in the D30 prompt.
* @param {Object} specialChoice The choice object with type and options
* @param {number|null} naturalRoll The natural D20 roll
* @returns {string} Display label
*/
static _buildSpecialLabel(specialChoice, naturalRoll) {
if (specialChoice.type === "special_strike") {
if (specialChoice.options.includes("lethal")) {
if (naturalRoll === 20) return "Lethal Strike (auto-hit)"
if (naturalRoll >= 16 && naturalRoll <= 19) return "Vital Strike (auto-hit)"
return "Lethal/Vital Strike (auto-hit)"
}
if (specialChoice.options.includes("vicious")) return "Vicious Strike (auto-hit)"
return "Special Strike (auto-hit)"
}
if (specialChoice.type === "special_defense") {
if (specialChoice.options.includes("perfect_spell")) return "Perfect Spell Defense (auto-block)"
if (specialChoice.options.includes("flawless")) return "Flawless Defense (auto-block)"
if (specialChoice.options.includes("legendary")) return "Legendary Defense (auto-block)"
if (specialChoice.options.includes("perfect")) return "Perfect Defense (auto-block)"
return "Special Defense (auto-block)"
}
return "Special Effect"
}
/* -------------------------------------------- */
/**
* Build the special effect name based on the D30 result and natural roll.
* @param {Object} specialChoice The choice object with type and options
* @param {number|null} naturalRoll The natural D20 roll
* @returns {string} The special effect name
*/
static _buildSpecialName(specialChoice, naturalRoll) {
if (specialChoice.type === "special_strike") {
if (specialChoice.options.includes("lethal")) {
if (naturalRoll === 20) return "Lethal Strike"
if (naturalRoll >= 16 && naturalRoll <= 19) return "Vital Strike"
return "Lethal/Vital Strike"
}
if (specialChoice.options.includes("vicious")) return "Vicious Strike"
return "Special Strike"
}
if (specialChoice.type === "special_defense") {
if (specialChoice.options.includes("perfect_spell")) return "Perfect Spell Defense"
if (specialChoice.options.includes("flawless")) return "Flawless Defense"
if (specialChoice.options.includes("legendary")) return "Legendary Defense"
if (specialChoice.options.includes("perfect")) return "Perfect Defense"
return "Special Defense"
}
return "Special Effect"
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static getCombatBonusDiceChoices() { static getCombatBonusDiceChoices() {
return ["1d4", "1d6", "1d8", "1d10", "1d12", "1d20", "1d20e"] return ["1d4", "1d6", "1d8", "1d10", "1d12", "1d20", "1d20e"]
@@ -542,6 +1010,7 @@ export default class LethalFantasyUtils {
buttons: [ buttons: [
{ {
action: "roll", action: "roll",
type: "button",
label: "Roll Bonus Die", label: "Roll Bonus Die",
icon: "fa-solid fa-dice", icon: "fa-solid fa-dice",
callback: (event, button) => { callback: (event, button) => {
@@ -551,6 +1020,7 @@ export default class LethalFantasyUtils {
}, },
{ {
action: "cancel", action: "cancel",
type: "button",
label: "Cancel", label: "Cancel",
icon: "fa-solid fa-xmark", icon: "fa-solid fa-xmark",
callback: () => null callback: () => null
@@ -598,6 +1068,7 @@ export default class LethalFantasyUtils {
buttons: [ buttons: [
{ {
action: "roll", action: "roll",
type: "button",
label: "Roll Shield", label: "Roll Shield",
icon: "fa-solid fa-shield", icon: "fa-solid fa-shield",
callback: (event, button) => { callback: (event, button) => {
@@ -611,6 +1082,7 @@ export default class LethalFantasyUtils {
}, },
{ {
action: "cancel", action: "cancel",
type: "button",
label: "Cancel", label: "Cancel",
icon: "fa-solid fa-xmark", icon: "fa-solid fa-xmark",
callback: () => null callback: () => null
@@ -681,6 +1153,7 @@ export default class LethalFantasyUtils {
if (currentGrit > 0) { if (currentGrit > 0) {
buttons.push({ buttons.push({
action: "grit", action: "grit",
type: "button",
label: `Spend 1 Grit (+1D6) [${currentGrit} left]`, label: `Spend 1 Grit (+1D6) [${currentGrit} left]`,
icon: "fa-solid fa-fist-raised", icon: "fa-solid fa-fist-raised",
callback: () => "grit" callback: () => "grit"
@@ -690,6 +1163,7 @@ export default class LethalFantasyUtils {
if (currentLuck > 0) { if (currentLuck > 0) {
buttons.push({ buttons.push({
action: "luck", action: "luck",
type: "button",
label: `Spend 1 Luck (+1D6) [${currentLuck} left]`, label: `Spend 1 Luck (+1D6) [${currentLuck} left]`,
icon: "fa-solid fa-clover", icon: "fa-solid fa-clover",
callback: () => "luck" callback: () => "luck"
@@ -698,6 +1172,7 @@ export default class LethalFantasyUtils {
buttons.push({ buttons.push({
action: "continue", action: "continue",
type: "button",
label: "Continue (no bonus)", label: "Continue (no bonus)",
icon: "fa-solid fa-forward", icon: "fa-solid fa-forward",
callback: () => "continue" callback: () => "continue"
@@ -711,6 +1186,7 @@ export default class LethalFantasyUtils {
${totalBonus > 0 ? `<p class="bonus-info">Bonus already added: +${totalBonus}</p>` : ''} ${totalBonus > 0 ? `<p class="bonus-info">Bonus already added: +${totalBonus}</p>` : ''}
</div> </div>
<p class="offer-text">You are losing! Spend Grit or Luck to add 1D6 to your defense?</p> <p class="offer-text">You are losing! Spend Grit or Luck to add 1D6 to your defense?</p>
<p class="shield-warning"><i class="fa-solid fa-triangle-exclamation"></i> If you intend to use a shield, you must spend Grit or Luck <strong>first</strong> — the shield roll comes after.</p>
</div> </div>
` `
@@ -772,12 +1248,14 @@ export default class LethalFantasyUtils {
const buttons = [ const buttons = [
{ {
action: "grit", action: "grit",
type: "button",
label: `Spend 1 Grit (+1D6) [${currentGrit} left]`, label: `Spend 1 Grit (+1D6) [${currentGrit} left]`,
icon: "fa-solid fa-fist-raised", icon: "fa-solid fa-fist-raised",
callback: () => "grit" callback: () => "grit"
}, },
{ {
action: "continue", action: "continue",
type: "button",
label: "Continue (no bonus)", label: "Continue (no bonus)",
icon: "fa-solid fa-forward", icon: "fa-solid fa-forward",
callback: () => "continue" callback: () => "continue"
@@ -831,51 +1309,70 @@ export default class LethalFantasyUtils {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async compareAttackDefense(data) { static async compareAttackDefense(data) {
console.log("compareAttackDefense called with:", data) log("compareAttackDefense called with:", data)
// Compute D30 effects from the attack D30 message directly.
// This is more reliable than depending on the caller-provided values, which are
// computed per-client and may differ between clients due to cross-client processing order.
const d30DamageMultiplier = data.attackD30message?.type === "damage_multiplier"
? data.attackD30message.multiplier
: (data.d30DamageMultiplier || 1)
const d30Bleed = data.attackD30message?.type === "combo"
? (data.attackD30message.effects?.some(e => e.type === "bleed" || e.type === "internal_injury") ? "true" : "")
: data.attackD30message?.type === "bleed" ? "true" : (data.d30Bleed || "")
const d30DrMultiplier = data.d30DrMultiplier || 1
const outcome = data.outcome || (data.attackRoll > data.defenseRoll ? "hit" : "miss") const outcome = data.outcome || (data.attackRoll > data.defenseRoll ? "hit" : "miss")
const isAttackWin = outcome !== "miss" const isAttackWin = outcome !== "miss"
console.log("isAttackWin:", isAttackWin, "attackRoll:", data.attackRoll, "defenseRoll:", data.defenseRoll) log("isAttackWin:", isAttackWin, "attackRoll:", data.attackRoll, "defenseRoll:", data.defenseRoll)
let damageButton = "" let damageButton = ""
if (isAttackWin && (data.attackWeaponId || data.attackRollKey)) { if (isAttackWin && (data.attackWeaponId || data.attackRollKey)) {
console.log("Creating damage button. defenderId:", data.defenderId) log("Creating damage button. defenderId:", data.defenderId)
// Déterminer le type de dégâts à lancer // Déterminer le type de dégâts à lancer
if (data.attackRollType === "weapon-attack") { if (data.attackRollType === "weapon-attack") {
damageButton = ` damageButton = `
<div class="attack-result-damage"> <div class="attack-result-damage single-btn">
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-defender-token-id="${data.defenderTokenId || ""}" data-extra-shield-dr="${data.shieldDamageReduction || 0}" data-weapon-id="${data.attackWeaponId}" data-damage-type="small"> <button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-defender-token-id="${data.defenderTokenId || ""}" data-extra-shield-dr="${data.shieldDamageReduction || 0}" data-weapon-id="${data.attackWeaponId}" data-damage-type="medium" data-d30-bleed="${d30Bleed}" data-d30-damage-mult="${d30DamageMultiplier}" data-d30-dr-mult="${d30DrMultiplier}">
<i class="fa-solid fa-dice-d6"></i> Damage (Small) <i class="fa-solid fa-dice-d20"></i> Damage
</button>
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-defender-token-id="${data.defenderTokenId || ""}" data-extra-shield-dr="${data.shieldDamageReduction || 0}" data-weapon-id="${data.attackWeaponId}" data-damage-type="medium">
<i class="fa-solid fa-dice-d20"></i> Damage (Medium)
</button> </button>
</div> </div>
` `
} else if (data.attackRollType === "monster-attack") { } else if (data.attackRollType === "monster-attack") {
damageButton = ` damageButton = `
<div class="attack-result-damage"> <div class="attack-result-damage single-btn">
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-defender-token-id="${data.defenderTokenId || ""}" data-extra-shield-dr="${data.shieldDamageReduction || 0}" data-attack-key="${data.attackRollKey}" data-damage-type="monster"> <button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-defender-token-id="${data.defenderTokenId || ""}" data-extra-shield-dr="${data.shieldDamageReduction || 0}" data-attack-key="${data.attackRollKey}" data-damage-type="monster" data-d30-bleed="${d30Bleed}" data-d30-damage-mult="${d30DamageMultiplier}" data-d30-dr-mult="${d30DrMultiplier}">
<i class="fa-solid fa-burst"></i> Damage <i class="fa-solid fa-burst"></i> Damage
</button> </button>
</div> </div>
` `
} else if (data.attackRollType === "spell-attack" || data.attackRollType === "miracle-attack") { } else if (data.attackRollType === "spell-attack" || data.attackRollType === "miracle-attack") {
const attacker = game.actors.get(data.attackerId) const attacker = game.actors.get(data.attackerId)
const spell = attacker?.items.get(data.attackWeaponId) const spell = attacker?.items.get(data.attackWeaponId || data.attackRollKey)
const damageDice = spell?.system?.damageDice const chosenTier = data.damageTier || "standard"
if (damageDice) { const allTiers = [
damageButton = ` { id: "standard", formula: spell?.system?.damageDice, label: "Standard" },
<div class="attack-result-damage"> { id: "overpowered", formula: spell?.system?.damageDiceOverpowered, label: "Overpowered" },
{ id: "overpowered2", formula: spell?.system?.damageDiceOverpowered2, label: "Overpowered 2" },
]
const tiers = allTiers.filter(t => t.id === chosenTier && t.formula)
if (tiers.length) {
const buttons = tiers.map(t => {
const escapedFormula = Handlebars.escapeExpression(t.formula)
return `
<button class="roll-damage-btn" <button class="roll-damage-btn"
data-attacker-id="${data.attackerId}" data-attacker-id="${data.attackerId}"
data-defender-id="${data.defenderId}" data-defender-id="${data.defenderId}"
data-defender-token-id="${data.defenderTokenId || ""}" data-defender-token-id="${data.defenderTokenId || ""}"
data-damage-type="spell" data-damage-type="spell"
data-damage-formula="${damageDice}"> data-damage-formula="${escapedFormula}"
<i class="fa-solid fa-wand-magic-sparkles"></i> Spell Damage (${damageDice}) data-d30-bleed="${d30Bleed}"
</button> data-d30-damage-mult="${d30DamageMultiplier}"
</div> data-d30-dr-mult="${d30DrMultiplier}">
` <i class="fa-solid fa-wand-magic-sparkles"></i> ${t.label} (${escapedFormula})
</button>`
}).join("")
damageButton = `<div class="attack-result-damage spell-damage">${buttons}</div>`
} }
} }
} }
@@ -902,22 +1399,22 @@ export default class LethalFantasyUtils {
</div> </div>
<div class="combat-result-text"> <div class="combat-result-text">
${outcome === "shielded-hit" ${outcome === "shielded-hit"
? `<i class="fa-solid fa-shield"></i> <strong>${data.attackerName}</strong> hits <strong>${data.defenderName}</strong>, but the shield blocked — apply armor DR + shield DR <strong>${data.shieldDamageReduction || 0}</strong>.` ? `<i class="fa-solid fa-shield"></i> <strong>${data.defenderName}</strong> has blocked with shield — apply armor DR + shield DR <strong>${data.shieldDamageReduction || 0}</strong>.`
: isAttackWin : isAttackWin
? `<i class="fa-solid fa-circle-check"></i> <strong>${data.attackerName}</strong> hits <strong>${data.defenderName}</strong>!` ? `<i class="fa-solid fa-circle-check"></i> <strong>${data.attackerName}</strong> hits <strong>${data.defenderName}</strong>!`
: `<i class="fa-solid fa-shield-halved"></i> <strong>${data.defenderName}</strong> parries the attack!` : `<i class="fa-solid fa-shield-halved"></i> <strong>${data.defenderName}</strong> avoided the attack!`
} }
</div> </div>
${damageButton} ${damageButton}
</div> </div>
` `
console.log("Creating combat result message...") log("Creating combat result message...")
await ChatMessage.create({ await ChatMessage.create({
content: resultMessage, content: resultMessage,
speaker: { alias: "Combat System" } speaker: { alias: "Combat System" }
}) })
console.log("Combat result message created!") log("Combat result message created!")
} }
static registerHandlebarsHelpers() { static registerHandlebarsHelpers() {
@@ -1054,7 +1551,7 @@ export default class LethalFantasyUtils {
return eval(expr); return eval(expr);
}) })
Handlebars.registerHelper('isOwnerOrGM', function (actor) { Handlebars.registerHelper('isOwnerOrGM', function (actor) {
console.log("Testing actor", actor.isOwner, game.userId) log("Testing actor", actor.isOwner, game.userId)
return actor.isOwner || game.isGM; return actor.isOwner || game.isGM;
}) })
Handlebars.registerHelper('upperCase', function (text) { Handlebars.registerHelper('upperCase', function (text) {
@@ -1092,25 +1589,32 @@ export default class LethalFantasyUtils {
static async applyDamage(message, event) { static async applyDamage(message, event) {
// Récupérer les données du message // Récupérer les données du message
let combatantId = event.currentTarget.dataset.combatantId let combatantId = event.currentTarget.dataset.combatantId
if (!combatantId || !game.combat) { if (!combatantId) {
ui.notifications.error("No combatant selected") ui.notifications.error("No combatant selected")
return return
} }
let combatant = game.combat.combatants.get(combatantId) // Try to find the target: first as a combat combatant, then as a scene token
if (!combatant) { let targetActor = null
ui.notifications.error("Combatant not found") if (game.combat) {
return const combatant = game.combat.combatants.get(combatantId)
if (combatant) {
targetActor = combatant.token?.actor || game.actors.get(combatant.actorId)
}
}
if (!targetActor) {
// Fall back to scene token lookup (non-combat tokens use tokenId as their combatantId)
const token = canvas.tokens?.placeables?.find(t => t.id === combatantId)
targetActor = token?.actor
} }
let targetActor = combatant.token?.actor || game.actors.get(combatant.actorId)
if (!targetActor) { if (!targetActor) {
ui.notifications.error("Target actor not found") ui.notifications.error("Target actor not found")
return return
} }
// Récupérer les données de dégâts du message // Récupérer les données de dégâts du message
let damageTotal = message.rolls[0]?.total || 0 // Use options.rollTotal (includes weapon modifier bonus) rather than roll.total (dice formula only)
let damageTotal = message.rolls[0]?.options?.rollTotal ?? message.rolls[0]?.total ?? 0
let weaponName = message.rolls[0]?.options?.rollName || "Unknown Weapon" let weaponName = message.rolls[0]?.options?.rollName || "Unknown Weapon"
// Calculer les DR // Calculer les DR
@@ -1142,21 +1646,25 @@ export default class LethalFantasyUtils {
buttons: [ buttons: [
{ {
action: "noDR", action: "noDR",
type: "button",
label: "No DR", label: "No DR",
callback: () => ({ drType: "none", damage: damageTotal }) callback: () => ({ drType: "none", damage: damageTotal })
}, },
{ {
action: "armorDR", action: "armorDR",
type: "button",
label: "With Armor DR", label: "With Armor DR",
callback: () => ({ drType: "armor", damage: Math.max(0, damageTotal - armorDR) }) callback: () => ({ drType: "armor", damage: Math.max(0, damageTotal - armorDR) })
}, },
{ {
action: "allDR", action: "allDR",
type: "button",
label: "With Armor + Shield DR", label: "With Armor + Shield DR",
callback: () => ({ drType: "all", damage: Math.max(0, damageTotal - totalDR) }) callback: () => ({ drType: "all", damage: Math.max(0, damageTotal - totalDR) })
}, },
{ {
action: "cancel", action: "cancel",
type: "button",
label: "Cancel", label: "Cancel",
callback: () => null callback: () => null
} }
@@ -1185,10 +1693,10 @@ export default class LethalFantasyUtils {
} }
) )
ChatMessage.create({ await ChatMessage.create({
user: game.user.id, user: game.user.id,
speaker: { alias: targetActor.name }, speaker: { alias: targetActor.name },
rollMode: "gmroll", mode: "gm",
content: messageContent content: messageContent
}) })
} }
-1
View File
@@ -1 +0,0 @@
MANIFEST-000583
View File
-8
View File
@@ -1,8 +0,0 @@
2026/05/01-23:33:08.433602 7f8fb27bf6c0 Recovering log #581
2026/05/01-23:33:08.476792 7f8fb27bf6c0 Delete type=3 #579
2026/05/01-23:33:08.476868 7f8fb27bf6c0 Delete type=0 #581
2026/05/01-23:33:55.878970 7f8d1bfff6c0 Level-0 table #586: started
2026/05/01-23:33:55.881418 7f8d1bfff6c0 Level-0 table #586: 0 bytes OK
2026/05/01-23:33:55.924908 7f8d1bfff6c0 Delete type=0 #584
2026/05/01-23:33:56.035970 7f8d1bfff6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
2026/05/01-23:33:56.036022 7f8d1bfff6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
-8
View File
@@ -1,8 +0,0 @@
2026/04/30-14:38:06.808992 7f3f35bff6c0 Recovering log #577
2026/04/30-14:38:06.818757 7f3f35bff6c0 Delete type=3 #575
2026/04/30-14:38:06.818831 7f3f35bff6c0 Delete type=0 #577
2026/04/30-14:38:35.518816 7f3ee77fe6c0 Level-0 table #582: started
2026/04/30-14:38:35.518836 7f3ee77fe6c0 Level-0 table #582: 0 bytes OK
2026/04/30-14:38:35.525869 7f3ee77fe6c0 Delete type=0 #580
2026/04/30-14:38:35.538258 7f3ee77fe6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
2026/04/30-14:38:35.538288 7f3ee77fe6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
Binary file not shown.
View File
-1
View File
@@ -1 +0,0 @@
MANIFEST-000580
View File
-8
View File
@@ -1,8 +0,0 @@
2026/05/01-23:33:08.486839 7f8fb17bd6c0 Recovering log #578
2026/05/01-23:33:08.536613 7f8fb17bd6c0 Delete type=3 #576
2026/05/01-23:33:08.536667 7f8fb17bd6c0 Delete type=0 #578
2026/05/01-23:33:55.999594 7f8d1bfff6c0 Level-0 table #583: started
2026/05/01-23:33:55.999624 7f8d1bfff6c0 Level-0 table #583: 0 bytes OK
2026/05/01-23:33:56.035856 7f8d1bfff6c0 Delete type=0 #581
2026/05/01-23:33:56.036000 7f8d1bfff6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
2026/05/01-23:33:56.036042 7f8d1bfff6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
-8
View File
@@ -1,8 +0,0 @@
2026/04/30-14:38:06.823818 7f3f353fe6c0 Recovering log #574
2026/04/30-14:38:06.834104 7f3f353fe6c0 Delete type=3 #572
2026/04/30-14:38:06.834187 7f3f353fe6c0 Delete type=0 #574
2026/04/30-14:38:35.525993 7f3ee77fe6c0 Level-0 table #579: started
2026/04/30-14:38:35.526019 7f3ee77fe6c0 Level-0 table #579: 0 bytes OK
2026/04/30-14:38:35.532067 7f3ee77fe6c0 Delete type=0 #577
2026/04/30-14:38:35.538267 7f3ee77fe6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
2026/04/30-14:38:35.538302 7f3ee77fe6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
Binary file not shown.
View File
-1
View File
@@ -1 +0,0 @@
MANIFEST-000585
View File
-8
View File
@@ -1,8 +0,0 @@
2026/05/01-23:33:08.376215 7f8fb0fbc6c0 Recovering log #583
2026/05/01-23:33:08.417318 7f8fb0fbc6c0 Delete type=3 #581
2026/05/01-23:33:08.417396 7f8fb0fbc6c0 Delete type=0 #583
2026/05/01-23:33:55.962045 7f8d1bfff6c0 Level-0 table #588: started
2026/05/01-23:33:55.962068 7f8d1bfff6c0 Level-0 table #588: 0 bytes OK
2026/05/01-23:33:55.999439 7f8d1bfff6c0 Delete type=0 #586
2026/05/01-23:33:56.035992 7f8d1bfff6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2026/05/01-23:33:56.036035 7f8d1bfff6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
-8
View File
@@ -1,8 +0,0 @@
2026/04/30-14:38:06.795186 7f3f353fe6c0 Recovering log #579
2026/04/30-14:38:06.805935 7f3f353fe6c0 Delete type=3 #577
2026/04/30-14:38:06.805994 7f3f353fe6c0 Delete type=0 #579
2026/04/30-14:38:35.512680 7f3ee77fe6c0 Level-0 table #584: started
2026/04/30-14:38:35.512729 7f3ee77fe6c0 Level-0 table #584: 0 bytes OK
2026/04/30-14:38:35.518704 7f3ee77fe6c0 Delete type=0 #582
2026/04/30-14:38:35.538247 7f3ee77fe6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2026/04/30-14:38:35.538281 7f3ee77fe6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
Binary file not shown.
-1
View File
@@ -1 +0,0 @@
MANIFEST-000280
-8
View File
@@ -1,8 +0,0 @@
2026/05/01-23:33:08.590994 7f8fb1fbe6c0 Recovering log #278
2026/05/01-23:33:08.636941 7f8fb1fbe6c0 Delete type=3 #276
2026/05/01-23:33:08.636992 7f8fb1fbe6c0 Delete type=0 #278
2026/05/01-23:33:56.204694 7f8d1bfff6c0 Level-0 table #283: started
2026/05/01-23:33:56.204728 7f8d1bfff6c0 Level-0 table #283: 0 bytes OK
2026/05/01-23:33:56.238272 7f8d1bfff6c0 Delete type=0 #281
2026/05/01-23:33:56.371888 7f8d1bfff6c0 Manual compaction at level-0 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
2026/05/01-23:33:56.426259 7f8d1bfff6c0 Manual compaction at level-1 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
-8
View File
@@ -1,8 +0,0 @@
2026/04/30-14:38:06.849252 7f3f353fe6c0 Recovering log #274
2026/04/30-14:38:06.859072 7f3f353fe6c0 Delete type=3 #272
2026/04/30-14:38:06.859126 7f3f353fe6c0 Delete type=0 #274
2026/04/30-14:38:35.538433 7f3ee77fe6c0 Level-0 table #279: started
2026/04/30-14:38:35.538452 7f3ee77fe6c0 Level-0 table #279: 0 bytes OK
2026/04/30-14:38:35.544715 7f3ee77fe6c0 Delete type=0 #277
2026/04/30-14:38:35.567736 7f3ee77fe6c0 Manual compaction at level-0 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
2026/04/30-14:38:35.567785 7f3ee77fe6c0 Manual compaction at level-1 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
Binary file not shown.
-1
View File
@@ -1 +0,0 @@
MANIFEST-000579
-8
View File
@@ -1,8 +0,0 @@
2026/05/01-23:33:08.543693 7f8fb0fbc6c0 Recovering log #577
2026/05/01-23:33:08.586596 7f8fb0fbc6c0 Delete type=3 #575
2026/05/01-23:33:08.586670 7f8fb0fbc6c0 Delete type=0 #577
2026/05/01-23:33:55.925044 7f8d1bfff6c0 Level-0 table #582: started
2026/05/01-23:33:55.925074 7f8d1bfff6c0 Level-0 table #582: 0 bytes OK
2026/05/01-23:33:55.961939 7f8d1bfff6c0 Delete type=0 #580
2026/05/01-23:33:56.035982 7f8d1bfff6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2026/05/01-23:33:56.036029 7f8d1bfff6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
-8
View File
@@ -1,8 +0,0 @@
2026/04/30-14:38:06.836968 7f3ee7fff6c0 Recovering log #573
2026/04/30-14:38:06.846980 7f3ee7fff6c0 Delete type=3 #571
2026/04/30-14:38:06.847050 7f3ee7fff6c0 Delete type=0 #573
2026/04/30-14:38:35.532186 7f3ee77fe6c0 Level-0 table #578: started
2026/04/30-14:38:35.532209 7f3ee77fe6c0 Level-0 table #578: 0 bytes OK
2026/04/30-14:38:35.538132 7f3ee77fe6c0 Delete type=0 #576
2026/04/30-14:38:35.538276 7f3ee77fe6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2026/04/30-14:38:35.538295 7f3ee77fe6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
Binary file not shown.
+4 -4
View File
@@ -387,11 +387,11 @@
min-width: 6rem; min-width: 6rem;
max-width: 6rem; max-width: 6rem;
} }
min-width: 10rem; min-width: 11rem;
max-width: 10rem; max-width: 11rem;
.input { .input {
min-width: 2.5rem; min-width: 3.5rem;
max-width: 2.5rem; max-width: 3.5rem;
} }
} }
.granted { .granted {
+69 -12
View File
@@ -145,9 +145,11 @@
} }
.grit-luck-dialog { .grit-luck-dialog {
color: var(--color-text-dark-primary, #191813);
.combat-status { .combat-status {
padding: 12px; padding: 12px;
background: linear-gradient(to bottom, rgba(42, 41, 32, 0.8) 0%, rgba(26, 25, 16, 0.9) 100%); background: linear-gradient(to bottom, rgba(42, 41, 32, 0.88) 0%, rgba(26, 25, 16, 0.95) 100%);
border: 1px solid rgba(212, 175, 55, 0.5); border: 1px solid rgba(212, 175, 55, 0.5);
border-radius: 6px; border-radius: 6px;
margin-bottom: 16px; margin-bottom: 16px;
@@ -171,11 +173,27 @@
} }
.offer-text { .offer-text {
color: #f0e6d2; color: var(--color-text-dark-primary, #191813);
font-size: calc(var(--font-size-standard) * 1); font-size: calc(var(--font-size-standard) * 1);
text-align: center; text-align: center;
font-weight: 600; font-weight: 600;
margin: 0 0 8px 0;
}
.shield-warning {
color: #7a4000;
background: rgba(255, 160, 0, 0.12);
border: 1px solid rgba(255, 160, 0, 0.4);
border-radius: 5px;
font-size: calc(var(--font-size-standard) * 0.88);
padding: 6px 10px;
margin: 0; margin: 0;
text-align: center;
i {
color: #c07000;
margin-right: 5px;
}
} }
} }
@@ -283,33 +301,72 @@
} }
.attack-result-damage { .attack-result-damage {
display: flex; display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 8px; gap: 8px;
justify-content: center;
&.single-btn {
grid-template-columns: 1fr;
max-width: 280px;
margin: 0 auto;
}
&.spell-damage {
grid-template-columns: 1fr;
width: 100%;
}
.roll-damage-btn { .roll-damage-btn {
padding: 10px 16px; padding: 10px 14px;
background: linear-gradient(to bottom, #8b0000 0%, #660000 100%); background: linear-gradient(to bottom, #8b0000 0%, #660000 100%);
border: 1px solid #ff0000; border: 1px solid #4b0000;
border-radius: 6px; border-radius: 6px;
color: #f0e6d2; color: #f0e6d2;
font-weight: 600; font-weight: 600;
font-size: calc(var(--font-size-standard) * 0.9);
text-align: center;
white-space: nowrap;
cursor: pointer; cursor: pointer;
transition: all 0.2s ease; transition: all 0.2s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
position: relative;
overflow: hidden;
&::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
transition: left 0.5s;
}
&:hover::before {
left: 100%;
}
i {
font-size: calc(var(--font-size-standard) * 1.1);
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
flex-shrink: 0;
}
&:hover { &:hover {
background: linear-gradient(to bottom, #a00000 0%, #7b0000 100%); background: linear-gradient(to bottom, #a00000 0%, #7b0000 100%);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
transform: translateY(-2px); transform: translateY(-2px);
border-color: #5b0000;
} }
&:active { &:active {
transform: translateY(0); transform: translateY(0);
} box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 3px rgba(0, 0, 0, 0.3);
i {
margin-right: 6px;
} }
} }
} }
+60
View File
@@ -89,6 +89,66 @@
font-size: 0.9rem; font-size: 0.9rem;
} }
/* Luck/Grit Styles */
#token-hud .luck-grit-wrap {
position: absolute;
left: 75px;
display: none;
top: 50%;
width: 80px;
text-align: start;
background: rgba(0, 0, 0, 0.8);
border: 1px solid rgba(139, 69, 19, 0.5);
border-radius: 4px;
padding: 4px 6px;
transform: translate(-100%, -50%);
}
#token-hud .luck-grit-hud-active {
display: block;
}
#token-hud .luck-grit-hud-disabled {
display: none;
}
#token-hud .luck-grit-row {
display: flex;
align-items: center;
gap: 4px;
margin: 2px 0;
}
#token-hud .luck-grit-label {
flex: 1;
color: #c9b896;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
}
#token-hud .luck-grit-btn {
width: 28px;
height: 22px;
padding: 0;
background: rgba(139, 69, 19, 0.25);
border: 1px solid rgba(139, 69, 19, 0.4);
border-radius: 3px;
color: #d4c5a9;
font-size: 12px;
font-weight: 700;
cursor: pointer;
line-height: 1;
display: flex;
align-items: center;
justify-content: center;
&:hover {
background: rgba(139, 69, 19, 0.5);
border-color: rgba(139, 69, 19, 0.7);
}
}
/* -------------------------------------------------- */ /* -------------------------------------------------- */
/* Dice Tray — injected into the Foundry chat sidebar */ /* Dice Tray — injected into the Foundry chat sidebar */
/* -------------------------------------------------- */ /* -------------------------------------------------- */
+67 -15
View File
@@ -176,6 +176,22 @@
} }
} }
.dialog-warning {
margin: 0.4rem 0.2rem 0.2rem;
padding: 0.35rem 0.5rem;
border-left: 3px solid #c8941a;
background: rgba(200, 148, 26, 0.12);
border-radius: 3px;
font-family: var(--font-secondary);
font-size: calc(var(--font-size-standard) * 0.9);
color: #7a5400;
line-height: 1.4;
i {
color: #c8941a;
margin-right: 0.4rem;
}
}
.lethalfantasy, .lethalfantasy,
.fvtt-lethal-fantasy, .fvtt-lethal-fantasy,
.message.lethalfantasy, .message.lethalfantasy,
@@ -631,14 +647,10 @@
.damage-buttons-grid { .damage-buttons-grid {
display: grid; display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 8px;
&.monster-damage {
grid-template-columns: 1fr; grid-template-columns: 1fr;
max-width: 280px; max-width: 280px;
margin: 0 auto; margin: 0 auto;
} gap: 8px;
.damage-roll-btn { .damage-roll-btn {
padding: 10px 14px; padding: 10px 14px;
@@ -831,6 +843,7 @@
display: grid; display: grid;
grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(2, 1fr);
gap: 8px; gap: 8px;
justify-items: center;
} }
} }
} }
@@ -1269,33 +1282,72 @@
} }
.attack-result-damage { .attack-result-damage {
display: flex; display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 8px; gap: 8px;
justify-content: center;
&.single-btn {
grid-template-columns: 1fr;
max-width: 280px;
margin: 0 auto;
}
&.spell-damage {
grid-template-columns: 1fr;
width: 100%;
}
.roll-damage-btn { .roll-damage-btn {
padding: 10px 16px; padding: 10px 14px;
background: linear-gradient(to bottom, #8b0000 0%, #660000 100%); background: linear-gradient(to bottom, #8b0000 0%, #660000 100%);
border: 1px solid #ff0000; border: 1px solid #4b0000;
border-radius: 6px; border-radius: 6px;
color: #f0e6d2; color: #f0e6d2;
font-weight: 600; font-weight: 600;
font-size: calc(var(--font-size-standard) * 0.9);
text-align: center;
white-space: nowrap;
cursor: pointer; cursor: pointer;
transition: all 0.2s ease; transition: all 0.2s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
position: relative;
overflow: hidden;
&::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
transition: left 0.5s;
}
&:hover::before {
left: 100%;
}
i {
font-size: calc(var(--font-size-standard) * 1.1);
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
flex-shrink: 0;
}
&:hover { &:hover {
background: linear-gradient(to bottom, #a00000 0%, #7b0000 100%); background: linear-gradient(to bottom, #a00000 0%, #7b0000 100%);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
transform: translateY(-2px); transform: translateY(-2px);
border-color: #5b0000;
} }
&:active { &:active {
transform: translateY(0); transform: translateY(0);
} box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 3px rgba(0, 0, 0, 0.3);
i {
margin-right: 6px;
} }
} }
} }
+19 -19
View File
@@ -9,95 +9,95 @@
<legend>{{localize "LETHALFANTASY.Label.biodata"}}</legend> <legend>{{localize "LETHALFANTASY.Label.biodata"}}</legend>
<div class="biodata"> <div class="biodata">
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Class</span> <span class="name">{{localize "LETHALFANTASY.Label.class"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.class systemFields.biodata.fields.class
value=system.biodata.class value=system.biodata.class
}} }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Level</span> <span class="name">{{localize "LETHALFANTASY.Label.level"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.level systemFields.biodata.fields.level
value=system.biodata.level value=system.biodata.level
}} }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Mortal</span> <span class="name">{{localize "LETHALFANTASY.Label.mortal"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.mortal systemFields.biodata.fields.mortal
value=system.biodata.mortal value=system.biodata.mortal
}} }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Alignment</span> <span class="name">{{localize "LETHALFANTASY.Label.alignment"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.alignment systemFields.biodata.fields.alignment
value=system.biodata.alignment value=system.biodata.alignment
}} }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Age</span> <span class="name">{{localize "LETHALFANTASY.Label.age"}}</span>
{{formInput systemFields.biodata.fields.age value=system.biodata.age}} {{formInput systemFields.biodata.fields.age value=system.biodata.age}}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Height</span> <span class="name">{{localize "LETHALFANTASY.Label.height"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.height systemFields.biodata.fields.height
value=system.biodata.height value=system.biodata.height
}} }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Weight</span> <span class="name">{{localize "LETHALFANTASY.Label.weight"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.weight systemFields.biodata.fields.weight
value=system.biodata.weight value=system.biodata.weight
}} }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Eyes</span> <span class="name">{{localize "LETHALFANTASY.Label.eyes"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.eyes systemFields.biodata.fields.eyes
value=system.biodata.eyes value=system.biodata.eyes
}} }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Hair</span> <span class="name">{{localize "LETHALFANTASY.Label.hair"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.hair systemFields.biodata.fields.hair
value=system.biodata.hair value=system.biodata.hair
}} }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Dev. Points (Total)</span> <span class="name">{{localize "LETHALFANTASY.Label.devPointsTotal"}}</span>
{{formInput {{formInput
systemFields.developmentPoints.fields.total systemFields.developmentPoints.fields.total
value=system.developmentPoints.total value=system.developmentPoints.total
}} }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Dev. Points (Rem.)</span> <span class="name">{{localize "LETHALFANTASY.Label.devPointsRem"}}</span>
{{formInput {{formInput
systemFields.developmentPoints.fields.remaining systemFields.developmentPoints.fields.remaining
value=system.developmentPoints.remaining value=system.developmentPoints.remaining
}} }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Magic User</span> <span class="name">{{localize "LETHALFANTASY.Label.magicUser"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.magicUser systemFields.biodata.fields.magicUser
value=system.biodata.magicUser value=system.biodata.magicUser
}} }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Cleric User</span> <span class="name">{{localize "LETHALFANTASY.Label.clericUser"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.clericUser systemFields.biodata.fields.clericUser
value=system.biodata.clericUser value=system.biodata.clericUser
}} }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Save bonus (1/5levels)</span> <span class="name">{{localize "LETHALFANTASY.Label.saveBonus"}}</span>
{{formInput {{formInput
systemFields.modifiers.fields.saveModifier systemFields.modifiers.fields.saveModifier
value=system.modifiers.saveModifier value=system.modifiers.saveModifier
@@ -107,7 +107,7 @@
{{#if system.biodata.magicUser}} {{#if system.biodata.magicUser}}
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Spell bonus (1/5levels)</span> <span class="name">{{localize "LETHALFANTASY.Label.spellBonus"}}</span>
{{formInput {{formInput
systemFields.modifiers.fields.levelSpellModifier systemFields.modifiers.fields.levelSpellModifier
value=system.modifiers.levelSpellModifier value=system.modifiers.levelSpellModifier
@@ -117,7 +117,7 @@
{{/if}} {{/if}}
{{#if system.biodata.clericUser}} {{#if system.biodata.clericUser}}
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Miracle bonus (1/5levels)</span> <span class="name">{{localize "LETHALFANTASY.Label.miracleBonus"}}</span>
{{formInput {{formInput
systemFields.modifiers.fields.levelMiracleModifier systemFields.modifiers.fields.levelMiracleModifier
value=system.modifiers.levelMiracleModifier value=system.modifiers.levelMiracleModifier
@@ -127,7 +127,7 @@
{{/if}} {{/if}}
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Last HD roll</span> <span class="name">{{localize "LETHALFANTASY.Label.lastHdRoll"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.hpPerLevel systemFields.biodata.fields.hpPerLevel
value=system.biodata.hpPerLevel value=system.biodata.hpPerLevel
@@ -136,7 +136,7 @@
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Natural DR</span> <span class="name">{{localize "LETHALFANTASY.Label.naturalDR"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.naturalDR systemFields.biodata.fields.naturalDR
value=system.biodata.naturalDR value=system.biodata.naturalDR
@@ -145,7 +145,7 @@
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Magical DR</span> <span class="name">{{localize "LETHALFANTASY.Label.magicalDR"}}</span>
{{formInput {{formInput
systemFields.biodata.fields.magicDR systemFields.biodata.fields.magicDR
value=system.biodata.magicDR value=system.biodata.magicDR
+4 -10
View File
@@ -87,16 +87,10 @@
<i class="fa-solid fa-shield-halved" data-roll-type="weapon-defense" data-roll-key="{{item.id}}"></i> <i class="fa-solid fa-shield-halved" data-roll-type="weapon-defense" data-roll-key="{{item.id}}"></i>
</a> </a>
<a class="rollable" data-roll-type="weapon-damage-small" data-roll-key="{{item.id}}" <a class="rollable" data-roll-type="weapon-damage" data-roll-key="{{item.id}}"
data-tooltip="Roll Damage (Small)"> data-tooltip="Roll Damage">
<i class="fa-regular fa-face-head-bandage" data-roll-type="weapon-damage-small" <i class="fa-regular fa-face-head-bandage" data-roll-type="weapon-damage"
data-roll-key="{{item.id}}"></i>S data-roll-key="{{item.id}}"></i>
</a>
<a class="rollable" data-roll-type="weapon-damage-medium" data-roll-key="{{item.id}}"
data-tooltip="Roll Damage (Medium)">
<i class="fa-regular fa-face-head-bandage" data-roll-type="weapon-damage-medium"
data-roll-key="{{item.id}}"></i>M
</a> </a>
</div> </div>
+2 -2
View File
@@ -5,12 +5,12 @@
<legend>{{localize "LETHALFANTASY.Label.divinityPoints"}}</legend> <legend>{{localize "LETHALFANTASY.Label.divinityPoints"}}</legend>
<div class="miracle-details"> <div class="miracle-details">
<div class="miracle-detail"> <div class="miracle-detail">
<span>Current</span> <span>{{localize "LETHALFANTASY.Label.current"}}</span>
{{formField systemFields.divinityPoints.fields.value value=system.divinityPoints.value localize=true}} {{formField systemFields.divinityPoints.fields.value value=system.divinityPoints.value localize=true}}
<a data-action="divinityPointsPlus"><i class="fa-solid fa-hexagon-plus"></i></a> <a data-action="divinityPointsPlus"><i class="fa-solid fa-hexagon-plus"></i></a>
<a data-action="divinityPointsMinus"><i class="fa-solid fa-hexagon-minus"></i></a> <a data-action="divinityPointsMinus"><i class="fa-solid fa-hexagon-minus"></i></a>
<span>Max</span> <span>{{localize "LETHALFANTASY.Label.max"}}</span>
{{formField systemFields.divinityPoints.fields.max value=system.divinityPoints.max localize=true {{formField systemFields.divinityPoints.fields.max value=system.divinityPoints.max localize=true
disabled=isPlayMode}} disabled=isPlayMode}}
</div> </div>
+21 -2
View File
@@ -5,12 +5,12 @@
<legend>{{localize "LETHALFANTASY.Label.aetherPoints"}}</legend> <legend>{{localize "LETHALFANTASY.Label.aetherPoints"}}</legend>
<div class="spell-details"> <div class="spell-details">
<div class="spell-detail"> <div class="spell-detail">
<span>Current</span> <span>{{localize "LETHALFANTASY.Label.current"}}</span>
{{formField systemFields.aetherPoints.fields.value value=system.aetherPoints.value localize=true}} {{formField systemFields.aetherPoints.fields.value value=system.aetherPoints.value localize=true}}
<a data-action="aetherPointsPlus"><i class="fa-solid fa-hexagon-plus"></i></a> <a data-action="aetherPointsPlus"><i class="fa-solid fa-hexagon-plus"></i></a>
<a data-action="aetherPointsMinus"><i class="fa-solid fa-hexagon-minus"></i></a> <a data-action="aetherPointsMinus"><i class="fa-solid fa-hexagon-minus"></i></a>
<span>Max</span> <span>{{localize "LETHALFANTASY.Label.max"}}</span>
{{formField systemFields.aetherPoints.fields.max value=system.aetherPoints.max localize=true {{formField systemFields.aetherPoints.fields.max value=system.aetherPoints.max localize=true
disabled=isPlayMode}} disabled=isPlayMode}}
</div> </div>
@@ -37,6 +37,25 @@
<i class="fa-duotone fa-solid fa-stars" data-roll-type="spell-power" data-roll-key="{{item.id}}"></i> <i class="fa-duotone fa-solid fa-stars" data-roll-type="spell-power" data-roll-key="{{item.id}}"></i>
</a> </a>
{{#if item.system.damageDice}}
<a data-action="rollSpellDamage" data-item-id="{{item.id}}" data-damage-tier="standard"
data-tooltip="Spell Damage (Standard)">
<i class="fa-solid fa-wand-magic-sparkles"></i>S
</a>
{{/if}}
{{#if item.system.damageDiceOverpowered}}
<a data-action="rollSpellDamage" data-item-id="{{item.id}}" data-damage-tier="overpowered"
data-tooltip="Spell Damage (Overpowered)">
<i class="fa-solid fa-wand-magic-sparkles"></i>O
</a>
{{/if}}
{{#if item.system.damageDiceOverpowered2}}
<a data-action="rollSpellDamage" data-item-id="{{item.id}}" data-damage-tier="overpowered2"
data-tooltip="Spell Damage (Overpowered 2)">
<i class="fa-solid fa-wand-magic-sparkles"></i>O2
</a>
{{/if}}
<div class="controls"> <div class="controls">
<a data-tooltip="{{localize 'LETHALFANTASY.Edit'}}" data-action="edit" data-item-id="{{item.id}}" <a data-tooltip="{{localize 'LETHALFANTASY.Edit'}}" data-action="edit" data-item-id="{{item.id}}"
data-item-uuid="{{item.uuid}}"><i class="fas fa-edit"></i></a> data-item-uuid="{{item.uuid}}"><i class="fas fa-edit"></i></a>
+10 -29
View File
@@ -40,45 +40,39 @@
{{#if (eq rollData.favor "favor")}} {{#if (eq rollData.favor "favor")}}
<div class="detail-badge favor-badge"> <div class="detail-badge favor-badge">
<i class="fa-solid fa-sparkles"></i> <i class="fa-solid fa-sparkles"></i>
<span>Favor</span> <span>{{localize "LETHALFANTASY.Label.favor"}}</span>
</div> </div>
{{/if}} {{/if}}
{{#if (eq rollData.favor "disfavor")}} {{#if (eq rollData.favor "disfavor")}}
<div class="detail-badge disfavor-badge"> <div class="detail-badge disfavor-badge">
<i class="fa-solid fa-skull"></i> <i class="fa-solid fa-skull"></i>
<span>Disfavor</span> <span>{{localize "LETHALFANTASY.Label.disfavor"}}</span>
</div> </div>
{{/if}} {{/if}}
{{#if rollData.letItFly}} {{#if rollData.letItFly}}
<div class="detail-badge special-badge"> <div class="detail-badge special-badge">
<i class="fa-solid fa-bow-arrow"></i> <i class="fa-solid fa-bow-arrow"></i>
<span>Let It Fly!</span> <span>{{localize "LETHALFANTASY.Label.letItFly"}}</span>
</div> </div>
{{/if}} {{/if}}
{{#if rollData.pointBlank}} {{#if rollData.pointBlank}}
<div class="detail-badge special-badge"> <div class="detail-badge special-badge">
<i class="fa-solid fa-bullseye-arrow"></i> <i class="fa-solid fa-bullseye-arrow"></i>
<span>Point Blank</span> <span>{{localize "LETHALFANTASY.Label.pointBlank"}}</span>
</div> </div>
{{/if}} {{/if}}
{{#if rollData.beyondSkill}} {{#if rollData.beyondSkill}}
<div class="detail-badge special-badge"> <div class="detail-badge special-badge">
<i class="fa-solid fa-target-lock"></i> <i class="fa-solid fa-target-lock"></i>
<span>Beyond Skill</span> <span>{{localize "LETHALFANTASY.Label.beyondSkill"}}</span>
</div> </div>
{{/if}} {{/if}}
{{#if rollData.damageSmall}} {{#if rollData.isDamage}}
<div class="detail-badge damage-badge">
<i class="fa-solid fa-dice-d6"></i>
<span>{{localize "LETHALFANTASY.Label.weapon-damage-small"}}</span>
</div>
{{/if}}
{{#if rollData.damageMedium}}
<div class="detail-badge damage-badge"> <div class="detail-badge damage-badge">
<i class="fa-solid fa-dice-d20"></i> <i class="fa-solid fa-dice-d20"></i>
<span>{{localize "LETHALFANTASY.Label.weapon-damage-medium"}}</span> <span>{{localize "LETHALFANTASY.Label.weapon-damage"}}</span>
</div> </div>
{{/if}} {{/if}}
@@ -111,7 +105,7 @@
{{#unless isPrivate}} {{#unless isPrivate}}
<div class="result-section"> <div class="result-section">
<div class="main-result"> <div class="main-result">
<div class="result-label">Total</div> <div class="result-label">{{localize "LETHALFANTASY.Label.total"}}</div>
<div class="result-value {{#if (eq resultType 'success')}}success{{else}}failure{{/if}}"> <div class="result-value {{#if (eq resultType 'success')}}success{{else}}failure{{/if}}">
{{total}} {{total}}
</div> </div>
@@ -177,7 +171,7 @@
{{else}} {{else}}
<div class="private-result"> <div class="private-result">
<i class="fa-solid fa-eye-slash"></i> <i class="fa-solid fa-eye-slash"></i>
<span>Private Roll</span> <span>{{localize "LETHALFANTASY.Label.privateRoll"}}</span>
</div> </div>
{{/unless}} {{/unless}}
@@ -202,19 +196,6 @@
}}+{{weaponDamageOptions.damageModifier}}{{/if}} }}+{{weaponDamageOptions.damageModifier}}{{/if}}
</button> </button>
{{else}} {{else}}
{{#if weaponDamageOptions.damageS}}
<button
class="damage-roll-btn"
data-weapon-id="{{weaponDamageOptions.weaponId}}"
data-damage-type="small"
data-damage-formula="{{weaponDamageOptions.damageS}}"
data-is-monster="false"
title="{{localize 'LETHALFANTASY.Label.rollDamage'}}"
>
<i class="fa-solid fa-dice-d6"></i>
Damage Small
</button>
{{/if}}
{{#if weaponDamageOptions.damageM}} {{#if weaponDamageOptions.damageM}}
<button <button
class="damage-roll-btn" class="damage-roll-btn"
@@ -225,7 +206,7 @@
title="{{localize 'LETHALFANTASY.Label.rollDamage'}}" title="{{localize 'LETHALFANTASY.Label.rollDamage'}}"
> >
<i class="fa-solid fa-dice-d20"></i> <i class="fa-solid fa-dice-d20"></i>
Damage Medium {{localize "LETHALFANTASY.Label.damage"}}
</button> </button>
{{/if}} {{/if}}
{{/if}} {{/if}}
+8
View File
@@ -13,6 +13,14 @@
<span>{{ localize "COMBAT.End" }}</span> <span>{{ localize "COMBAT.End" }}</span>
</button> </button>
{{#if combat.round}}
<button type="button" class="combat-control combat-control-lg" data-action="rollMonsterProgression"
data-tooltip="{{ localize 'LETHALFANTASY.Combat.RollMonsters' }}">
<i class="fa-solid fa-dragon" inert></i>
<span>{{ localize "LETHALFANTASY.Combat.RollMonsters" }}</span>
</button>
{{/if}}
<!-- <button type="button" class="inline-control combat-control icon fa-solid fa-arrow-right" data-action="nextTurn" <!-- <button type="button" class="inline-control combat-control icon fa-solid fa-arrow-right" data-action="nextTurn"
data-tooltip aria-label="{{ localize "COMBAT.TurnNext" }}"></button> --> data-tooltip aria-label="{{ localize "COMBAT.TurnNext" }}"></button> -->
<button type="button" class="inline-control combat-control icon fa-solid fa-forward-step" data-action="nextRound" <button type="button" class="inline-control combat-control icon fa-solid fa-forward-step" data-action="nextRound"
+16
View File
@@ -0,0 +1,16 @@
<div class="control-icon lethal-luck-grit-hud" data-action="lethal-luck-grit-hud">
<i class="fa-solid fa-dice" title="Adjust Luck/Grit" style="width:36px;height:36px;display:flex;align-items:center;justify-content:center;font-size:18px;cursor:pointer"></i>
<div class="luck-grit-wrap luck-grit-hud-disabled">
<div class="luck-grit-row">
<span class="luck-grit-label">Luck</span>
<button class="luck-grit-btn" data-resource="luck" data-amount="-1">1</button>
<button class="luck-grit-btn" data-resource="luck" data-amount="1">+1</button>
</div>
<div class="luck-grit-row">
<span class="luck-grit-label">Grit</span>
<button class="luck-grit-btn" data-resource="grit" data-amount="-1">1</button>
<button class="luck-grit-btn" data-resource="grit" data-amount="1">+1</button>
</div>
</div>
</div>
+4 -1
View File
@@ -7,7 +7,7 @@
{{formField systemFields.miracleType value=system.miracleType}} {{formField systemFields.miracleType value=system.miracleType}}
{{formField systemFields.level value=system.level}} {{formField systemFields.level value=system.level}}
<label>Components</label> <label>{{localize "LETHALFANTASY.Label.components"}}</label>
<div class="shift-right"> <div class="shift-right">
{{formField systemFields.components.fields.verbal value=system.components.verbal}} {{formField systemFields.components.fields.verbal value=system.components.verbal}}
{{formField systemFields.components.fields.somatic value=system.components.somatic}} {{formField systemFields.components.fields.somatic value=system.components.somatic}}
@@ -27,6 +27,9 @@
{{formField systemFields.areaAffected value=system.areaAffected}} {{formField systemFields.areaAffected value=system.areaAffected}}
{{formField systemFields.duration value=system.duration}} {{formField systemFields.duration value=system.duration}}
{{formField systemFields.savingThrow value=system.savingThrow}} {{formField systemFields.savingThrow value=system.savingThrow}}
{{formField systemFields.damageDice value=system.damageDice}}
{{formField systemFields.damageDiceOverpowered value=system.damageDiceOverpowered}}
{{formField systemFields.damageDiceOverpowered2 value=system.damageDiceOverpowered2}}
+5 -5
View File
@@ -6,23 +6,23 @@
<div class="biodata"> <div class="biodata">
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Alignment</span> <span class="name">{{localize "LETHALFANTASY.Label.alignment"}}</span>
{{formInput systemFields.biodata.fields.alignment value=system.biodata.alignment }} {{formInput systemFields.biodata.fields.alignment value=system.biodata.alignment }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Height</span> <span class="name">{{localize "LETHALFANTASY.Label.height"}}</span>
{{formInput systemFields.biodata.fields.height value=system.biodata.height }} {{formInput systemFields.biodata.fields.height value=system.biodata.height }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Weight</span> <span class="name">{{localize "LETHALFANTASY.Label.weight"}}</span>
{{formInput systemFields.biodata.fields.weight value=system.biodata.weight }} {{formInput systemFields.biodata.fields.weight value=system.biodata.weight }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Length</span> <span class="name">{{localize "LETHALFANTASY.Label.length"}}</span>
{{formInput systemFields.biodata.fields.length value=system.biodata.length }} {{formInput systemFields.biodata.fields.length value=system.biodata.length }}
</div> </div>
<div class="biodata-elem"> <div class="biodata-elem">
<span class="name">Vision</span> <span class="name">{{localize "LETHALFANTASY.Label.vision"}}</span>
{{formInput systemFields.biodata.fields.vision value=system.biodata.vision }} {{formInput systemFields.biodata.fields.vision value=system.biodata.vision }}
</div> </div>
+1 -1
View File
@@ -160,7 +160,7 @@
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend>Hand To Hand Attacks</legend> <legend>{{localize "LETHALFANTASY.Label.handToHandAttacks"}}</legend>
<div class="attacks"> <div class="attacks">
{{#each system.combatHTH as |item key|}} {{#each system.combatHTH as |item key|}}
<div class="attack" data-attack-key="{{key}}" > <div class="attack" data-attack-key="{{key}}" >
+45
View File
@@ -0,0 +1,45 @@
<div class="lethalfantasy-range-defense-dialog">
<fieldSet class="">
<legend>{{localize "LETHALFANTASY.Label.rangeAttackDialog"}}</legend>
<div class="field-section">
<span class="field-name">Attacker Movement :</span>
<select name="movement" data-tooltip-direction="UP">
{{selectOptions attackerMovementChoices selected=movement}}
</select>
</div>
<div class="field-section">
<span class="field-name">Range :</span>
<select name="range" data-tooltip-direction="UP">
{{selectOptions rangeChoices selected=range}}
</select>
</div>
<div class="field-section">
<span class="field-name">Target Size :</span>
<select name="size" data-tooltip-direction="UP">
{{selectOptions sizeChoices selected=size}}
</select>
</div>
<div class="field-section">
<span class="field-name">Aim :</span>
<select name="attackerAim" data-tooltip-direction="UP">
{{selectOptions attackerAimChoices selected=attackerAim}}
</select>
</div>
</fieldSet>
<fieldSet>
<legend>{{localize "LETHALFANTASY.Roll.visibility"}}</legend>
<span class="fieldset-centered">
<select name="visibility">
{{selectOptions rollModes selected=visibility localize=true}}
</select>
</span>
</fieldSet>
</div>
+6 -5
View File
@@ -55,8 +55,7 @@
<div class="dialog-save">Add Granted Attack Dice <div class="dialog-save">Add Granted Attack Dice
<input type="checkbox" data-action="selectGranted" name="granted" /> <input type="checkbox" data-action="selectGranted" name="granted" />
</div> </div>
{{#if rollTarget.weapon}} {{#if isRangedAttack}}
{{#if (eq rollTarget.weapon.system.weaponType "melee")}}{{else}}
<div class="dialog-save">Point Blank Range Attack <div class="dialog-save">Point Blank Range Attack
<input <input
type="checkbox" type="checkbox"
@@ -84,13 +83,16 @@
</select> </select>
</div> </div>
{{/if}} {{/if}}
{{/if}}
{{/if}} {{/if}}
{{#if (match rollType "defense")}} {{#if (match rollType "defense")}}
<div class="dialog-save">Add Granted Defense Dice <div class="dialog-save">Add Granted Defense Dice
<input type="checkbox" data-action="selectGranted" name="granted" /> <input type="checkbox" data-action="selectGranted" name="granted" />
</div> </div>
<div class="dialog-warning">
<i class="fa-solid fa-triangle-exclamation"></i>
{{localize "LETHALFANTASY.Warning.defenseShieldOrder"}}
</div>
{{/if}} {{/if}}
{{#if (match rollType "damage")}} {{#if (match rollType "damage")}}
<div class="dialog-save">Add Granted Damage Dice <div class="dialog-save">Add Granted Damage Dice
@@ -121,7 +123,6 @@
</select> </select>
{{#if (eq rollType "save")}} {{#if (eq rollType "save")}}
{{#if rollTarget.magicUser}}
<div> <div>
<span>Save against spell (+{{rollTarget.actorModifiers.saveModifier}}) <span>Save against spell (+{{rollTarget.actorModifiers.saveModifier}})
?</span> ?</span>
@@ -129,10 +130,10 @@
type="checkbox" type="checkbox"
name="saveSpellCheck" name="saveSpellCheck"
data-action="saveSpellCheck" data-action="saveSpellCheck"
{{#if saveSpell}}checked{{/if}}
/> />
</div> </div>
{{/if}} {{/if}}
{{/if}}
</fieldSet> </fieldSet>
{{/if}} {{/if}}
+3 -3
View File
@@ -22,9 +22,9 @@
{{formField systemFields.hascover value=system.hascover}} {{formField systemFields.hascover value=system.hascover}}
{{#if system.hascover}} {{#if system.hascover}}
<label>Cover vs ranged attacks</label> <label>{{localize "LETHALFANTASY.Label.coverRanged"}}</label>
<div class="shift-right"> <div class="shift-right">
<label>Standing </label> <label>{{localize "LETHALFANTASY.Label.standing"}}</label>
<div class="flexrow">{{formField <div class="flexrow">{{formField
systemFields.standing.fields.min systemFields.standing.fields.min
value=system.standing.min value=system.standing.min
@@ -33,7 +33,7 @@
</div> </div>
</div> </div>
<div class="shift-right"> <div class="shift-right">
<label>Crouching</label> <label>{{localize "LETHALFANTASY.Label.crouching"}}</label>
<div class="flexrow">{{formField <div class="flexrow">{{formField
systemFields.crouching.fields.min systemFields.crouching.fields.min
value=system.crouching.min value=system.crouching.min
+5 -1
View File
@@ -6,8 +6,10 @@
{{formField systemFields.level value=system.level}} {{formField systemFields.level value=system.level}}
{{formField systemFields.cost value=system.cost}} {{formField systemFields.cost value=system.cost}}
{{formField systemFields.costOverpowered value=system.costOverpowered}}
{{formField systemFields.costOverpowered2 value=system.costOverpowered2}}
<label>Components</label> <label>{{localize "LETHALFANTASY.Label.components"}}</label>
<div class="shift-right"> <div class="shift-right">
{{formField systemFields.components.fields.verbal value=system.components.verbal}} {{formField systemFields.components.fields.verbal value=system.components.verbal}}
{{formField systemFields.components.fields.somatic value=system.components.somatic}} {{formField systemFields.components.fields.somatic value=system.components.somatic}}
@@ -31,6 +33,8 @@
{{formField systemFields.extraAetherPoints value=system.extraAetherPoints}} {{formField systemFields.extraAetherPoints value=system.extraAetherPoints}}
{{formField systemFields.criticalType value=system.criticalType}} {{formField systemFields.criticalType value=system.criticalType}}
{{formField systemFields.damageDice value=system.damageDice}} {{formField systemFields.damageDice value=system.damageDice}}
{{formField systemFields.damageDiceOverpowered value=system.damageDiceOverpowered}}
{{formField systemFields.damageDiceOverpowered2 value=system.damageDiceOverpowered2}}
<fieldset> <fieldset>
+5 -9
View File
@@ -10,18 +10,14 @@
{{formField systemFields.weaponType value=system.weaponType localize=true}} {{formField systemFields.weaponType value=system.weaponType localize=true}}
{{formField systemFields.weaponClass value=system.weaponClass localize=true}} {{formField systemFields.weaponClass value=system.weaponClass localize=true}}
<label>Damage Type</label> <label>{{localize "LETHALFANTASY.Label.damageType"}}</label>
<div class="shift-right"> <div class="shift-right">
{{formField systemFields.damageType.fields.typeP value=system.damageType.typeP}} {{formField systemFields.damageType.fields.typeP value=system.damageType.typeP}}
{{formField systemFields.damageType.fields.typeB value=system.damageType.typeB}} {{formField systemFields.damageType.fields.typeB value=system.damageType.typeB}}
{{formField systemFields.damageType.fields.typeS value=system.damageType.typeS}} {{formField systemFields.damageType.fields.typeS value=system.damageType.typeS}}
</div> </div>
<label>Damage</label> {{formField systemFields.damage.fields.damageM value=system.damage.damageM label=(localize "LETHALFANTASY.Label.damage")}}
<div class="shift-right">
{{formField systemFields.damage.fields.damageS value=system.damage.damageS}}
{{formField systemFields.damage.fields.damageM value=system.damage.damageM}}
</div>
{{formField systemFields.applyStrengthDamageBonus value=system.applyStrengthDamageBonus localize=true}} {{formField systemFields.applyStrengthDamageBonus value=system.applyStrengthDamageBonus localize=true}}
@@ -34,7 +30,7 @@
{{/if}} {{/if}}
{{#if (eq system.weaponType "ranged")}} {{#if (eq system.weaponType "ranged")}}
<label>Speed</label> <label>{{localize "LETHALFANTASY.Label.speed"}}</label>
<div class="shift-right"> <div class="shift-right">
{{formField systemFields.speed.fields.simpleAim value=system.speed.simpleAim}} {{formField systemFields.speed.fields.simpleAim value=system.speed.simpleAim}}
{{formField systemFields.speed.fields.carefulAim value=system.speed.carefulAim}} {{formField systemFields.speed.fields.carefulAim value=system.speed.carefulAim}}
@@ -47,7 +43,7 @@
{{formField systemFields.defense value=system.defense}} {{formField systemFields.defense value=system.defense}}
<label>Range</label> <label>{{localize "LETHALFANTASY.Label.range"}}</label>
<div class="shift-right"> <div class="shift-right">
{{formField systemFields.weaponRange.fields.pointBlank value=system.weaponRange.pointBlank}} {{formField systemFields.weaponRange.fields.pointBlank value=system.weaponRange.pointBlank}}
{{formField systemFields.weaponRange.fields.short value=system.weaponRange.short}} {{formField systemFields.weaponRange.fields.short value=system.weaponRange.short}}
@@ -60,7 +56,7 @@
{{formField systemFields.equipped value=system.equipped}} {{formField systemFields.equipped value=system.equipped}}
<label>Bonuses</label> <label>{{localize "LETHALFANTASY.Label.bonuses"}}</label>
<div class="shift-right"> <div class="shift-right">
{{formField systemFields.bonuses.fields.attackBonus value=system.bonuses.attackBonus}} {{formField systemFields.bonuses.fields.attackBonus value=system.bonuses.attackBonus}}
{{formField systemFields.bonuses.fields.defenseBonus value=system.bonuses.defenseBonus}} {{formField systemFields.bonuses.fields.defenseBonus value=system.bonuses.defenseBonus}}
+2
View File
@@ -0,0 +1,2 @@
import { CompendiumsManager } from './CompendiumsManager.mjs';
CompendiumsManager.packToDistDir('packs_src', 'packs-system');
+2
View File
@@ -0,0 +1,2 @@
import { CompendiumsManager } from './CompendiumsManager.mjs';
CompendiumsManager.unpackToSrcDir('packs_src', 'packs-system');