Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b567c8bbea | |||
| 60b351f50d | |||
| ace726a1fc | |||
| 67499bc199 | |||
| 7eae95cbbd | |||
| 1b53bf9152 | |||
| 2570bf707e | |||
| cbeaaeec99 | |||
| 37badf2619 | |||
| 5839616863 | |||
| 89298490ef | |||
| bb42de19bd | |||
| 53f9c33419 | |||
| 06eba5f835 | |||
| 46fa2d15a3 | |||
| 8aae7bada0 | |||
| ceb62bca3f | |||
| 110ac65ba5 | |||
| 9b75fd4d96 | |||
| 141d6048e0 | |||
| ea7acf6bf8 | |||
| c20750caa7 | |||
| ce630feb51 | |||
| b35b684d50 | |||
| f6fb0b68b8 | |||
| e45edd60c4 | |||
| d389a85a9f | |||
| c217490a5b |
@@ -0,0 +1 @@
|
|||||||
|
packs/** filter=lfs diff=lfs merge=lfs -text
|
||||||
+11
@@ -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/
|
||||||
|
|
||||||
|
|||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cSpell.words": [
|
||||||
|
"biodata",
|
||||||
|
"LETHALFANTASY"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
# CLAUDE.md
|
|
||||||
|
|
||||||
This file provides guidance to Claude Code (claude.ai/code) when working with this repository.
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
FoundryVTT v13+ game system for the **Lethal Fantasy RPG**. Entry point: `lethal-fantasy.mjs`.
|
|
||||||
|
|
||||||
## Commands
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Compile LESS styles (styles/ -> css/)
|
|
||||||
npx gulp css # one-shot
|
|
||||||
npx gulp # compile + watch
|
|
||||||
|
|
||||||
# Lint
|
|
||||||
npx eslint .
|
|
||||||
|
|
||||||
# Compendium pack management (LevelDB <-> YAML source)
|
|
||||||
npm run pushLDBtoYML # export packs-system/ LevelDB -> source YAML
|
|
||||||
npm run pullYMLtoLDB # import source YAML -> packs-system/ LevelDB
|
|
||||||
```
|
|
||||||
|
|
||||||
No test suite exists.
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
Four layers in `module/`, all wired in `lethal-fantasy.mjs` via the `init` hook:
|
|
||||||
|
|
||||||
| Layer | Path | Purpose |
|
|
||||||
|---|---|---|
|
|
||||||
| Config | `module/config/` | Game constants. `SYSTEM` is `globalThis.SYSTEM` — always use `SYSTEM.*` for enumerations. |
|
|
||||||
| Models | `module/models/` | `TypeDataModel` subclasses — data schemas per document type. |
|
|
||||||
| Documents | `module/documents/` | Actor/Item/Roll/ChatMessage subclasses — game logic, roll processing, hooks. |
|
|
||||||
| Applications | `module/applications/` | `ApplicationV2` sheets + custom combat tracker. |
|
|
||||||
|
|
||||||
**Actor types**: `character`, `monster`
|
|
||||||
**Item types**: `skill`, `gift`, `vulnerability`, `weapon`, `armor`, `shield`, `spell`, `miracle`, `equipment`
|
|
||||||
|
|
||||||
Each layer has an `_module.mjs` barrel file that re-exports all classes from that layer.
|
|
||||||
|
|
||||||
Templates (`.hbs`) live in `templates/`. Styles are authored in LESS under `styles/` and compiled to `css/`.
|
|
||||||
|
|
||||||
### Key Patterns
|
|
||||||
|
|
||||||
- **Sheets**: Extend `HandlebarsApplicationMixin(foundry.applications.sheets.ActorSheetV2)` — imported from `foundry.applications.api`. **Not** the legacy `ActorSheet`. Child sheets (e.g. `character-sheet.mjs`) extend `base-actor-sheet.mjs` and override `static PARTS` and `DEFAULT_OPTIONS.actions`. Template paths are prefixed `systems/fvtt-lethal-fantasy/templates/`. Actor sheets have a play/edit toggle via `_sheetMode` and `SHEET_MODES`.
|
|
||||||
- **Models**: `static defineSchema()` using `foundry.data.fields.*`. Field definitions derived from SYSTEM config objects.
|
|
||||||
- **Rolls**: `LethalFantasyRoll` extends `Roll` with rich metadata via `this.options`. `D30Roll` is a separate class for D30 result tables (initialized in the `ready` hook).
|
|
||||||
- **Socket**: Events use `game.socket.on(\`system.${SYSTEM.id}\`, ...)`. Multi-player attack-defense uses a global `pendingDefenses` Map.
|
|
||||||
- **i18n**: All user-visible strings are keys in `lang/en.json` as `LETHALFANTASY.Category.Key`. Always use `game.i18n.localize(key)`.
|
|
||||||
|
|
||||||
### Compendium Packs
|
|
||||||
|
|
||||||
Five LevelDB packs in `packs-system/`: skills, equipment, gifts, vulnerabilities, spells-miracles. Use the `tools/` scripts to export/import editable YAML.
|
|
||||||
|
|
||||||
## Code Style
|
|
||||||
|
|
||||||
- No semicolons, double quotes, 2-space indent
|
|
||||||
- JSDoc `/** */` required on all functions/classes
|
|
||||||
- Max line length 180 (strings/templates exempt)
|
|
||||||
- Arrow functions: omit parens for single param
|
|
||||||
- ESLint + Prettier config in `eslint.config.mjs`
|
|
||||||
+59
-11
@@ -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;
|
||||||
@@ -3280,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,
|
||||||
@@ -3549,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,
|
||||||
@@ -4139,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 */
|
||||||
/* -------------------------------------------------- */
|
/* -------------------------------------------------- */
|
||||||
|
|||||||
+34
-4
@@ -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": {
|
||||||
@@ -505,8 +529,6 @@
|
|||||||
"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",
|
||||||
@@ -626,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": {}
|
||||||
@@ -828,6 +852,12 @@
|
|||||||
"cost": {
|
"cost": {
|
||||||
"label": "Cost"
|
"label": "Cost"
|
||||||
},
|
},
|
||||||
|
"costOverpowered": {
|
||||||
|
"label": "Cost (Overpowered)"
|
||||||
|
},
|
||||||
|
"costOverpowered2": {
|
||||||
|
"label": "Cost (Overpowered 2)"
|
||||||
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"label": "Description"
|
"label": "Description"
|
||||||
},
|
},
|
||||||
|
|||||||
+698
-335
File diff suppressed because it is too large
Load Diff
@@ -24,30 +24,29 @@ export class LethalFantasyCombatTracker extends foundry.applications.sidebar.tab
|
|||||||
|
|
||||||
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 });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,33 +57,6 @@ export class LethalFantasyCombatTracker extends foundry.applications.sidebar.tab
|
|||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
await game.combat.rollMonsterProgression();
|
await game.combat.rollMonsterProgression();
|
||||||
}
|
}
|
||||||
|
|
||||||
activateListeners(html) {
|
|
||||||
super.activateListeners(html);
|
|
||||||
// Display Combat settings
|
|
||||||
html.find(".initiative-plus").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 });
|
|
||||||
});
|
|
||||||
|
|
||||||
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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LethalFantasyCombat extends Combat {
|
export class LethalFantasyCombat extends Combat {
|
||||||
@@ -94,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
|
||||||
@@ -164,19 +136,19 @@ export class LethalFantasyCombat extends Combat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resetProgression(cId) {
|
async resetProgression(cId) {
|
||||||
let c = this.combatants.get(cId);
|
let c = this.combatants.get(cId);
|
||||||
c.update({ 'system.progressionCount': 0 });
|
await c.update({ 'system.progressionCount': 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
setCasting(cId) {
|
async setCasting(cId) {
|
||||||
let c = this.combatants.get(cId);
|
let c = this.combatants.get(cId);
|
||||||
c.setFlag(SYSTEM.id, "casting", true);
|
await c.setFlag(SYSTEM.id, "casting", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetCasting(cId) {
|
async resetCasting(cId) {
|
||||||
let c = this.combatants.get(cId);
|
let c = this.combatants.get(cId);
|
||||||
c.setFlag(SYSTEM.id, "casting", false);
|
await c.setFlag(SYSTEM.id, "casting", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
isCasting(cId) {
|
isCasting(cId) {
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -180,44 +180,44 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
|||||||
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 })
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -255,25 +255,28 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
|||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
action: "noDR",
|
action: "noDR",
|
||||||
|
type: "button",
|
||||||
label: game.i18n.localize("LETHALFANTASY.Combat.spellNoDR"),
|
label: game.i18n.localize("LETHALFANTASY.Combat.spellNoDR"),
|
||||||
icon: "fa-solid fa-wand-magic-sparkles",
|
icon: "fa-solid fa-wand-magic-sparkles",
|
||||||
callback: () => 0
|
callback: () => 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: "applyDR",
|
action: "applyDR",
|
||||||
|
type: "button",
|
||||||
label: game.i18n.localize("LETHALFANTASY.Combat.spellApplyDR"),
|
label: game.i18n.localize("LETHALFANTASY.Combat.spellApplyDR"),
|
||||||
icon: "fa-solid fa-shield",
|
icon: "fa-solid fa-shield",
|
||||||
callback: (event, button) => Number(button.form?.elements?.manualDr?.value) || 0
|
callback: (event, button) => Number(button.form?.elements?.manualDr?.value) || 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: "cancel",
|
action: "cancel",
|
||||||
|
type: "button",
|
||||||
label: game.i18n.localize("LETHALFANTASY.Combat.proceedNo"),
|
label: game.i18n.localize("LETHALFANTASY.Combat.proceedNo"),
|
||||||
callback: () => null
|
callback: () => "cancel"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
rejectClose: false
|
rejectClose: false
|
||||||
})
|
})
|
||||||
if (manualDR === null) return
|
if (manualDR === null || manualDR === "cancel") return
|
||||||
|
|
||||||
const rollOpts = {
|
const rollOpts = {
|
||||||
type: "spell-damage",
|
type: "spell-damage",
|
||||||
@@ -286,28 +289,16 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
|||||||
actorName: this.actor.name,
|
actorName: this.actor.name,
|
||||||
actorImage: this.actor.img
|
actorImage: this.actor.img
|
||||||
}
|
}
|
||||||
const roll = new LethalFantasyRoll(formula, {}, rollOpts)
|
await LethalFantasyRoll.rollSpellDamageToMessage(formula, rollOpts)
|
||||||
await roll.evaluate()
|
|
||||||
const diceResults = []
|
|
||||||
for (const term of roll.dice) {
|
|
||||||
for (const r of term.results) {
|
|
||||||
diceResults.push({ dice: `1D${term.faces}`, value: r.result })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
roll.options.diceResults = diceResults
|
|
||||||
roll.options.rollTotal = roll.total
|
|
||||||
if (game?.dice3d) await game.dice3d.showForRoll(roll, game.user, true)
|
|
||||||
await roll.toMessage()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
@@ -315,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -108,6 +108,10 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Possible Flawless or Legendary Defense or Add D20E to Defense"
|
"description": "Possible Flawless or Legendary Defense or Add D20E to Defense"
|
||||||
|
},
|
||||||
|
"saving_throws": {
|
||||||
|
"type": "save_auto_success",
|
||||||
|
"description": "Saving Throw Succeeds Regardless of Opposing Roll"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"29": {
|
"29": {
|
||||||
@@ -145,6 +149,11 @@
|
|||||||
"type": "gain_grit",
|
"type": "gain_grit",
|
||||||
"amount": 1,
|
"amount": 1,
|
||||||
"description": "Gain 1 Grit"
|
"description": "Gain 1 Grit"
|
||||||
|
},
|
||||||
|
"saving_throws": {
|
||||||
|
"type": "gain_grit",
|
||||||
|
"amount": 1,
|
||||||
|
"description": "Gain 1 Grit"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"28": {
|
"28": {
|
||||||
@@ -199,6 +208,12 @@
|
|||||||
"amount": 1,
|
"amount": 1,
|
||||||
"target": "skill",
|
"target": "skill",
|
||||||
"description": "Add 1 to Skill Roll"
|
"description": "Add 1 to Skill Roll"
|
||||||
|
},
|
||||||
|
"saving_throws": {
|
||||||
|
"type": "bonus_flat",
|
||||||
|
"amount": 1,
|
||||||
|
"target": "save",
|
||||||
|
"description": "Add 1 to Saving Throw"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"21": {
|
"21": {
|
||||||
@@ -239,6 +254,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"
|
||||||
|
},
|
||||||
|
"saving_throws": {
|
||||||
|
"type": "bonus_dice",
|
||||||
|
"dice": "D6",
|
||||||
|
"target": "save",
|
||||||
|
"description": "Granted D6 (1-6) Saving Throw Modifier for this Saving Throw Attempt"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"20": {
|
"20": {
|
||||||
@@ -325,7 +346,7 @@
|
|||||||
"target": "spell_defense"
|
"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"
|
"description": "Possible 20/20 Spell defense that Saves Against Any Magical Attack Except a Lethal Magical Strike or add D12 to spell defense"
|
||||||
},
|
},
|
||||||
"skill_rolls": {
|
"skill_rolls": {
|
||||||
"type": "bonus_flat",
|
"type": "bonus_flat",
|
||||||
@@ -349,6 +370,12 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"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"
|
||||||
|
},
|
||||||
|
"saving_throws": {
|
||||||
|
"type": "bonus_flat",
|
||||||
|
"amount": 20,
|
||||||
|
"target": "save",
|
||||||
|
"description": "20 Added to Saving Throw"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"15": {
|
"15": {
|
||||||
@@ -359,10 +386,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 +399,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 +413,15 @@
|
|||||||
"type": "counter_attack",
|
"type": "counter_attack",
|
||||||
"options": [
|
"options": [
|
||||||
"kick",
|
"kick",
|
||||||
"punch",
|
"punch"
|
||||||
"shield_bash"
|
|
||||||
],
|
],
|
||||||
"description": "Kick, Punch or Shield Bash"
|
"description": "Kick or Punch"
|
||||||
|
},
|
||||||
|
"saving_throws": {
|
||||||
|
"type": "bonus_flat",
|
||||||
|
"amount": 1,
|
||||||
|
"target": "save",
|
||||||
|
"description": "Add 1 to Saving Throw"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"13": {},
|
"13": {},
|
||||||
@@ -398,7 +429,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 +444,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 +457,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 +471,15 @@
|
|||||||
"type": "counter_attack",
|
"type": "counter_attack",
|
||||||
"options": [
|
"options": [
|
||||||
"kick",
|
"kick",
|
||||||
"punch",
|
"punch"
|
||||||
"shield_bash"
|
|
||||||
],
|
],
|
||||||
"description": "Kick, Punch or Shield Bash"
|
"description": "Kick or Punch"
|
||||||
|
},
|
||||||
|
"saving_throws": {
|
||||||
|
"type": "bonus_flat",
|
||||||
|
"amount": 1,
|
||||||
|
"target": "save",
|
||||||
|
"description": "Add 1 to Saving Throw"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"8": {
|
"8": {
|
||||||
@@ -475,6 +510,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"
|
||||||
|
},
|
||||||
|
"saving_throws": {
|
||||||
|
"type": "mulligan",
|
||||||
|
"description": "Mulligan, Can Re-Roll This Saving Throw"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"7": {
|
"7": {
|
||||||
@@ -496,10 +535,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 +548,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 +562,15 @@
|
|||||||
"type": "counter_attack",
|
"type": "counter_attack",
|
||||||
"options": [
|
"options": [
|
||||||
"kick",
|
"kick",
|
||||||
"punch",
|
"punch"
|
||||||
"shield_bash"
|
|
||||||
],
|
],
|
||||||
"description": "Kick, Punch, or Shield Bash"
|
"description": "Kick or Punch"
|
||||||
|
},
|
||||||
|
"saving_throws": {
|
||||||
|
"type": "bonus_flat",
|
||||||
|
"amount": 1,
|
||||||
|
"target": "save",
|
||||||
|
"description": "Add 1 to Saving Throw"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"3": {
|
"3": {
|
||||||
@@ -610,6 +653,10 @@
|
|||||||
"type": "spell_calamity",
|
"type": "spell_calamity",
|
||||||
"description": "A possible spell calamity has occurred"
|
"description": "A possible spell calamity has occurred"
|
||||||
},
|
},
|
||||||
|
"arcane_spell_defense": {
|
||||||
|
"type": "spell_calamity",
|
||||||
|
"description": "Possible Spell Calamity or Catastrophe"
|
||||||
|
},
|
||||||
"melee_attack": {
|
"melee_attack": {
|
||||||
"type": "fumble",
|
"type": "fumble",
|
||||||
"detail": "melee_fumble",
|
"detail": "melee_fumble",
|
||||||
|
|||||||
+53
-16
@@ -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
|
}
|
||||||
|
|
||||||
|
/* *************************************************/
|
||||||
|
getNaturalDR() {
|
||||||
|
if (this.type === "monster") {
|
||||||
|
return Number(this.system.hp?.damageResistance) || 0
|
||||||
}
|
}
|
||||||
this.update({ "system.hp.value": hp })
|
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,10 +205,39 @@ 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") {
|
if (rollType === "spell-attack" || rollType === "spell-power") {
|
||||||
const cost = Number(rollTarget.system?.cost) || 0
|
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
|
const currentAether = Number(this.system.aetherPoints?.value) || 0
|
||||||
if (cost > currentAether) {
|
if (cost > currentAether) {
|
||||||
ui.notifications.warn(`${this.name} cannot cast ${rollTarget.name}: insufficient Aether (needs ${cost}, has ${currentAether}).`)
|
ui.notifications.warn(`${this.name} cannot cast ${rollTarget.name}: insufficient Aether (needs ${cost}, has ${currentAether}).`)
|
||||||
@@ -222,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)
|
||||||
@@ -264,7 +301,7 @@ export default class LethalFantasyActor extends Actor {
|
|||||||
combat: foundry.utils.duplicate(this.system.combat),
|
combat: foundry.utils.duplicate(this.system.combat),
|
||||||
isRangedAttack: weapon.system.weaponType === "ranged"
|
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") {
|
||||||
@@ -287,7 +324,7 @@ export default class LethalFantasyActor extends Actor {
|
|||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
*/
|
*/
|
||||||
@@ -25,7 +27,8 @@ export default class D30Roll {
|
|||||||
RANGED_DEFENSE: "ranged_defense",
|
RANGED_DEFENSE: "ranged_defense",
|
||||||
ARCANE_SPELL_ATTACK: "arcane_spell_attack",
|
ARCANE_SPELL_ATTACK: "arcane_spell_attack",
|
||||||
ARCANE_SPELL_DEFENSE: "arcane_spell_defense",
|
ARCANE_SPELL_DEFENSE: "arcane_spell_defense",
|
||||||
SKILL_ROLLS: "skill_rolls"
|
SKILL_ROLLS: "skill_rolls",
|
||||||
|
SAVING_THROWS: "saving_throws"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +43,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")
|
||||||
@@ -137,11 +140,15 @@ export default class D30Roll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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 options.isSpellSave ? this.ROLL_TYPES.ARCANE_SPELL_DEFENSE : this.ROLL_TYPES.SAVING_THROWS
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|||||||
+130
-46
@@ -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
|
||||||
@@ -285,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")) {
|
dice = options.rollTarget.weapon.system.damage.damageM
|
||||||
options.damageSmall = true
|
|
||||||
dice = options.rollTarget.weapon.system.damage.damageS
|
|
||||||
} else {
|
|
||||||
options.damageMedium = true
|
|
||||||
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
|
||||||
@@ -338,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,
|
||||||
@@ -360,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) {
|
||||||
@@ -391,9 +391,11 @@ 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) => {
|
||||||
@@ -436,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
|
||||||
@@ -445,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)
|
||||||
}
|
}
|
||||||
@@ -524,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,
|
||||||
@@ -555,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)
|
||||||
}
|
}
|
||||||
@@ -604,7 +604,7 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
rollD30.total,
|
rollD30.total,
|
||||||
options.rollType,
|
options.rollType,
|
||||||
options.rollTarget?.weapon,
|
options.rollTarget?.weapon,
|
||||||
{ isRanged: isRangedForD30 }
|
{ isRanged: isRangedForD30, isSpellSave: saveSpell }
|
||||||
)
|
)
|
||||||
options.D30message = d30Message
|
options.D30message = d30Message
|
||||||
}
|
}
|
||||||
@@ -623,9 +623,6 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
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)
|
||||||
@@ -668,6 +665,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.
|
||||||
@@ -681,6 +682,10 @@ 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ***********************************************************/
|
/* ***********************************************************/
|
||||||
@@ -716,6 +721,8 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
content,
|
content,
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
|
action: "initiative",
|
||||||
|
type: "button",
|
||||||
label: label,
|
label: label,
|
||||||
callback: (event, button) => {
|
callback: (event, button) => {
|
||||||
const output = Array.from(button.form.elements).reduce((obj, input) => {
|
const output = Array.from(button.form.elements).reduce((obj, input) => {
|
||||||
@@ -782,9 +789,19 @@ 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",
|
||||||
|
label: weaponLabel,
|
||||||
callback: (event, button) => {
|
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)
|
||||||
@@ -810,6 +827,7 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
}
|
}
|
||||||
buttons.push({
|
buttons.push({
|
||||||
action: "roll",
|
action: "roll",
|
||||||
|
type: "button",
|
||||||
label: label,
|
label: label,
|
||||||
callback: (event, button) => {
|
callback: (event, button) => {
|
||||||
let pos = $('#combat-action-dialog').position()
|
let pos = $('#combat-action-dialog').position()
|
||||||
@@ -821,6 +839,7 @@ 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) => {
|
callback: (event, button) => {
|
||||||
let pos = $('#combat-action-dialog').position()
|
let pos = $('#combat-action-dialog').position()
|
||||||
@@ -836,6 +855,7 @@ 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) => {
|
callback: (event, button) => {
|
||||||
let pos = $('#combat-action-dialog').position()
|
let pos = $('#combat-action-dialog').position()
|
||||||
@@ -854,12 +874,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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -889,12 +909,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
|
||||||
}
|
}
|
||||||
@@ -905,13 +949,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))
|
||||||
@@ -951,7 +996,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
|
||||||
@@ -971,7 +1016,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 }) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -983,18 +1028,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))
|
||||||
@@ -1026,13 +1071,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",
|
||||||
{
|
{
|
||||||
@@ -1043,7 +1088,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 }) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1083,6 +1128,8 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
content,
|
content,
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
|
action: "rangeDefense",
|
||||||
|
type: "button",
|
||||||
label: label,
|
label: label,
|
||||||
callback: (event, button) => {
|
callback: (event, button) => {
|
||||||
const output = Array.from(button.form.elements).reduce((obj, input) => {
|
const output = Array.from(button.form.elements).reduce((obj, input) => {
|
||||||
@@ -1099,7 +1146,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", "")
|
||||||
@@ -1242,6 +1289,8 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
content,
|
content,
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
|
action: "rangedAttack",
|
||||||
|
type: "button",
|
||||||
label,
|
label,
|
||||||
callback: (event, button) => {
|
callback: (event, button) => {
|
||||||
const output = Array.from(button.form.elements).reduce((obj, input) => {
|
const output = Array.from(button.form.elements).reduce((obj, input) => {
|
||||||
@@ -1377,10 +1426,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":
|
||||||
@@ -1397,7 +1444,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1435,16 +1482,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,
|
||||||
@@ -1453,7 +1499,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 = {
|
||||||
@@ -1524,4 +1570,42 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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}`
|
||||||
|
for (const r of term.results) {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
roll.options.diceResults = diceResults
|
||||||
|
roll.options.rollTotal = diceSum
|
||||||
|
return roll.toMessage()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -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 },
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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,25 +281,8 @@ 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
|
||||||
|
|
||||||
// Ranged weapon attacks from PCs use the ranged attack dialog (range, movement, aim modifiers)
|
|
||||||
if (rollType === "weapon-attack" && rollTarget?.isRangedAttack === true) {
|
|
||||||
let roll = await LethalFantasyRoll.promptRangedAttack({
|
|
||||||
rollType: "weapon-attack",
|
|
||||||
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,
|
||||||
@@ -310,7 +293,11 @@ 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
|
||||||
|
|
||||||
|
|||||||
+32
-26
@@ -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,25 +182,10 @@ 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 attacks use a specialized dialog with range/movement/size/aim modifiers
|
// Ranged monster defense uses the ranged defense dialog (movement, range, size modifiers)
|
||||||
if (rollType === "monster-attack" && rollTarget?.attackMode === "ranged") {
|
|
||||||
let roll = await LethalFantasyRoll.promptRangedAttack({
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ranged monster defense uses the same ranged defense dialog as PC characters
|
|
||||||
if (rollType === "monster-defense" && rollTarget?.isRangedDefense === true) {
|
if (rollType === "monster-defense" && rollTarget?.isRangedDefense === true) {
|
||||||
let roll = await LethalFantasyRoll.promptRangedDefense({
|
let roll = await LethalFantasyRoll.promptRangedDefense({
|
||||||
actorId: this.parent.id,
|
actorId: this.parent.id,
|
||||||
@@ -207,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({}, { messageMode: 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":
|
||||||
@@ -267,8 +274,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
|
|||||||
}, { messageMode: roll.options.rollMode ?? game.settings.get("core", "rollMode") })
|
}, { 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)
|
||||||
@@ -315,7 +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
|
||||||
await this.roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr)
|
await this.roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr, d30Effects)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,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) {
|
||||||
@@ -401,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) {
|
||||||
@@ -420,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 }) })
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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({
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+546
-51
@@ -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
|
||||||
@@ -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,6 +676,7 @@ 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
|
||||||
@@ -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) => {
|
||||||
@@ -467,16 +749,18 @@ export default class LethalFantasyUtils {
|
|||||||
attackRollType,
|
attackRollType,
|
||||||
attackRollKey,
|
attackRollKey,
|
||||||
attackD30result,
|
attackD30result,
|
||||||
attackD30message,
|
attackD30message,
|
||||||
attackRerollContext,
|
attackRerollContext,
|
||||||
defenderId: defender.id,
|
attackNaturalRoll: msg.attackNaturalRoll,
|
||||||
|
damageTier: msg.damageTier,
|
||||||
|
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"
|
||||||
@@ -773,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"
|
||||||
@@ -832,30 +1309,39 @@ 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 single-btn">
|
<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>
|
||||||
@@ -863,11 +1349,13 @@ export default class LethalFantasyUtils {
|
|||||||
} 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 || data.attackRollKey)
|
const spell = attacker?.items.get(data.attackWeaponId || data.attackRollKey)
|
||||||
const tiers = [
|
const chosenTier = data.damageTier || "standard"
|
||||||
{ formula: spell?.system?.damageDice, label: "Standard" },
|
const allTiers = [
|
||||||
{ formula: spell?.system?.damageDiceOverpowered, label: "Overpowered" },
|
{ id: "standard", formula: spell?.system?.damageDice, label: "Standard" },
|
||||||
{ formula: spell?.system?.damageDiceOverpowered2, label: "Overpowered 2" },
|
{ id: "overpowered", formula: spell?.system?.damageDiceOverpowered, label: "Overpowered" },
|
||||||
].filter(t => t.formula)
|
{ id: "overpowered2", formula: spell?.system?.damageDiceOverpowered2, label: "Overpowered 2" },
|
||||||
|
]
|
||||||
|
const tiers = allTiers.filter(t => t.id === chosenTier && t.formula)
|
||||||
if (tiers.length) {
|
if (tiers.length) {
|
||||||
const buttons = tiers.map(t => {
|
const buttons = tiers.map(t => {
|
||||||
const escapedFormula = Handlebars.escapeExpression(t.formula)
|
const escapedFormula = Handlebars.escapeExpression(t.formula)
|
||||||
@@ -877,7 +1365,10 @@ export default class LethalFantasyUtils {
|
|||||||
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="${escapedFormula}">
|
data-damage-formula="${escapedFormula}"
|
||||||
|
data-d30-bleed="${d30Bleed}"
|
||||||
|
data-d30-damage-mult="${d30DamageMultiplier}"
|
||||||
|
data-d30-dr-mult="${d30DrMultiplier}">
|
||||||
<i class="fa-solid fa-wand-magic-sparkles"></i> ${t.label} (${escapedFormula})
|
<i class="fa-solid fa-wand-magic-sparkles"></i> ${t.label} (${escapedFormula})
|
||||||
</button>`
|
</button>`
|
||||||
}).join("")
|
}).join("")
|
||||||
@@ -918,12 +1409,12 @@ export default class LethalFantasyUtils {
|
|||||||
</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() {
|
||||||
@@ -1060,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) {
|
||||||
@@ -1155,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
|
||||||
}
|
}
|
||||||
@@ -1198,7 +1693,7 @@ 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 },
|
||||||
mode: "gm",
|
mode: "gm",
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
MANIFEST-000615
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
2026/05/23-18:45:10.214922 7fa233fff6c0 Recovering log #613
|
|
||||||
2026/05/23-18:45:10.223944 7fa233fff6c0 Delete type=3 #611
|
|
||||||
2026/05/23-18:45:10.223997 7fa233fff6c0 Delete type=0 #613
|
|
||||||
2026/05/23-19:09:56.190877 7fa2327fc6c0 Level-0 table #618: started
|
|
||||||
2026/05/23-19:09:56.190922 7fa2327fc6c0 Level-0 table #618: 0 bytes OK
|
|
||||||
2026/05/23-19:09:56.224359 7fa2327fc6c0 Delete type=0 #616
|
|
||||||
2026/05/23-19:09:56.339160 7fa2327fc6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
|
|
||||||
2026/05/23-19:09:56.339194 7fa2327fc6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
2026/05/20-23:09:33.153266 7f179e7ed6c0 Recovering log #609
|
|
||||||
2026/05/20-23:09:33.205459 7f179e7ed6c0 Delete type=3 #607
|
|
||||||
2026/05/20-23:09:33.205507 7f179e7ed6c0 Delete type=0 #609
|
|
||||||
2026/05/20-23:16:53.517842 7f179d7eb6c0 Level-0 table #614: started
|
|
||||||
2026/05/20-23:16:53.517893 7f179d7eb6c0 Level-0 table #614: 0 bytes OK
|
|
||||||
2026/05/20-23:16:53.523991 7f179d7eb6c0 Delete type=0 #612
|
|
||||||
2026/05/20-23:16:53.536989 7f179d7eb6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
|
|
||||||
2026/05/20-23:16:53.537026 7f179d7eb6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
|
|
||||||
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
MANIFEST-000612
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
2026/05/23-18:45:10.228083 7fa232ffd6c0 Recovering log #610
|
|
||||||
2026/05/23-18:45:10.236935 7fa232ffd6c0 Delete type=3 #608
|
|
||||||
2026/05/23-18:45:10.236958 7fa232ffd6c0 Delete type=0 #610
|
|
||||||
2026/05/23-19:09:56.261648 7fa2327fc6c0 Level-0 table #615: started
|
|
||||||
2026/05/23-19:09:56.261672 7fa2327fc6c0 Level-0 table #615: 0 bytes OK
|
|
||||||
2026/05/23-19:09:56.304021 7fa2327fc6c0 Delete type=0 #613
|
|
||||||
2026/05/23-19:09:56.339181 7fa2327fc6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
|
|
||||||
2026/05/23-19:09:56.339208 7fa2327fc6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
2026/05/20-23:09:33.234730 7f179e7ed6c0 Recovering log #606
|
|
||||||
2026/05/20-23:09:33.288868 7f179e7ed6c0 Delete type=3 #604
|
|
||||||
2026/05/20-23:09:33.288920 7f179e7ed6c0 Delete type=0 #606
|
|
||||||
2026/05/20-23:16:53.524172 7f179d7eb6c0 Level-0 table #611: started
|
|
||||||
2026/05/20-23:16:53.524219 7f179d7eb6c0 Level-0 table #611: 0 bytes OK
|
|
||||||
2026/05/20-23:16:53.530312 7f179d7eb6c0 Delete type=0 #609
|
|
||||||
2026/05/20-23:16:53.537003 7f179d7eb6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
|
|
||||||
2026/05/20-23:16:53.537059 7f179d7eb6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
|
|
||||||
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
MANIFEST-000617
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
2026/05/23-18:45:10.200781 7fa2337fe6c0 Recovering log #615
|
|
||||||
2026/05/23-18:45:10.211345 7fa2337fe6c0 Delete type=3 #613
|
|
||||||
2026/05/23-18:45:10.211416 7fa2337fe6c0 Delete type=0 #615
|
|
||||||
2026/05/23-19:09:56.304132 7fa2327fc6c0 Level-0 table #620: started
|
|
||||||
2026/05/23-19:09:56.304162 7fa2327fc6c0 Level-0 table #620: 0 bytes OK
|
|
||||||
2026/05/23-19:09:56.339034 7fa2327fc6c0 Delete type=0 #618
|
|
||||||
2026/05/23-19:09:56.339189 7fa2327fc6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
|
|
||||||
2026/05/23-19:09:56.339203 7fa2327fc6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
2026/05/20-23:09:33.082007 7f179dfec6c0 Recovering log #611
|
|
||||||
2026/05/20-23:09:33.140910 7f179dfec6c0 Delete type=3 #609
|
|
||||||
2026/05/20-23:09:33.140962 7f179dfec6c0 Delete type=0 #611
|
|
||||||
2026/05/20-23:16:53.510592 7f179d7eb6c0 Level-0 table #616: started
|
|
||||||
2026/05/20-23:16:53.510664 7f179d7eb6c0 Level-0 table #616: 0 bytes OK
|
|
||||||
2026/05/20-23:16:53.517661 7f179d7eb6c0 Delete type=0 #614
|
|
||||||
2026/05/20-23:16:53.536973 7f179d7eb6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
|
|
||||||
2026/05/20-23:16:53.537037 7f179d7eb6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
|
|
||||||
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
MANIFEST-000312
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
2026/05/23-18:45:10.252202 7fa2337fe6c0 Recovering log #310
|
|
||||||
2026/05/23-18:45:10.261300 7fa2337fe6c0 Delete type=3 #308
|
|
||||||
2026/05/23-18:45:10.261343 7fa2337fe6c0 Delete type=0 #310
|
|
||||||
2026/05/23-19:09:56.467263 7fa2327fc6c0 Level-0 table #315: started
|
|
||||||
2026/05/23-19:09:56.467308 7fa2327fc6c0 Level-0 table #315: 0 bytes OK
|
|
||||||
2026/05/23-19:09:56.509084 7fa2327fc6c0 Delete type=0 #313
|
|
||||||
2026/05/23-19:09:56.608544 7fa2327fc6c0 Manual compaction at level-0 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
|
|
||||||
2026/05/23-19:09:56.665018 7fa2327fc6c0 Manual compaction at level-1 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
2026/05/20-23:09:33.368596 7f179e7ed6c0 Recovering log #306
|
|
||||||
2026/05/20-23:09:33.422152 7f179e7ed6c0 Delete type=3 #304
|
|
||||||
2026/05/20-23:09:33.422210 7f179e7ed6c0 Delete type=0 #306
|
|
||||||
2026/05/20-23:16:53.560903 7f179d7eb6c0 Level-0 table #311: started
|
|
||||||
2026/05/20-23:16:53.560969 7f179d7eb6c0 Level-0 table #311: 0 bytes OK
|
|
||||||
2026/05/20-23:16:53.568455 7f179d7eb6c0 Delete type=0 #309
|
|
||||||
2026/05/20-23:16:53.568616 7f179d7eb6c0 Manual compaction at level-0 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
|
|
||||||
2026/05/20-23:16:53.578679 7f179d7eb6c0 Manual compaction at level-1 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
|
|
||||||
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
MANIFEST-000611
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
2026/05/23-18:45:10.238924 7fa233fff6c0 Recovering log #609
|
|
||||||
2026/05/23-18:45:10.250309 7fa233fff6c0 Delete type=3 #607
|
|
||||||
2026/05/23-18:45:10.250371 7fa233fff6c0 Delete type=0 #609
|
|
||||||
2026/05/23-19:09:56.224507 7fa2327fc6c0 Level-0 table #614: started
|
|
||||||
2026/05/23-19:09:56.224539 7fa2327fc6c0 Level-0 table #614: 0 bytes OK
|
|
||||||
2026/05/23-19:09:56.261516 7fa2327fc6c0 Delete type=0 #612
|
|
||||||
2026/05/23-19:09:56.339172 7fa2327fc6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
|
|
||||||
2026/05/23-19:09:56.339199 7fa2327fc6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
2026/05/20-23:09:33.302872 7f179efee6c0 Recovering log #605
|
|
||||||
2026/05/20-23:09:33.362229 7f179efee6c0 Delete type=3 #603
|
|
||||||
2026/05/20-23:09:33.362319 7f179efee6c0 Delete type=0 #605
|
|
||||||
2026/05/20-23:16:53.530498 7f179d7eb6c0 Level-0 table #610: started
|
|
||||||
2026/05/20-23:16:53.530547 7f179d7eb6c0 Level-0 table #610: 0 bytes OK
|
|
||||||
2026/05/20-23:16:53.536854 7f179d7eb6c0 Delete type=0 #608
|
|
||||||
2026/05/20-23:16:53.537015 7f179d7eb6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
|
|
||||||
2026/05/20-23:16:53.537048 7f179d7eb6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
|
|
||||||
Binary file not shown.
@@ -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 {
|
||||||
|
|||||||
@@ -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 */
|
||||||
/* -------------------------------------------------- */
|
/* -------------------------------------------------- */
|
||||||
|
|||||||
+4
-7
@@ -647,15 +647,11 @@
|
|||||||
|
|
||||||
.damage-buttons-grid {
|
.damage-buttons-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
grid-template-columns: 1fr;
|
||||||
|
max-width: 280px;
|
||||||
|
margin: 0 auto;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
|
||||||
&.monster-damage {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
max-width: 280px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.damage-roll-btn {
|
.damage-roll-btn {
|
||||||
padding: 10px 14px;
|
padding: 10px 14px;
|
||||||
background: linear-gradient(to bottom, #8b4513 0%, #6b3410 100%);
|
background: linear-gradient(to bottom, #8b4513 0%, #6b3410 100%);
|
||||||
@@ -847,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -69,16 +69,10 @@
|
|||||||
</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}}
|
||||||
|
|
||||||
@@ -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}}
|
||||||
|
|||||||
@@ -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>
|
||||||
+37
-40
@@ -55,35 +55,33 @@
|
|||||||
<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"
|
data-action="selectPointBlank"
|
||||||
data-action="selectPointBlank"
|
name="pointBlankV"
|
||||||
name="pointBlankV"
|
/>
|
||||||
/>
|
</div>
|
||||||
</div>
|
<div class="dialog-save">Beyond Skill Range Attack
|
||||||
<div class="dialog-save">Beyond Skill Range Attack
|
<input
|
||||||
<input
|
type="checkbox"
|
||||||
type="checkbox"
|
data-action="selectBeyondSkill"
|
||||||
data-action="selectBeyondSkill"
|
name="beyondSkillV"
|
||||||
name="beyondSkillV"
|
/>
|
||||||
/>
|
</div>
|
||||||
</div>
|
<div class="dialog-save">Let it Fly (Pure D20E)
|
||||||
<div class="dialog-save">Let it Fly (Pure D20E)
|
<input
|
||||||
<input
|
type="checkbox"
|
||||||
type="checkbox"
|
data-action="selectLetItFly"
|
||||||
data-action="selectLetItFly"
|
name="letItFlyV"
|
||||||
name="letItFlyV"
|
/>
|
||||||
/>
|
</div>
|
||||||
</div>
|
<div class="dialog-save">Aiming
|
||||||
<div class="dialog-save">Aiming
|
<select name="attackerAim" data-tooltip-direction="UP">
|
||||||
<select name="attackerAim" data-tooltip-direction="UP">
|
{{selectOptions attackerAimChoices selected=attackerAim}}
|
||||||
{{selectOptions attackerAimChoices selected=attackerAim}}
|
</select>
|
||||||
</select>
|
</div>
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
@@ -125,17 +123,16 @@
|
|||||||
</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>
|
<input
|
||||||
<input
|
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}}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
{{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>{{localize "LETHALFANTASY.Label.components"}}</label>
|
<label>{{localize "LETHALFANTASY.Label.components"}}</label>
|
||||||
<div class="shift-right">
|
<div class="shift-right">
|
||||||
|
|||||||
@@ -17,11 +17,7 @@
|
|||||||
{{formField systemFields.damageType.fields.typeS value=system.damageType.typeS}}
|
{{formField systemFields.damageType.fields.typeS value=system.damageType.typeS}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label>{{localize "LETHALFANTASY.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}}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
import { CompendiumsManager } from './CompendiumsManager.mjs';
|
||||||
|
CompendiumsManager.packToDistDir('packs_src', 'packs-system');
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
import { CompendiumsManager } from './CompendiumsManager.mjs';
|
||||||
|
CompendiumsManager.unpackToSrcDir('packs_src', 'packs-system');
|
||||||
Reference in New Issue
Block a user