Compare commits
98 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 25648aa2a3 | |||
| 41b1199704 | |||
| 3df46b5848 | |||
| 05c93f9475 | |||
| bb005ee9fc | |||
| fa5c4cc9ce | |||
| 3b0d4e032e | |||
| 539841c4ff | |||
| ffba37b59e | |||
| 1a7585e1f6 | |||
| 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 | |||
| 38eb1a8d3d | |||
| 4724cdf2bb | |||
| 6d06c8ddad | |||
| 2770774aa3 | |||
| e417b61625 | |||
| 9a8d580ef6 | |||
| 9ccb0f90f0 | |||
| 6cf0880ad3 | |||
| 96306623e5 | |||
| 7279cd752d | |||
| db3e8b5d35 | |||
| 54421e4a83 | |||
| ac44419b7a | |||
| a3fc0a42b9 | |||
| c8ce840e98 | |||
| 55a040062a | |||
| 1818a76499 | |||
| 55d1b41ca4 | |||
| 841ed82277 | |||
| 968d156d09 | |||
| 59ff098fca | |||
| b8174d5e22 | |||
| 7f15450566 | |||
| 28fdaff2ec | |||
| 81584ed5d6 | |||
| 8c9a13faf1 | |||
| 6c6c473147 | |||
| 2e2a917a45 | |||
| 343abc32e2 | |||
| c37d92af25 | |||
| 42945d33db | |||
| 1bf88bac06 | |||
| 3ad5681539 | |||
| df6f8e5710 | |||
| 52877e3a68 | |||
| a06dfa0ae9 | |||
| 0836cada75 | |||
| 61ed1597e7 | |||
| 96062c6fd9 | |||
| f6b35536de | |||
| 7d27562bb4 | |||
| 64f2efdcb9 | |||
| 66f7aade25 | |||
| 8f682a1458 | |||
| fa3054f24b | |||
| 59a891630e | |||
| 35b88b3914 | |||
| cb8bcfd9ea | |||
| eedce1a498 | |||
| 76a99fe33f | |||
| 59a39850ce | |||
| 6eeb391d1a | |||
| c7727076bf | |||
| d0411f9ec9 | |||
| e5653a4edc | |||
| 527e33a805 | |||
| b5857cb3b7 | |||
| 7a06e8a5c9 | |||
| b4d6616cb4 | |||
| aaef4dd896 |
@@ -0,0 +1 @@
|
||||
packs/** filter=lfs diff=lfs merge=lfs -text
|
||||
@@ -8,45 +8,56 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "💡 The ${{ gitea.repository }} repository will cloned to the runner."
|
||||
- run: echo "💡 The ${{ gitea.repository }} repository will cloned to the runner."
|
||||
|
||||
#- uses: actions/checkout@v3
|
||||
- uses: RouxAntoine/checkout@v3.5.4
|
||||
#- uses: actions/checkout@v3
|
||||
- uses: RouxAntoine/checkout@v3.5.4
|
||||
|
||||
# get part of the tag after the `v`
|
||||
- name: Extract tag version number
|
||||
id: get_version
|
||||
uses: battila7/get-version-action@v2
|
||||
# get part of the tag after the `v`
|
||||
- name: Extract tag version number
|
||||
id: get_version
|
||||
uses: battila7/get-version-action@v2
|
||||
|
||||
# Substitute the Manifest and Download URLs in the module.json
|
||||
- name: Substitute Manifest and Download Links For Versioned Ones
|
||||
id: sub_manifest_link_version
|
||||
uses: microsoft/variable-substitution@v1
|
||||
with:
|
||||
files: 'system.json'
|
||||
env:
|
||||
version: ${{steps.get_version.outputs.version-without-v}}
|
||||
url: https://www.uberwald.me/gitea/${{gitea.repository}}
|
||||
manifest: https://www.uberwald.me/gitea/public/${{gitea.repository}}/releases/download/latest/system.json
|
||||
download: https://www.uberwald.me/gitea/${{gitea.repository}}/releases/download/${{github.event.release.tag_name}}/fvtt-lethal-fantasy-${{github.event.release.tag_name}}.zip
|
||||
# Substitute the Manifest and Download URLs in the module.json
|
||||
- name: Substitute Manifest and Download Links For Versioned Ones
|
||||
id: sub_manifest_link_version
|
||||
uses: microsoft/variable-substitution@v1
|
||||
with:
|
||||
files: "system.json"
|
||||
env:
|
||||
version: ${{steps.get_version.outputs.version-without-v}}
|
||||
url: https://www.uberwald.me/gitea/${{gitea.repository}}
|
||||
manifest: https://www.uberwald.me/gitea/public/${{gitea.repository}}/releases/download/latest/system.json
|
||||
download: https://www.uberwald.me/gitea/${{gitea.repository}}/releases/download/${{github.event.release.tag_name}}/fvtt-lethal-fantasy-${{github.event.release.tag_name}}.zip
|
||||
|
||||
# Create a zip file with all files required by the module to add to the release
|
||||
- run: |
|
||||
apt update -y
|
||||
apt install -y zip
|
||||
# Create a zip file with all files required by the module to add to the release
|
||||
- run: |
|
||||
apt update -y
|
||||
apt install -y zip
|
||||
|
||||
- run: zip -r ./fvtt-lethal-fantasy-${{github.event.release.tag_name}}.zip system.json README.md LICENSE assets/ css/ lang/ module/ packs-system/ templates/ lethal-fantasy.mjs
|
||||
- run: zip -r ./fvtt-lethal-fantasy-${{github.event.release.tag_name}}.zip system.json README.md LICENSE assets/ css/ lang/ module/ packs-system/ templates/ lethal-fantasy.mjs
|
||||
|
||||
- name: setup go
|
||||
uses: https://github.com/actions/setup-go@v4
|
||||
with:
|
||||
go-version: '>=1.20.1'
|
||||
- name: setup go
|
||||
uses: https://github.com/actions/setup-go@v4
|
||||
with:
|
||||
go-version: ">=1.20.1"
|
||||
|
||||
- name: Use Go Action
|
||||
id: use-go-action
|
||||
uses: https://gitea.com/actions/release-action@main
|
||||
with:
|
||||
files: |-
|
||||
./fvtt-lethal-fantasy-${{github.event.release.tag_name}}.zip
|
||||
system.json
|
||||
api_key: '${{secrets.ALLOW_PUSH_RELEASE}}'
|
||||
- name: Use Go Action
|
||||
id: use-go-action
|
||||
uses: https://gitea.com/actions/release-action@main
|
||||
with:
|
||||
files: |-
|
||||
./fvtt-lethal-fantasy-${{github.event.release.tag_name}}.zip
|
||||
system.json
|
||||
api_key: "${{secrets.ALLOW_PUSH_RELEASE}}"
|
||||
|
||||
- name: Publish to Foundry server
|
||||
uses: djlechuck/foundryvtt-publish-package-action@v1
|
||||
with:
|
||||
token: ${{ secrets.FOUNDRY_PUBLISH_KEY }}
|
||||
id: "fvtt-lethal-fantasy"
|
||||
version: ${{github.event.release.tag_name}}
|
||||
manifest: "https://www.uberwald.me/gitea/uberwald/fvtt-lethal-fantasy/releases/download/latest/system.json"
|
||||
notes: "https://www.uberwald.me/gitea/public/fvtt-lethal-fantasy/raw/branch/main/changelog.md"
|
||||
compatibility-minimum: "14"
|
||||
compatibility-verified: "14"
|
||||
|
||||
+12
@@ -7,4 +7,16 @@ styles/*.css
|
||||
node_modules/
|
||||
|
||||
.history
|
||||
.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,78 @@
|
||||
# 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** from system.json
|
||||
- **globalThis side effects** moved from top-level to `init` hook
|
||||
- **console.log → log()** helper guarded by setting
|
||||
- **Stale Tenebris refs** → LETHALFANTASY
|
||||
|
||||
### Pass 2 — V1/V2 Mixing, Fire-and-Forget
|
||||
- V1 sheet registrations, activateListeners/jQuery, FilePicker paths fixed
|
||||
- Fire-and-forget Promises now awaited
|
||||
- Misnamed `LethalFantasySkill` → `LethalFantasyWeapon`
|
||||
|
||||
### Pass 3 — Code Review Fixes
|
||||
- Duplicated dialogs fixed via `_onRender` bindings
|
||||
- renderChatMessage reverted to HTML hook
|
||||
- All review awaits confirmed
|
||||
|
||||
### Pass 4 — D30 Dialog Removal & Dead Code Audit
|
||||
- **D30 choice dialog removed** — auto-rolls bonus dice; special strike/defense reported as `specialEffect: "flag"` (informational)
|
||||
- **Spell calamity choice restored** — catch-all for non-standard choices uses `specialEffect: "flag"`
|
||||
- **Dead `specialEffect === "auto"` branches removed** from chat-reaction.mjs (×2), combat.mjs (×1), reaction-message.hbs
|
||||
- **Deleted `d30-special-choice.hbs` and `_buildSpecialLabel()`**
|
||||
- **Dead code audit** — 2 runtime bugs fixed, ~20 dead exports/methods, 33 unused i18n keys, 2 unused templates
|
||||
- **3 critical bugs fixed**: SYSTEM.ROLL_TYPE, SYSTEM.EQUIPMENT_CATEGORIES, missing imports in combat.mjs
|
||||
- **`isPrimaryController` consolidated** to local function
|
||||
- **Aether/Grace deduction merged** via `_deductResourceOnCast()`
|
||||
- **`nextDefenseData` deduped** via `_storeNextDefenseData()`
|
||||
- **`buildDefenseReactionButtons` extracted** from combat.mjs; fixes stale Grit/Luck snapshots
|
||||
- **HP HUD toggling extracted** to helpers.mjs
|
||||
- **`node --check` passes all 55 `.mjs` files**
|
||||
|
||||
### Pass 5 — Live Verification
|
||||
- **D30=30 auto-roll verified** — Club attack shows D30=30 flag
|
||||
- **Defense request dialog verified** — Monster defense dialog with weapon dropdown
|
||||
- **Defense reaction dialog verified** — Luck spent, bonus die added, combat result correct
|
||||
- **AZA→Monster attack flow tested end-to-end**: Club attack (D20=16, D30=6) → Monster defense (D20=1) → defense reactions (Continue) → D30 attack bonus processed (+2, total 18)
|
||||
- **BUG FOUND & FIXED: `d30ChangedAttack` infinite loop** — chat-reaction.mjs:452-455 do-while reset block missing `d30ChangedAttack = false`; added at line 456
|
||||
- **BUG FIX CONFIRMED**: Re-tested full flow — AZA Club attack (13, D30=12) → defense dialog → Monster defense (2, D30=24) → reaction dialog (only 1 show!) → Continue → "AZA hits Monster!" combat result → damage roll (1d6=2, total 3) → Apply Damage button. No infinite loop. Full E2E success.
|
||||
|
||||
## Key Decisions
|
||||
- **Auto-roll bonus dice without dialog** — matches existing D30=27 (d6E) flow
|
||||
- **`buildDefenseReactionButtons` extracts only button-building** — defense while-loop structures differ between same-client and cross-client; merging loops risks behavioral divergence
|
||||
- **Inline grit/luck deduction uses live actor values**
|
||||
- **Aether/Grace helper uses `costFn` parameter**
|
||||
|
||||
## Next Steps
|
||||
1. Test defense request dialogs (character/monster/save) — more variants
|
||||
2. Test all reaction message variants (shield block/fail, d30Bonus/Flag, grit, luck, etc.)
|
||||
3. Create Player user in Foundry for cross-client socket testing
|
||||
4. Prune dead code: unused exports (~20), unused i18n keys (33), unused templates (2)
|
||||
|
||||
## Critical Context
|
||||
- **Chat buttons not interactive via DevTools snapshot** — need JS fallback: `document.querySelectorAll('button').forEach(b => { if (...) b.click(); })`
|
||||
- **Defense flow**: Attack card → target button (`.request-defense-btn`) → defense dialog → defense roll → defense reactions dialog → combat result card with Damage button → damage roll dialog → Apply Damage → HP application
|
||||
- **Clicking "Damage" directly bypasses defense** — rolls unapplied damage to chat
|
||||
- **Same-owner guard** (`chat-reaction.mjs:180-182`) — skips defense when GM owns both, unless `!defenderIsMonster`
|
||||
- **`d30ChangedAttack` infinite loop** — variable wasn't reset in do-while block; fix at `chat-reaction.mjs:456`
|
||||
- **Deserialized weapon object** — `weapon.name` works, `weapon.id` undefined, `weapon._id` works
|
||||
- **Fvtt server**: port 31000, foundrydata-dev
|
||||
- **No player user configured** — cannot test cross-client socket flow
|
||||
|
||||
## Relevant Files
|
||||
- `module/hooks/chat-reaction.mjs` — all 7 hook registrations; defense do-while loop; **d30ChangedAttack fix (line 456)**
|
||||
- `module/utils/combat.mjs` — `buildDefenseReactionButtons`, `_storeNextDefenseData`
|
||||
- `module/utils/d30.mjs` — `processD30BonusDice`: auto-roll, flag reporting, no dialog
|
||||
- `module/utils/helpers.mjs` — `_toggleHudWraps`/`_disableHudWraps`
|
||||
- `module/utils.mjs` — barrel re-exporting 23 static methods
|
||||
- `module/models/equipment.mjs` — EQUIPMENT_CATEGORY fix
|
||||
- `module/applications/combat.mjs` — added imports
|
||||
- `templates/chat/reaction-message.hbs` — d30 removed
|
||||
- `templates/dialogs/d30-special-choice.hbs` — deleted
|
||||
- `lang/en.json` — 33 unused i18n keys remain
|
||||
@@ -1 +1,7 @@
|
||||
<svg style="height: 512px; width: 512px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><g class="" style="" transform="translate(0,0)"><path d="M373.47 25.5c-33.475-.064-67.614 13.444-94.44 43.156l37.22 145.156-33.437.032 35.343 132.093-116.718-188.375 50.03 5.375L202.5 47.312C120.437-1.43 4.756 40.396 8.5 158.156c4.402 138.44 191.196 184.6 247.406 331.625 59.376-147.035 251.26-184.33 246.656-331.624-2.564-82.042-64.6-132.532-129.093-132.656z" fill="#fff" fill-opacity="1"></path></g></svg>
|
||||
<svg style="height: 512px; width: 512px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||
<g class="" style="" transform="translate(0,0)">
|
||||
<path
|
||||
d="M373.47 25.5c-33.475-.064-67.614 13.444-94.44 43.156l37.22 145.156-33.437.032 35.343 132.093-116.718-188.375 50.03 5.375L202.5 47.312C120.437-1.43 4.756 40.396 8.5 158.156c4.402 138.44 191.196 184.6 247.406 331.625 59.376-147.035 251.26-184.33 246.656-331.624-2.564-82.042-64.6-132.532-129.093-132.656z"
|
||||
fill="#dc2626" fill-opacity="1"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 506 B After Width: | Height: | Size: 533 B |
@@ -0,0 +1,10 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<!-- Heart shape -->
|
||||
<path
|
||||
d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"
|
||||
fill="#4ade80" stroke="#22c55e" />
|
||||
<!-- Plus sign inside heart -->
|
||||
<line x1="12" y1="8" x2="12" y2="14" stroke="#ffffff" stroke-width="2.5" />
|
||||
<line x1="9" y1="11" x2="15" y2="11" stroke="#ffffff" stroke-width="2.5" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 572 B |
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
## v13.0.12
|
||||
|
||||
- Fix favor/disfavor
|
||||
- Fix granted dice
|
||||
- Cosmetic fixes
|
||||
+2495
-191
File diff suppressed because it is too large
Load Diff
+281
-23
@@ -1,8 +1,32 @@
|
||||
{
|
||||
"COMBAT": {
|
||||
"Round": "Second",
|
||||
"Rounds": "Seconds",
|
||||
"RoundNext": "Next second"
|
||||
"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}",
|
||||
"RoundNext": "Next second",
|
||||
"RoundPrev": "Previous second",
|
||||
"Rounds": "Seconds",
|
||||
"Settings": "Combat Settings",
|
||||
"ToggleDead": "Toggle Dead",
|
||||
"ToggleVis": "Toggle Visible",
|
||||
"TurnEnd": "End Turn",
|
||||
"TurnNext": "Next Turn",
|
||||
"TurnPrev": "Previous Turn"
|
||||
},
|
||||
"LETHALFANTASY": {
|
||||
"Armor": {
|
||||
@@ -83,7 +107,7 @@
|
||||
},
|
||||
"challenges": {
|
||||
"agility": {
|
||||
"label": "Agility"
|
||||
"label": "Dexterity"
|
||||
},
|
||||
"dying": {
|
||||
"label": "Dying"
|
||||
@@ -152,6 +176,57 @@
|
||||
"wis": {
|
||||
"label": "Wisdom"
|
||||
}
|
||||
},
|
||||
"agility": {
|
||||
"label": "Agility"
|
||||
},
|
||||
"app": {
|
||||
"label": "Appearance"
|
||||
},
|
||||
"cha": {
|
||||
"label": "Charisma"
|
||||
},
|
||||
"con": {
|
||||
"label": "Constitution"
|
||||
},
|
||||
"contagion": {
|
||||
"label": "Contagion Save"
|
||||
},
|
||||
"dex": {
|
||||
"label": "Dexterity"
|
||||
},
|
||||
"dodge": {
|
||||
"label": "Dodge Save"
|
||||
},
|
||||
"dying": {
|
||||
"label": "Dying Challenge"
|
||||
},
|
||||
"int": {
|
||||
"label": "Intelligence"
|
||||
},
|
||||
"luc": {
|
||||
"label": "Luck"
|
||||
},
|
||||
"pain": {
|
||||
"label": "Pain Save"
|
||||
},
|
||||
"painCourage": {
|
||||
"label": "Pain/Courage Save"
|
||||
},
|
||||
"poison": {
|
||||
"label": "Poison Save"
|
||||
},
|
||||
"str": {
|
||||
"label": "Strength"
|
||||
},
|
||||
"toughness": {
|
||||
"label": "Toughness Save"
|
||||
},
|
||||
"will": {
|
||||
"label": "Willpower Save"
|
||||
},
|
||||
"wis": {
|
||||
"label": "Wisdom"
|
||||
}
|
||||
},
|
||||
"Monster": {
|
||||
@@ -181,7 +256,7 @@
|
||||
},
|
||||
"challenges": {
|
||||
"agility": {
|
||||
"label": "Agility"
|
||||
"label": "Dexterity"
|
||||
},
|
||||
"dying": {
|
||||
"label": "Dying"
|
||||
@@ -250,6 +325,21 @@
|
||||
"wis": {
|
||||
"label": "Wisdom"
|
||||
}
|
||||
},
|
||||
"perception": {
|
||||
"label": "Perception"
|
||||
},
|
||||
"resistIntimidation": {
|
||||
"label": "Resist Intimidation"
|
||||
},
|
||||
"resistPerformance": {
|
||||
"label": "Resist Performance"
|
||||
},
|
||||
"resistTorture": {
|
||||
"label": "Resist Torture"
|
||||
},
|
||||
"stealth": {
|
||||
"label": "Stealth"
|
||||
}
|
||||
},
|
||||
"Delete": "Delete",
|
||||
@@ -281,6 +371,10 @@
|
||||
}
|
||||
},
|
||||
"Label": {
|
||||
"agility": "Dexterity",
|
||||
"applyDamage": "Apply damage to:",
|
||||
"selectTarget": "Select target for attack:",
|
||||
"rollDamage": "Roll Damage",
|
||||
"gotoToken": "Go to token",
|
||||
"combatAction": "Combat action",
|
||||
"currentAction": "Current ongoing action",
|
||||
@@ -290,31 +384,36 @@
|
||||
"miracle-power": "Miracle - Power",
|
||||
"miracle-attack": "Miracle - Attack",
|
||||
"spell": "Spell",
|
||||
"will":"Will",
|
||||
"dodge":"Dodge",
|
||||
"toughness":"Toughness",
|
||||
"contagion":"Contagion",
|
||||
"poison":"Poison",
|
||||
"pain":"Pain",
|
||||
"paincourage":"Pain/Courage",
|
||||
"will": "Will",
|
||||
"dodge": "Dodge",
|
||||
"toughness": "Toughness",
|
||||
"contagion": "Contagion",
|
||||
"poison": "Poison",
|
||||
"pain": "Pain",
|
||||
"paincourage": "Pain/Courage",
|
||||
"granted": "Granted Dice",
|
||||
"shields": "Shields",
|
||||
"armorHitPoints": "Armor hit points",
|
||||
"grantedAttackDice": "Granted attack",
|
||||
"grantedDamageDice": "Granted damage",
|
||||
"grantedDefenseDice": "Granted defense",
|
||||
"damageResistance": "Damage resistance",
|
||||
"damageResistance": "DR",
|
||||
"damageResistanceShort": "DR",
|
||||
"shieldDamageReduction": "Shield DR",
|
||||
"shieldDefenseDice": "Shield dice",
|
||||
"stealth": "Stealth",
|
||||
"progressionDice": "Progression/Lethargy dice",
|
||||
"rollProgressionCount": "Roll progression count",
|
||||
"rollProgressionDice": "Roll progression/Lethargy dice",
|
||||
"earned": "Earned",
|
||||
"divinityPoints": "Divinity points",
|
||||
"divinityPoints": "Grace",
|
||||
"aetherPoints": "Aether points",
|
||||
"attacks": "Attacks",
|
||||
"attackMode": "Attack Mode",
|
||||
"meleeModeLabel": "Melee (8 attacks)",
|
||||
"rangedModeLabel": "Ranged (4 attacks)",
|
||||
"monster": "Monster",
|
||||
"Resist" :"Resist",
|
||||
"Resist": "Resist",
|
||||
"resist": "Resist",
|
||||
"resistTorture": "Resist torture",
|
||||
"resistPerformance": "Resist performance",
|
||||
@@ -348,7 +447,7 @@
|
||||
"cha": "CHA",
|
||||
"challenge": "Challenge",
|
||||
"challenges": {
|
||||
"agility": "Agility",
|
||||
"agility": "Dexterity",
|
||||
"dying": "Dying",
|
||||
"strength": "Strength"
|
||||
},
|
||||
@@ -387,8 +486,17 @@
|
||||
"notes": "Notes",
|
||||
"pc": "PC",
|
||||
"perception": "Perception",
|
||||
"pointBlank": "Point blank",
|
||||
"short": "Short",
|
||||
"medium": "Medium",
|
||||
"long": "Long",
|
||||
"extreme": "Extreme",
|
||||
"outOfSkill": "Out of skill",
|
||||
"range": "Range",
|
||||
"rangeDefenseDialog": "Ranged defense dialog",
|
||||
"rangeDefenseRoll": "Ranged defense roll",
|
||||
"rangeAttackDialog": "Ranged attack dialog",
|
||||
"rangeAttackRoll": "Ranged attack roll",
|
||||
"rangedAttackDefense": "Ranged attack defense",
|
||||
"resource": "Resource",
|
||||
"resources": "Resources",
|
||||
@@ -420,7 +528,43 @@
|
||||
"monster-damage": "Monster damage",
|
||||
"monster-defense": "Monster defense",
|
||||
"weapons": "Weapons",
|
||||
"wis": "WIS"
|
||||
"wis": "WIS",
|
||||
"combatProgressionStart": "Combat start threshold",
|
||||
"miracle": "Miracle",
|
||||
"titleStandard": "Standard Roll",
|
||||
"privateRoll": "Private Roll",
|
||||
"current": "Current",
|
||||
"max": "Max",
|
||||
"speed": "Speed",
|
||||
"bonuses": "Bonuses",
|
||||
"handToHandAttacks": "Hand To Hand Attacks",
|
||||
"beyondSkill": "Beyond Skill",
|
||||
"letItFly": "Let It Fly!",
|
||||
"class": "Class",
|
||||
"mortal": "Mortal",
|
||||
"alignment": "Alignment",
|
||||
"age": "Age",
|
||||
"height": "Height",
|
||||
"weight": "Weight",
|
||||
"eyes": "Eyes",
|
||||
"hair": "Hair",
|
||||
"magicUser": "Magic User",
|
||||
"clericUser": "Cleric User",
|
||||
"lastHdRoll": "Last HD roll",
|
||||
"naturalDR": "Natural DR",
|
||||
"magicalDR": "Magical DR",
|
||||
"saveBonus": "Save bonus (1/5 levels)",
|
||||
"spellBonus": "Spell bonus (1/5 levels)",
|
||||
"miracleBonus": "Miracle bonus (1/5 levels)",
|
||||
"devPointsTotal": "Dev. Points (Total)",
|
||||
"devPointsRem": "Dev. Points (Rem.)",
|
||||
"length": "Length",
|
||||
"vision": "Vision",
|
||||
"damageType": "Damage Type",
|
||||
"components": "Components",
|
||||
"coverRanged": "Cover vs ranged attacks",
|
||||
"standing": "Standing",
|
||||
"crouching": "Crouching"
|
||||
},
|
||||
"Miracle": {
|
||||
"FIELDS": {
|
||||
@@ -476,6 +620,15 @@
|
||||
},
|
||||
"savingThrow": {
|
||||
"label": "Saving throw"
|
||||
},
|
||||
"damageDiceOverpowered": {
|
||||
"label": "Overpowered Damage Dice"
|
||||
},
|
||||
"damageDiceOverpowered2": {
|
||||
"label": "Overpowered 2 Damage Dice"
|
||||
},
|
||||
"damageDice": {
|
||||
"label": "Damage Dice"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -495,7 +648,9 @@
|
||||
"messageLethargyKO": "{spellName} : Lethargy still ongoing ... ( dice result : {roll} )",
|
||||
"messageProgressionKO": "{name} can't attack this second.",
|
||||
"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": {
|
||||
"FIELDS": {}
|
||||
@@ -510,7 +665,9 @@
|
||||
"save": "Save roll {save}",
|
||||
"success": "Success",
|
||||
"visibility": "Visibility",
|
||||
"favorDisfavor": "Favor/Disfavor"
|
||||
"favorDisfavor": "Favor/Disfavor",
|
||||
"displayArmor": "Target: {targetName} — Armor DR: {targetArmor} — Damage: {realDamage}",
|
||||
"resourceLost": "Resource spent"
|
||||
},
|
||||
"Save": {
|
||||
"FIELDS": {
|
||||
@@ -552,7 +709,7 @@
|
||||
"label": "Min"
|
||||
}
|
||||
},
|
||||
"damagereduction": {
|
||||
"damageReduction": {
|
||||
"label": "Damage reduction"
|
||||
},
|
||||
"defense": {
|
||||
@@ -595,7 +752,8 @@
|
||||
"label": "Min"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoDestruction": "Auto-Destruction"
|
||||
},
|
||||
"Skill": {
|
||||
"Category": {
|
||||
@@ -652,6 +810,9 @@
|
||||
"weaponClass": {
|
||||
"label": "Class"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"weaponBonus": "Weapon bonus exceeds the allowed maximum (skill total / 10)"
|
||||
}
|
||||
},
|
||||
"Spell": {
|
||||
@@ -691,6 +852,12 @@
|
||||
"cost": {
|
||||
"label": "Cost"
|
||||
},
|
||||
"costOverpowered": {
|
||||
"label": "Cost (Overpowered)"
|
||||
},
|
||||
"costOverpowered2": {
|
||||
"label": "Cost (Overpowered 2)"
|
||||
},
|
||||
"description": {
|
||||
"label": "Description"
|
||||
},
|
||||
@@ -714,14 +881,35 @@
|
||||
},
|
||||
"catalyst": {
|
||||
"label": "Catalyst"
|
||||
},
|
||||
"damageDice": {
|
||||
"label": "Damage dice"
|
||||
},
|
||||
"damageDiceOverpowered": {
|
||||
"label": "Overpowered Damage Dice"
|
||||
},
|
||||
"damageDiceOverpowered2": {
|
||||
"label": "Overpowered 2 Damage Dice"
|
||||
}
|
||||
},
|
||||
"Range": {
|
||||
"contact": "Contact",
|
||||
"distant": "Distant",
|
||||
"loin": "Far",
|
||||
"na": "N/A",
|
||||
"proche": "Close"
|
||||
}
|
||||
},
|
||||
"ToggleSheet": "Toggle mode",
|
||||
"Tooltip": {
|
||||
"addEquipment": "New equipment",
|
||||
"addSpell": "New spells",
|
||||
"skill": "Skills list"
|
||||
"skill": "Skills list",
|
||||
"combatProgressionStart": "First attack of combat can succeed on a roll of 1 through this value. Resets to 1 for subsequent attacks.",
|
||||
"addMiracle": "Add Miracle",
|
||||
"gifts": "Gifts list",
|
||||
"skills": "Skills list",
|
||||
"vulnerabilities": "Vulnerabilities list"
|
||||
},
|
||||
"Vulnerability": {
|
||||
"FIELDS": {
|
||||
@@ -736,7 +924,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"Warning": {},
|
||||
"Warning": {
|
||||
"defenseShieldOrder": "To avoid a hit without using the shield, roll Grit or Luck first — then roll the shield."
|
||||
},
|
||||
"Weapon": {
|
||||
"FIELDS": {
|
||||
"isAgile": {
|
||||
@@ -855,6 +1045,74 @@
|
||||
"melee": "Melee",
|
||||
"ranged": "Ranged"
|
||||
}
|
||||
},
|
||||
"Dialog": {
|
||||
"applyDamageTo": "Apply damage to",
|
||||
"weapon": "Weapon",
|
||||
"totalDamage": "Total Damage",
|
||||
"damageReduction": "Damage Reduction",
|
||||
"armorDR": "Armor DR",
|
||||
"shieldDR": "Shield DR",
|
||||
"totalDR": "Total DR",
|
||||
"selectOption": "Select damage application option",
|
||||
"noDR": "No DR",
|
||||
"withArmor": "With Armor DR only",
|
||||
"withAll": "With Armor + Shield DR",
|
||||
"damage": "damage"
|
||||
},
|
||||
"DamageApplied": {
|
||||
"subtitle": "suffered damage",
|
||||
"damageDealt": "Damage dealt",
|
||||
"from": "from"
|
||||
},
|
||||
"ProgressionMessage": {
|
||||
"canAct": "ready to act!",
|
||||
"cannotAct": "cannot act this second",
|
||||
"diceResult": "Dice result",
|
||||
"progressionCount": "Progression count:"
|
||||
},
|
||||
"Combat": {
|
||||
"RollMonsters": "Roll Monsters",
|
||||
"monstersNotRolledTitle": "Monsters Not Rolled",
|
||||
"monstersNotRolledMsg": "Monsters have not rolled this second. Proceed anyway?",
|
||||
"proceedYes": "Proceed",
|
||||
"proceedNo": "Cancel",
|
||||
"spellDRDialogTitle": "Spell Damage — Apply DR?",
|
||||
"spellDRDialogMsg": "Enter a damage reduction value to subtract, or click No DR to apply full damage.",
|
||||
"spellDRLabel": "DR:",
|
||||
"spellNoDR": "No DR",
|
||||
"spellApplyDR": "Apply DR",
|
||||
"chooseWeapon": "Choose a weapon for your reaction",
|
||||
"chooseSave": "Choose a save type",
|
||||
"chooseBonusDie": "Select a bonus die",
|
||||
"attackRoll": "Attack roll",
|
||||
"currentDefense": "Current defense",
|
||||
"shieldDice": "Shield dice",
|
||||
"shieldDR": "Shield DR",
|
||||
"attacker": "Attacker",
|
||||
"defender": "Defender"
|
||||
},
|
||||
"D30": {
|
||||
"chooseEffect": "Choose a D30 special effect to apply"
|
||||
},
|
||||
"EquipmentCategories": {
|
||||
"ClassKit": "Class Kit",
|
||||
"Clothing": "Clothing",
|
||||
"EssentialKit": "Essential Kit",
|
||||
"FoodDrink": "Food & Drink",
|
||||
"LandTransport": "Land Transport",
|
||||
"Light": "Light",
|
||||
"LoadBearing": "Load Bearing",
|
||||
"Misc": "Miscellaneous",
|
||||
"Mount": "Mount",
|
||||
"Music": "Music",
|
||||
"Sleeping": "Sleeping",
|
||||
"WaterTransport": "Water Transport"
|
||||
},
|
||||
"DiceTray": {
|
||||
"CountTitle": "Number of dice",
|
||||
"ExplodeTitle": "Exploding dice — re-roll on maximum value",
|
||||
"ChatTitle": "Free Roll"
|
||||
}
|
||||
},
|
||||
"TYPES": {
|
||||
|
||||
+122
-73
@@ -4,25 +4,36 @@
|
||||
*/
|
||||
|
||||
import { SYSTEM } from "./module/config/system.mjs"
|
||||
globalThis.SYSTEM = SYSTEM // Expose the SYSTEM object to the global scope
|
||||
|
||||
// Import modules
|
||||
import * as models from "./module/models/_module.mjs"
|
||||
import * as documents from "./module/documents/_module.mjs"
|
||||
import * as applications from "./module/applications/_module.mjs"
|
||||
|
||||
import { LethalFantasyCombatTracker, LethalFantasyCombat} from "./module/applications/combat.mjs"
|
||||
import { LethalFantasyCombatTracker, LethalFantasyCombat } from "./module/applications/combat.mjs"
|
||||
import { Macros } from "./module/macros.mjs"
|
||||
import { setupTextEnrichers } from "./module/enrichers.mjs"
|
||||
import { default as LethalFantasyUtils } from "./module/utils.mjs"
|
||||
import LethalFantasyUtils, { log } from "./module/utils.mjs"
|
||||
|
||||
export class ClassCounter{static printHello(){console.log("Hello")}static sendJsonPostRequest(e,s){const t={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)};return fetch(e,t).then((e=>{if(!e.ok)throw new Error("La requête a échoué avec le statut "+e.status);return e.json()})).catch((e=>{throw console.error("Erreur envoi de la requête:",e),e}))}static registerUsageCount(e=game.system.id,s={}){if(game.user.isGM){game.settings.register(e,"world-key",{name:"Unique world key",scope:"world",config:!1,default:"",type:String});let t=game.settings.get(e,"world-key");null!=t&&""!=t&&"NONE"!=t&&"none"!=t.toLowerCase()||(t=foundry.utils.randomID(32),game.settings.set(e,"world-key",t));let a={name:e,system:game.system.id,worldKey:t,version:game.system.version,language:game.settings.get("core","language"),remoteAddr:game.data.addresses.remote,nbInstalledModules:game.modules.size,nbActiveModules:game.modules.filter((e=>e.active)).length,nbPacks:game.world.packs.size,nbUsers:game.users.size,nbScenes:game.scenes.size,nbActors:game.actors.size,nbPlaylist:game.playlists.size,nbTables:game.tables.size,nbCards:game.cards.size,optionsData:s,foundryVersion:`${game.release.generation}.${game.release.build}`};this.sendJsonPostRequest("https://www.uberwald.me/fvtt_appcount/count_post.php",a)}}}
|
||||
// Import chat reaction hooks (renderChatMessageHTML, preCreateChatMessage, defense/attack reactions, resource costing, auto-damage)
|
||||
import "./module/hooks/chat-reaction.mjs"
|
||||
|
||||
Hooks.once("init", function () {
|
||||
globalThis.SYSTEM = SYSTEM
|
||||
globalThis.pendingDefenses = new Map()
|
||||
console.info("Lethal Fantasy RPG | Initializing System")
|
||||
console.info(SYSTEM.ASCII)
|
||||
|
||||
game.settings.register(game.system.id, "debug", {
|
||||
name: "Debug logging",
|
||||
scope: "client",
|
||||
config: true,
|
||||
default: false,
|
||||
type: Boolean,
|
||||
})
|
||||
|
||||
globalThis.lethalFantasy = game.system
|
||||
globalThis.log = log
|
||||
game.system.CONST = SYSTEM
|
||||
|
||||
// Expose the system API
|
||||
@@ -54,21 +65,19 @@ Hooks.once("init", function () {
|
||||
miracle: models.LethalFantasyMiracle
|
||||
}
|
||||
|
||||
// Register sheet application classes
|
||||
Actors.unregisterSheet("core", ActorSheet)
|
||||
Actors.registerSheet("lethalFantasy", applications.LethalFantasyCharacterSheet, { types: ["character"], makeDefault: true })
|
||||
Actors.registerSheet("lethalFantasy", applications.LethalFantasyMonsterSheet, { types: ["monster"], makeDefault: true })
|
||||
// Register sheet application classes (V2)
|
||||
foundry.documents.collections.Actors.registerSheet("lethalFantasy", applications.LethalFantasyCharacterSheet, { types: ["character"], makeDefault: true })
|
||||
foundry.documents.collections.Actors.registerSheet("lethalFantasy", applications.LethalFantasyMonsterSheet, { types: ["monster"], makeDefault: true })
|
||||
|
||||
Items.unregisterSheet("core", ItemSheet)
|
||||
Items.registerSheet("lethalFantasy", applications.LethalFantasySkillSheet, { types: ["skill"], makeDefault: true })
|
||||
Items.registerSheet("lethalFantasy", applications.LethalFantasyGiftSheet, { types: ["gift"], makeDefault: true })
|
||||
Items.registerSheet("lethalFantasy", applications.LethalFantasyVulnerabilitySheet, { types: ["vulnerability"], makeDefault: true })
|
||||
Items.registerSheet("lethalFantasy", applications.LethalFantasyWeaponSheet, { types: ["weapon"], makeDefault: true })
|
||||
Items.registerSheet("lethalFantasy", applications.LethalFantasySpellSheet, { types: ["spell"], makeDefault: true })
|
||||
Items.registerSheet("lethalFantasy", applications.LethalFantasyArmorSheet, { types: ["armor"], makeDefault: true })
|
||||
Items.registerSheet("lethalFantasy", applications.LethalFantasyShieldSheet, { types: ["shield"], makeDefault: true })
|
||||
Items.registerSheet("lethalFantasy", applications.LethalFantasyEquipmentSheet, { types: ["equipment"], makeDefault: true })
|
||||
Items.registerSheet("lethalFantasy", applications.LethalFantasyMiracleSheet, { types: ["miracle"], makeDefault: true })
|
||||
foundry.documents.collections.Items.registerSheet("lethalFantasy", applications.LethalFantasySkillSheet, { types: ["skill"], makeDefault: true })
|
||||
foundry.documents.collections.Items.registerSheet("lethalFantasy", applications.LethalFantasyGiftSheet, { types: ["gift"], makeDefault: true })
|
||||
foundry.documents.collections.Items.registerSheet("lethalFantasy", applications.LethalFantasyVulnerabilitySheet, { types: ["vulnerability"], makeDefault: true })
|
||||
foundry.documents.collections.Items.registerSheet("lethalFantasy", applications.LethalFantasyWeaponSheet, { types: ["weapon"], makeDefault: true })
|
||||
foundry.documents.collections.Items.registerSheet("lethalFantasy", applications.LethalFantasySpellSheet, { types: ["spell"], makeDefault: true })
|
||||
foundry.documents.collections.Items.registerSheet("lethalFantasy", applications.LethalFantasyArmorSheet, { types: ["armor"], makeDefault: true })
|
||||
foundry.documents.collections.Items.registerSheet("lethalFantasy", applications.LethalFantasyShieldSheet, { types: ["shield"], makeDefault: true })
|
||||
foundry.documents.collections.Items.registerSheet("lethalFantasy", applications.LethalFantasyEquipmentSheet, { types: ["equipment"], makeDefault: true })
|
||||
foundry.documents.collections.Items.registerSheet("lethalFantasy", applications.LethalFantasyMiracleSheet, { types: ["miracle"], makeDefault: true })
|
||||
|
||||
// Other Document Configuration
|
||||
CONFIG.ChatMessage.documentClass = documents.LethalFantasyChatMessage
|
||||
@@ -76,20 +85,12 @@ Hooks.once("init", function () {
|
||||
// Dice system configuration
|
||||
CONFIG.Dice.rolls.push(documents.LethalFantasyRoll)
|
||||
|
||||
game.settings.register("lethalFantasy", "worldKey", {
|
||||
name: "Unique world key",
|
||||
scope: "world",
|
||||
config: false,
|
||||
type: String,
|
||||
default: "",
|
||||
})
|
||||
|
||||
// Activate socket handler
|
||||
game.socket.on(`system.${SYSTEM.id}`, LethalFantasyUtils.handleSocketEvent)
|
||||
|
||||
setupTextEnrichers()
|
||||
LethalFantasyUtils.registerHandlebarsHelpers()
|
||||
LethalFantasyUtils.setHookListeners( )
|
||||
LethalFantasyUtils.setHookListeners()
|
||||
|
||||
console.info("LETHAL FANTASY | System Initialized")
|
||||
})
|
||||
@@ -105,19 +106,16 @@ function preLocalizeConfig() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CONFIG.Dice.rollModes = Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
|
||||
|
||||
// localizeConfigObject(SYSTEM.ACTION.TAG_CATEGORIES, ["label"])
|
||||
// localizeConfigObject(CONFIG.Dice.rollModes, ["label"])
|
||||
}
|
||||
|
||||
Hooks.once("ready", function () {
|
||||
console.info("LETHAL FANTASY | Ready")
|
||||
|
||||
if (!SYSTEM.DEV_MODE) {
|
||||
registerWorldCount("lethalFantasy")
|
||||
}
|
||||
// Initialiser la table des résultats D30
|
||||
documents.D30Roll.initialize()
|
||||
|
||||
// Saignement piloté par le combat tracker
|
||||
_registerBleedingHooks()
|
||||
|
||||
_showUserGuide()
|
||||
|
||||
@@ -131,37 +129,96 @@ Hooks.once("ready", function () {
|
||||
}
|
||||
})
|
||||
|
||||
// Test if version below 13
|
||||
let hookName = "renderChatMessage"
|
||||
if (foundry.utils.isNewerVersion(game.version, "12.0", )) {
|
||||
hookName = "renderChatMessageHTML"
|
||||
/**
|
||||
* Saignement piloté par le combat tracker.
|
||||
* Chaque round = 1 seconde → les acteurs qui saignent perdent 1 HP/blessure.
|
||||
* Hors combat, une notification prévient le MJ que des blessures saignent encore.
|
||||
*/
|
||||
function _registerBleedingHooks() {
|
||||
if (!game.user.isGM) return
|
||||
|
||||
Hooks.on("combatRound", async (combat, previous, current) => {
|
||||
if (previous === current) return
|
||||
const processed = new Set()
|
||||
for (const combatant of combat.combatants) {
|
||||
const actor = combatant.actor
|
||||
if (!actor || processed.has(actor.id)) continue
|
||||
processed.add(actor.id)
|
||||
await _applyBleedingTick(actor)
|
||||
}
|
||||
})
|
||||
|
||||
Hooks.on("combatEnd", async (combat) => {
|
||||
const bleeding = _findBleedingActors()
|
||||
if (bleeding.length) {
|
||||
ui.notifications.warn(
|
||||
game.i18n.format("LETHALFANTASY.Notifications.bleedingCombatEnd", {
|
||||
names: bleeding.map(a => a.name).join(", "),
|
||||
})
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
Hooks.on("combatStart", async (combat) => {
|
||||
const bleeding = _findBleedingActors()
|
||||
if (bleeding.length) {
|
||||
ui.notifications.warn(
|
||||
game.i18n.format("LETHALFANTASY.Notifications.bleedingCombatStart", {
|
||||
names: bleeding.map(a => a.name).join(", "),
|
||||
})
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
Hooks.on(hookName, (message, html, data) => {
|
||||
const typeMessage = data.message.flags.lethalFantasy?.typeMessage
|
||||
// Message de demande de jet de dés
|
||||
if (typeMessage === "askRoll") {
|
||||
// Affichage des boutons de jet de dés uniquement pour les joueurs
|
||||
if (game.user.isGM) {
|
||||
html.find(".ask-roll-dice").each((i, btn) => {
|
||||
btn.style.display = "none"
|
||||
})
|
||||
} else {
|
||||
html.find(".ask-roll-dice").click((event) => {
|
||||
const btn = $(event.currentTarget)
|
||||
const type = btn.data("type")
|
||||
const value = btn.data("value")
|
||||
const avantage = btn.data("avantage") ?? "="
|
||||
const character = game.user.character
|
||||
if (type === SYSTEM.ROLL_TYPE.RESOURCE) character.rollResource(value)
|
||||
else if (type === SYSTEM.ROLL_TYPE.SAVE) character.rollSave(value, avantage)
|
||||
})
|
||||
|
||||
/**
|
||||
* Appliquer 1 HP de dégât par blessure active, décrémenter la durée.
|
||||
* @param {import("foundry/common/documents.mjs").Actor} actor
|
||||
*/
|
||||
async function _applyBleedingTick(actor) {
|
||||
if (!actor?.system?.hp?.wounds) return
|
||||
const wounds = foundry.utils.duplicate(actor.system.hp.wounds)
|
||||
let hpLoss = 0
|
||||
let changed = false
|
||||
for (const wound of wounds) {
|
||||
if (wound.duration > 0 && wound.value > 0) {
|
||||
hpLoss += 1
|
||||
wound.duration -= 1
|
||||
if (wound.duration <= 0) {
|
||||
wound.value = 0
|
||||
wound.description = ""
|
||||
}
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
})
|
||||
if (!changed) return
|
||||
const currentHp = actor.system.hp.value ?? 0
|
||||
await actor.update({
|
||||
"system.hp.value": currentHp - hpLoss,
|
||||
"system.hp.wounds": wounds,
|
||||
})
|
||||
}
|
||||
|
||||
Hooks.on("getCombatTrackerEntryContext", (html, options) => {
|
||||
LethalFantasyUtils.pushCombatOptions(html, options);
|
||||
});
|
||||
/**
|
||||
* Retourne les acteurs (monde + tokens) qui ont des blessures actives.
|
||||
* @returns {import("foundry/common/documents.mjs").Actor[]}
|
||||
*/
|
||||
function _findBleedingActors() {
|
||||
const actors = []
|
||||
for (const actor of game.actors.values()) {
|
||||
if (actor?.system?.hp?.wounds?.some(w => w.duration > 0 && w.value > 0)) {
|
||||
actors.push(actor)
|
||||
}
|
||||
}
|
||||
for (const token of canvas.tokens?.placeables ?? []) {
|
||||
if (token.actor && !actors.includes(token.actor)) {
|
||||
if (token.actor?.system?.hp?.wounds?.some(w => w.duration > 0 && w.value > 0)) {
|
||||
actors.push(token.actor)
|
||||
}
|
||||
}
|
||||
}
|
||||
return actors
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a macro when dropping an entity on the hotbar
|
||||
@@ -176,16 +233,8 @@ Hooks.on("hotbarDrop", (bar, data, slot) => {
|
||||
}
|
||||
})
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
* Register world usage statistics
|
||||
* @param {string} registerKey
|
||||
* Inject the Lethal Fantasy dice tray into the chat sidebar.
|
||||
*/
|
||||
async function registerWorldCount(registerKey) {
|
||||
if (game.user.isGM) {
|
||||
try {
|
||||
ClassCounter.registerUsageCount(game.system.id, {})
|
||||
} catch {
|
||||
console.log("No usage log ")
|
||||
}
|
||||
}
|
||||
}
|
||||
Hooks.on("renderChatLog", (_chatLog, html) => applications.injectDiceTray(_chatLog, html))
|
||||
|
||||
@@ -9,4 +9,5 @@ export { default as LethalFantasySpellSheet } from "./sheets/spell-sheet.mjs"
|
||||
export { default as LethalFantasyEquipmentSheet } from "./sheets/equipment-sheet.mjs"
|
||||
export { default as LethalFantasyShieldSheet } from "./sheets/shield-sheet.mjs"
|
||||
export { default as LethalFantasyMiracleSheet } from "./sheets/miracle-sheet.mjs"
|
||||
export { injectDiceTray } from "./free-roll.mjs"
|
||||
|
||||
|
||||
+120
-58
@@ -1,44 +1,63 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
import { log } from "../utils.mjs"
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class LethalFantasyCombatTracker extends CombatTracker {
|
||||
export class LethalFantasyCombatTracker extends foundry.applications.sidebar.tabs.CombatTracker {
|
||||
|
||||
async getData(options) {
|
||||
let data = await super.getData(options);
|
||||
for (let u of data.turns) {
|
||||
static PARTS = {
|
||||
"header": {
|
||||
"template": "systems/fvtt-lethal-fantasy/templates/combat-tracker-header-v2.hbs"
|
||||
},
|
||||
"tracker": {
|
||||
"template": "systems/fvtt-lethal-fantasy/templates/combat-tracker-v2.hbs"
|
||||
},
|
||||
"footer": {
|
||||
"template": "systems/fvtt-lethal-fantasy/templates/combat-tracker-footer-v2.hbs"
|
||||
}
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = foundry.utils.mergeObject(super.DEFAULT_OPTIONS, {
|
||||
actions: {
|
||||
initiativePlus: LethalFantasyCombatTracker.#initiativePlus,
|
||||
initiativeMinus: LethalFantasyCombatTracker.#initiativeMinus,
|
||||
rollMonsterProgression: LethalFantasyCombatTracker.#rollMonsterProgression,
|
||||
},
|
||||
});
|
||||
|
||||
async _prepareContext(options) {
|
||||
let data = await super._prepareContext(options);
|
||||
log("Combat Tracker Data", data);
|
||||
/*for (let u of data.turns) {
|
||||
let c = game.combat.combatants.get(u.id);
|
||||
u.progressionCount = c.system.progressionCount
|
||||
u.isMonster = c.actor.type === "monster"
|
||||
}
|
||||
console.log("Combat Data", data);
|
||||
log("Combat Data", data);*/
|
||||
return data;
|
||||
}
|
||||
|
||||
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 });
|
||||
console.log("Initiative Plus");
|
||||
});
|
||||
|
||||
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 async #initiativePlus(ev) {
|
||||
ev.preventDefault();
|
||||
let cId = ev.target.closest(".combatant").dataset.combatantId;
|
||||
let c = game.combat.combatants.get(cId);
|
||||
await c.update({ 'initiative': c.initiative + 1 });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static get defaultOptions() {
|
||||
let path = "systems/fvtt-lethal-fantasy/templates/combat-tracker.hbs";
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
template: path,
|
||||
});
|
||||
static async #initiativeMinus(ev) {
|
||||
ev.preventDefault();
|
||||
let cId = ev.target.closest(".combatant").dataset.combatantId;
|
||||
let c = game.combat.combatants.get(cId);
|
||||
let newInit = Math.max(c.initiative - 1, 0);
|
||||
await c.update({ 'initiative': newInit });
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll progression dice for all monster combatants that are eligible this round.
|
||||
* @param {Event} ev Click event.
|
||||
*/
|
||||
static async #rollMonsterProgression(ev) {
|
||||
ev.preventDefault();
|
||||
await game.combat.rollMonsterProgression();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +68,7 @@ export class LethalFantasyCombat extends Combat {
|
||||
* @returns {Combatant[]}
|
||||
*/
|
||||
setupTurns() {
|
||||
console?.log("Setup Turns....");
|
||||
log("Setup Turns....");
|
||||
this.turns ||= [];
|
||||
|
||||
// Determine the turn order and the current turn
|
||||
@@ -65,42 +84,73 @@ export class LethalFantasyCombat extends Combat {
|
||||
return this.turns = turns;
|
||||
}
|
||||
|
||||
async startCombat() {
|
||||
this._playCombatSound("startEncounter")
|
||||
const updateData = { round: 0, turn: 0 }
|
||||
Hooks.callAll("combatStart", this, updateData)
|
||||
await this.update(updateData)
|
||||
return this
|
||||
}
|
||||
|
||||
async rollInitiative(ids, options) {
|
||||
console.log("%%%%%%%%% Roll Initiative", ids, options);
|
||||
|
||||
ids = typeof ids === "string" ? [ids] : ids;
|
||||
let messages = [];
|
||||
let rollMode = game.settings.get("core", "rollMode");
|
||||
|
||||
let updates = [];
|
||||
for (let cId of ids) {
|
||||
const c = this.combatants.get(cId);
|
||||
let user = game.users.find(u => u.active && u.character && u.character.id === c.actor.id);
|
||||
if (user?.hasPlayerOwner) {
|
||||
console.log("Rolling initiative for", c.actor.name);
|
||||
game.socket.emit(`system.${SYSTEM.id}`, { type: "rollInitiative", actorId: c.actor.id, combatId: this.id, combatantId: c.id });
|
||||
const playerOwner = game.users.find(u => u.active && !u.isGM && u.character?.id === c.actor.id);
|
||||
if (game.user.isGM && playerOwner) {
|
||||
game.socket.emit(`system.${SYSTEM.id}`, { type: "rollInitiative", userId: playerOwner.id, actorId: c.actor.id, combatId: this.id, combatantId: c.id });
|
||||
} else {
|
||||
user = game.users.find(u => u.active && u.isGM);
|
||||
c.actor.system.rollInitiative(this.id, c.id);
|
||||
await c.actor.system.rollInitiative(this.id, c.id);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
resetProgression(cId) {
|
||||
let c = this.combatants.get(cId);
|
||||
c.update({ 'system.progressionCount': 0 });
|
||||
/** Roll progression dice for all eligible monster combatants this round. Called manually by the GM. */
|
||||
async rollMonsterProgression() {
|
||||
const currentRound = this.round;
|
||||
const monsters = this.combatants.filter(c => c.actor?.type === "monster" && !c.isDefeated);
|
||||
|
||||
if (monsters.length === 0) {
|
||||
ui.notifications.warn("No monsters in combat.");
|
||||
return;
|
||||
}
|
||||
|
||||
let rolled = 0;
|
||||
for (let c of monsters) {
|
||||
if (c.initiative !== null && currentRound >= c.initiative) {
|
||||
await c.actor.system.rollProgressionDice(this.id, c.id);
|
||||
rolled++;
|
||||
}
|
||||
}
|
||||
|
||||
if (rolled === 0) {
|
||||
const earliest = monsters.reduce((min, c) => (c.initiative !== null && c.initiative < min) ? c.initiative : min, Infinity);
|
||||
if (earliest === Infinity) {
|
||||
ui.notifications.warn("Monsters have no initiative set. Roll initiative first.");
|
||||
} else {
|
||||
ui.notifications.info(`No monsters act yet — earliest monster initiative is ${earliest} (current round: ${currentRound}).`);
|
||||
}
|
||||
} else {
|
||||
this._monsterProgressionRolledRound = currentRound;
|
||||
}
|
||||
}
|
||||
|
||||
setCasting(cId) {
|
||||
async resetProgression(cId) {
|
||||
let c = this.combatants.get(cId);
|
||||
c.setFlag(SYSTEM.id, "casting", true);
|
||||
await c.update({ 'system.progressionCount': 0 });
|
||||
}
|
||||
|
||||
resetCasting(cId) {
|
||||
async setCasting(cId) {
|
||||
let c = this.combatants.get(cId);
|
||||
c.setFlag(SYSTEM.id, "casting", false);
|
||||
await c.setFlag(SYSTEM.id, "casting", true);
|
||||
}
|
||||
|
||||
async resetCasting(cId) {
|
||||
let c = this.combatants.get(cId);
|
||||
await c.setFlag(SYSTEM.id, "casting", false);
|
||||
}
|
||||
|
||||
isCasting(cId) {
|
||||
@@ -109,15 +159,12 @@ export class LethalFantasyCombat extends Combat {
|
||||
}
|
||||
|
||||
async nextTurn() {
|
||||
console.log("NEXT TURN");
|
||||
|
||||
let turn = this.turn ?? -1;
|
||||
let skipDefeated = this.settings.skipDefeated;
|
||||
|
||||
// Determine the next turn number
|
||||
let next = null;
|
||||
for (let [i, t] of this.turns.entries()) {
|
||||
console.log("Turn", t);
|
||||
if (i <= turn) continue;
|
||||
if (skipDefeated && t.isDefeated) continue;
|
||||
next = i;
|
||||
@@ -141,7 +188,6 @@ export class LethalFantasyCombat extends Combat {
|
||||
this.turnsDone = false
|
||||
|
||||
let turn = this.turn === null ? null : 0; // Preserve the fact that it's no-one's turn currently.
|
||||
console.log("ROUND", this);
|
||||
|
||||
let advanceTime = Math.max(this.turns.length - this.turn, 0) * CONFIG.time.turnTime;
|
||||
advanceTime += CONFIG.time.roundTime;
|
||||
@@ -159,14 +205,30 @@ export class LethalFantasyCombat extends Combat {
|
||||
return this;
|
||||
}
|
||||
|
||||
// Warn if eligible monsters have not rolled progression dice this round
|
||||
const eligibleMonsters = this.combatants.filter(
|
||||
c => c.actor?.type === "monster" && !c.isDefeated && c.initiative !== null && this.round >= c.initiative
|
||||
);
|
||||
if (eligibleMonsters.length > 0 && this._monsterProgressionRolledRound !== this.round) {
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/dialogs/combat-monsters-not-rolled.hbs", {message: game.i18n.localize("LETHALFANTASY.Combat.monstersNotRolledMsg")})
|
||||
const proceed = await foundry.applications.api.DialogV2.confirm({
|
||||
window: { title: game.i18n.localize("LETHALFANTASY.Combat.monstersNotRolledTitle") },
|
||||
content,
|
||||
yes: { label: game.i18n.localize("LETHALFANTASY.Combat.proceedYes") },
|
||||
no: { label: game.i18n.localize("LETHALFANTASY.Combat.proceedNo") },
|
||||
rejectClose: false,
|
||||
});
|
||||
if (!proceed) return this;
|
||||
}
|
||||
|
||||
for (let c of this.combatants) {
|
||||
if ( nextRound >= c.initiative) {
|
||||
let user = game.users.find(u => u.active && u.character && u.character.id === c.actor.id);
|
||||
if (user?.hasPlayerOwner) {
|
||||
game.socket.emit(`system.${SYSTEM.id}`, { type: "rollProgressionDice", progressionCount: c.system.progressionCount+1, actorId: c.actor.id, combatId: this.id, combatantId: c.id });
|
||||
if (nextRound >= c.initiative) {
|
||||
if (c.actor.type === "monster") continue; // Monsters roll manually via the "Roll Monsters" button
|
||||
const playerOwner = game.users.find(u => u.active && !u.isGM && u.character?.id === c.actor.id);
|
||||
if (game.user.isGM && playerOwner) {
|
||||
game.socket.emit(`system.${SYSTEM.id}`, { type: "rollProgressionDice", userId: playerOwner.id, progressionCount: c.system.progressionCount + 1, actorId: c.actor.id, combatId: this.id, combatantId: c.id });
|
||||
} else {
|
||||
user = game.users.find(u => u.active && u.isGM);
|
||||
c.actor.system.rollProgressionDice(this.id, c.id);
|
||||
await c.actor.system.rollProgressionDice(this.id, c.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* Free Dice Tray — injected into the Foundry chat sidebar.
|
||||
*
|
||||
* Provides a compact bar for GM and players to roll any standard die (d4–d30)
|
||||
* or its exploding variant (dXx) without needing an actor sheet.
|
||||
* Supports selecting how many dice to roll (1–9).
|
||||
*/
|
||||
|
||||
/** Standard dice available in Lethal Fantasy */
|
||||
const DICE_TYPES = ["d4", "d6", "d8", "d10", "d12", "d20", "d30"]
|
||||
|
||||
/**
|
||||
* Inject the dice tray bar into the ChatLog HTML.
|
||||
* Called from `Hooks.on("renderChatLog", ...)`.
|
||||
*
|
||||
* @param {Application} _chatLog
|
||||
* @param {HTMLElement|jQuery} html
|
||||
*/
|
||||
export async function injectDiceTray(_chatLog, html) {
|
||||
const el = (html instanceof HTMLElement) ? html : (html[0] ?? html)
|
||||
if (!el?.querySelector) return
|
||||
if (el.querySelector(".lf-dice-tray")) return
|
||||
|
||||
const bar = document.createElement("div")
|
||||
bar.className = "lf-dice-tray"
|
||||
|
||||
const diceButtons = DICE_TYPES.map(d => ({ value: d, label: d.toUpperCase() }))
|
||||
const countOptions = Array.from({ length: 9 }, (_, i) => i + 1)
|
||||
bar.innerHTML = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/ui/dice-tray.hbs", {
|
||||
countTitle: game.i18n.localize("LETHALFANTASY.DiceTray.CountTitle"),
|
||||
explodeTitle: game.i18n.localize("LETHALFANTASY.DiceTray.ExplodeTitle"),
|
||||
countOptions,
|
||||
diceButtons
|
||||
})
|
||||
|
||||
bar.addEventListener("click", async ev => {
|
||||
const btn = ev.target.closest(".lf-dt-die-btn")
|
||||
if (!btn) return
|
||||
ev.stopPropagation()
|
||||
|
||||
const dieType = btn.dataset.die
|
||||
const count = parseInt(bar.querySelector(".lf-dt-count").value) || 1
|
||||
const explode = bar.querySelector(".lf-dt-explode").checked
|
||||
|
||||
try {
|
||||
await rollFreeDie(dieType, count, explode)
|
||||
} catch (err) {
|
||||
console.error("Lethal Fantasy | Dice Tray error:", err)
|
||||
ui.notifications?.error("Dice Tray roll failed — see console")
|
||||
}
|
||||
})
|
||||
|
||||
const anchor = el.querySelector(".chat-form")
|
||||
?? el.querySelector(".chat-message-form")
|
||||
?? el.querySelector("form")
|
||||
if (anchor) {
|
||||
anchor.parentElement.insertBefore(bar, anchor)
|
||||
} else {
|
||||
el.appendChild(bar)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll one or more dice of the given type and post the result to chat.
|
||||
* For exploding dice, follows the Lethal Fantasy rule: each exploded reroll
|
||||
* contributes (result − 1) to the total, same as all other system rolls.
|
||||
*
|
||||
* @param {string} dieType Die face, e.g. "d20"
|
||||
* @param {number} count Number of dice to roll (1–9)
|
||||
* @param {boolean} explode Whether to use the exploding variant (max triggers reroll at −1)
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function rollFreeDie(dieType, count = 1, explode = false) {
|
||||
const sides = parseInt(dieType.replace("d", "")) || 20
|
||||
const baseFormula = `1d${sides}`
|
||||
const label = explode
|
||||
? `${count}${dieType.toUpperCase()}E`
|
||||
: `${count}${dieType.toUpperCase()}`
|
||||
|
||||
const dieLabel = dieType.toUpperCase()
|
||||
const dieChips = []
|
||||
let total = 0
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
const r0 = await new Roll(baseFormula).evaluate()
|
||||
if (game?.dice3d) await game.dice3d.showForRoll(r0, game.user, true)
|
||||
let diceResult = r0.dice[0].results[0].result
|
||||
dieChips.push({ label: dieLabel, value: diceResult, exploded: false })
|
||||
total += diceResult
|
||||
|
||||
if (explode) {
|
||||
while (diceResult === sides) {
|
||||
const rx = await new Roll(baseFormula).evaluate()
|
||||
if (game?.dice3d) await game.dice3d.showForRoll(rx, game.user, true)
|
||||
diceResult = rx.dice[0].results[0].result
|
||||
const contrib = diceResult - 1
|
||||
dieChips.push({ label: `${dieLabel}-1`, value: contrib, exploded: true })
|
||||
total += contrib
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const dieChipsWithClasses = dieChips.map(chip => ({
|
||||
...chip,
|
||||
classes: ["lf-frc-die-chip", !chip.exploded && chip.value === sides ? "lf-frc-max" : "", chip.value === 1 ? "lf-frc-min" : ""].filter(Boolean).join(" ")
|
||||
}))
|
||||
|
||||
const totalLabel = game.i18n.localize("LETHALFANTASY.Label.total").toUpperCase()
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/free-roll-card.hbs", {
|
||||
titleText: game.i18n.localize("LETHALFANTASY.DiceTray.ChatTitle"),
|
||||
badge: label,
|
||||
dieChips: dieChipsWithClasses,
|
||||
totalLabel,
|
||||
total
|
||||
})
|
||||
|
||||
const rollMode = game.settings.get("core", "rollMode")
|
||||
// Normalize old-style rollMode keys (v12/v13) to new-style (v14), fallback to "public"
|
||||
const modeMap = { publicroll: "public", gmroll: "gm", blindroll: "blind", selfroll: "self" }
|
||||
const mode = modeMap[rollMode] ?? rollMode ?? "public"
|
||||
const msgData = {
|
||||
speaker: ChatMessage.getSpeaker(),
|
||||
content,
|
||||
sound: CONFIG.sounds.dice,
|
||||
mode,
|
||||
}
|
||||
await ChatMessage.create(msgData)
|
||||
}
|
||||
@@ -23,7 +23,7 @@ export default class LethalFantasyArmorSheet extends LethalFantasyItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ export default class LethalFantasyActorSheet extends HandlebarsApplicationMixin(
|
||||
actor: this.document,
|
||||
system: this.document.system,
|
||||
source: this.document.toObject(),
|
||||
enrichedDescription: await TextEditor.enrichHTML(this.document.system.description, { async: true }),
|
||||
enrichedDescription: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true }),
|
||||
isEditMode: this.isEditMode,
|
||||
isPlayMode: this.isPlayMode,
|
||||
isEditable: this.isEditable,
|
||||
@@ -78,7 +78,6 @@ export default class LethalFantasyActorSheet extends HandlebarsApplicationMixin(
|
||||
/** @override */
|
||||
_onRender(context, options) {
|
||||
this.#dragDrop.forEach((d) => d.bind(this.element))
|
||||
// Add listeners to rollable elements
|
||||
const rollables = this.element.querySelectorAll(".rollable")
|
||||
rollables.forEach((d) => d.addEventListener("click", this._onRoll.bind(this)))
|
||||
}
|
||||
@@ -100,7 +99,7 @@ export default class LethalFantasyActorSheet extends HandlebarsApplicationMixin(
|
||||
dragover: this._onDragOver.bind(this),
|
||||
drop: this._onDrop.bind(this),
|
||||
}
|
||||
return new DragDrop(d)
|
||||
return new foundry.applications.ux.DragDrop.implementation(d)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -140,7 +139,7 @@ export default class LethalFantasyActorSheet extends HandlebarsApplicationMixin(
|
||||
if ("link" in event.target.dataset) return
|
||||
|
||||
const el = event.currentTarget.closest('[data-drag="true"]')
|
||||
const dragType = el.dataset.dragType
|
||||
const dragType = el?.dataset?.dragType
|
||||
|
||||
let dragData = {}
|
||||
|
||||
@@ -234,12 +233,12 @@ export default class LethalFantasyActorSheet extends HandlebarsApplicationMixin(
|
||||
const attr = target.dataset.edit
|
||||
const current = foundry.utils.getProperty(this.document, attr)
|
||||
const { img } = this.document.constructor.getDefaultArtwork?.(this.document.toObject()) ?? {}
|
||||
const fp = new FilePicker({
|
||||
const fp = new foundry.applications.ux.FilePicker.implementation({
|
||||
current,
|
||||
type: "image",
|
||||
redirectToRoot: img ? [img] : [],
|
||||
callback: (path) => {
|
||||
this.document.update({ [attr]: path })
|
||||
callback: async (path) => {
|
||||
await this.document.update({ [attr]: path })
|
||||
},
|
||||
top: this.position.top + 40,
|
||||
left: this.position.left + 10,
|
||||
@@ -261,7 +260,7 @@ export default class LethalFantasyActorSheet extends HandlebarsApplicationMixin(
|
||||
item = await fromUuid(uuid)
|
||||
if (!item) item = this.document.items.get(id)
|
||||
if (!item) return
|
||||
item.sheet.render(true)
|
||||
item.sheet.render({ force: true })
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,8 +283,8 @@ export default class LethalFantasyActorSheet extends HandlebarsApplicationMixin(
|
||||
* @private
|
||||
* @static
|
||||
*/
|
||||
static #onCreateSpell(event, target) {
|
||||
const item = this.document.createEmbeddedDocuments("Item", [{ name: "Nouveau sortilège", type: "spell" }])
|
||||
static async #onCreateSpell(event, target) {
|
||||
await this.document.createEmbeddedDocuments("Item", [{ name: "Nouveau sortilège", type: "spell" }])
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
@@ -58,22 +58,22 @@ export default class LethalFantasyItemSheet extends HandlebarsApplicationMixin(f
|
||||
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = {
|
||||
fields: this.document.schema.fields,
|
||||
systemFields: this.document.system.schema.fields,
|
||||
item: this.document,
|
||||
system: this.document.system,
|
||||
source: this.document.toObject(),
|
||||
enrichedDescription: await TextEditor.enrichHTML(this.document.system.description, { async: true }),
|
||||
isEditMode: this.isEditMode,
|
||||
isPlayMode: this.isPlayMode,
|
||||
isEditable: this.isEditable,
|
||||
}
|
||||
let context = await super._prepareContext()
|
||||
context.fields = this.document.schema.fields
|
||||
context.systemFields = this.document.system.schema.fields
|
||||
context.item = this.document
|
||||
context.system = this.document.system
|
||||
context.source = this.document.toObject()
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
context.isEditMode = this.isEditMode
|
||||
context.isPlayMode = this.isPlayMode
|
||||
context.isEditable = this.isEditable
|
||||
return context
|
||||
}
|
||||
|
||||
/** @override */
|
||||
_onRender(context, options) {
|
||||
super._onRender(context, options)
|
||||
this.#dragDrop.forEach((d) => d.bind(this.element))
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ export default class LethalFantasyItemSheet extends HandlebarsApplicationMixin(f
|
||||
dragover: this._onDragOver.bind(this),
|
||||
drop: this._onDrop.bind(this),
|
||||
}
|
||||
return new DragDrop(d)
|
||||
return new foundry.applications.ux.DragDrop.implementation(d)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -177,12 +177,12 @@ export default class LethalFantasyItemSheet extends HandlebarsApplicationMixin(f
|
||||
const attr = target.dataset.edit
|
||||
const current = foundry.utils.getProperty(this.document, attr)
|
||||
const { img } = this.document.constructor.getDefaultArtwork?.(this.document.toObject()) ?? {}
|
||||
const fp = new FilePicker({
|
||||
const fp = new foundry.applications.ux.FilePicker.implementation({
|
||||
current,
|
||||
type: "image",
|
||||
redirectToRoot: img ? [img] : [],
|
||||
callback: (path) => {
|
||||
this.document.update({ [attr]: path })
|
||||
callback: async (path) => {
|
||||
await this.document.update({ [attr]: path })
|
||||
},
|
||||
top: this.position.top + 40,
|
||||
left: this.position.left + 10,
|
||||
|
||||
@@ -22,6 +22,7 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
divinityPointsMinus: LethalFantasyCharacterSheet.#onDivinityPointsMinus,
|
||||
aetherPointsPlus: LethalFantasyCharacterSheet.#onAetherPointsPlus,
|
||||
aetherPointsMinus: LethalFantasyCharacterSheet.#onAetherPointsMinus,
|
||||
rollSpellDamage: LethalFantasyCharacterSheet.#onRollSpellDamage,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -70,10 +71,10 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
biography: { id: "biography", group: "sheet", icon: "fa-solid fa-book", label: "LETHALFANTASY.Label.biography" },
|
||||
}
|
||||
if (this.actor.system.biodata.magicUser) {
|
||||
tabs.spells = { id: "spells", group: "sheet", icon: "fa-sharp-duotone fa-solid fa-wand-magic-sparkles", label: "LETHALFANTASY.Label.spells" }
|
||||
tabs.spells = { id: "spells", group: "sheet", icon: "fa-solid fa-wand-magic-sparkles", label: "LETHALFANTASY.Label.spells" }
|
||||
}
|
||||
if (this.actor.system.biodata.clericUser) {
|
||||
tabs.miracles = { id: "miracles", group: "sheet", icon: "fa-sharp-duotone fa-solid fa-hands-praying", label: "LETHALFANTASY.Label.miracles" }
|
||||
tabs.miracles = { id: "miracles", group: "sheet", icon: "fa-solid fa-hands-praying", label: "LETHALFANTASY.Label.miracles" }
|
||||
}
|
||||
for (const v of Object.values(tabs)) {
|
||||
v.active = this.tabGroups[v.group] === v.id
|
||||
@@ -90,21 +91,31 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
return context
|
||||
}
|
||||
|
||||
_generateTooltip(type, target) {
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _preparePartContext(partId, context) {
|
||||
const doc = this.document
|
||||
switch (partId) {
|
||||
case "main":
|
||||
context.armorDR = this.actor.getArmorDR()
|
||||
context.damageReduction = this.actor.computeDamageReduction()
|
||||
context.damageReductionShield = this.actor.getShieldDR()
|
||||
break
|
||||
case "skills":
|
||||
case "skills": {
|
||||
context.tab = context.tabs.skills
|
||||
context.skills = doc.itemTypes.skill
|
||||
// Organiser les skills par catégorie
|
||||
const categories = ['layperson', 'professional', 'weapon', 'armor', 'resist']
|
||||
context.skillsByCategory = categories.map(cat => {
|
||||
return {
|
||||
category: cat,
|
||||
label: `LETHALFANTASY.Skill.Category.${cat}`,
|
||||
skills: context.skills.filter(s => s.system.category === cat)
|
||||
}
|
||||
}).filter(catData => catData.skills.length > 0)
|
||||
context.gifts = doc.itemTypes.gift
|
||||
context.vulnerabilities = doc.itemTypes.vulnerability
|
||||
break
|
||||
}
|
||||
case "spells":
|
||||
context.tab = context.tabs.spells
|
||||
context.spells = doc.itemTypes.spell
|
||||
@@ -127,8 +138,8 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
break
|
||||
case "biography":
|
||||
context.tab = context.tabs.biography
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await TextEditor.enrichHTML(doc.system.notes, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.notes, { async: true })
|
||||
break
|
||||
}
|
||||
return context
|
||||
@@ -143,18 +154,17 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
*/
|
||||
async _onDrop(event) {
|
||||
if (!this.isEditable || !this.isEditMode) return
|
||||
const data = TextEditor.getDragEventData(event)
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event)
|
||||
|
||||
// Handle different data types
|
||||
switch (data.type) {
|
||||
case "Item":
|
||||
const item = await fromUuid(data.uuid)
|
||||
return this._onDropItem(item)
|
||||
if (data.type === "Item") {
|
||||
const item = await fromUuid(data.uuid)
|
||||
return this._onDropItem(item)
|
||||
}
|
||||
}
|
||||
|
||||
static async #onRangedAttackDefense(event, target) {
|
||||
const hasTarget = false
|
||||
// Future use : const hasTarget = false
|
||||
|
||||
let roll = await LethalFantasyRoll.promptRangedDefense({
|
||||
actorId: this.actor.id,
|
||||
@@ -163,61 +173,130 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
})
|
||||
if (!roll) return null
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
await roll.toMessage({}, { messageMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
static async #onRollInitiative(event, target) {
|
||||
await this.document.system.rollInitiative()
|
||||
}
|
||||
|
||||
static #onArmorHitPointsPlus(event, target) {
|
||||
static async #onArmorHitPointsPlus(event, target) {
|
||||
let armorHP = this.actor.system.combat.armorHitPoints
|
||||
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
|
||||
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
|
||||
points += 1
|
||||
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
|
||||
points -= 1
|
||||
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
|
||||
points += 1
|
||||
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
|
||||
points -= 1
|
||||
points = Math.max(points, 0)
|
||||
this.actor.update({ "system.aetherPoints.value": points })
|
||||
await this.actor.update({ "system.aetherPoints.value": points })
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles spell damage roll from the spell sheet tab.
|
||||
* Shows a DR dialog then rolls the appropriate damage formula.
|
||||
* @param {PointerEvent} event
|
||||
* @param {HTMLElement} target
|
||||
*/
|
||||
static async #onRollSpellDamage(event, target) {
|
||||
if (this.isEditMode) return
|
||||
const itemId = target.dataset.itemId
|
||||
const tier = target.dataset.damageTier
|
||||
const spell = this.actor.items.get(itemId)
|
||||
if (!spell) return
|
||||
|
||||
const formulaMap = {
|
||||
standard: spell.system.damageDice,
|
||||
overpowered: spell.system.damageDiceOverpowered,
|
||||
overpowered2: spell.system.damageDiceOverpowered2,
|
||||
}
|
||||
const formula = formulaMap[tier]
|
||||
if (!formula) return
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/dialogs/spell-dr.hbs", {
|
||||
msg: game.i18n.localize("LETHALFANTASY.Combat.spellDRDialogMsg"),
|
||||
label: game.i18n.localize("LETHALFANTASY.Combat.spellDRLabel")
|
||||
})
|
||||
const manualDR = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: game.i18n.localize("LETHALFANTASY.Combat.spellDRDialogTitle") },
|
||||
classes: ["lethalfantasy"],
|
||||
position: { width: 320 },
|
||||
content,
|
||||
buttons: [
|
||||
{
|
||||
action: "noDR",
|
||||
type: "button",
|
||||
label: game.i18n.localize("LETHALFANTASY.Combat.spellNoDR"),
|
||||
icon: "fa-solid fa-wand-magic-sparkles",
|
||||
callback: () => 0
|
||||
},
|
||||
{
|
||||
action: "applyDR",
|
||||
type: "button",
|
||||
label: game.i18n.localize("LETHALFANTASY.Combat.spellApplyDR"),
|
||||
icon: "fa-solid fa-shield",
|
||||
callback: (event, button) => Number(button.form?.elements?.manualDr?.value) || 0
|
||||
},
|
||||
{
|
||||
action: "cancel",
|
||||
type: "button",
|
||||
label: game.i18n.localize("LETHALFANTASY.Combat.proceedNo"),
|
||||
callback: () => "cancel"
|
||||
}
|
||||
],
|
||||
rejectClose: false
|
||||
})
|
||||
if (manualDR === null || manualDR === "cancel") return
|
||||
|
||||
const rollOpts = {
|
||||
type: "spell-damage",
|
||||
rollType: "spell-damage",
|
||||
rollName: `${spell.name} — ${formula}`,
|
||||
isDamage: true,
|
||||
rollData: { isDamage: true },
|
||||
manualDR,
|
||||
actorId: this.actor.id,
|
||||
actorName: this.actor.name,
|
||||
actorImage: this.actor.img
|
||||
}
|
||||
await LethalFantasyRoll.rollSpellDamageToMessage(formula, rollOpts)
|
||||
}
|
||||
|
||||
static #onCreateEquipment(event, target) {
|
||||
}
|
||||
|
||||
_onRender(context, options) {
|
||||
// Inputs with class `item-quantity`
|
||||
const woundDescription = this.element.querySelectorAll('.wound-data')
|
||||
for (const input of woundDescription) {
|
||||
input.addEventListener("change", (e) => {
|
||||
input.addEventListener("change", async (e) => {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
const newValue = e.currentTarget.value
|
||||
@@ -225,11 +304,11 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
const fieldName = e.currentTarget.dataset.name
|
||||
let tab = foundry.utils.duplicate(this.actor.system.hp.wounds)
|
||||
tab[index][fieldName] = newValue
|
||||
console.log(tab, index, fieldName, newValue)
|
||||
this.actor.update({ "system.hp.wounds": tab });
|
||||
log(tab, index, fieldName, newValue)
|
||||
await this.actor.update({ "system.hp.wounds": tab });
|
||||
})
|
||||
}
|
||||
super._onRender();
|
||||
super._onRender(context, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -250,10 +329,11 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
|
||||
async _onRoll(event, target) {
|
||||
if (this.isEditMode) return
|
||||
console.log("Roll event", event)
|
||||
const rollType = event.target.dataset.rollType
|
||||
let rollKey = event.target.dataset.rollKey;
|
||||
let rollDice = event.target.dataset?.rollDice;
|
||||
const el = event.currentTarget
|
||||
const rollType = el.dataset.rollType
|
||||
if (!rollType) return
|
||||
let rollKey = el.dataset.rollKey
|
||||
let rollDice = el.dataset.rollDice
|
||||
|
||||
this.actor.prepareRoll(rollType, rollKey, rollDice)
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class LethalFantasyEquipmentSheet extends LethalFantasyItemSheet
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,4 @@ export default class LethalFantasyGiftSheet extends LethalFantasyItemSheet {
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class LethalFantasyMiracleSheet extends LethalFantasyItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
|
||||
|
||||
@@ -63,9 +63,6 @@ export default class LethalFantasyMonsterSheet extends LethalFantasyActorSheet {
|
||||
return context
|
||||
}
|
||||
|
||||
_generateTooltip(type, target) {
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _preparePartContext(partId, context) {
|
||||
const doc = this.document
|
||||
@@ -78,8 +75,8 @@ export default class LethalFantasyMonsterSheet extends LethalFantasyActorSheet {
|
||||
break
|
||||
case "biography":
|
||||
context.tab = context.tabs.biography
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await TextEditor.enrichHTML(doc.system.notes, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.notes, { async: true })
|
||||
break
|
||||
}
|
||||
return context
|
||||
@@ -94,7 +91,7 @@ export default class LethalFantasyMonsterSheet extends LethalFantasyActorSheet {
|
||||
*/
|
||||
async _onDrop(event) {
|
||||
if (!this.isEditable || !this.isEditMode) return
|
||||
const data = TextEditor.getDragEventData(event)
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event)
|
||||
|
||||
// Handle different data types
|
||||
switch (data.type) {
|
||||
@@ -114,11 +111,13 @@ export default class LethalFantasyMonsterSheet extends LethalFantasyActorSheet {
|
||||
})
|
||||
if (!roll) return null
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
await roll.toMessage({}, { messageMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
static async #onRollInitiative(event, target) {
|
||||
await this.document.system.rollInitiative(event, target)
|
||||
const combat = game.combat
|
||||
const combatant = combat?.combatants.find(c => c.actorId === this.document.id)
|
||||
await this.document.system.rollInitiative(combat?.id, combatant?.id)
|
||||
}
|
||||
|
||||
getBestWeaponClassSkill(skills, rollType, multiplier = 1.0) {
|
||||
@@ -165,9 +164,11 @@ export default class LethalFantasyMonsterSheet extends LethalFantasyActorSheet {
|
||||
|
||||
async _onRoll(event, target) {
|
||||
if (this.isEditMode) return
|
||||
const rollType = event.target.dataset.rollType
|
||||
let rollKey = event.target.dataset.rollKey
|
||||
let rollDice = event.target.dataset?.rollDice || "0"
|
||||
const rollable = event.target.closest('.rollable')
|
||||
if (!rollable) return
|
||||
const rollType = rollable.dataset.rollType
|
||||
let rollKey = rollable.dataset.rollKey
|
||||
let rollDice = rollable.dataset?.rollDice || "0"
|
||||
this.actor.system.prepareMonsterRoll(rollType, rollKey, rollDice)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class LethalFantasyShieldSheet extends LethalFantasyItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class LethalFantasySkillSheet extends LethalFantasyItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class LethalFantasySpellSheet extends LethalFantasyItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class LethalFantasyVulnerabilitySheet extends LethalFantasyItemSh
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class LethalFantasyWeaponSheet extends LethalFantasyItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,620 @@
|
||||
{
|
||||
"d30_dice_results": {
|
||||
"30": {
|
||||
"melee_attack": {
|
||||
"type": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"type": "special_strike",
|
||||
"options": [
|
||||
"lethal",
|
||||
"vital"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "bonus_dice",
|
||||
"dice": "D20E",
|
||||
"target": "attack"
|
||||
}
|
||||
],
|
||||
"description": "Possible Lethal or Vital Strike or Add D20E to Attack"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"type": "special_strike",
|
||||
"options": [
|
||||
"lethal",
|
||||
"vital"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "bonus_dice",
|
||||
"dice": "D20E",
|
||||
"target": "attack"
|
||||
}
|
||||
],
|
||||
"description": "Possible Lethal or Vital Strike or Add D20E to Attack"
|
||||
},
|
||||
"melee_defense": {
|
||||
"type": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"type": "special_defense",
|
||||
"options": [
|
||||
"flawless",
|
||||
"legendary"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "bonus_dice",
|
||||
"dice": "D20E",
|
||||
"target": "defense"
|
||||
}
|
||||
],
|
||||
"description": "Possible Flawless or Legendary Defense or Add D20E to Defense"
|
||||
},
|
||||
"arcane_spell_attack": {
|
||||
"type": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"type": "special_strike",
|
||||
"options": [
|
||||
"lethal_magical",
|
||||
"vital_magical"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "bonus_dice",
|
||||
"dice": "D20E",
|
||||
"target": "spell_attack"
|
||||
}
|
||||
],
|
||||
"description": "Possible Lethal or Vital Magical Strike or Add D20E to Spell Attack"
|
||||
},
|
||||
"skill_rolls": {
|
||||
"type": "skill_auto_success",
|
||||
"description": "Skill Succeeds Regardless of Opposing Roll"
|
||||
},
|
||||
"ranged_defense": {
|
||||
"type": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"type": "special_defense",
|
||||
"options": [
|
||||
"flawless",
|
||||
"legendary"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "bonus_dice",
|
||||
"dice": "D20E",
|
||||
"target": "defense"
|
||||
}
|
||||
],
|
||||
"description": "Possible Flawless or Legendary Defense or Add D20E to Defense"
|
||||
},
|
||||
"arcane_spell_defense": {
|
||||
"type": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"type": "spell_calamity"
|
||||
},
|
||||
{
|
||||
"type": "bonus_dice",
|
||||
"dice": "D20E",
|
||||
"target": "spell_defense"
|
||||
}
|
||||
],
|
||||
"description": "Possible Spell Catastrophe or adds D20E to Spell Defense"
|
||||
}
|
||||
},
|
||||
"29": {
|
||||
"melee_attack": {
|
||||
"type": "gain_grit",
|
||||
"amount": 1,
|
||||
"description": "Gain 1 Grit"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "gain_grit",
|
||||
"amount": 1,
|
||||
"description": "Gain 1 Grit"
|
||||
},
|
||||
"melee_defense": {
|
||||
"type": "gain_grit",
|
||||
"amount": 1,
|
||||
"description": "Gain 1 Grit"
|
||||
},
|
||||
"arcane_spell_attack": {
|
||||
"type": "gain_grit",
|
||||
"amount": 1,
|
||||
"description": "Gain 1 Grit"
|
||||
},
|
||||
"skill_rolls": {
|
||||
"type": "gain_grit",
|
||||
"amount": 1,
|
||||
"description": "Gain 1 Grit"
|
||||
},
|
||||
"ranged_defense": {
|
||||
"type": "gain_grit",
|
||||
"amount": 1,
|
||||
"description": "Gain 1 Grit"
|
||||
},
|
||||
"arcane_spell_defense": {
|
||||
"type": "gain_grit",
|
||||
"amount": 1,
|
||||
"description": "Gain 1 Grit"
|
||||
}
|
||||
},
|
||||
"28": {
|
||||
"melee_attack": {
|
||||
"type": "shield_destruction",
|
||||
"description": "Shield Destruction"
|
||||
}
|
||||
},
|
||||
"27": {
|
||||
"melee_attack": {
|
||||
"type": "bonus_dice",
|
||||
"dice": "D6",
|
||||
"target": "attack",
|
||||
"description": "Granted D6 (1-6) Attack Modifier for This Melee Attack"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "bonus_dice",
|
||||
"dice": "D6",
|
||||
"target": "attack",
|
||||
"description": "Granted D6 (1-6) Attack Modifier for This Ranged Attack"
|
||||
},
|
||||
"melee_defense": {
|
||||
"type": "luck_die",
|
||||
"scope": "combat",
|
||||
"description": "Granted 1 Luck dice for Use in This Combat Only"
|
||||
},
|
||||
"arcane_spell_attack": {
|
||||
"type": "no_lethargy",
|
||||
"description": "No Spell Lethargy the Aether Approves of Characters Efforts"
|
||||
},
|
||||
"ranged_defense": {
|
||||
"type": "luck_die",
|
||||
"scope": "combat",
|
||||
"description": "Granted 1 Luck dice for Use in This Combat Only"
|
||||
},
|
||||
"arcane_spell_defense": {
|
||||
"type": "flash_of_pain",
|
||||
"duration_dice": "1D6E",
|
||||
"target": "caster",
|
||||
"description": "Caster Suffers Severe pain and will be under a flash of pain for 1D6E seconds"
|
||||
}
|
||||
},
|
||||
"26": {
|
||||
"melee_attack": {
|
||||
"type": "shield_destruction",
|
||||
"description": "Shield Destruction"
|
||||
}
|
||||
},
|
||||
"25": {
|
||||
"skill_rolls": {
|
||||
"type": "bonus_flat",
|
||||
"amount": 1,
|
||||
"target": "skill",
|
||||
"description": "Add 1 to Skill Roll"
|
||||
}
|
||||
},
|
||||
"21": {
|
||||
"melee_attack": {
|
||||
"type": "flash_of_pain",
|
||||
"duration_dice": "1D6E",
|
||||
"target": "defender",
|
||||
"description": "Hit Inflicts Flash of Pain 1D6E seconds"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "flash_of_pain",
|
||||
"duration_dice": "1D6E",
|
||||
"target": "defender",
|
||||
"description": "Hit Inflicts Flash of Pain 1D6E seconds"
|
||||
},
|
||||
"melee_defense": {
|
||||
"type": "recover_pain",
|
||||
"description": "Defender Recovers or ignores any flash of pain"
|
||||
},
|
||||
"arcane_spell_attack": {
|
||||
"type": "flash_of_pain",
|
||||
"duration_dice": "1D6E",
|
||||
"target": "defender",
|
||||
"description": "Magical Damage inflicts Flash of pain 1D6E seconds"
|
||||
},
|
||||
"skill_rolls": {
|
||||
"type": "bonus_dice",
|
||||
"dice": "D6",
|
||||
"target": "skill",
|
||||
"description": "Granted D6 (1-6) Skill Modifier for this Skill Attempt"
|
||||
},
|
||||
"ranged_defense": {
|
||||
"type": "recover_pain",
|
||||
"description": "Defender Recovers or ignores any flash of pain"
|
||||
},
|
||||
"arcane_spell_defense": {
|
||||
"type": "flash_of_pain",
|
||||
"duration_dice": "1D6E",
|
||||
"target": "caster",
|
||||
"description": "Caster Suffers Severe pain and will be under a flash of pain for 1D6E seconds"
|
||||
}
|
||||
},
|
||||
"20": {
|
||||
"melee_attack": {
|
||||
"type": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"type": "special_strike",
|
||||
"options": [
|
||||
"vicious"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "bonus_dice",
|
||||
"dice": "D12",
|
||||
"target": "attack"
|
||||
}
|
||||
],
|
||||
"description": "Possible Vicious Strike or Add D12 to attack"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"type": "special_strike",
|
||||
"options": [
|
||||
"vicious"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "bonus_dice",
|
||||
"dice": "D12",
|
||||
"target": "attack"
|
||||
}
|
||||
],
|
||||
"description": "Possible Vicious Strike or add D12 to attack"
|
||||
},
|
||||
"melee_defense": {
|
||||
"type": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"type": "special_defense",
|
||||
"options": [
|
||||
"perfect"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "bonus_dice",
|
||||
"dice": "D12",
|
||||
"target": "defense"
|
||||
}
|
||||
],
|
||||
"description": "Possible 20/20 defense that avoids Any Attack Except a Lethal Strike or adds D12 to defense"
|
||||
},
|
||||
"arcane_spell_attack": {
|
||||
"type": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"type": "special_strike",
|
||||
"options": [
|
||||
"vicious_magical"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "bonus_dice",
|
||||
"dice": "D12",
|
||||
"target": "spell_attack"
|
||||
}
|
||||
],
|
||||
"description": "Possible Vicious Application of a Magical Attack or add D12 to attack"
|
||||
},
|
||||
"skill_rolls": {
|
||||
"type": "bonus_flat",
|
||||
"amount": 20,
|
||||
"target": "skill",
|
||||
"description": "20 Added to Skill Roll"
|
||||
},
|
||||
"ranged_defense": {
|
||||
"type": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"type": "special_defense",
|
||||
"options": [
|
||||
"perfect"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "bonus_dice",
|
||||
"dice": "D12",
|
||||
"target": "defense"
|
||||
}
|
||||
],
|
||||
"description": "Possible 20/20 defense that avoids Any Attack Except a Lethal Strike or adds D12 to defense"
|
||||
},
|
||||
"arcane_spell_defense": {
|
||||
"type": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"type": "special_defense",
|
||||
"options": [
|
||||
"perfect_spell"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "bonus_dice",
|
||||
"dice": "D12",
|
||||
"target": "spell_defense"
|
||||
}
|
||||
],
|
||||
"description": "Possible 20/20 Spell defense that Saves Against Any Magical Attack Except a Lethal Magical Strike or add D12 to spell defense"
|
||||
}
|
||||
},
|
||||
"15": {
|
||||
"melee_attack": {
|
||||
"type": "combo",
|
||||
"effects": [
|
||||
{
|
||||
"type": "bleed"
|
||||
},
|
||||
{
|
||||
"type": "internal_injury"
|
||||
}
|
||||
],
|
||||
"description": "Bleed, Internal Injury on Hit"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "bleed",
|
||||
"description": "Bleed"
|
||||
},
|
||||
"melee_defense": {
|
||||
"type": "counter_attack",
|
||||
"options": [
|
||||
"kick",
|
||||
"punch"
|
||||
],
|
||||
"description": "Kick or Punch"
|
||||
},
|
||||
"skill_rolls": {
|
||||
"type": "bonus_flat",
|
||||
"amount": 1,
|
||||
"target": "skill",
|
||||
"description": "Add 1 to Skill Roll"
|
||||
},
|
||||
"ranged_defense": {
|
||||
"type": "counter_attack",
|
||||
"options": [
|
||||
"kick",
|
||||
"punch"
|
||||
],
|
||||
"description": "Kick or Punch"
|
||||
}
|
||||
},
|
||||
"13": {},
|
||||
"11": {
|
||||
"melee_attack": {
|
||||
"type": "flurry",
|
||||
"condition": "hit_or_miss",
|
||||
"description": "Flurry Attack on Hit or Miss"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "double_damage_dice",
|
||||
"description": "Roll 2x Damage Dice"
|
||||
}
|
||||
},
|
||||
"10": {
|
||||
"melee_attack": {
|
||||
"type": "combo",
|
||||
"effects": [
|
||||
{
|
||||
"type": "bleed"
|
||||
},
|
||||
{
|
||||
"type": "internal_injury"
|
||||
}
|
||||
],
|
||||
"description": "Bleed, Internal Injury on Hit"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "bleed",
|
||||
"description": "Bleed"
|
||||
},
|
||||
"melee_defense": {
|
||||
"type": "counter_attack",
|
||||
"options": [
|
||||
"kick",
|
||||
"punch"
|
||||
],
|
||||
"description": "Kick or Punch"
|
||||
},
|
||||
"skill_rolls": {
|
||||
"type": "bonus_flat",
|
||||
"amount": 1,
|
||||
"target": "skill",
|
||||
"description": "Add 1 to Skill Roll"
|
||||
},
|
||||
"ranged_defense": {
|
||||
"type": "counter_attack",
|
||||
"options": [
|
||||
"kick",
|
||||
"punch"
|
||||
],
|
||||
"description": "Kick or Punch"
|
||||
}
|
||||
},
|
||||
"8": {
|
||||
"melee_attack": {
|
||||
"type": "mulligan",
|
||||
"description": "Mulligan, Can Choose to Re-roll This Attack"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "mulligan",
|
||||
"description": "Mulligan, Can Choose to Re-Roll This Attack"
|
||||
},
|
||||
"melee_defense": {
|
||||
"type": "mulligan",
|
||||
"description": "Mulligan, Can Choose to Re-Roll This Defense"
|
||||
},
|
||||
"arcane_spell_attack": {
|
||||
"type": "mulligan",
|
||||
"description": "Mulligan, Can Re-Roll This Spell Attack"
|
||||
},
|
||||
"skill_rolls": {
|
||||
"type": "mulligan",
|
||||
"description": "Mulligan, Can Re-Roll This Skill roll"
|
||||
},
|
||||
"ranged_defense": {
|
||||
"type": "mulligan",
|
||||
"description": "Mulligan, Can Choose to Re-Roll This Defense"
|
||||
},
|
||||
"arcane_spell_defense": {
|
||||
"type": "mulligan",
|
||||
"description": "Mulligan, Can Re-Roll This Spell Defense"
|
||||
}
|
||||
},
|
||||
"7": {
|
||||
"melee_attack": {
|
||||
"type": "flurry",
|
||||
"condition": "hit_or_miss",
|
||||
"description": "Flurry Attack on Hit or Miss"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "double_damage_dice",
|
||||
"description": "Roll 2x Damage Dice"
|
||||
}
|
||||
},
|
||||
"5": {
|
||||
"melee_attack": {
|
||||
"type": "combo",
|
||||
"effects": [
|
||||
{
|
||||
"type": "bleed"
|
||||
},
|
||||
{
|
||||
"type": "internal_injury"
|
||||
}
|
||||
],
|
||||
"description": "Bleed, Internal Injury on Hit"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "bleed",
|
||||
"description": "Bleed"
|
||||
},
|
||||
"melee_defense": {
|
||||
"type": "counter_attack",
|
||||
"options": [
|
||||
"kick",
|
||||
"punch"
|
||||
],
|
||||
"description": "Kick or Punch"
|
||||
},
|
||||
"skill_rolls": {
|
||||
"type": "bonus_flat",
|
||||
"amount": 1,
|
||||
"target": "skill",
|
||||
"description": "Add 1 to Skill Roll"
|
||||
},
|
||||
"ranged_defense": {
|
||||
"type": "counter_attack",
|
||||
"options": [
|
||||
"kick",
|
||||
"punch"
|
||||
],
|
||||
"description": "Kick or Punch"
|
||||
}
|
||||
},
|
||||
"3": {
|
||||
"melee_attack": {
|
||||
"type": "damage_multiplier",
|
||||
"multiplier": 3,
|
||||
"description": "Triple Damage"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "damage_multiplier",
|
||||
"multiplier": 3,
|
||||
"description": "Triple Damage"
|
||||
},
|
||||
"melee_defense": {
|
||||
"type": "dr_multiplier",
|
||||
"multiplier": 3,
|
||||
"includes_shield": true,
|
||||
"description": "DR Tripled including Shield"
|
||||
},
|
||||
"arcane_spell_attack": {
|
||||
"type": "damage_multiplier",
|
||||
"multiplier": 3,
|
||||
"description": "Triple Damage on Spell Damage"
|
||||
},
|
||||
"ranged_defense": {
|
||||
"type": "dr_multiplier",
|
||||
"multiplier": 3,
|
||||
"includes_shield": true,
|
||||
"description": "DR Tripled including Shield"
|
||||
},
|
||||
"arcane_spell_defense": {
|
||||
"type": "bonus_dice",
|
||||
"dice": "D12",
|
||||
"target": "spell_defense",
|
||||
"description": "D12 Added to Spell Defense Modifier"
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"melee_attack": {
|
||||
"type": "damage_multiplier",
|
||||
"multiplier": 2,
|
||||
"description": "Double Damage"
|
||||
},
|
||||
"ranged_attack": {
|
||||
"type": "damage_multiplier",
|
||||
"multiplier": 2,
|
||||
"description": "Double Damage"
|
||||
},
|
||||
"melee_defense": {
|
||||
"type": "dr_multiplier",
|
||||
"multiplier": 2,
|
||||
"includes_shield": true,
|
||||
"description": "DR Doubled including Shield"
|
||||
},
|
||||
"arcane_spell_attack": {
|
||||
"type": "damage_multiplier",
|
||||
"multiplier": 2,
|
||||
"description": "Double Damage on Spell Damage"
|
||||
},
|
||||
"ranged_defense": {
|
||||
"type": "dr_multiplier",
|
||||
"multiplier": 2,
|
||||
"includes_shield": true,
|
||||
"description": "DR Doubled including Shield"
|
||||
},
|
||||
"arcane_spell_defense": {
|
||||
"type": "bonus_dice",
|
||||
"dice": "D6",
|
||||
"target": "spell_defense",
|
||||
"description": "D6 Added to Spell Defense Modifier"
|
||||
}
|
||||
},
|
||||
"1": {
|
||||
"ranged_attack": {
|
||||
"type": "fumble",
|
||||
"detail": "ranged_ammo_broken",
|
||||
"description": "Possible Fumble Ranged ammo is broken unrecoverable"
|
||||
},
|
||||
"arcane_spell_attack": {
|
||||
"type": "spell_calamity",
|
||||
"description": "A possible spell calamity has occurred"
|
||||
},
|
||||
"melee_attack": {
|
||||
"type": "fumble",
|
||||
"detail": "melee_fumble",
|
||||
"description": "Possible Fumble"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"flash_of_pain": "Causes the victim to defend against melee and spell attacks with disfavor. They can only walk and cannot attack, cast spells, call miracles or perform skills.",
|
||||
"shield_destruction_condition": "Shield destruction occurs only if damage exceeds the shields DR.",
|
||||
"matching_30s": "Matching 30s on skill rolls cancel each other out and is resolved by the skill roll.",
|
||||
"skill_roll_30": "A 30 on a skill roll indicates success at highest level of the skill involved."
|
||||
}
|
||||
}
|
||||
+123
-109
@@ -44,118 +44,128 @@ export const MONEY = {
|
||||
}
|
||||
|
||||
export const MORTAL_CHOICES = {
|
||||
"mankind": {label: "Mankind", value: "Mankind", defenseBonus: 0},
|
||||
"elf": {label: "Elf", value: "Elf", defenseBonus: 0},
|
||||
"dwarf": {label: "Dwarf", value: "Dwarf", defenseBonus: 0},
|
||||
"halfelf": {label: "Half-Elf", value: "Half-Elf", defenseBonus: 0},
|
||||
"halforc": {label: "Half-Orc", value: "Half-Orc", defenseBonus: 0},
|
||||
"gnome": {label: "Gnome", value: "Gnome", defenseBonus: 2},
|
||||
"shirefolk": {label: "Shire Folk", value: "Shire Folk", defenseBonus: 2},
|
||||
"Elf": {label: "Elf", value: "Elf", defenseBonus: 0},
|
||||
"Half-orc": {label: "Half-Orc", value: "Half-Orc", defenseBonus: 0},
|
||||
"Half-Orc": {label: "Half-Orc", value: "Half-Orc", defenseBonus: 0},
|
||||
"Dwarf": {label: "Dwarf", value: "Dwarf", defenseBonus: 0},
|
||||
"Half-elf": {label: "Half-Elf", value: "Half-Elf", defenseBonus: 0},
|
||||
"Gnome": {label: "Gnome", value: "Gnome", defenseBonus: 2},
|
||||
"Shire Folk": {label: "Shire Folk", value: "Shire Folk", defenseBonus: 2},
|
||||
"Shire folk": {label: "Shire Folk", value: "Shire Folk", defenseBonus: 2},
|
||||
"Mankind": {label: "Human", value: "Human", defenseBonus: 0},
|
||||
"mankind": { label: "Mankind", id: "mankind", defenseBonus: 0 },
|
||||
"elf": { label: "Elf", id: "elf", defenseBonus: 0 },
|
||||
"dwarf": { label: "Dwarf", id: "dwarf", defenseBonus: 0 },
|
||||
"halfelf": { label: "Half-Elf", id: "halfelf", defenseBonus: 0 },
|
||||
"halforc": { label: "Half-Orc", id: "halforc", defenseBonus: 0 },
|
||||
"gnome": { label: "Gnome", id: "gnome", defenseBonus: 2 },
|
||||
"halflings": { label: "Halfling", id: "halflings", defenseBonus: 2 }
|
||||
}
|
||||
|
||||
export const FAVOR_CHOICES = {
|
||||
"none": {label: "None", value: "none"},
|
||||
"favor": {label: "Favor", value: "favor"},
|
||||
"disfavor": {label: "Disfavor", value: "disfavor"}
|
||||
"none": { label: "None", value: "none" },
|
||||
"favor": { label: "Favor", value: "favor" },
|
||||
"disfavor": { label: "Disfavor", value: "disfavor" }
|
||||
}
|
||||
|
||||
export const MOVEMENT_CHOICES = {
|
||||
"none": {label: "None (D8E)", value: "D8"},
|
||||
"walk": {label: "Walk (D10E)", value: "D10"},
|
||||
"jog": {label: "Jog (D12E)", value: "D12"},
|
||||
"run": {label: "Run (D20E)", value: "D20"},
|
||||
"incombat": {label: "In Combat (D12E)", value: "D12"}
|
||||
"none": { label: "None (D20E Disfavor)", disfavor: true, value: "2D20kl" },
|
||||
"walk": { label: "Walk (D20E)", disfavor: true, value: "D20" },
|
||||
"incombat": { label: "In Combat (D20E)", favor: false, value: "D20" },
|
||||
"run": { label: "Jog/Run/Sprint (D20E Favor)", favor: true, value: "2D20kh" }
|
||||
}
|
||||
|
||||
export const MOVE_DIRECTION_CHOICES = {
|
||||
"none": {label: "None (+0)", value: "0"},
|
||||
"away": {label: "Away (+4)", value: "+4"},
|
||||
"toward": {label: "Toward (+0)", value: "0"},
|
||||
"lateral": {label: "Lateral (+10)", value: "+10"}
|
||||
"away": { label: "Away (+0)", value: "+0" },
|
||||
"toward": { label: "Toward (0)", value: "0" },
|
||||
"lateral": { label: "Lateral (Red +5)", value: "+5" },
|
||||
"none": { label: "None (+0)", value: "0" },
|
||||
}
|
||||
|
||||
export const SIZE_CHOICES = {
|
||||
"tiny": {label: "Tiny (+10)", value: "+10"},
|
||||
"small": {label: "Small (+5)", value: "+5"},
|
||||
"medium": {label: "Medium (+0)", value: "0"},
|
||||
"huge": {label: "Huge (-10)", value: "-10"}
|
||||
"tiny": { label: "Tiny (Blue +11)", value: "+11" },
|
||||
"small": { label: "Small (Purple +7)", value: "+7" },
|
||||
"medium": { label: "Medium (Red +5)", value: "+5" },
|
||||
"large": { label: "Large (Yellow +1)", value: "+1" },
|
||||
"huge": { label: "Huge (0)", value: "0" }
|
||||
}
|
||||
|
||||
export const RANGE_CHOICES = {
|
||||
"pointblank": {label: "Point Blank (-5)", value: "-5"},
|
||||
"short": {label: "Short (+0)", value: "0"},
|
||||
"medium": {label: "Medium (+8)", value: "+8"},
|
||||
"long": {label: "Long (+15)", value: "+15"},
|
||||
"extreme": {label: "Extreme (+20)", value: "+20"},
|
||||
"beyondskill": {label: "Beyond Skill (+25)", value: "+25"}
|
||||
"pointblank": { label: "Point Blank (Special)", value: "pointblank" },
|
||||
"short": { label: "Short (+0)", value: "0" },
|
||||
"medium": { label: "Medium (Red +5)", value: "+5" },
|
||||
"long": { label: "Long (Purple +7)", value: "+7" },
|
||||
"extreme": { label: "Extreme (Grey +9)", value: "+9" },
|
||||
"beyondskill": { label: "Beyond Skill (Blue +11)", value: "beyondskill" }
|
||||
}
|
||||
|
||||
export const ATTACKER_MOVEMENT_CHOICES = {
|
||||
"none": { label: "None / Stationary (D20E Favor)", favor: true, value: "2D20kh" },
|
||||
"walk": { label: "Walk (D20E)", value: "D20" },
|
||||
"incombat": { label: "In Combat (D20E)", value: "D20" },
|
||||
"run": { label: "Jog/Run/Sprint (D20E Disfavor)", disfavor: true, value: "2D20kl" }
|
||||
}
|
||||
|
||||
export const ATTACKER_AIM_CHOICES = {
|
||||
"simple": {label: "Simple (+0)", value: "0"},
|
||||
"careful": {label: "Careful (-4)", value: "-4"},
|
||||
"focused": {label: "Focused (-8)", value: "-8"}
|
||||
"simple": { label: "Simple (+0)", value: "0" },
|
||||
"careful": { label: "Careful (Red +5)", value: "+4" },
|
||||
"focused": { label: "Focused (Grey +9)", value: "+9" }
|
||||
}
|
||||
|
||||
export const SPELL_LETHARGY_DICE = [
|
||||
{dice: "D6", level: "1-5", value: "6", maxLevel: 5},
|
||||
{dice: "D8", level: "6-10", value: "8", maxLevel: 10},
|
||||
{dice: "D10", value: "10", level: "11-15", maxLevel: 15},
|
||||
{dice: "D12", value: "12", level: "16-20", maxLevel: 20},
|
||||
{dice: "D20", value: "20", level: "21-25", maxLevel: 25}
|
||||
{ dice: "D6", level: "1-5", value: "6", maxLevel: 5 },
|
||||
{ dice: "D8", level: "6-10", value: "8", maxLevel: 10 },
|
||||
{ dice: "D10", value: "10", level: "11-15", maxLevel: 15 },
|
||||
{ dice: "D12", value: "12", level: "16-20", maxLevel: 20 },
|
||||
{ dice: "D20", value: "20", level: "21-25", maxLevel: 25 }
|
||||
]
|
||||
|
||||
export const GRANTED_DICE_CHOICES = {
|
||||
"0": { label: "None", value: "0" },
|
||||
"D2": { label: "D2", value: "D2" },
|
||||
"D3": { label: "D3", value: "D3" },
|
||||
"D4": { label: "D4", value: "D4" },
|
||||
"D6": { label: "D6", value: "D6" },
|
||||
"D8": { label: "D8", value: "D8" },
|
||||
"D10": { label: "D10", value: "D10" },
|
||||
"D12": { label: "D12", value: "D12" },
|
||||
"D20": { label: "D20", value: "D20" }
|
||||
}
|
||||
|
||||
export const INITIATIVE_DICE_CHOICES_PER_CLASS = {
|
||||
"untrained": [
|
||||
{ "name": "Asleep or totally distracted (2D12)", "value": "2D12" },
|
||||
{ "name": "Awake but unsuspecting (2D8)", "value": "2D8" },
|
||||
{ "name": "Declared Ready on Alert (2D6)", "value": "2D6" },
|
||||
{ "name": "Aware of the enemy, can hear them but not see (2D4)", "value": "2D4" },
|
||||
{ "name": "Aware and know exactly where the enemy is (2D3)", "value": "2D3" }
|
||||
/*{ "name": "Aware of the enemy, can hear them but not see (2D4)", "value": "2D4" },
|
||||
{ "name": "Aware and know exactly where the enemy is (2D3)", "value": "2D3" }*/
|
||||
],
|
||||
"fighter": [
|
||||
{ "name": "Asleep or totally distracted (1D12)", "value": "1D12" },
|
||||
{ "name": "Awake but unsuspecting (1D8)", "value": "1D8" },
|
||||
{ "name": "Declared Ready on Alert (1D6)", "value": "1D6" },
|
||||
{ "name": "Aware of the enemy, can hear them but not see (1D4)", "value": "1D4" },
|
||||
{ "name": "Aware and know exactly where the enemy is (1D3)", "value": "1D3" }
|
||||
{ "name": "Declared Ready on Alert (1)", "value": "1" },
|
||||
/*{ "name": "Aware of the enemy, can hear them but not see (1D4)", "value": "1D4" },
|
||||
{ "name": "Aware and know exactly where the enemy is (1D3)", "value": "1D3" }*/
|
||||
],
|
||||
"rogue": [
|
||||
{ "name": "Asleep or totally distracted (1D10)", "value": "1D10" },
|
||||
{ "name": "Awake but unsuspecting (1D8)", "value": "1D8" },
|
||||
{ "name": "Declared Ready on Alert (1D6)", "value": "1D6" },
|
||||
{ "name": "Aware of the enemy, can hear them but not see (1D3)", "value": "1D3" },
|
||||
{ "name": "Aware and know exactly where the enemy is (1D2)", "value": "1D2" }
|
||||
{ "name": "Declared Ready on Alert (1)", "value": "1" },
|
||||
/*{ "name": "Aware of the enemy, can hear them but not see (1D3)", "value": "1D3" },
|
||||
{ "name": "Aware and know exactly where the enemy is (1D2)", "value": "1D2" }*/
|
||||
],
|
||||
"ranger": [
|
||||
{ "name": "Asleep or totally distracted (1D10)", "value": "1D10" },
|
||||
{ "name": "Awake but unsuspecting (1D8)", "value": "1D8" },
|
||||
{ "name": "Declared Ready on Alert (1D6)", "value": "1D6" },
|
||||
{ "name": "Aware of the enemy, can hear them but not see (1D4)", "value": "1D4" },
|
||||
{ "name": "Aware and know exactly where the enemy is (1D3)", "value": "1D3"}
|
||||
{ "name": "Declared Ready on Alert (1)", "value": "1" },
|
||||
/*{ "name": "Aware of the enemy, can hear them but not see (1D4)", "value": "1D4" },
|
||||
{ "name": "Aware and know exactly where the enemy is (1D3)", "value": "1D3" }*/
|
||||
],
|
||||
"cleric": [
|
||||
{ "name": "Asleep or totally distracted (1D12)", "value": "1D12" },
|
||||
{ "name": "Awake but unsuspecting (1D10)", "value": "1D10" },
|
||||
{ "name": "Declared Ready on Alert (1D8)", "value": "1D8" },
|
||||
{ "name": "Aware of the enemy, can hear them but not see (1D6)", "value": "1D6" },
|
||||
{ "name": "Aware and know exactly where the enemy is (1D4)", "value": "1D4" }
|
||||
{ "name": "Declared Ready on Alert (1)", "value": "1" },
|
||||
/*{ "name": "Aware of the enemy, can hear them but not see (1D6)", "value": "1D6" },
|
||||
{ "name": "Aware and know exactly where the enemy is (1D4)", "value": "1D4" }*/
|
||||
],
|
||||
"magicuser": [
|
||||
{ "name": "Sleeping to recover Aether Points (2D20)", "value": "2D20" },
|
||||
{ "name": "Asleep or totally distracted (1D20)", "value": "1D20" },
|
||||
{ "name": "Awake but unsuspecting (1D12)", "value": "1D12" },
|
||||
{ "name": "Declared Ready on Alert (1D10)", "value": "1D10" },
|
||||
{ "name": "Aware of the enemy, can hear them but not see (1D8)", "value": "1D8" },
|
||||
{ "name": "Aware and know exactly where the enemy is (1D6)", "value": "1D6" }
|
||||
{ "name": "Declared Ready on Alert (1)", "value": "1" },
|
||||
/*{ "name": "Aware of the enemy, can hear them but not see (1D8)", "value": "1D8" },
|
||||
{ "name": "Aware and know exactly where the enemy is (1D6)", "value": "1D6" }*/
|
||||
]
|
||||
}
|
||||
|
||||
@@ -169,12 +179,12 @@ export const CHAR_CLASSES = {
|
||||
}
|
||||
|
||||
export const CHAR_CLASSES_DEFINES = {
|
||||
"untrained": {id: "untrained", label: "Untrained"},
|
||||
"fighter": {id: "fighter", label: "Fighter"},
|
||||
"rogue": {id: "rogue", label: "Rogue"},
|
||||
"ranger": {id: "ranger", label: "Ranger"},
|
||||
"cleric": {id: "cleric", label: "Cleric"},
|
||||
"magicuser": {id: "magicuser", label: "Magic User"}
|
||||
"untrained": { id: "untrained", label: "Untrained" },
|
||||
"fighter": { id: "fighter", label: "Fighter" },
|
||||
"rogue": { id: "rogue", label: "Rogue" },
|
||||
"ranger": { id: "ranger", label: "Ranger" },
|
||||
"cleric": { id: "cleric", label: "Cleric" },
|
||||
"magicuser": { id: "magicuser", label: "Magic User" }
|
||||
}
|
||||
|
||||
export const DICE_VALUES = {
|
||||
@@ -187,10 +197,11 @@ export const DICE_VALUES = {
|
||||
"d20": "D20"
|
||||
}
|
||||
|
||||
export const CHARACTERISTIC_ATTACK = [ "str", "int", "wis", "dex"]
|
||||
export const CHARACTERISTIC_RANGED_ATTACK = [ "int", "wis", "dex"]
|
||||
export const CHARACTERISTIC_DEFENSE = [ "int", "wis", "dex" ]
|
||||
export const CHARACTERISTIC_DAMAGE = [ "str" ]
|
||||
export const CHARACTERISTIC_ATTACK = ["str", "int", "wis", "dex"]
|
||||
export const CHARACTERISTIC_RANGED_ATTACK = ["int", "wis", "dex"]
|
||||
export const CHARACTERISTIC_DEFENSE = ["int", "wis", "dex"]
|
||||
export const CHARACTERISTIC_RANGED_DEFENSE = ["int", "wis", "dex"]
|
||||
export const CHARACTERISTIC_DAMAGE = ["str"]
|
||||
|
||||
export const DEFENSE_DICE_VALUES = {
|
||||
"0": "0",
|
||||
@@ -226,41 +237,41 @@ export const SPELL_CRITICAL = {
|
||||
}
|
||||
|
||||
export const CHOICE_MODIFIERS = {
|
||||
"-9": "-9",
|
||||
"-8": "-8",
|
||||
"-7": "-7",
|
||||
"-6": "-6",
|
||||
"-5": "-5",
|
||||
"-4": "-4",
|
||||
"-3": "-3",
|
||||
"-2": "-2",
|
||||
"-1": "-1",
|
||||
"+0": "0",
|
||||
"+1": "+1",
|
||||
"+2": "+2",
|
||||
"+3": "+3",
|
||||
"+4": "+4",
|
||||
"+5": "+5",
|
||||
"+6": "+6",
|
||||
"+7": "+7",
|
||||
"+8": "+8",
|
||||
"+9": "+9",
|
||||
"+10": "+10",
|
||||
"+11": "+11",
|
||||
"+12": "+12",
|
||||
"+13": "+13",
|
||||
"+14": "+14",
|
||||
"+15": "+15",
|
||||
"+16": "+16",
|
||||
"+17": "+17",
|
||||
"+18": "+18",
|
||||
"+19": "+19",
|
||||
"+20": "+20",
|
||||
"+21": "+21",
|
||||
"+22": "+22",
|
||||
"+23": "+23",
|
||||
"+24": "+24",
|
||||
"+25": "+25"
|
||||
"-9": "-9",
|
||||
"-8": "-8",
|
||||
"-7": "-7",
|
||||
"-6": "-6",
|
||||
"-5": "-5",
|
||||
"-4": "-4",
|
||||
"-3": "-3",
|
||||
"-2": "-2",
|
||||
"-1": "-1",
|
||||
"+0": "0",
|
||||
"+1": "+1",
|
||||
"+2": "+2",
|
||||
"+3": "+3",
|
||||
"+4": "+4",
|
||||
"+5": "+5",
|
||||
"+6": "+6",
|
||||
"+7": "+7",
|
||||
"+8": "+8",
|
||||
"+9": "+9",
|
||||
"+10": "+10",
|
||||
"+11": "+11",
|
||||
"+12": "+12",
|
||||
"+13": "+13",
|
||||
"+14": "+14",
|
||||
"+15": "+15",
|
||||
"+16": "+16",
|
||||
"+17": "+17",
|
||||
"+18": "+18",
|
||||
"+19": "+19",
|
||||
"+20": "+20",
|
||||
"+21": "+21",
|
||||
"+22": "+22",
|
||||
"+23": "+23",
|
||||
"+24": "+24",
|
||||
"+25": "+25"
|
||||
}
|
||||
|
||||
export const ASCII = `
|
||||
@@ -301,6 +312,7 @@ export const SYSTEM = {
|
||||
CHARACTERISTIC_ATTACK,
|
||||
CHARACTERISTIC_RANGED_ATTACK,
|
||||
CHARACTERISTIC_DEFENSE,
|
||||
CHARACTERISTIC_RANGED_DEFENSE,
|
||||
CHARACTERISTIC_DAMAGE,
|
||||
INITIATIVE_DICE_CHOICES_PER_CLASS,
|
||||
CHAR_CLASSES,
|
||||
@@ -316,8 +328,10 @@ export const SYSTEM = {
|
||||
RANGE_CHOICES,
|
||||
FAVOR_CHOICES,
|
||||
ATTACKER_AIM_CHOICES,
|
||||
ATTACKER_MOVEMENT_CHOICES,
|
||||
MORTAL_CHOICES,
|
||||
SPELL_CRITICAL,
|
||||
MIRACLE_TYPES,
|
||||
SPELL_LETHARGY_DICE
|
||||
SPELL_LETHARGY_DICE,
|
||||
GRANTED_DICE_CHOICES
|
||||
}
|
||||
|
||||
@@ -2,3 +2,4 @@ export { default as LethalFantasyActor } from "./actor.mjs"
|
||||
export { default as LethalFantasyItem } from "./item.mjs"
|
||||
export { default as LethalFantasyRoll } from "./roll.mjs"
|
||||
export { default as LethalFantasyChatMessage } from "./chat-message.mjs"
|
||||
export { default as D30Roll } from "./d30-roll.mjs"
|
||||
|
||||
+185
-51
@@ -65,22 +65,105 @@ export default class LethalFantasyActor extends Actor {
|
||||
}
|
||||
}
|
||||
}
|
||||
goodSkill.weaponSkillModifier = maxValue * multiplier
|
||||
goodSkill.weaponSkillModifier = Math.ceil(maxValue * multiplier)
|
||||
return goodSkill
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
async applyDamage(hpLoss) {
|
||||
let hp = this.system.hp.value + hpLoss
|
||||
if (hp < 0) {
|
||||
hp = 0
|
||||
}
|
||||
this.update({ "system.hp.value": hp })
|
||||
await this.update({ "system.hp.value": hp })
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
async prepareRoll(rollType, rollKey, rollDice ) {
|
||||
console.log("Preparing roll", rollType, rollKey, rollDice)
|
||||
getNaturalDR() {
|
||||
if (this.type === "monster") {
|
||||
return Number(this.system.hp?.damageResistance) || 0
|
||||
}
|
||||
return Number(this.system.biodata?.naturalDR) || 0
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
getMagicDR() {
|
||||
if (this.type === "monster") return 0
|
||||
return Number(this.system.biodata?.magicDR) || 0
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
computeDamageReduction() {
|
||||
if (this.type === "monster") {
|
||||
let hpDR = this.getNaturalDR()
|
||||
let combatDR = Number(this.system.combat?.damageReduction) || 0
|
||||
return hpDR + combatDR
|
||||
}
|
||||
let naturalDR = this.getNaturalDR()
|
||||
let magicDR = this.getMagicDR()
|
||||
let armorDR = this.getArmorDR()
|
||||
return naturalDR + magicDR + armorDR
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
getShieldDR() {
|
||||
// Pour les monstres, utiliser combat.shieldDamageReduction
|
||||
if (this.type === "monster") {
|
||||
return Number(this.system.combat?.shieldDamageReduction) || 0
|
||||
}
|
||||
// Pour les personnages, utiliser les items de type shield
|
||||
let dr = 0
|
||||
for (let item of this.items) {
|
||||
if (item.type === "shield" && item.system.equipped) {
|
||||
dr += Number(item.system.damageReduction)
|
||||
}
|
||||
}
|
||||
return dr
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
getArmorDR() {
|
||||
let dr = 0
|
||||
for (let item of this.items) {
|
||||
if (item.type === "armor" && item.system.equipped) {
|
||||
dr += Number(item.system.damageReduction)
|
||||
}
|
||||
}
|
||||
return dr
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
getArmorDefenseValue() {
|
||||
let defenseValue = 0
|
||||
for (let item of this.items) {
|
||||
if (item.type === "armor" && item.system.equipped) {
|
||||
defenseValue += Number(item.system.defense)
|
||||
}
|
||||
}
|
||||
return defenseValue
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
fuzzyNameSearchWeaponSkills(weaponName, weaponClass = null) {
|
||||
// Get all weapon skills without the " skill" suffix
|
||||
let skills = this.items.filter((i) => i.type === "skill" && i.system.weaponClass === weaponClass && i.system.category === "weapon")
|
||||
// Remove parenthesis in the weapon name for better matching
|
||||
weaponName = weaponName.replace(/\(.*?\)/g, "").trim()
|
||||
// Now search if we find all the words of the weapon name in the skill name
|
||||
skills = skills.filter((s) => {
|
||||
let skillName = s.name.toLowerCase().replace(" skill", "").trim()
|
||||
let wName = weaponName.toLowerCase().trim()
|
||||
let wWords = wName.split(" ")
|
||||
for (let w of wWords) {
|
||||
if (!skillName.includes(w)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
return skills
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
async prepareRoll(rollType, rollKey, rollDice, defenderId, defenderTokenId, extraShieldDr = 0, d30Effects = {}) {
|
||||
log("Preparing roll", rollType, rollKey, rollDice, defenderId)
|
||||
let rollTarget
|
||||
switch (rollType) {
|
||||
case "granted":
|
||||
@@ -89,7 +172,7 @@ export default class LethalFantasyActor extends Actor {
|
||||
formula: foundry.utils.duplicate(this.system.granted[rollKey]),
|
||||
rollKey: rollKey
|
||||
}
|
||||
if ( rollTarget.formula === "" || rollTarget.formula === undefined) {
|
||||
if (rollTarget.formula === "" || rollTarget.formula === undefined) {
|
||||
rollTarget.formula = 0
|
||||
}
|
||||
break;
|
||||
@@ -122,75 +205,126 @@ export default class LethalFantasyActor extends Actor {
|
||||
case "spell-power":
|
||||
case "miracle-attack":
|
||||
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
|
||||
// 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: await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/dialogs/power-level.hbs", {itemName: rollTarget.name}),
|
||||
buttons,
|
||||
rejectClose: false,
|
||||
}) || "standard"
|
||||
} else {
|
||||
damageTier = "standard"
|
||||
}
|
||||
}
|
||||
rollTarget.damageTier = damageTier
|
||||
if (rollType === "spell-attack" || rollType === "spell-power") {
|
||||
const tierCostMap = { standard: "cost", overpowered: "costOverpowered", overpowered2: "costOverpowered2" }
|
||||
const costField = tierCostMap[damageTier] || "cost"
|
||||
const cost = Number(rollTarget.system?.[costField]) || 0
|
||||
const currentAether = Number(this.system.aetherPoints?.value) || 0
|
||||
if (cost > currentAether) {
|
||||
ui.notifications.warn(`${this.name} cannot cast ${rollTarget.name}: insufficient Aether (needs ${cost}, has ${currentAether}).`)
|
||||
return
|
||||
}
|
||||
}
|
||||
if (rollType === "miracle-attack" || rollType === "miracle-power") {
|
||||
const cost = Number(rollTarget.system?.level) || 0
|
||||
const currentGrace = Number(this.system.divinityPoints?.value) || 0
|
||||
if (cost > currentGrace) {
|
||||
ui.notifications.warn(`${this.name} cannot invoke ${rollTarget.name}: insufficient Grace (needs ${cost}, has ${currentGrace}).`)
|
||||
return
|
||||
}
|
||||
}
|
||||
break
|
||||
case "shield-roll": {
|
||||
rollTarget = this.items.find((i) => i.type === "shield" && i.id === rollKey)
|
||||
let shieldSkill = this.items.find((i) => i.type === "skill" && i.name.toLowerCase() === rollTarget.name.toLowerCase())
|
||||
rollTarget.skill = shieldSkill
|
||||
rollTarget.rollKey = rollKey
|
||||
}
|
||||
rollTarget = this.items.find((i) => i.type === "shield" && i.id === rollKey)
|
||||
let shieldSkill = this.items.find((i) => i.type === "skill" && i.name.toLowerCase() === rollTarget.name.toLowerCase())
|
||||
rollTarget.skill = shieldSkill
|
||||
rollTarget.rollKey = rollKey
|
||||
}
|
||||
break;
|
||||
case "weapon-damage-small":
|
||||
case "weapon-damage-medium":
|
||||
case "weapon-damage":
|
||||
case "weapon-attack":
|
||||
case "weapon-defense": {
|
||||
let weapon = this.items.find((i) => i.type === "weapon" && i.id === rollKey)
|
||||
let skill
|
||||
let skills = this.items.filter((i) => i.type === "skill" && i.name.toLowerCase() === weapon.name.toLowerCase())
|
||||
let weapon = this.items.find((i) => i.type === "weapon" && i.id === rollKey)
|
||||
let skill
|
||||
let skills = this.items.filter((i) => i.type === "skill" && i.system.category === "weapon" && i.name.toLowerCase() === weapon.name.toLowerCase())
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 1.0)
|
||||
} else {
|
||||
skills = this.fuzzyNameSearchWeaponSkills(weapon.name, weapon.system.weaponClass)
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 1.0)
|
||||
} else {
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.name.toLowerCase().replace(" skill", "") === weapon.name.toLowerCase())
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.system.category === "weapon" && i.system.weaponClass === weapon.system.weaponClass)
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 1.0)
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 0.5)
|
||||
} else {
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.system.weaponClass === weapon.system.weaponClass)
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.system.category === "weapon" && i.system.weaponClass.includes(SYSTEM.WEAPON_CATEGORIES[weapon.system.weaponClass]))
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 0.5)
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 0.25)
|
||||
} else {
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.system.weaponClass.includes(SYSTEM.WEAPON_CATEGORIES[weapon.system.weaponClass]))
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 0.25)
|
||||
} else {
|
||||
ui.notifications.warn(game.i18n.localize("LETHALFANTASY.Notifications.skillNotFound"))
|
||||
return
|
||||
}
|
||||
ui.notifications.warn(game.i18n.localize("LETHALFANTASY.Notifications.skillNotFound"))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!weapon || !skill) {
|
||||
console.error("Weapon or skill not found", weapon, skill)
|
||||
ui.notifications.warn(game.i18n.localize("LETHALFANTASY.Notifications.skillNotFound"))
|
||||
return
|
||||
}
|
||||
rollTarget = skill
|
||||
rollTarget.weapon = weapon
|
||||
rollTarget.weaponSkillModifier = skill.weaponSkillModifier
|
||||
rollTarget.rollKey = rollKey
|
||||
rollTarget.combat = foundry.utils.duplicate(this.system.combat)
|
||||
if ( rollType === "weapon-damage-small" || rollType === "weapon-damage-medium") {
|
||||
rollTarget.grantedDice = this.system.granted.damageDice
|
||||
}
|
||||
if ( rollType === "weapon-attack") {
|
||||
rollTarget.grantedDice = this.system.granted.attackDice
|
||||
}
|
||||
if ( rollType === "weapon-defense") {
|
||||
rollTarget.grantedDice = this.system.granted.defenseDice
|
||||
}
|
||||
}
|
||||
if (!weapon || !skill) {
|
||||
console.error("Weapon or skill not found", weapon, skill)
|
||||
ui.notifications.warn(game.i18n.localize("LETHALFANTASY.Notifications.skillNotFound"))
|
||||
return
|
||||
}
|
||||
// Créer un objet plain au lieu de modifier directement le skill
|
||||
rollTarget = {
|
||||
...skill,
|
||||
weapon: weapon,
|
||||
weaponSkillModifier: skill.weaponSkillModifier,
|
||||
rollKey: rollKey,
|
||||
combat: foundry.utils.duplicate(this.system.combat),
|
||||
isRangedAttack: weapon.system.weaponType === "ranged"
|
||||
}
|
||||
if (rollType === "weapon-damage") {
|
||||
rollTarget.grantedDice = this.system.granted.damageDice
|
||||
}
|
||||
if (rollType === "weapon-attack") {
|
||||
rollTarget.grantedDice = this.system.granted.attackDice
|
||||
}
|
||||
if (rollType === "weapon-defense") {
|
||||
rollTarget.armorDefense = this.getArmorDefenseValue()
|
||||
rollTarget.grantedDice = this.system.granted.defenseDice
|
||||
// Check if this is a ranged defense
|
||||
rollTarget.isRangedDefense = game.lethalFantasy?.nextDefenseData?.isRanged ?? false
|
||||
}
|
||||
}
|
||||
break
|
||||
default:
|
||||
ui.notifications.error(game.i18n.localize("LETHALFANTASY.Notifications.rollTypeNotFound") + String(rollType))
|
||||
break
|
||||
return
|
||||
}
|
||||
|
||||
// In all cases
|
||||
rollTarget.magicUser = this.system.biodata.magicUser
|
||||
rollTarget.actorModifiers = foundry.utils.duplicate(this.system.modifiers)
|
||||
rollTarget.actorLevel = this.system.biodata.level
|
||||
await this.system.roll(rollType, rollTarget)
|
||||
await this.system.roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr, d30Effects)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class LethalFantasyChatMessage extends ChatMessage {
|
||||
messageData.isWhisper = false
|
||||
messageData.alias = this.user.name
|
||||
}
|
||||
data.content = `<section class="dice-rolls">${rollHTML}</section>`
|
||||
data.content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/dice-rolls.hbs", {rollHTML})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
import { log } from "../utils.mjs"
|
||||
|
||||
/**
|
||||
* Classe pour gérer les résultats du D30 dans Lethal Fantasy
|
||||
*/
|
||||
export default class D30Roll {
|
||||
/**
|
||||
* Table des résultats D30 chargée depuis le fichier JSON
|
||||
* @type {Object}
|
||||
*/
|
||||
static resultsTable = null
|
||||
|
||||
/**
|
||||
* Définitions des conditions spéciales
|
||||
* @type {Object}
|
||||
*/
|
||||
static definitions = null
|
||||
|
||||
/**
|
||||
* Types de jets supportés
|
||||
* @type {Object}
|
||||
*/
|
||||
static ROLL_TYPES = {
|
||||
MELEE_ATTACK: "melee_attack",
|
||||
RANGED_ATTACK: "ranged_attack",
|
||||
MELEE_DEFENSE: "melee_defense",
|
||||
RANGED_DEFENSE: "ranged_defense",
|
||||
ARCANE_SPELL_ATTACK: "arcane_spell_attack",
|
||||
ARCANE_SPELL_DEFENSE: "arcane_spell_defense",
|
||||
SKILL_ROLLS: "skill_rolls"
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise la classe en chargeant la table des résultats
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
static async initialize() {
|
||||
try {
|
||||
const response = await fetch("systems/fvtt-lethal-fantasy/module/config/d30_results_tables.json")
|
||||
const data = await response.json()
|
||||
|
||||
this.resultsTable = data.d30_dice_results
|
||||
this.definitions = data.definitions
|
||||
|
||||
log("D30Roll | D30 results table loaded successfully")
|
||||
} catch (error) {
|
||||
console.error("D30Roll | Error loading D30 table:", error)
|
||||
ui.notifications.error("Unable to load D30 results table")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère le résultat d'un jet de D30 sous forme d'objet structuré.
|
||||
* @param {number} diceValue La valeur du dé (1-30)
|
||||
* @param {string} rollType Le type de jet externe (ex: "weapon-attack", "spell-attack", etc.)
|
||||
* @param {Object} weapon L'arme ou l'objet utilisé (optionnel, nécessaire pour certains types)
|
||||
* @param {Object} options Options supplémentaires (optionnel)
|
||||
* @param {boolean} options.isRanged Si true, utilise ranged_defense au lieu de melee_defense
|
||||
* @returns {Object|null} L'objet effet `{ type, description, ...fields }` ou null si aucun effet
|
||||
*/
|
||||
static getResult(diceValue, rollType, weapon = null, options = {}) {
|
||||
if (!this.resultsTable) {
|
||||
console.warn("D30Roll | Results table is not initialized. Call D30Roll.initialize() first.")
|
||||
return null
|
||||
}
|
||||
|
||||
if (diceValue < 1 || diceValue > 30) {
|
||||
console.warn(`D30Roll | Invalid dice value: ${diceValue}. Must be between 1 and 30.`)
|
||||
return null
|
||||
}
|
||||
|
||||
const internalType = this.convertToInternalType(rollType, weapon, options)
|
||||
|
||||
if (!internalType) {
|
||||
console.warn(`D30Roll | Could not convert roll type: ${rollType}`)
|
||||
return null
|
||||
}
|
||||
|
||||
if (!Object.values(this.ROLL_TYPES).includes(internalType)) {
|
||||
console.warn(`D30Roll | Invalid internal roll type: ${internalType}`)
|
||||
return null
|
||||
}
|
||||
|
||||
const resultEntry = this.resultsTable[diceValue]
|
||||
if (!resultEntry) {
|
||||
console.warn(`D30Roll | No entry found for value ${diceValue}`)
|
||||
return null
|
||||
}
|
||||
|
||||
const result = resultEntry[internalType]
|
||||
return result ?? null
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le type d'effet d'un résultat D30.
|
||||
* @param {Object|null} result L'objet retourné par getResult()
|
||||
* @returns {string|null} Le type d'effet ou null
|
||||
*/
|
||||
static getEffectType(result) {
|
||||
return result?.type ?? null
|
||||
}
|
||||
|
||||
/**
|
||||
* Convertit un rollType externe en rollType interne
|
||||
* @param {string} externalType Le type de jet externe (ex: "weapon-attack")
|
||||
* @param {Object} weapon L'arme ou l'objet utilisé (optionnel)
|
||||
* @param {Object} options Options supplémentaires (optionnel)
|
||||
* @param {boolean} options.isRanged Si true, utilise ranged_defense au lieu de melee_defense
|
||||
* @returns {string|null} Le type interne correspondant ou null
|
||||
*/
|
||||
static convertToInternalType(externalType, weapon = null, options = {}) {
|
||||
// Attack types - need weapon to determine if melee or ranged
|
||||
if (externalType === "weapon-attack") {
|
||||
if (!weapon) {
|
||||
console.warn("D30Roll | Weapon object required for weapon-attack type")
|
||||
// Fall through to use options.isRanged if available, otherwise default melee
|
||||
}
|
||||
return (options.isRanged || weapon?.system?.weaponType === "ranged")
|
||||
? this.ROLL_TYPES.RANGED_ATTACK
|
||||
: this.ROLL_TYPES.MELEE_ATTACK
|
||||
}
|
||||
|
||||
// Monster attacks - check options.isRanged (set from rollTarget.attackMode) or weapon type
|
||||
if (externalType === "monster-attack") {
|
||||
if (options.isRanged || weapon?.system?.weaponType === "ranged") {
|
||||
return this.ROLL_TYPES.RANGED_ATTACK
|
||||
}
|
||||
return this.ROLL_TYPES.MELEE_ATTACK
|
||||
}
|
||||
|
||||
// Defense types
|
||||
if (externalType === "weapon-defense" || externalType === "monster-defense") {
|
||||
return options.isRanged ? this.ROLL_TYPES.RANGED_DEFENSE : this.ROLL_TYPES.MELEE_DEFENSE
|
||||
}
|
||||
|
||||
// Spell/Miracle types
|
||||
if (externalType === "spell-attack" || externalType === "spell" || externalType === "spell-power"
|
||||
|| externalType === "miracle-attack" || externalType === "miracle" || externalType === "miracle-power") {
|
||||
return this.ROLL_TYPES.ARCANE_SPELL_ATTACK
|
||||
}
|
||||
|
||||
// Skill types
|
||||
if (externalType === "skill" || externalType === "monster-skill" || externalType === "challenge") {
|
||||
return this.ROLL_TYPES.SKILL_ROLLS
|
||||
}
|
||||
|
||||
// Saving throw types
|
||||
if (externalType === "save") {
|
||||
return this.ROLL_TYPES.ARCANE_SPELL_DEFENSE
|
||||
}
|
||||
|
||||
// If no match, return null
|
||||
console.warn(`D30Roll | Unknown external roll type: ${externalType}`)
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère toutes les informations pour une valeur de dé donnée
|
||||
* @param {number} diceValue La valeur du dé (1-30)
|
||||
* @returns {Object|null} Tous les résultats pour cette valeur ou null
|
||||
*/
|
||||
static getAllResultsForValue(diceValue) {
|
||||
if (!this.resultsTable) {
|
||||
console.warn("D30Roll | Results table is not initialized.")
|
||||
return null
|
||||
}
|
||||
|
||||
if (diceValue < 1 || diceValue > 30) {
|
||||
console.warn(`D30Roll | Invalid dice value: ${diceValue}`)
|
||||
return null
|
||||
}
|
||||
|
||||
return this.resultsTable[diceValue]
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère la définition d'une condition spéciale
|
||||
* @param {string} definitionKey La clé de la définition (ex: "flash_of_pain")
|
||||
* @returns {string|null} La définition ou null
|
||||
*/
|
||||
static getDefinition(definitionKey) {
|
||||
if (!this.definitions) {
|
||||
console.warn("D30Roll | Definitions are not initialized.")
|
||||
return null
|
||||
}
|
||||
|
||||
return this.definitions[definitionKey] || null
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si un résultat est vide
|
||||
* @param {Object|null} result Le résultat à vérifier
|
||||
* @returns {boolean} True si le résultat est vide
|
||||
*/
|
||||
static isEmptyResult(result) {
|
||||
return !result || !result.type
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère un résultat formaté pour l'affichage
|
||||
* @param {number} diceValue La valeur du dé (1-30)
|
||||
* @param {string} rollType Le type de jet externe
|
||||
* @param {Object} weapon L'arme ou l'objet utilisé (optionnel)
|
||||
* @param {Object} options Options supplémentaires (optionnel)
|
||||
* @returns {Object} Un objet avec le résultat et des informations de formatage
|
||||
*/
|
||||
static getFormattedResult(diceValue, rollType, weapon = null, options = {}) {
|
||||
const result = this.getResult(diceValue, rollType, weapon, options)
|
||||
const internalType = this.convertToInternalType(rollType, weapon, options)
|
||||
|
||||
return {
|
||||
value: diceValue,
|
||||
rollType: rollType,
|
||||
internalType: internalType,
|
||||
result: result,
|
||||
isEmpty: this.isEmptyResult(result),
|
||||
hasResult: !this.isEmptyResult(result)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si la table est chargée
|
||||
* @returns {boolean} True si la table est chargée
|
||||
*/
|
||||
static isInitialized() {
|
||||
return this.resultsTable !== null && this.definitions !== null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
import { prompt } from "./roll-prompt.mjs"
|
||||
import { promptInitiative, promptCombatAction, promptRangedDefense, promptRangedAttack } from "./roll-combat.mjs"
|
||||
import { rollSpellDamageToMessage } from "./roll-damage.mjs"
|
||||
|
||||
export default class LethalFantasyRoll extends Roll {
|
||||
/**
|
||||
* The HTML template path used to render dice checks of this type
|
||||
* @type {string}
|
||||
*/
|
||||
static CHAT_TEMPLATE = "systems/fvtt-lethal-fantasy/templates/chat-message.hbs"
|
||||
|
||||
get type() {
|
||||
return this.options.type
|
||||
}
|
||||
|
||||
get titleFormula() {
|
||||
return this.options.titleFormula
|
||||
}
|
||||
|
||||
get rollName() {
|
||||
return this.options.rollName
|
||||
}
|
||||
|
||||
get target() {
|
||||
return this.options.target
|
||||
}
|
||||
|
||||
get value() {
|
||||
return this.options.value
|
||||
}
|
||||
|
||||
get treshold() {
|
||||
return this.options.treshold
|
||||
}
|
||||
|
||||
get actorId() {
|
||||
return this.options.actorId
|
||||
}
|
||||
|
||||
get actorName() {
|
||||
return this.options.actorName
|
||||
}
|
||||
|
||||
get actorImage() {
|
||||
return this.options.actorImage
|
||||
}
|
||||
|
||||
get modifier() {
|
||||
return this.options.modifier
|
||||
}
|
||||
|
||||
get resultType() {
|
||||
return this.options.resultType
|
||||
}
|
||||
|
||||
get isFailure() {
|
||||
return this.resultType === "failure"
|
||||
}
|
||||
|
||||
get hasTarget() {
|
||||
return this.options.hasTarget
|
||||
}
|
||||
|
||||
get targetName() {
|
||||
return this.options.targetName
|
||||
}
|
||||
|
||||
get targetArmor() {
|
||||
return this.options.targetArmor
|
||||
}
|
||||
|
||||
get targetMalus() {
|
||||
return this.options.targetMalus
|
||||
}
|
||||
|
||||
get realDamage() {
|
||||
return this.options.realDamage
|
||||
}
|
||||
|
||||
get rollTotal() {
|
||||
return this.options.rollTotal
|
||||
}
|
||||
|
||||
get diceResults() {
|
||||
return this.options.diceResults
|
||||
}
|
||||
|
||||
get rollTarget() {
|
||||
return this.options.rollTarget
|
||||
}
|
||||
|
||||
get D30result() {
|
||||
return this.options.D30result
|
||||
}
|
||||
|
||||
get D30message() {
|
||||
return this.options.D30message
|
||||
}
|
||||
|
||||
get badResult() {
|
||||
return this.options.badResult
|
||||
}
|
||||
|
||||
get rollData() {
|
||||
return this.options.rollData
|
||||
}
|
||||
|
||||
get defenderId() {
|
||||
return this.options.defenderId
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a title based on the given type.
|
||||
*
|
||||
* @param {string} type The type of the roll.
|
||||
* @param {string} target The target of the roll.
|
||||
* @returns {string} The generated title.
|
||||
*/
|
||||
static createTitle(type, target) {
|
||||
switch (type) {
|
||||
case "challenge":
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.titleChallenge")}`
|
||||
case "save":
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.titleSave")}`
|
||||
case "monster-skill":
|
||||
case "skill":
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.titleSkill")}`
|
||||
case "weapon-attack":
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-attack")}`
|
||||
case "weapon-defense":
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-defense")}`
|
||||
case "weapon-damage":
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-damage")}`
|
||||
case "spell":
|
||||
case "spell-attack":
|
||||
case "spell-power":
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.spell")}`
|
||||
case "miracle":
|
||||
case "miracle-attack":
|
||||
case "miracle-power":
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.miracle")}`
|
||||
default:
|
||||
return game.i18n.localize("LETHALFANTASY.Label.titleStandard")
|
||||
}
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async render(chatOptions = {}) {
|
||||
let chatData = await this._getChatCardData(chatOptions.isPrivate)
|
||||
log("ChatData", chatData)
|
||||
return await foundry.applications.handlebars.renderTemplate(this.constructor.CHAT_TEMPLATE, chatData)
|
||||
}
|
||||
|
||||
/*
|
||||
* Generates the data required for rendering a roll chat card.
|
||||
*/
|
||||
async _getChatCardData(isPrivate) {
|
||||
// Générer la liste des combatants de la scène
|
||||
let combatants = []
|
||||
let isAttack = this.type === "weapon-attack" || this.type === "monster-attack" || this.type === "spell-attack" || this.type === "miracle-attack"
|
||||
if (this.rollData?.isDamage || isAttack) {
|
||||
// D'abord, ajouter les combattants du combat actif
|
||||
if (game?.combat?.combatants) {
|
||||
for (let c of game.combat.combatants) {
|
||||
if (c.actorId !== this.actorId) {
|
||||
combatants.push({ id: c.id, name: c.name, tokenId: c.token.id })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensuite, ajouter tous les tokens de la scène active qui ne sont pas déjà dans la liste
|
||||
if (canvas?.scene?.tokens) {
|
||||
const existingTokenIds = new Set(combatants.map(c => c.tokenId))
|
||||
for (let token of canvas.scene.tokens) {
|
||||
if (token.actorId !== this.actorId && !existingTokenIds.has(token.id)) {
|
||||
combatants.push({
|
||||
id: token.id,
|
||||
name: token.name,
|
||||
tokenId: token.id
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Récupérer les informations de l'arme pour les attaques réussies
|
||||
let weaponDamageOptions = null
|
||||
log("Roll type:", this.type, "rollTarget:", this.rollTarget, "Has weapon:", !!this.rollTarget?.weapon)
|
||||
if (this.type === "weapon-attack" && this.rollTarget?.weapon) {
|
||||
const weapon = this.rollTarget.weapon
|
||||
weaponDamageOptions = {
|
||||
weaponId: weapon._id || weapon.id,
|
||||
weaponName: weapon.name,
|
||||
damageM: weapon.system?.damage?.damageM
|
||||
}
|
||||
log("Weapon damage options:", weaponDamageOptions)
|
||||
} else if (this.type === "monster-attack" && this.rollTarget) {
|
||||
weaponDamageOptions = {
|
||||
weaponId: this.rollTarget.rollKey,
|
||||
weaponName: this.rollTarget.name,
|
||||
damageFormula: this.rollTarget.damageDice,
|
||||
damageModifier: this.rollTarget.damageModifier,
|
||||
isMonster: true
|
||||
}
|
||||
log("Monster damage options:", weaponDamageOptions)
|
||||
}
|
||||
|
||||
const cardData = {
|
||||
css: [SYSTEM.id, "dice-roll"],
|
||||
data: this.data,
|
||||
diceTotal: this.dice.reduce((t, d) => t + d.total, 0),
|
||||
isGM: game.user.isGM,
|
||||
formula: this.formula,
|
||||
titleFormula: this.titleFormula,
|
||||
rollName: this.rollName,
|
||||
rollType: this.type,
|
||||
rollTarget: this.rollTarget,
|
||||
total: this.rollTotal,
|
||||
isFailure: this.isFailure,
|
||||
actorId: this.actorId,
|
||||
diceResults: this.diceResults,
|
||||
actingCharName: this.actorName,
|
||||
actingCharImg: this.actorImage,
|
||||
resultType: this.resultType,
|
||||
hasTarget: this.hasTarget,
|
||||
targetName: this.targetName,
|
||||
targetArmor: this.targetArmor,
|
||||
D30result: this.D30result,
|
||||
D30message: this.D30message,
|
||||
badResult: this.badResult,
|
||||
rollData: this.rollData,
|
||||
isPrivate: isPrivate,
|
||||
combatants: combatants,
|
||||
weaponDamageOptions: weaponDamageOptions,
|
||||
isAttack: isAttack,
|
||||
defenderId: this.defenderId,
|
||||
// Vérifier si l'utilisateur peut sélectionner une cible (est GM ou possède l'acteur)
|
||||
canSelectTarget: game.user.isGM || game.actors.get(this.actorId)?.testUserPermission(game.user, "OWNER")
|
||||
}
|
||||
cardData.cssClass = cardData.css.join(" ")
|
||||
cardData.tooltip = isPrivate ? "" : await this.getTooltip()
|
||||
return cardData
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the roll result to a chat message.
|
||||
*
|
||||
* @param {Object} [messageData={}] Additional data to include in the message.
|
||||
* @param {Object} options Options for message creation.
|
||||
* @param {string} options.messageMode The mode of the roll (e.g., public, private).
|
||||
* @param {boolean} [options.create=true] Whether to create the message.
|
||||
* @returns {Promise} - A promise that resolves when the message is created.
|
||||
*/
|
||||
async toMessage(messageData = {}, { messageMode, create = true } = {}) {
|
||||
return await super.toMessage(
|
||||
{
|
||||
isSave: this.isSave,
|
||||
isChallenge: this.isChallenge,
|
||||
isFailure: this.resultType === "failure",
|
||||
rollType: this.type,
|
||||
rollTarget: this.rollTarget,
|
||||
actingCharName: this.actorName,
|
||||
actingCharImg: this.actorImage,
|
||||
hasTarget: this.hasTarget,
|
||||
targetName: this.targetName,
|
||||
targetArmor: this.targetArmor,
|
||||
targetMalus: this.targetMalus,
|
||||
realDamage: this.realDamage,
|
||||
rollData: this.rollData,
|
||||
...messageData,
|
||||
},
|
||||
{ messageMode, create },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Attach imported prompt methods
|
||||
LethalFantasyRoll.prompt = prompt
|
||||
LethalFantasyRoll.promptInitiative = promptInitiative
|
||||
LethalFantasyRoll.promptCombatAction = promptCombatAction
|
||||
LethalFantasyRoll.promptRangedDefense = promptRangedDefense
|
||||
LethalFantasyRoll.promptRangedAttack = promptRangedAttack
|
||||
LethalFantasyRoll.rollSpellDamageToMessage = rollSpellDamageToMessage
|
||||
@@ -0,0 +1,714 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
import D30Roll from "./d30-roll.mjs"
|
||||
import LethalFantasyUtils from "../utils.mjs"
|
||||
|
||||
/* ***********************************************************/
|
||||
export async function promptInitiative(options = {}) {
|
||||
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
|
||||
const fieldRollMode = new foundry.data.fields.StringField({
|
||||
choices: rollModes,
|
||||
blank: false,
|
||||
default: "public",
|
||||
})
|
||||
|
||||
if (SYSTEM.INITIATIVE_DICE_CHOICES_PER_CLASS[options.actorClass]) {
|
||||
options.initiativeDiceChoice = SYSTEM.INITIATIVE_DICE_CHOICES_PER_CLASS[options.actorClass]
|
||||
} else {
|
||||
options.initiativeDiceChoice = SYSTEM.INITIATIVE_DICE_CHOICES_PER_CLASS["untrained"]
|
||||
}
|
||||
|
||||
let dialogContext = {
|
||||
actorClass: options.actorClass,
|
||||
initiativeDiceChoice: options.initiativeDiceChoice,
|
||||
initiativeDice: "1D20",
|
||||
maxInit: options.maxInit,
|
||||
fieldRollMode,
|
||||
rollModes
|
||||
}
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/roll-initiative-dialog.hbs", dialogContext)
|
||||
|
||||
const label = game.i18n.localize("LETHALFANTASY.Label.initiative")
|
||||
const rollContext = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Initiative Roll" },
|
||||
classes: ["lethalfantasy"],
|
||||
content,
|
||||
buttons: [
|
||||
{
|
||||
action: "initiative",
|
||||
type: "button",
|
||||
label: label,
|
||||
callback: (event, button) => {
|
||||
const output = Array.from(button.form.elements).reduce((obj, input) => {
|
||||
if (input.name) obj[input.name] = input.value
|
||||
return obj
|
||||
}, {})
|
||||
return output
|
||||
},
|
||||
},
|
||||
],
|
||||
rejectClose: false // Click on Close button will not launch an error
|
||||
})
|
||||
|
||||
if (!rollContext) return
|
||||
|
||||
// When the value is a plain number (e.g. "1" for Declared Ready on Alert), wrapping it in
|
||||
// min(1, maxInit) produces a dice-less formula that FoundryVTT cannot evaluate to a valid
|
||||
// total. Use the constant directly; min() is only needed for actual dice expressions.
|
||||
const isDiceFormula = /[dD]/.test(rollContext.initiativeDice)
|
||||
const formula = isDiceFormula ? `min(${rollContext.initiativeDice}, ${options.maxInit})` : rollContext.initiativeDice
|
||||
|
||||
let initRoll = new Roll(formula, options.data)
|
||||
await initRoll.evaluate()
|
||||
let msg = await initRoll.toMessage({ flavor: `Initiative for ${options.actorName}` }, { messageMode: rollContext.visibility })
|
||||
if (game?.dice3d && initRoll.dice?.length) {
|
||||
await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
|
||||
}
|
||||
|
||||
if (options.combatId && options.combatantId) {
|
||||
let combat = game.combats.get(options.combatId)
|
||||
await combat.updateEmbeddedDocuments("Combatant", [{ _id: options.combatantId, initiative: initRoll.total, 'system.progressionCount': 0, [`flags.${SYSTEM.id}.firstActionTaken`]: false }])
|
||||
}
|
||||
}
|
||||
|
||||
/* ***********************************************************/
|
||||
export async function promptCombatAction(options = {}) {
|
||||
|
||||
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
|
||||
const fieldRollMode = new foundry.data.fields.StringField({
|
||||
choices: rollModes,
|
||||
blank: false,
|
||||
default: "public",
|
||||
})
|
||||
|
||||
let combatant = game.combats.get(options.combatId)?.combatants?.get(options.combatantId)
|
||||
if (!combatant) {
|
||||
console.error("No combatant found for this combat")
|
||||
return
|
||||
}
|
||||
let currentAction = combatant.getFlag(SYSTEM.id, "currentAction")
|
||||
|
||||
let position = game.user.getFlag(SYSTEM.id, "combat-action-dialog-pos") || { top: -1, left: -1 }
|
||||
|
||||
let dialogContext = {
|
||||
progressionDiceId: "",
|
||||
fieldRollMode,
|
||||
rollModes,
|
||||
currentAction,
|
||||
...options
|
||||
}
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/combat-action-dialog.hbs", dialogContext)
|
||||
|
||||
let buttons = []
|
||||
if (currentAction) {
|
||||
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({
|
||||
action: "roll",
|
||||
type: "button",
|
||||
label: weaponLabel,
|
||||
callback: (event, button) => {
|
||||
let pos = $('#combat-action-dialog').position()
|
||||
game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", pos)
|
||||
return "rollProgressionDice"
|
||||
},
|
||||
})
|
||||
} else if (currentAction.type === "spell" || currentAction.type === "miracle") {
|
||||
let label = ""
|
||||
if (currentAction.spellStatus === "castingTime") {
|
||||
let pos = $('#combat-action-dialog').position()
|
||||
game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", pos)
|
||||
label = "Wait casting time"
|
||||
}
|
||||
if (currentAction.spellStatus === "toBeCasted") {
|
||||
let pos = $('#combat-action-dialog').position()
|
||||
game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", pos)
|
||||
label = "Cast spell/miracle"
|
||||
}
|
||||
if (currentAction.spellStatus === "lethargy") {
|
||||
let pos = $('#combat-action-dialog').position()
|
||||
game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", pos)
|
||||
label = "Roll lethargy dice"
|
||||
}
|
||||
buttons.push({
|
||||
action: "roll",
|
||||
type: "button",
|
||||
label: label,
|
||||
callback: (event, button) => {
|
||||
let pos = $('#combat-action-dialog').position()
|
||||
game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", foundry.utils.duplicate(pos))
|
||||
return "rollLethargyDice"
|
||||
},
|
||||
})
|
||||
}
|
||||
} else {
|
||||
buttons.push({
|
||||
action: "roll",
|
||||
type: "button",
|
||||
label: "Select action",
|
||||
callback: (event, button) => {
|
||||
let pos = $('#combat-action-dialog').position()
|
||||
game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", foundry.utils.duplicate(pos))
|
||||
const output = Array.from(button.form.elements).reduce((obj, input) => {
|
||||
if (input.name) obj[input.name] = input.value
|
||||
return obj
|
||||
}, {})
|
||||
return output
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
buttons.push({
|
||||
action: "cancel",
|
||||
type: "button",
|
||||
label: "Other action, not listed here",
|
||||
callback: (event, button) => {
|
||||
let pos = $('#combat-action-dialog').position()
|
||||
game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", foundry.utils.duplicate(pos))
|
||||
return null;
|
||||
}
|
||||
})
|
||||
|
||||
let rollContext = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Combat Action Dialog" },
|
||||
id: "combat-action-dialog",
|
||||
classes: ["lethalfantasy"],
|
||||
position,
|
||||
content,
|
||||
buttons,
|
||||
rejectClose: false // Click on Close button will not launch an error
|
||||
})
|
||||
|
||||
log("RollContext", dialogContext, rollContext)
|
||||
// If action is cancelled, exit
|
||||
if (rollContext === null || rollContext === "cancel") {
|
||||
await combatant.setFlag(SYSTEM.id, "currentAction", "")
|
||||
let message = `${combatant.name} : Other action, progression reset`
|
||||
await ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
|
||||
return
|
||||
}
|
||||
|
||||
// Setup the current action
|
||||
if (!currentAction || currentAction === "") {
|
||||
// Get the item from the returned selectedChoice value
|
||||
let selectedChoice = rollContext.selectedChoice
|
||||
let rangedMode
|
||||
if (selectedChoice.match("simpleAim")) {
|
||||
selectedChoice = selectedChoice.replace("simpleAim", "")
|
||||
rangedMode = "simpleAim"
|
||||
}
|
||||
if (selectedChoice.match("carefulAim")) {
|
||||
selectedChoice = selectedChoice.replace("carefulAim", "")
|
||||
rangedMode = "carefulAim"
|
||||
}
|
||||
if (selectedChoice.match("focusedAim")) {
|
||||
selectedChoice = selectedChoice.replace("focusedAim", "")
|
||||
rangedMode = "focusedAim"
|
||||
}
|
||||
let selectedItem = combatant.actor.items.find(i => i.id === selectedChoice)
|
||||
// Setup flag for combat action usage
|
||||
let actionItem = foundry.utils.duplicate(selectedItem)
|
||||
// First action of this combat: use the class-based starting threshold;
|
||||
// all subsequent actions reset to 1 (normal progression).
|
||||
const firstActionTaken = combatant.getFlag(SYSTEM.id, "firstActionTaken")
|
||||
actionItem.progressionCount = firstActionTaken ? 1 : (combatant.actor.system.combat?.combatProgressionStart ?? 1)
|
||||
if (!firstActionTaken) await combatant.setFlag(SYSTEM.id, "firstActionTaken", true)
|
||||
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: await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/dialogs/damage-tier.hbs", {itemName: selectedItem.name}),
|
||||
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.spellStatus = "castingTime"
|
||||
// Set the flag on the combatant
|
||||
await combatant.setFlag(SYSTEM.id, "currentAction", actionItem)
|
||||
let message = `${combatant.name} action : ${selectedItem.name}, start rolling progression dice or casting time`
|
||||
await ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
|
||||
rollContext = (actionItem.type === "weapon") ? "rollProgressionDice" : "rollLethargyDice" // Set the roll context to rollProgressionDice
|
||||
currentAction = actionItem
|
||||
}
|
||||
|
||||
if (currentAction) {
|
||||
if (rollContext === "rollLethargyDice") {
|
||||
if (currentAction.spellStatus === "castingTime") {
|
||||
let time = currentAction.type === "spell" ? currentAction.system.castingTime : currentAction.system.prayerTime
|
||||
if (currentAction.castingTime < time) {
|
||||
let message = `Casting time : ${currentAction.name}, count : ${currentAction.castingTime}/${time}`
|
||||
await ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
|
||||
currentAction.castingTime += 1
|
||||
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
|
||||
return
|
||||
} else {
|
||||
// Last counting second — announce ready and transition immediately (no extra second consumed)
|
||||
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.spellStatus = "toBeCasted"
|
||||
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
|
||||
return
|
||||
}
|
||||
}
|
||||
if (currentAction.spellStatus === "toBeCasted") {
|
||||
combatant.actor.prepareRoll((currentAction.type === "spell") ? "spell-attack" : "miracle-attack", currentAction._id)
|
||||
if (currentAction.type === "spell") {
|
||||
currentAction.spellStatus = "lethargy"
|
||||
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
|
||||
} else {
|
||||
// No lethargy for miracle
|
||||
await combatant.setFlag(SYSTEM.id, "currentAction", "")
|
||||
}
|
||||
return
|
||||
}
|
||||
if (currentAction.spellStatus === "lethargy") {
|
||||
// Roll lethargy dice
|
||||
let dice = LethalFantasyUtils.getLethargyDice(currentAction.system.level)
|
||||
let roll = new Roll(dice)
|
||||
await roll.evaluate()
|
||||
if (game?.dice3d) {
|
||||
await game.dice3d.showForRoll(roll)
|
||||
}
|
||||
let max = roll.dice[0].faces - 1
|
||||
let toCompare = Math.min(currentAction.progressionCount, max)
|
||||
if (roll.total <= toCompare) {
|
||||
// Notify that the player can act now with a chat message
|
||||
const messageContent = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-lethal-fantasy/templates/progression-message.hbs",
|
||||
{
|
||||
success: true,
|
||||
actorName: combatant.actor.name,
|
||||
weaponName: currentAction.name,
|
||||
rollResult: roll.total,
|
||||
isLethargy: true
|
||||
}
|
||||
)
|
||||
await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
|
||||
// Update the combatant progression count
|
||||
await combatant.setFlag(SYSTEM.id, "currentAction", "")
|
||||
// Display the action selection window again
|
||||
combatant.actor.system.rollProgressionDice(options.combatId, options.combatantId)
|
||||
} else {
|
||||
// Notify that the player cannot act now with a chat message
|
||||
currentAction.progressionCount += 1
|
||||
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
|
||||
const messageContent = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-lethal-fantasy/templates/progression-message.hbs",
|
||||
{
|
||||
success: false,
|
||||
actorName: combatant.actor.name,
|
||||
weaponName: currentAction.name,
|
||||
rollResult: roll.total,
|
||||
progressionCount: currentAction.progressionCount,
|
||||
isLethargy: true
|
||||
}
|
||||
)
|
||||
await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rollContext === "rollProgressionDice") {
|
||||
let formula = currentAction.system.combatProgressionDice
|
||||
if (currentAction?.rangedMode) {
|
||||
let toSplit = currentAction.system.speed[currentAction.rangedMode]
|
||||
let split = toSplit.split("+")
|
||||
currentAction.rangedLoad = Number(split[0]) || 0
|
||||
formula = split[1]
|
||||
log("Ranged Mode", currentAction.rangedMode, currentAction.rangedLoad, formula)
|
||||
}
|
||||
// Range weapon loading
|
||||
if (!currentAction.weaponLoaded && currentAction.rangedLoad) {
|
||||
if (currentAction.progressionCount < currentAction.rangedLoad) {
|
||||
let message = `Ranged weapon ${currentAction.name} is loading, loading count : ${currentAction.progressionCount}/${currentAction.rangedLoad}`
|
||||
await ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
|
||||
currentAction.progressionCount += 1
|
||||
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
|
||||
} else {
|
||||
let message = `Ranged weapon ${currentAction.name} is loaded !`
|
||||
await ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
|
||||
currentAction.weaponLoaded = true
|
||||
currentAction.progressionCount = 1
|
||||
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Melee mode
|
||||
let isMonster = combatant.actor.type === "monster"
|
||||
// Get the dice and roll it if
|
||||
let roll = new Roll(formula)
|
||||
await roll.evaluate()
|
||||
|
||||
let max = roll.dice[0].faces - 1
|
||||
max = Math.min(currentAction.progressionCount, max)
|
||||
let msg = await roll.toMessage({ flavor: `Progression Roll for ${currentAction.name}, progression count : ${currentAction.progressionCount}/${max}` }, { messageMode: rollContext.visibility })
|
||||
if (game?.dice3d) {
|
||||
await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
|
||||
}
|
||||
|
||||
if (roll.total <= max) {
|
||||
// Notify that the player can act now with a chat message
|
||||
const messageContent = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-lethal-fantasy/templates/progression-message.hbs",
|
||||
{
|
||||
success: true,
|
||||
actorName: combatant.actor.name,
|
||||
weaponName: currentAction.name,
|
||||
rollResult: roll.total
|
||||
}
|
||||
)
|
||||
await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
|
||||
await combatant.setFlag(SYSTEM.id, "currentAction", "")
|
||||
combatant.actor.prepareRoll(currentAction.type === "weapon" ? "weapon-attack" : "spell-attack", currentAction._id)
|
||||
} else {
|
||||
// Notify that the player cannot act now with a chat message
|
||||
currentAction.progressionCount += 1
|
||||
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
|
||||
const messageContent = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-lethal-fantasy/templates/progression-message.hbs",
|
||||
{
|
||||
success: false,
|
||||
actorName: combatant.actor.name,
|
||||
weaponName: currentAction.name,
|
||||
rollResult: roll.total,
|
||||
progressionCount: currentAction.progressionCount
|
||||
}
|
||||
)
|
||||
await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ***********************************************************/
|
||||
export async function promptRangedDefense(options = {}) {
|
||||
|
||||
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes);
|
||||
const fieldRollMode = new foundry.data.fields.StringField({
|
||||
choices: rollModes,
|
||||
blank: false,
|
||||
default: "public",
|
||||
})
|
||||
|
||||
let dialogContext = {
|
||||
movementChoices: SYSTEM.MOVEMENT_CHOICES,
|
||||
moveDirectionChoices: SYSTEM.MOVE_DIRECTION_CHOICES,
|
||||
sizeChoices: SYSTEM.SIZE_CHOICES,
|
||||
rangeChoices: SYSTEM.RANGE_CHOICES,
|
||||
attackerAimChoices: SYSTEM.ATTACKER_AIM_CHOICES,
|
||||
movement: "none",
|
||||
moveDirection: "none",
|
||||
size: "+5",
|
||||
range: "short",
|
||||
attackerAim: "simple",
|
||||
fieldRollMode,
|
||||
rollModes
|
||||
}
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/range-defense-dialog.hbs", dialogContext)
|
||||
|
||||
const label = game.i18n.localize("LETHALFANTASY.Label.rangeDefenseRoll")
|
||||
const rollContext = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Range Defense" },
|
||||
classes: ["lethalfantasy"],
|
||||
content,
|
||||
buttons: [
|
||||
{
|
||||
action: "rangeDefense",
|
||||
type: "button",
|
||||
label: label,
|
||||
callback: (event, button) => {
|
||||
const output = Array.from(button.form.elements).reduce((obj, input) => {
|
||||
if (input.name) obj[input.name] = input.value
|
||||
return obj
|
||||
}, {})
|
||||
return output
|
||||
},
|
||||
},
|
||||
],
|
||||
rejectClose: false // Click on Close button will not launch an error
|
||||
})
|
||||
|
||||
// If the user cancels the dialog, exit
|
||||
if (rollContext === null) return
|
||||
|
||||
log("RollContext", rollContext)
|
||||
// Add disfavor/favor option if point blank range
|
||||
if (rollContext.range === "pointblank") {
|
||||
rollContext.movement = rollContext.movement.replace("kh", "")
|
||||
rollContext.movement = rollContext.movement.replace("kl", "")
|
||||
rollContext.movement += "kl" // Add the kl to the movement (disfavor for point blank range)
|
||||
rollContext.range = "0"
|
||||
}
|
||||
if (rollContext.range === "beyondskill") {
|
||||
rollContext.movement = rollContext.movement.replace("kh", "")
|
||||
rollContext.movement = rollContext.movement.replace("kl", "")
|
||||
rollContext.movement += "kh" // Add the kl to the movement (favor for point blank range)
|
||||
rollContext.range = "+11"
|
||||
}
|
||||
|
||||
// Build the final modifier
|
||||
let fullModifier = Number(rollContext.moveDirection) +
|
||||
Number(rollContext.size) +
|
||||
Number(rollContext.range) +
|
||||
Number(rollContext?.attackerAim || 0)
|
||||
|
||||
let modifierFormula
|
||||
if (fullModifier === 0) {
|
||||
modifierFormula = "0"
|
||||
} else {
|
||||
let modAbs = Math.abs(fullModifier)
|
||||
modifierFormula = `D${modAbs + 1} -1`
|
||||
}
|
||||
|
||||
let rollData = { ...rollContext }
|
||||
// Merge rollContext object into options object
|
||||
options = { ...options, ...rollContext }
|
||||
options.rollName = "Ranged Defense"
|
||||
options.rollType = "weapon-defense"
|
||||
options.type = options.rollType // Required: this.type reads options.type
|
||||
options.rollMode = rollContext.visibility // Required: callers pass roll.options.rollMode to toMessage
|
||||
|
||||
const rollBase = new this(rollContext.movement, options.data, rollData)
|
||||
const rollModifier = new Roll(modifierFormula, options.data, rollData)
|
||||
await rollModifier.evaluate()
|
||||
await rollBase.evaluate()
|
||||
let rollD30 = await new Roll("1D30").evaluate()
|
||||
options.D30result = rollD30.total
|
||||
options.D30message = D30Roll.getResult(rollD30.total, options.rollType, options.rollTarget?.weapon, { isRanged: true })
|
||||
|
||||
let badResult = 0
|
||||
if (rollContext.movement.includes("kh")) {
|
||||
rollData.favor = "favor"
|
||||
badResult = Math.min(rollBase.terms[0].results[0].result, rollBase.terms[0].results[1]?.result || 20)
|
||||
}
|
||||
if (rollContext.movement.includes("kl")) {
|
||||
rollData.favor = "disfavor"
|
||||
badResult = Math.max(rollBase.terms[0].results[0].result, rollBase.terms[0].results[1]?.result || 1)
|
||||
}
|
||||
let dice = rollContext.movement
|
||||
let maxValue = 20 // As per latest changes (was : Number(dice.match(/\d+$/)[0])
|
||||
let rollTotal = -1
|
||||
let diceResults = []
|
||||
let resultType
|
||||
|
||||
let diceResult = rollBase.dice[0].results[0].result
|
||||
diceResults.push({ dice: `${dice.toUpperCase()}`, value: diceResult })
|
||||
let diceSum = diceResult
|
||||
while (diceResult === maxValue) {
|
||||
let r = await new Roll(dice).evaluate()
|
||||
diceResult = r.dice[0].results[0].result
|
||||
diceResults.push({ dice: `${dice.toUpperCase()}-1`, value: diceResult - 1 })
|
||||
diceSum += (diceResult - 1)
|
||||
rollBase.dice[0].results.push({ result: diceResult, active: true })
|
||||
}
|
||||
if (fullModifier !== 0) {
|
||||
diceResults.push({ dice: `${rollModifier.formula.toUpperCase()}`, value: rollModifier.total })
|
||||
if (fullModifier < 0) {
|
||||
rollTotal = Math.max(diceSum - rollModifier.total, 0)
|
||||
} else {
|
||||
rollTotal = diceSum + rollModifier.total
|
||||
}
|
||||
} else {
|
||||
rollTotal = diceSum
|
||||
}
|
||||
rollBase.options = { ...rollBase.options, ...options }
|
||||
rollBase.options.resultType = resultType
|
||||
rollBase.options.rollTotal = rollTotal
|
||||
rollBase.options.diceResults = diceResults
|
||||
rollBase.options.rollTarget = options.rollTarget
|
||||
rollBase.options.titleFormula = `1D20E + ${modifierFormula}`
|
||||
rollBase.options.D30result = options.D30result
|
||||
rollBase.options.D30message = options.D30message
|
||||
rollBase.options.rollName = "Ranged Defense"
|
||||
rollBase.options.badResult = badResult
|
||||
rollBase.options.rollData = foundry.utils.duplicate(rollData)
|
||||
|
||||
return rollBase
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts the GM for ranged attack context (movement, range, target size, aim) when a monster
|
||||
* attacks with a ranged weapon, then evaluates an exploding D20 attack roll with the resulting modifiers.
|
||||
*
|
||||
* @param {Object} options Options for the roll.
|
||||
* @param {string} options.actorId The attacker actor ID.
|
||||
* @param {string} options.actorName The attacker actor name.
|
||||
* @param {Object} options.rollTarget The rollTarget containing attackModifier and related data.
|
||||
* @returns {Promise<LethalFantasyRoll|null>} The resulting roll, or null if cancelled.
|
||||
*/
|
||||
export async function promptRangedAttack(options = {}) {
|
||||
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes)
|
||||
const fieldRollMode = new foundry.data.fields.StringField({
|
||||
choices: rollModes,
|
||||
blank: false,
|
||||
default: "public",
|
||||
})
|
||||
|
||||
let dialogContext = {
|
||||
attackerMovementChoices: SYSTEM.ATTACKER_MOVEMENT_CHOICES,
|
||||
rangeChoices: SYSTEM.RANGE_CHOICES,
|
||||
sizeChoices: SYSTEM.SIZE_CHOICES,
|
||||
attackerAimChoices: SYSTEM.ATTACKER_AIM_CHOICES,
|
||||
movement: "none",
|
||||
range: "short",
|
||||
size: "+5",
|
||||
attackerAim: "simple",
|
||||
fieldRollMode,
|
||||
rollModes
|
||||
}
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/range-attack-dialog.hbs", dialogContext)
|
||||
|
||||
const label = game.i18n.localize("LETHALFANTASY.Label.rangeAttackRoll")
|
||||
const rollContext = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Ranged Attack" },
|
||||
classes: ["lethalfantasy"],
|
||||
content,
|
||||
buttons: [
|
||||
{
|
||||
action: "rangedAttack",
|
||||
type: "button",
|
||||
label,
|
||||
callback: (event, button) => {
|
||||
const output = Array.from(button.form.elements).reduce((obj, input) => {
|
||||
if (input.name) obj[input.name] = input.value
|
||||
return obj
|
||||
}, {})
|
||||
return output
|
||||
},
|
||||
},
|
||||
],
|
||||
rejectClose: false
|
||||
})
|
||||
|
||||
if (rollContext === null) return null
|
||||
|
||||
// Handle pointblank: attacker at point blank gets favor (standing still easier to aim)
|
||||
if (rollContext.range === "pointblank") {
|
||||
rollContext.movement = rollContext.movement.replace("kh", "")
|
||||
rollContext.movement = rollContext.movement.replace("kl", "")
|
||||
rollContext.movement += "kh" // Favor for attacker at point blank
|
||||
rollContext.range = "0"
|
||||
}
|
||||
// Handle beyondskill: extreme range gives disfavor to attacker
|
||||
if (rollContext.range === "beyondskill") {
|
||||
rollContext.movement = rollContext.movement.replace("kh", "")
|
||||
rollContext.movement = rollContext.movement.replace("kl", "")
|
||||
rollContext.movement += "kl" // Disfavor for attacker beyond skill range
|
||||
rollContext.range = "+11"
|
||||
}
|
||||
|
||||
// Compute contextual penalty: range + target_size, reduced by aim bonus and attack modifier
|
||||
const attackModifier = options.rollTarget?.attackModifier ?? 0
|
||||
const contextualPenalty = Number(rollContext.range) + Number(rollContext.size)
|
||||
const aimBonus = Number(rollContext.attackerAim || 0)
|
||||
const fullModifier = contextualPenalty - aimBonus - attackModifier
|
||||
|
||||
let modifierFormula
|
||||
if (fullModifier === 0) {
|
||||
modifierFormula = "0"
|
||||
} else {
|
||||
const modAbs = Math.abs(fullModifier)
|
||||
modifierFormula = `D${modAbs + 1} -1`
|
||||
}
|
||||
|
||||
const rollData = { ...rollContext }
|
||||
options = { ...options, ...rollContext }
|
||||
options.rollName = "Ranged Attack"
|
||||
options.rollType = options.rollType || "monster-attack"
|
||||
options.type = options.rollType // Required: this.type reads options.type, used to build weaponDamageOptions in toHTML
|
||||
options.rollMode = rollContext.visibility // Required: callers pass roll.options.rollMode to toMessage
|
||||
options.isRangedAttack = true
|
||||
|
||||
const rollBase = new this(rollContext.movement, options.data, rollData)
|
||||
const rollModifier = new Roll(modifierFormula, options.data, rollData)
|
||||
await rollModifier.evaluate()
|
||||
await rollBase.evaluate()
|
||||
const rollD30 = await new Roll("1D30").evaluate()
|
||||
options.D30result = rollD30.total
|
||||
options.D30message = D30Roll.getResult(rollD30.total, options.rollType, undefined, { isRanged: true })
|
||||
|
||||
// Determine favor from dice formula
|
||||
let badResult = 0
|
||||
if (rollContext.movement.includes("kh")) {
|
||||
rollData.favor = "favor"
|
||||
badResult = Math.min(rollBase.terms[0].results[0].result, rollBase.terms[0].results[1]?.result || 20)
|
||||
}
|
||||
if (rollContext.movement.includes("kl")) {
|
||||
rollData.favor = "disfavor"
|
||||
badResult = Math.max(rollBase.terms[0].results[0].result, rollBase.terms[0].results[1]?.result || 1)
|
||||
}
|
||||
|
||||
const dice = rollContext.movement
|
||||
const maxValue = 20
|
||||
let rollTotal = -1
|
||||
let diceResults = []
|
||||
|
||||
let diceResult = rollBase.dice[0].results[0].result
|
||||
diceResults.push({ dice: `${dice.toUpperCase()}`, value: diceResult })
|
||||
let diceSum = diceResult
|
||||
// Exploding dice
|
||||
while (diceResult === maxValue) {
|
||||
const r = await new Roll(dice).evaluate()
|
||||
diceResult = r.dice[0].results[0].result
|
||||
diceResults.push({ dice: `${dice.toUpperCase()}-1`, value: diceResult - 1 })
|
||||
diceSum += (diceResult - 1)
|
||||
rollBase.dice[0].results.push({ result: diceResult, active: true })
|
||||
}
|
||||
|
||||
if (fullModifier !== 0) {
|
||||
diceResults.push({ dice: `${rollModifier.formula.toUpperCase()}`, value: rollModifier.total })
|
||||
if (fullModifier > 0) {
|
||||
// Net penalty: subtract from roll
|
||||
rollTotal = Math.max(diceSum - rollModifier.total, 0)
|
||||
} else {
|
||||
// Net bonus: add to roll
|
||||
rollTotal = diceSum + rollModifier.total
|
||||
}
|
||||
} else {
|
||||
rollTotal = diceSum
|
||||
}
|
||||
|
||||
rollBase.options = { ...rollBase.options, ...options }
|
||||
rollBase.options.resultType = undefined
|
||||
rollBase.options.rollTotal = rollTotal
|
||||
rollBase.options.diceResults = diceResults
|
||||
rollBase.options.rollTarget = options.rollTarget
|
||||
rollBase.options.titleFormula = `1D20E + ${modifierFormula}`
|
||||
rollBase.options.D30result = options.D30result
|
||||
rollBase.options.D30message = options.D30message
|
||||
rollBase.options.rollName = "Ranged Attack"
|
||||
rollBase.options.badResult = badResult
|
||||
rollBase.options.rollData = foundry.utils.duplicate(rollData)
|
||||
|
||||
return rollBase
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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>}
|
||||
*/
|
||||
export async function rollSpellDamageToMessage(formula, rollOpts) {
|
||||
const roll = new this(formula, {}, rollOpts)
|
||||
await roll.evaluate()
|
||||
const shouldExplode = !/NE$/i.test(formula)
|
||||
const diceResults = []
|
||||
let diceSum = 0
|
||||
for (const term of roll.dice) {
|
||||
const singleDice = `1D${term.faces}`
|
||||
const termResults = Array.from(term.results)
|
||||
for (const r of termResults) {
|
||||
let diceResult = r.result
|
||||
diceResults.push({ dice: singleDice.toUpperCase(), value: diceResult })
|
||||
diceSum += diceResult
|
||||
if (shouldExplode && term.faces > 0) {
|
||||
while (diceResult === term.faces) {
|
||||
const xr = await new Roll(singleDice).evaluate()
|
||||
// Optional chaining guards against unexpected roll structure
|
||||
diceResult = xr.dice?.[0]?.results?.[0]?.result ?? (term.faces - 1)
|
||||
diceResults.push({ dice: `${singleDice.toUpperCase()}-1`, value: diceResult - 1 })
|
||||
diceSum += (diceResult - 1)
|
||||
term.results.push({ result: diceResult, active: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
roll.options.diceResults = diceResults
|
||||
roll.options.rollTotal = diceSum
|
||||
return roll.toMessage()
|
||||
}
|
||||
@@ -0,0 +1,598 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
import D30Roll from "./d30-roll.mjs"
|
||||
|
||||
/**
|
||||
* Prompt the user with a dialog to configure and execute a roll.
|
||||
*
|
||||
* @param {Object} options Configuration options for the roll.
|
||||
* @param {string} options.rollType The type of roll being performed (e.g., RESOURCE, DAMAGE, ATTACK, SAVE).
|
||||
* @param {string} options.rollValue The initial value or formula for the roll.
|
||||
* @param {string} options.rollTarget The target of the roll.
|
||||
* @param {"="|"+"|"++"|"-"|"--"} options.rollAdvantage If there is an avantage (+), a disadvantage (-), a double advantage (++), a double disadvantage (--) or a normal roll (=).
|
||||
* @param {string} options.actorId The ID of the actor performing the roll.
|
||||
* @param {string} options.actorName The name of the actor performing the roll.
|
||||
* @param {string} options.actorImage The image of the actor performing the roll.
|
||||
* @param {boolean} options.hasTarget Whether the roll has a target.
|
||||
* @param {Object} options.target The target of the roll, if any.
|
||||
* @param {Object} options.data Additional data for the roll.
|
||||
*
|
||||
* @returns {Promise<Object|null>} The roll result or null if the dialog was cancelled.
|
||||
*/
|
||||
export async function prompt(options = {}) {
|
||||
try {
|
||||
let dice = "1D20"
|
||||
let maxValue = 20
|
||||
let baseFormula = "1D20"
|
||||
let modifierFormula = "1D0"
|
||||
let hasModifier = true
|
||||
let hasChangeDice = false
|
||||
let hasD30 = false
|
||||
let hasFavor = false
|
||||
let hasMaxValue = true
|
||||
let hasGrantedDice = false
|
||||
let pointBlank = false
|
||||
let letItFly = false
|
||||
let saveSpell = game.lethalFantasy?.spellDefense ?? false
|
||||
let beyondSkill = false
|
||||
let hasStaticModifier = false
|
||||
let hasExplode = true
|
||||
let actor = game.actors.get(options.actorId)
|
||||
|
||||
if (options.rollType === "challenge" || options.rollType === "save") {
|
||||
options.rollName = game.i18n.localize(`LETHALFANTASY.Label.${options.rollTarget.rollKey}`)
|
||||
hasD30 = options.rollType === "save"
|
||||
if (options.rollTarget.rollKey === "dying") {
|
||||
dice = options.rollTarget.value
|
||||
hasModifier = false
|
||||
hasChangeDice = true
|
||||
hasFavor = true
|
||||
} else {
|
||||
dice = "1D20"
|
||||
hasFavor = true
|
||||
}
|
||||
|
||||
} else if (options.rollType === "granted") {
|
||||
hasD30 = false
|
||||
options.rollName = `Granted ${options.rollTarget.rollKey}`
|
||||
dice = options.rollTarget.formula
|
||||
baseFormula = options.rollTarget.formula
|
||||
hasModifier = false
|
||||
hasMaxValue = false
|
||||
hasChangeDice = false
|
||||
hasFavor = false
|
||||
|
||||
} else if (options.rollType === "monster-attack" || options.rollType === "monster-defense") {
|
||||
hasD30 = true
|
||||
options.rollName = options.rollTarget.name
|
||||
dice = "1D20"
|
||||
baseFormula = "D20"
|
||||
hasModifier = true
|
||||
hasChangeDice = false
|
||||
hasFavor = true
|
||||
if (options.rollType === "monster-attack") {
|
||||
options.rollTarget.value = options.rollTarget.attackModifier
|
||||
options.rollTarget.charModifier = 0
|
||||
} else {
|
||||
options.rollTarget.value = options.rollTarget.defenseModifier
|
||||
options.rollTarget.charModifier = 0
|
||||
options.isRangedDefense = options.rollTarget.isRangedDefense ?? false
|
||||
}
|
||||
|
||||
} else if (options.rollType === "monster-skill") {
|
||||
options.rollName = game.i18n.localize(`LETHALFANTASY.Label.${options.rollTarget.rollKey}`)
|
||||
dice = "1D20"
|
||||
baseFormula = "D20"
|
||||
hasModifier = true
|
||||
hasFavor = true
|
||||
hasChangeDice = false
|
||||
|
||||
} else if (options.rollType === "skill") {
|
||||
options.rollName = options.rollTarget.name
|
||||
hasD30 = true
|
||||
dice = "1D20"
|
||||
baseFormula = "D20"
|
||||
hasModifier = true
|
||||
hasFavor = true
|
||||
hasChangeDice = false
|
||||
options.rollTarget.value = Math.floor(options.rollTarget.system.skillTotal / 10)
|
||||
|
||||
} else if (options.rollType === "weapon-attack" || options.rollType === "weapon-defense") {
|
||||
hasD30 = true
|
||||
options.rollName = options.rollTarget.name
|
||||
dice = "1D20"
|
||||
baseFormula = "D20"
|
||||
hasModifier = true
|
||||
hasChangeDice = false
|
||||
hasFavor = true
|
||||
if (options.rollType === "weapon-attack") {
|
||||
if (options.rollTarget.weapon.system.weaponType === "melee") {
|
||||
options.rollTarget.value = options.rollTarget.combat.attackModifier + options.rollTarget.weaponSkillModifier + options.rollTarget.weapon.system.bonuses.attackBonus
|
||||
options.rollTarget.charModifier = options.rollTarget.combat.attackModifier
|
||||
} else {
|
||||
options.rollTarget.value = options.rollTarget.combat.rangedAttackModifier + options.rollTarget.weaponSkillModifier + options.rollTarget.weapon.system.bonuses.attackBonus
|
||||
options.rollTarget.charModifier = options.rollTarget.combat.rangedAttackModifier
|
||||
}
|
||||
} else {
|
||||
// For defense, check if it's a ranged defense
|
||||
const defenseModifier = options.rollTarget.isRangedDefense
|
||||
? options.rollTarget.combat.rangedDefenseModifier
|
||||
: options.rollTarget.combat.defenseModifier
|
||||
options.rollTarget.value = defenseModifier + options.rollTarget.weaponSkillModifier + options.rollTarget.weapon.system.bonuses.defenseBonus + options.rollTarget.armorDefense
|
||||
options.rollTarget.charModifier = defenseModifier
|
||||
// Store isRanged flag for D30 lookup
|
||||
options.isRangedDefense = options.rollTarget.isRangedDefense
|
||||
}
|
||||
|
||||
} else if (options.rollType === "spell" || options.rollType === "spell-attack" || options.rollType === "spell-power") {
|
||||
hasD30 = true
|
||||
options.rollName = options.rollTarget.name
|
||||
dice = "1D20"
|
||||
baseFormula = "D20"
|
||||
hasModifier = true
|
||||
hasChangeDice = false
|
||||
hasFavor = true
|
||||
options.rollTarget.value = options.rollTarget.actorModifiers.levelSpellModifier + options.rollTarget.actorModifiers.intSpellModifier
|
||||
options.rollTarget.charModifier = options.rollTarget.actorModifiers.intSpellModifier
|
||||
hasStaticModifier = options.rollType === "spell-power"
|
||||
//hasModifier = options.rollType !== "spell-attack"
|
||||
if (hasStaticModifier) {
|
||||
options.rollTarget.staticModifier = options.rollTarget.actorLevel
|
||||
} else {
|
||||
options.rollTarget.staticModifier = 0
|
||||
}
|
||||
|
||||
} else if (options.rollType === "miracle" || options.rollType === "miracle-attack" || options.rollType === "miracle-power") {
|
||||
hasD30 = true
|
||||
options.rollName = options.rollTarget.name
|
||||
dice = "1D20"
|
||||
baseFormula = "D20"
|
||||
hasChangeDice = false
|
||||
hasFavor = true
|
||||
options.rollTarget.value = options.rollTarget.actorModifiers.levelMiracleModifier + options.rollTarget.actorModifiers.chaMiracleModifier
|
||||
options.rollTarget.charModifier = options.rollTarget.actorModifiers.chaMiracleModifier
|
||||
hasStaticModifier = options.rollType === "miracle-power"
|
||||
//hasModifier = options.rollType !== "miracle-attack"
|
||||
if (hasStaticModifier) {
|
||||
options.rollTarget.staticModifier = options.rollTarget.actorLevel
|
||||
} else {
|
||||
options.rollTarget.staticModifier = 0
|
||||
}
|
||||
|
||||
} else if (options.rollType === "shield-roll") {
|
||||
hasD30 = false
|
||||
options.rollName = "Shield Defense"
|
||||
dice = options.rollTarget.system.defense.toUpperCase()
|
||||
baseFormula = dice
|
||||
hasModifier = true
|
||||
hasChangeDice = false
|
||||
hasMaxValue = false
|
||||
hasExplode = false
|
||||
hasFavor = true
|
||||
options.rollTarget.value = 0
|
||||
|
||||
} else if (options.rollType.includes("weapon-damage")) {
|
||||
options.rollName = options.rollTarget.name
|
||||
options.isDamage = true
|
||||
hasModifier = true
|
||||
hasChangeDice = false
|
||||
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.charModifier = damageBonus
|
||||
dice = options.rollTarget.weapon.system.damage.damageM
|
||||
if (/NE$/i.test(dice)) {
|
||||
hasMaxValue = false
|
||||
hasExplode = false
|
||||
}
|
||||
dice = dice.replace(/NE$/i, "").replace("E", "")
|
||||
baseFormula = dice
|
||||
|
||||
} else if (options.rollType.includes("monster-damage")) {
|
||||
options.rollName = options.rollTarget.name
|
||||
options.isDamage = true
|
||||
hasModifier = true
|
||||
hasChangeDice = false
|
||||
options.rollTarget.value = options.rollTarget.damageModifier
|
||||
options.rollTarget.charModifier = 0
|
||||
dice = options.rollTarget.damageDice
|
||||
dice = dice.replace("E", "")
|
||||
baseFormula = dice
|
||||
if (options.rollTarget.noExplode) {
|
||||
hasMaxValue = false
|
||||
hasExplode = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (options.rollType === "save" && (options.rollTarget.rollKey === "pain" || options.rollTarget.rollKey === "paincourage")) {
|
||||
dice = options.rollTarget.rollDice
|
||||
baseFormula = options.rollTarget.rollDice
|
||||
hasModifier = false
|
||||
}
|
||||
|
||||
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes);
|
||||
|
||||
|
||||
const fieldRollMode = new foundry.data.fields.StringField({
|
||||
choices: rollModes,
|
||||
blank: false,
|
||||
default: "public",
|
||||
})
|
||||
|
||||
const choiceModifier = SYSTEM.CHOICE_MODIFIERS
|
||||
const choiceDice = SYSTEM.CHOICE_DICE
|
||||
const choiceFavor = SYSTEM.FAVOR_CHOICES
|
||||
|
||||
let modifier = "+0"
|
||||
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 = {
|
||||
rollType: options.rollType,
|
||||
rollTarget: options.rollTarget,
|
||||
rollName: options.rollName,
|
||||
actorName: options.actorName,
|
||||
rollModes,
|
||||
hasModifier,
|
||||
hasFavor,
|
||||
hasChangeDice,
|
||||
pointBlank,
|
||||
baseValue: options.rollTarget.value,
|
||||
attackerAimChoices: SYSTEM.ATTACKER_AIM_CHOICES,
|
||||
attackerAim: "0",
|
||||
changeDice: `${dice}`,
|
||||
fieldRollMode,
|
||||
choiceModifier,
|
||||
choiceDice,
|
||||
choiceFavor,
|
||||
baseFormula,
|
||||
dice,
|
||||
hasTarget: options.hasTarget,
|
||||
modifier,
|
||||
saveSpell,
|
||||
favor: "none",
|
||||
targetName,
|
||||
isRangedAttack
|
||||
}
|
||||
let rollContext
|
||||
if (options.rollContext) {
|
||||
rollContext = foundry.utils.duplicate(options.rollContext)
|
||||
hasGrantedDice = !!rollContext.hasGrantedDice
|
||||
pointBlank = !!rollContext.pointBlank
|
||||
beyondSkill = !!rollContext.beyondSkill
|
||||
letItFly = !!rollContext.letItFly
|
||||
saveSpell = !!rollContext.saveSpell
|
||||
const _rawMode = rollContext.rollMode || game.settings.get("core", "rollMode")
|
||||
const _modeMap = { publicroll: "public", gmroll: "gm", blindroll: "blind", selfroll: "self" }
|
||||
rollContext.visibility ||= _modeMap[_rawMode] ?? _rawMode ?? "public"
|
||||
rollContext.modifier ||= modifier
|
||||
rollContext.favor ||= "none"
|
||||
rollContext.changeDice ||= `${dice}`
|
||||
rollContext.attackerAim ||= "0"
|
||||
} else {
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/roll-dialog.hbs", dialogContext)
|
||||
|
||||
let position = game.user.getFlag(SYSTEM.id, "roll-dialog-pos") || { top: -1, left: -1 }
|
||||
const label = game.i18n.localize("LETHALFANTASY.Roll.roll")
|
||||
rollContext = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Roll dialog" },
|
||||
classes: ["lethalfantasy"],
|
||||
content,
|
||||
position,
|
||||
buttons: [
|
||||
{
|
||||
action: "roll",
|
||||
type: "button",
|
||||
label: label,
|
||||
callback: (event, button, dialog) => {
|
||||
log("Roll context", event, button, dialog)
|
||||
let position = dialog?.position
|
||||
game.user.setFlag(SYSTEM.id, "roll-dialog-pos", foundry.utils.duplicate(position))
|
||||
const output = Array.from(button.form.elements).reduce((obj, input) => {
|
||||
if (input.name) obj[input.name] = input.value
|
||||
return obj
|
||||
}, {})
|
||||
return output
|
||||
},
|
||||
},
|
||||
],
|
||||
actions: {
|
||||
"selectGranted": (event, button) => {
|
||||
hasGrantedDice = event.target.checked
|
||||
},
|
||||
"selectBeyondSkill": (event, button) => {
|
||||
beyondSkill = button.checked
|
||||
},
|
||||
"selectPointBlank": (event, button) => {
|
||||
pointBlank = button.checked
|
||||
},
|
||||
"selectLetItFly": (event, button) => {
|
||||
letItFly = button.checked
|
||||
},
|
||||
"saveSpellCheck": (event, button) => {
|
||||
saveSpell = button.checked
|
||||
},
|
||||
"gotoToken": (event, button) => {
|
||||
let tokenId = $(button).data("tokenId")
|
||||
let token = canvas.tokens?.get(tokenId)
|
||||
if (token) {
|
||||
canvas.animatePan({ x: token.x, y: token.y, duration: 200 })
|
||||
canvas.tokens.releaseAll()
|
||||
token.control({ releaseOthers: true })
|
||||
}
|
||||
}
|
||||
},
|
||||
rejectClose: false // Click on Close button will not launch an error
|
||||
})
|
||||
}
|
||||
|
||||
// If the user cancels the dialog, exit
|
||||
if (rollContext === null) return
|
||||
log("rollContext", rollContext, hasGrantedDice)
|
||||
rollContext.saveSpell = saveSpell // Update fucking flag
|
||||
|
||||
let fullModifier = 0
|
||||
let titleFormula = ""
|
||||
dice = rollContext.changeDice || dice
|
||||
if (hasModifier) {
|
||||
let bonus = Number(options.rollTarget.value)
|
||||
fullModifier = rollContext.modifier === "" ? 0 : parseInt(rollContext.modifier, 10) + bonus
|
||||
fullModifier += (rollContext.saveSpell) ? (options.rollTarget.actorModifiers?.saveModifier ?? 0) : 0
|
||||
if (Number(rollContext.attackerAim) > 0) {
|
||||
fullModifier += Number(rollContext.attackerAim)
|
||||
}
|
||||
|
||||
if (fullModifier === 0) {
|
||||
modifierFormula = "0"
|
||||
} else {
|
||||
let modAbs = Math.abs(fullModifier)
|
||||
modifierFormula = `D${modAbs + 1} - 1`
|
||||
}
|
||||
if (hasStaticModifier) {
|
||||
modifierFormula += ` + ${options.rollTarget.staticModifier}`
|
||||
}
|
||||
let sign = fullModifier < 0 ? "-" : "+"
|
||||
if (hasExplode) {
|
||||
titleFormula = `${dice}E ${sign} ${modifierFormula}`
|
||||
} else {
|
||||
titleFormula = `${dice} ${sign} ${modifierFormula}`
|
||||
}
|
||||
} else {
|
||||
modifierFormula = "0"
|
||||
fullModifier = 0
|
||||
baseFormula = `${dice}`
|
||||
if (hasExplode) {
|
||||
titleFormula = `${dice}E`
|
||||
} else {
|
||||
titleFormula = `${dice}`
|
||||
}
|
||||
}
|
||||
|
||||
// Latest addition : favor choice at point blank range
|
||||
if (pointBlank) {
|
||||
rollContext.favor = "favor"
|
||||
}
|
||||
if (beyondSkill) {
|
||||
rollContext.favor = "disfavor"
|
||||
}
|
||||
|
||||
// Specific pain case
|
||||
if (options.rollType === "save" && options.rollTarget.rollKey === "pain" || options.rollTarget.rollKey === "paincourage") {
|
||||
baseFormula = options.rollTarget.rollDice
|
||||
titleFormula = `${dice}`
|
||||
modifierFormula = "0"
|
||||
fullModifier = 0
|
||||
}
|
||||
|
||||
// Specific pain/poison/contagion case
|
||||
if (options.rollType === "save" && (options.rollTarget.rollKey === "poison" || options.rollTarget.rollKey === "contagion")) {
|
||||
hasD30 = false
|
||||
hasStaticModifier = true
|
||||
modifierFormula = ` + ${Math.abs(fullModifier)}`
|
||||
titleFormula = `${dice}E + ${Math.abs(fullModifier)}`
|
||||
}
|
||||
|
||||
if (letItFly) {
|
||||
baseFormula = "1D20"
|
||||
titleFormula = `1D20E`
|
||||
modifierFormula = "0"
|
||||
fullModifier = 0
|
||||
hasFavor = false
|
||||
hasExplode = true
|
||||
rollContext.favor = "none"
|
||||
}
|
||||
|
||||
const maxMatch = baseFormula ? baseFormula.match(/\d+$/) : null
|
||||
maxValue = maxMatch ? Number(maxMatch[0]) : 0
|
||||
|
||||
const rollData = {
|
||||
type: options.rollType,
|
||||
rollType: options.rollType,
|
||||
target: options.rollTarget,
|
||||
rollName: options.rollName,
|
||||
actorId: options.actorId,
|
||||
actorName: options.actorName,
|
||||
actorImage: options.actorImage,
|
||||
rollMode: rollContext.visibility,
|
||||
hasTarget: options.hasTarget,
|
||||
isDamage: options.isDamage,
|
||||
pointBlank,
|
||||
beyondSkill,
|
||||
letItFly,
|
||||
hasGrantedDice,
|
||||
titleFormula,
|
||||
targetName,
|
||||
...rollContext,
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook event that fires before the roll is made.
|
||||
* @function
|
||||
* @memberof hookEvents
|
||||
* @param {Object} options Options for the roll.
|
||||
* @param {Object} rollData All data related to the roll.
|
||||
* @returns {boolean} Explicitly return `false` to prevent roll to be made.
|
||||
*/
|
||||
if (Hooks.call("fvtt-lethal-fantasy.preRoll", options, rollData) === false) return
|
||||
|
||||
let rollBase = new this(baseFormula, options.data, rollData)
|
||||
const rollModifier = new Roll(modifierFormula, options.data, rollData)
|
||||
await rollModifier.evaluate()
|
||||
await rollBase.evaluate()
|
||||
|
||||
let rollFavor
|
||||
let badResult
|
||||
if (rollContext.favor === "favor") {
|
||||
rollFavor = new this(baseFormula, options.data, rollData)
|
||||
await rollFavor.evaluate()
|
||||
log("Favor dice", {
|
||||
rollBaseTotal: rollBase.total,
|
||||
rollFavorTotal: rollFavor.total,
|
||||
rollBaseResults: rollBase.dice.map(d => d.results.map(r => r.result)),
|
||||
rollFavorResults: rollFavor.dice.map(d => d.results.map(r => r.result)),
|
||||
baseFormula
|
||||
})
|
||||
if (game?.dice3d) {
|
||||
game.dice3d.showForRoll(rollFavor, game.user, true)
|
||||
}
|
||||
if (Number(rollFavor.result) > Number(rollBase.result)) {
|
||||
badResult = rollBase.result
|
||||
rollBase = rollFavor
|
||||
} else {
|
||||
badResult = rollFavor.result
|
||||
}
|
||||
rollFavor = null
|
||||
}
|
||||
|
||||
if (rollContext.favor === "disfavor") {
|
||||
rollFavor = new this(baseFormula, options.data, rollData)
|
||||
await rollFavor.evaluate()
|
||||
log("Disfavor dice", {
|
||||
rollBaseTotal: rollBase.total,
|
||||
rollFavorTotal: rollFavor.total,
|
||||
rollBaseResults: rollBase.dice.map(d => d.results.map(r => r.result)),
|
||||
rollFavorResults: rollFavor.dice.map(d => d.results.map(r => r.result)),
|
||||
baseFormula
|
||||
})
|
||||
if (game?.dice3d) {
|
||||
game.dice3d.showForRoll(rollFavor, game.user, true)
|
||||
}
|
||||
if (Number(rollFavor.result) < Number(rollBase.result)) {
|
||||
badResult = rollBase.result
|
||||
rollBase = rollFavor
|
||||
} else {
|
||||
badResult = rollFavor.result
|
||||
}
|
||||
rollFavor = null
|
||||
}
|
||||
|
||||
if (options.forceNoD30) {
|
||||
hasD30 = false
|
||||
}
|
||||
|
||||
if (hasD30) {
|
||||
let rollD30 = await new Roll("1D30").evaluate()
|
||||
if (game?.dice3d) {
|
||||
game.dice3d.showForRoll(rollD30, game.user, true)
|
||||
}
|
||||
options.D30result = rollD30.total
|
||||
|
||||
// Compute isRanged for D30: covers defense (isRangedDefense), monster ranged attacks (attackMode),
|
||||
// and PC weapon attacks (isRangedAttack or weaponType)
|
||||
const isRangedForD30 = options.isRangedDefense
|
||||
|| options.rollTarget?.attackMode === "ranged"
|
||||
|| options.rollTarget?.isRangedAttack === true
|
||||
|| options.rollTarget?.weapon?.system?.weaponType === "ranged"
|
||||
const d30Message = D30Roll.getResult(
|
||||
rollD30.total,
|
||||
options.rollType,
|
||||
options.rollTarget?.weapon,
|
||||
{ isRanged: isRangedForD30, isSpellSave: saveSpell }
|
||||
)
|
||||
options.D30message = d30Message
|
||||
}
|
||||
|
||||
let rollTotal = 0
|
||||
let diceResults = []
|
||||
let resultType
|
||||
let diceSum = 0
|
||||
|
||||
let singleDice = `1D${maxValue}`
|
||||
for (let i = 0; i < rollBase.dice.length; i++) {
|
||||
const dieResults = rollBase.dice[i].results
|
||||
const resultCount = dieResults.length
|
||||
for (let j = 0; j < resultCount; j++) {
|
||||
let diceResult = dieResults[j].result
|
||||
diceResults.push({ dice: `${singleDice.toUpperCase()}`, value: diceResult })
|
||||
diceSum += diceResult
|
||||
if (hasMaxValue) {
|
||||
while (diceResult === maxValue) {
|
||||
let r = await new Roll(baseFormula).evaluate()
|
||||
diceResult = r.dice[0].results[0].result
|
||||
diceResults.push({ dice: `${singleDice.toUpperCase()}-1`, value: diceResult - 1 })
|
||||
diceSum += (diceResult - 1)
|
||||
// Add to DieTerm results so DSN/Foundry display shows explosion dice
|
||||
dieResults.push({ result: diceResult, active: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasGrantedDice && options.rollTarget.grantedDice && options.rollTarget.grantedDice !== "") {
|
||||
titleFormula += ` + ${options.rollTarget.grantedDice.toUpperCase()}`
|
||||
let grantedRoll = new Roll(options.rollTarget.grantedDice)
|
||||
await grantedRoll.evaluate()
|
||||
if (game?.dice3d) {
|
||||
await game.dice3d.showForRoll(grantedRoll, game.user, true)
|
||||
}
|
||||
diceResults.push({ dice: `${options.rollTarget.grantedDice.toUpperCase()}`, value: grantedRoll.total })
|
||||
rollTotal += grantedRoll.total
|
||||
}
|
||||
|
||||
if (fullModifier !== 0) {
|
||||
diceResults.push({ dice: `${rollModifier.formula.toUpperCase()}`, value: rollModifier.total })
|
||||
if (fullModifier < 0) {
|
||||
rollTotal += Math.max(diceSum - rollModifier.total, 0)
|
||||
} else {
|
||||
rollTotal += diceSum + rollModifier.total
|
||||
}
|
||||
} else {
|
||||
rollTotal += diceSum
|
||||
}
|
||||
|
||||
rollBase.options.resultType = resultType
|
||||
rollBase.options.rollTotal = rollTotal
|
||||
rollBase.options.diceResults = diceResults
|
||||
rollBase.options.rollTarget = options.rollTarget
|
||||
rollBase.options.titleFormula = titleFormula
|
||||
rollBase.options.D30result = options.D30result
|
||||
rollBase.options.D30message = options.D30message
|
||||
rollBase.options.badResult = badResult
|
||||
rollBase.options.rollData = foundry.utils.duplicate(rollData)
|
||||
rollBase.options.defenderId = options.defenderId
|
||||
rollBase.options.defenderTokenId = options.defenderTokenId
|
||||
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.
|
||||
* @function
|
||||
* @memberof hookEvents
|
||||
* @param {Object} options Options for the roll.
|
||||
* @param {Object} rollData All data related to the roll.
|
||||
* @param {LethalFantasyRoll} roll The resulting roll.
|
||||
* @returns {boolean} Explicitly return `false` to prevent roll to be made.
|
||||
*/
|
||||
if (Hooks.call("fvtt-lethal-fantasy.Roll", options, rollData, rollBase) === false) return
|
||||
|
||||
return rollBase
|
||||
} finally {
|
||||
// Clear one-shot flag so it doesn't leak to subsequent non-spell saves
|
||||
if (game.lethalFantasy) game.lethalFantasy.spellDefense = false
|
||||
}
|
||||
}
|
||||
+1
-1122
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -32,20 +32,20 @@ export class Macros {
|
||||
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}');`
|
||||
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")
|
||||
break
|
||||
|
||||
case "rollDamage":
|
||||
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 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)
|
||||
break
|
||||
|
||||
case "rollAttack":
|
||||
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")
|
||||
break
|
||||
|
||||
@@ -57,7 +57,7 @@ export class Macros {
|
||||
|
||||
/**
|
||||
* 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 {*} name
|
||||
* @param {*} command
|
||||
@@ -72,7 +72,7 @@ export class Macros {
|
||||
type: "script",
|
||||
img: img,
|
||||
command: command,
|
||||
flags: { "tenebris.macro": true },
|
||||
flags: { "lethalFantasy.macro": true },
|
||||
},
|
||||
{ displaySheet: false },
|
||||
)
|
||||
|
||||
+67
-14
@@ -65,7 +65,7 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
}
|
||||
|
||||
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 }),
|
||||
painDamage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
wounds: new fields.ArrayField(new fields.SchemaField(woundFieldSchema), {
|
||||
@@ -90,9 +90,9 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
current: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
})
|
||||
schema.granted = new fields.SchemaField({
|
||||
attackDice: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
defenseDice: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
damageDice: new fields.StringField({ required: true, nullable: false, initial: "" })
|
||||
attackDice: new fields.StringField({ required: true, nullable: false, initial: "0", choices: SYSTEM.GRANTED_DICE_CHOICES }),
|
||||
defenseDice: new fields.StringField({ required: true, nullable: false, initial: "0", choices: SYSTEM.GRANTED_DICE_CHOICES }),
|
||||
damageDice: new fields.StringField({ required: true, nullable: false, initial: "0", choices: SYSTEM.GRANTED_DICE_CHOICES })
|
||||
})
|
||||
|
||||
schema.movement = new fields.SchemaField({
|
||||
@@ -120,6 +120,8 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
magicUser: new fields.BooleanField({ initial: false }),
|
||||
clericUser: new fields.BooleanField({ initial: false }),
|
||||
hpPerLevel: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
naturalDR: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
magicDR: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
})
|
||||
|
||||
schema.modifiers = new fields.SchemaField({
|
||||
@@ -150,9 +152,11 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
attackModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
rangedAttackModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
defenseModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
rangedDefenseModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
defenseBonus: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
damageModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
armorHitPoints: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
combatProgressionStart: new fields.NumberField({ ...requiredInteger, initial: 1, min: 1 }),
|
||||
})
|
||||
|
||||
const moneyField = (label) => {
|
||||
@@ -174,6 +178,31 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
/** @override */
|
||||
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Character"]
|
||||
|
||||
static migrateData(data) {
|
||||
if (data?.biodata?.mortal) {
|
||||
if (!SYSTEM.MORTAL_CHOICES[data.biodata.mortal]) {
|
||||
for (let key in SYSTEM.MORTAL_CHOICES) {
|
||||
let mortal = SYSTEM.MORTAL_CHOICES[key]
|
||||
if (mortal.label.toLowerCase() === data.biodata.mortal.toLowerCase()) {
|
||||
data.biodata.mortal = mortal.id
|
||||
}
|
||||
if (data.biodata.mortal.toLowerCase().includes("shire")) {
|
||||
data.biodata.mortal = "halflings"
|
||||
}
|
||||
if (data.biodata.mortal.toLowerCase().includes("human")) {
|
||||
data.biodata.mortal = "mankind"
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!SYSTEM.MORTAL_CHOICES[data.biodata.mortal]) {
|
||||
console.warn("Lethal Fantasy | Migrate data: Mortal not found, forced to mankind", data.biodata.mortal)
|
||||
data.biodata.mortal = "mankind"
|
||||
}
|
||||
}
|
||||
|
||||
return super.migrateData(data)
|
||||
}
|
||||
|
||||
prepareDerivedData() {
|
||||
super.prepareDerivedData();
|
||||
let grit = 0
|
||||
@@ -210,8 +239,8 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
this.saves.toughness.value = conDef.toughness_save + this.modifiers.saveModifier
|
||||
this.challenges.dying.value = conDef.stabilization_dice
|
||||
|
||||
this.saves.contagion.value = this.characteristics.con.value + this.modifiers.saveModifier
|
||||
this.saves.poison.value = this.characteristics.con.value + this.modifiers.saveModifier
|
||||
this.saves.contagion.value = this.characteristics.con.value;// + this.modifiers.saveModifier
|
||||
this.saves.poison.value = this.characteristics.con.value; // + this.modifiers.saveModifier
|
||||
|
||||
this.combat.attackModifier = 0
|
||||
for (let chaKey of SYSTEM.CHARACTERISTIC_ATTACK) {
|
||||
@@ -231,6 +260,12 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
this.combat.defenseModifier += chaDef.defense
|
||||
}
|
||||
|
||||
this.combat.rangedDefenseModifier = this.combat.defenseBonus
|
||||
for (let chaKey of SYSTEM.CHARACTERISTIC_RANGED_DEFENSE) {
|
||||
let chaDef = SYSTEM.CHARACTERISTICS_TABLES[chaKey].find(s => s.value === this.characteristics[chaKey].value)
|
||||
this.combat.rangedDefenseModifier += chaDef.defense
|
||||
}
|
||||
|
||||
this.combat.damageModifier = 0
|
||||
for (let chaKey of SYSTEM.CHARACTERISTIC_DAMAGE) {
|
||||
let chaDef = SYSTEM.CHARACTERISTICS_TABLES[chaKey].find(s => s.value === this.characteristics[chaKey].value)
|
||||
@@ -246,7 +281,7 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
* @param {"="|"+"|"++"|"-"|"--"} rollAdvantage If there is an avantage (+), a disadvantage (-), a double advantage (++), a double disadvantage (--) or a normal roll (=).
|
||||
* @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled.
|
||||
*/
|
||||
async roll(rollType, rollTarget) {
|
||||
async roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr = 0, d30Effects = {}) {
|
||||
const hasTarget = false
|
||||
let roll = await LethalFantasyRoll.prompt({
|
||||
rollType,
|
||||
@@ -255,11 +290,18 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
actorName: this.parent.name,
|
||||
actorImage: this.parent.img,
|
||||
hasTarget,
|
||||
target: false
|
||||
target: false,
|
||||
defenderId,
|
||||
defenderTokenId,
|
||||
extraShieldDr,
|
||||
damageTier: rollTarget.damageTier || "standard",
|
||||
d30Bleed: d30Effects.d30Bleed || false,
|
||||
d30DamageMultiplier: d30Effects.d30DamageMultiplier || 1,
|
||||
d30DrMultiplier: d30Effects.d30DrMultiplier || 1
|
||||
})
|
||||
if (!roll) return null
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
await roll.toMessage({}, { messageMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
async rollInitiative(combatId = undefined, combatantId = undefined) {
|
||||
@@ -268,23 +310,29 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
|
||||
let wisDef = SYSTEM.CHARACTERISTICS_TABLES.wis.find((c) => c.value === this.characteristics.wis.value)
|
||||
let maxInit = Number(wisDef.init_cap) || 1000
|
||||
console.log("Rolling initiative for", this)
|
||||
|
||||
let roll = await LethalFantasyRoll.promptInitiative({
|
||||
actorId: this.parent.id,
|
||||
actorName: this.parent.name,
|
||||
actorImage: this.parent.img,
|
||||
combatId,
|
||||
combatantId ,
|
||||
combatantId,
|
||||
actorClass,
|
||||
maxInit,
|
||||
})
|
||||
if (!roll) return null
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
await roll.toMessage({}, { messageMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
async rollProgressionDice(combatId, combatantId, rollProgressionCount) {
|
||||
let combatant = game.combats.get(combatId)?.combatants?.get(combatantId)
|
||||
|
||||
// Don't roll if the combatant is defeated
|
||||
if (combatant?.isDefeated) {
|
||||
ui.notifications.warn(`${this.parent.name} is defeated and cannot attack.`)
|
||||
return
|
||||
}
|
||||
|
||||
// Get all weapons from the actor
|
||||
let weapons = this.parent.items.filter(i => i.type === "weapon" && i.system.weaponType === "melee")
|
||||
@@ -302,16 +350,21 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
let formula = ""
|
||||
if (s.type === "spell") {
|
||||
let dice = LethalFantasyUtils.getLethargyDice(s.system.level)
|
||||
title = `${s.name} (Casting time: ${s.system.castingTime}, Lethargy: ${dice})`
|
||||
title = `${s.name} (Casting time: ${s.system.castingTime}, Lethargy: ${dice})`
|
||||
formula = `${s.system.castingTime}+${dice}`
|
||||
} else {
|
||||
title = `${s.name} (Prayer time: ${s.system.prayerTime})`
|
||||
title = `${s.name} (Prayer time: ${s.system.prayerTime})`
|
||||
formula = `${s.system.prayerTime}`
|
||||
}
|
||||
weaponsChoices.push({ id: s.id, name: title, combatProgressionDice: formula })
|
||||
}
|
||||
}
|
||||
|
||||
if (weaponsChoices.length === 0) {
|
||||
ui.notifications.warn(`${this.parent.name} has no weapons or spells available for combat. Add a weapon to the character sheet first.`)
|
||||
return
|
||||
}
|
||||
|
||||
let roll = await LethalFantasyRoll.promptCombatAction({
|
||||
actorId: this.parent.id,
|
||||
actorName: this.parent.name,
|
||||
|
||||
@@ -7,7 +7,7 @@ export default class LethalFantasyEquipment extends foundry.abstract.TypeDataMod
|
||||
const requiredInteger = { required: true, nullable: false, integer: true }
|
||||
|
||||
schema.description = new fields.HTMLField({ required: true, textSearch: true })
|
||||
schema.category = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.EQUIPMENT_CATEGORIES })
|
||||
schema.category = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.EQUIPMENT_CATEGORY })
|
||||
|
||||
schema.encLoad = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
schema.hi = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
|
||||
|
||||
@@ -35,6 +35,9 @@ export default class LethalFantasyMiracle extends foundry.abstract.TypeDataModel
|
||||
|
||||
schema.attackRoll = new fields.StringField({ required: true, initial: "" })
|
||||
schema.powerRoll = new fields.StringField({ required: true, initial: "" })
|
||||
schema.damageDice = new fields.StringField({ required: false, initial: "" })
|
||||
schema.damageDiceOverpowered = new fields.StringField({ required: false, initial: "" })
|
||||
schema.damageDiceOverpowered2 = new fields.StringField({ required: false, initial: "" })
|
||||
|
||||
return schema
|
||||
}
|
||||
|
||||
+188
-33
@@ -56,15 +56,33 @@ 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({
|
||||
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 }),
|
||||
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 }),
|
||||
painDamage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
})
|
||||
|
||||
const attackField = (label) => {
|
||||
const attackField = (label, initialNoExplode = false) => {
|
||||
const schema = {
|
||||
key: new fields.StringField({ required: true, nullable: false, initial: `attack${label}` }),
|
||||
name: new fields.StringField({ required: true, nullable: false, initial: `Attack ${label}` }),
|
||||
@@ -73,6 +91,8 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
|
||||
defenseModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
damageDice: new fields.StringField({ required: true, nullable: false, initial: "1D6" }),
|
||||
damageModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
enabled: new fields.BooleanField({ initial: true, required: true, nullable: false }),
|
||||
noExplode: new fields.BooleanField({ initial: initialNoExplode, required: true, nullable: false }),
|
||||
}
|
||||
return new fields.SchemaField(schema, { label })
|
||||
}
|
||||
@@ -108,17 +128,46 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
|
||||
schema.biodata = new fields.SchemaField({
|
||||
alignment: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
vision: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
height: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
height: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
length: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
weight: new fields.StringField({ required: true, nullable: false, initial: "" })
|
||||
weight: new fields.StringField({ required: true, nullable: false, initial: "" })
|
||||
})
|
||||
schema.combat = new fields.SchemaField({
|
||||
attackModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
defenseModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
damageModifier: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
armorHitPoints: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
damageReduction: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
shieldDamageReduction: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
shieldDefenseDice: new fields.StringField({ required: true, nullable: false, initial: "d4" })
|
||||
})
|
||||
schema.combatHTH = new fields.SchemaField({
|
||||
attack1: attackField("1", true),
|
||||
attack2: attackField("2", true)
|
||||
})
|
||||
|
||||
schema.attackMode = new fields.StringField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
initial: "melee",
|
||||
choices: { melee: "Melee", ranged: "Ranged" }
|
||||
})
|
||||
|
||||
schema.rangedAttacks = new fields.SchemaField({
|
||||
attack1: attackField("1"),
|
||||
attack2: attackField("2"),
|
||||
attack3: attackField("3"),
|
||||
attack4: attackField("4")
|
||||
})
|
||||
|
||||
schema.rangedWeaponRange = new fields.SchemaField({
|
||||
pointBlank: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
short: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
medium: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
long: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
extreme: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
outOfSkill: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
|
||||
})
|
||||
|
||||
return schema
|
||||
}
|
||||
@@ -133,8 +182,24 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
|
||||
* @param {"="|"+"|"++"|"-"|"--"} rollAdvantage If there is an avantage (+), a disadvantage (-), a double advantage (++), a double disadvantage (--) or a normal roll (=).
|
||||
* @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled.
|
||||
*/
|
||||
async roll(rollType, rollTarget) {
|
||||
async roll(rollType, rollTarget, defenderId = undefined, defenderTokenId = undefined, extraShieldDr = 0, d30Effects = {}) {
|
||||
const hasTarget = false
|
||||
|
||||
// Ranged monster defense uses the ranged defense dialog (movement, range, size modifiers)
|
||||
if (rollType === "monster-defense" && rollTarget?.isRangedDefense === true) {
|
||||
let roll = await LethalFantasyRoll.promptRangedDefense({
|
||||
actorId: this.parent.id,
|
||||
actorName: this.parent.name,
|
||||
actorImage: this.parent.img,
|
||||
rollTarget,
|
||||
defenderId,
|
||||
defenderTokenId,
|
||||
})
|
||||
if (!roll) return null
|
||||
await roll.toMessage({}, { messageMode: roll.options.rollMode })
|
||||
return
|
||||
}
|
||||
|
||||
let roll = await LethalFantasyRoll.prompt({
|
||||
rollType,
|
||||
rollTarget,
|
||||
@@ -142,21 +207,50 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
|
||||
actorName: this.parent.name,
|
||||
actorImage: this.parent.img,
|
||||
hasTarget,
|
||||
target: false
|
||||
target: false,
|
||||
defenderId,
|
||||
defenderTokenId,
|
||||
extraShieldDr,
|
||||
damageTier: rollTarget.damageTier || "standard",
|
||||
d30Bleed: d30Effects.d30Bleed || false,
|
||||
d30DamageMultiplier: d30Effects.d30DamageMultiplier || 1,
|
||||
d30DrMultiplier: d30Effects.d30DrMultiplier || 1
|
||||
})
|
||||
if (!roll) return null
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
await roll.toMessage({}, { messageMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
async prepareMonsterRoll(rollType, rollKey, rollDice = undefined, tokenId = undefined) {
|
||||
async prepareMonsterRoll(rollType, rollKey, rollDice = undefined, tokenId = undefined, damageModifier = undefined, defenderId = undefined, defenderTokenId = undefined, extraShieldDr = 0, d30Effects = {}) {
|
||||
let rollTarget
|
||||
switch (rollType) {
|
||||
case "monster-attack":
|
||||
case "monster-defense":
|
||||
case "monster-damage":
|
||||
rollTarget = foundry.utils.duplicate(this.attacks[rollKey])
|
||||
case "monster-damage": {
|
||||
const attacksSet = this.attackMode === "ranged" ? this.rangedAttacks : this.attacks
|
||||
rollTarget = foundry.utils.duplicate(attacksSet[rollKey])
|
||||
rollTarget.rollKey = rollKey
|
||||
rollTarget.attackMode = this.attackMode
|
||||
if (rollType === "monster-defense") {
|
||||
rollTarget.isRangedDefense = game.lethalFantasy?.nextDefenseData?.isRanged ?? false
|
||||
}
|
||||
// Si damageModifier est fourni (depuis le chat), l'utiliser au lieu de celui de la fiche
|
||||
if (damageModifier !== undefined && rollType === "monster-damage") {
|
||||
rollTarget.damageModifier = damageModifier
|
||||
}
|
||||
break
|
||||
}
|
||||
case "monster-attack-hth":
|
||||
case "monster-defense-hth":
|
||||
case "monster-damage-hth":
|
||||
rollTarget = foundry.utils.duplicate(this.combatHTH[rollKey])
|
||||
rollTarget.rollKey = rollKey
|
||||
// Si damageModifier est fourni (depuis le chat), l'utiliser au lieu de celui de la fiche
|
||||
if (damageModifier !== undefined && rollType === "monster-damage-hth") {
|
||||
rollTarget.damageModifier = damageModifier
|
||||
}
|
||||
// Convertir le type de roll pour utiliser les mêmes handlers que les attaques normales
|
||||
rollType = rollType.replace("-hth", "")
|
||||
break
|
||||
case "monster-skill":
|
||||
rollTarget = foundry.utils.duplicate(this.resists[rollKey])
|
||||
@@ -167,10 +261,22 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
|
||||
rollTarget.rollKey = rollKey
|
||||
rollTarget.rollDice = rollDice
|
||||
break
|
||||
case "weapon-damage-small":
|
||||
case "weapon-damage-medium":
|
||||
case "shield-defense": {
|
||||
// Lance directement le dé de défense du bouclier
|
||||
const formula = rollDice || this.combat.shieldDefenseDice
|
||||
const roll = new Roll(formula)
|
||||
await roll.evaluate()
|
||||
|
||||
const flavor = game.i18n.localize("LETHALFANTASY.Label.shieldDefenseDice")
|
||||
await roll.toMessage({
|
||||
flavor,
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.parent })
|
||||
}, { messageMode: roll.options.rollMode ?? game.settings.get("core", "rollMode") })
|
||||
return
|
||||
}
|
||||
case "weapon-damage":
|
||||
case "weapon-attack":
|
||||
case "weapon-defense":
|
||||
case "weapon-defense": {
|
||||
let weapon = this.actor.items.find((i) => i.type === "weapon" && i.id === rollKey)
|
||||
let skill
|
||||
let skills = this.actor.items.filter((i) => i.type === "skill" && i.name.toLowerCase() === weapon.name.toLowerCase())
|
||||
@@ -201,20 +307,22 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
|
||||
return
|
||||
}
|
||||
rollTarget = skill
|
||||
rollTarget.weapon = weapon
|
||||
rollTarget.weapon = foundry.utils.duplicate(weapon)
|
||||
rollTarget.weaponSkillModifier = skill.weaponSkillModifier
|
||||
rollTarget.rollKey = rollKey
|
||||
rollTarget.combat = foundry.utils.duplicate(this.combat)
|
||||
}
|
||||
break
|
||||
default:
|
||||
ui.notifications.error(game.i18n.localize("LETHALFANTASY.Notifications.rollTypeNotFound") + String(rollType))
|
||||
break
|
||||
return
|
||||
}
|
||||
|
||||
// In all cases
|
||||
rollTarget.tokenId = tokenId
|
||||
console.log(rollTarget)
|
||||
await this.roll(rollType, rollTarget)
|
||||
if (rollTarget) {
|
||||
rollTarget.tokenId = tokenId
|
||||
await this.roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr, d30Effects)
|
||||
}
|
||||
}
|
||||
|
||||
async rollInitiative(combatId = undefined, combatantId = undefined) {
|
||||
@@ -233,46 +341,93 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
|
||||
})
|
||||
if (!roll) return null
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
await roll.toMessage({}, { messageMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
async rollProgressionDice(combatId, combatantId) {
|
||||
let combatant = game.combats.get(combatId)?.combatants?.get(combatantId)
|
||||
|
||||
const rollModes = Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
|
||||
// Don't roll if the combatant is defeated
|
||||
if (combatant?.isDefeated) {
|
||||
ui.notifications.warn(`${this.parent.name} is defeated and cannot attack.`)
|
||||
return
|
||||
}
|
||||
|
||||
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes)
|
||||
const fieldRollMode = new foundry.data.fields.StringField({
|
||||
choices: rollModes,
|
||||
blank: false,
|
||||
default: "public",
|
||||
})
|
||||
|
||||
let roll = new Roll("1D8")
|
||||
let roll = new Roll("1D12")
|
||||
await roll.evaluate()
|
||||
let combatant = game.combats.get(combatId)?.combatants?.get(combatantId)
|
||||
|
||||
let msg = await roll.toMessage({ flavor: `Progression Roll for ${this.parent.name}` } )
|
||||
let msg = await roll.toMessage({ flavor: `Progression Roll for ${this.parent.name}` })
|
||||
if (game?.dice3d) {
|
||||
await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
|
||||
}
|
||||
|
||||
let hasAttack = false
|
||||
for (let key in this.attacks) {
|
||||
let attack = this.attacks[key]
|
||||
if (attack.attackScore > 0 && attack.attackScore === roll.total) {
|
||||
const attacksSet = this.attackMode === "ranged" ? this.rangedAttacks : this.attacks
|
||||
for (let key in attacksSet) {
|
||||
let attack = attacksSet[key]
|
||||
if (attack.enabled && attack.attackScore > 0 && attack.attackScore === roll.total) {
|
||||
hasAttack = true
|
||||
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionOKMonster", { isMonster: true, name: this.parent.name, weapon: attack.name, roll: roll.total })
|
||||
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: this.parent }) })
|
||||
const messageContent = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-lethal-fantasy/templates/progression-message.hbs",
|
||||
{
|
||||
success: true,
|
||||
actorName: this.parent.name,
|
||||
weaponName: attack.name,
|
||||
rollResult: roll.total
|
||||
}
|
||||
)
|
||||
await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: this.parent }) })
|
||||
let token = combatant?.token
|
||||
this.prepareMonsterRoll("monster-attack", key, undefined, token?.id)
|
||||
if ( token?.object ) {
|
||||
token.object?.control({releaseOthers: true});
|
||||
if (token?.object) {
|
||||
token.object?.control({ releaseOthers: true });
|
||||
return canvas.animatePan(token.object.center);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check Hand To Hand attacks as well
|
||||
if (!hasAttack) {
|
||||
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionKOMonster", { isMonster: true, name: this.parent.name, roll: roll.total })
|
||||
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: this.parent }) })
|
||||
}
|
||||
for (let key in this.combatHTH) {
|
||||
let attack = this.combatHTH[key]
|
||||
if (attack.enabled && attack.attackScore > 0 && attack.attackScore === roll.total) {
|
||||
hasAttack = true
|
||||
const messageContent = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-lethal-fantasy/templates/progression-message.hbs",
|
||||
{
|
||||
success: true,
|
||||
actorName: this.parent.name,
|
||||
weaponName: `${attack.name} (HTH)`,
|
||||
rollResult: roll.total
|
||||
}
|
||||
)
|
||||
await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: this.parent }) })
|
||||
let token = combatant?.token
|
||||
this.prepareMonsterRoll("monster-attack-hth", key, undefined, token?.id)
|
||||
if (token?.object) {
|
||||
token.object?.control({ releaseOthers: true });
|
||||
return canvas.animatePan(token.object.center);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hasAttack) {
|
||||
const messageContent = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-lethal-fantasy/templates/progression-message.hbs",
|
||||
{
|
||||
success: false,
|
||||
actorName: this.parent.name,
|
||||
rollResult: roll.total
|
||||
}
|
||||
)
|
||||
await ChatMessage.create({ content: messageContent, speaker: ChatMessage.getSpeaker({ actor: this.parent }) })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@ export default class LethalFantasyShield extends foundry.abstract.TypeDataModel
|
||||
const requiredInteger = { required: true, nullable: false, integer: true }
|
||||
|
||||
schema.description = new fields.HTMLField({ required: true, textSearch: true })
|
||||
schema.defense = new fields.StringField({required: true, initial: "d4", choices: SYSTEM.SHIELD_DEFENSE_DICE})
|
||||
schema.defense = new fields.StringField({ required: true, initial: "d4", choices: SYSTEM.SHIELD_DEFENSE_DICE })
|
||||
schema.movementreduction = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
|
||||
schema.hascover = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.damageReduction = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
|
||||
|
||||
schema.standing = new fields.SchemaField({
|
||||
min: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
|
||||
@@ -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.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.components = new fields.SchemaField({
|
||||
@@ -39,6 +41,9 @@ export default class LethalFantasySpell extends foundry.abstract.TypeDataModel {
|
||||
|
||||
schema.attackRoll = new fields.StringField({ required: true, initial: "" })
|
||||
schema.powerRoll = new fields.StringField({ required: true, initial: "" })
|
||||
schema.damageDice = new fields.StringField({ required: false, initial: "" })
|
||||
schema.damageDiceOverpowered = new fields.StringField({ required: false, initial: "" })
|
||||
schema.damageDiceOverpowered2 = new fields.StringField({ required: false, initial: "" })
|
||||
|
||||
return schema
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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() {
|
||||
const fields = foundry.data.fields
|
||||
const schema = {}
|
||||
@@ -45,9 +46,9 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
|
||||
})
|
||||
|
||||
schema.bonuses = new fields.SchemaField({
|
||||
attackBonus: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
damageBonus: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
defenseBonus: 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 }),
|
||||
defenseBonus: new fields.NumberField({ ...requiredInteger, required: true, initial: 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"]
|
||||
|
||||
get weaponCategory() {
|
||||
return game.i18n.localize(CATEGORY[this.weaponType].label)
|
||||
return game.i18n.localize(WEAPON_TYPE[this.weaponType] || this.weaponType)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+29
-246
@@ -1,249 +1,32 @@
|
||||
import { log, loadCompendiumData, loadCompendium, pushCombatOptions, setHookListeners, registerHandlebarsHelpers, getLethargyDice } from "./utils/helpers.mjs"
|
||||
import { hasD30Reroll, processD30BonusDice, _rollD30BonusDie, _buildSpecialName } from "./utils/d30.mjs"
|
||||
import { handleSocketEvent, handleAttackerGritOffer, handleAttackBoosted, showDefenseRequest, compareAttackDefense, applyDamage, offerAttackerGritBonus, getCombatBonusDiceChoices, getShieldReactionData, buildDefenseReactionButtons, promptCombatBonusDie, promptAdHocShield, rollBonusDie, rerollConfiguredRoll } from "./utils/combat.mjs"
|
||||
|
||||
export { log }
|
||||
|
||||
export default class LethalFantasyUtils {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async loadCompendiumData(compendium) {
|
||||
const pack = game.packs.get(compendium)
|
||||
return await pack?.getDocuments() ?? []
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async loadCompendium(compendium, filter = item => true) {
|
||||
let compendiumData = await LethalFantasyUtils.loadCompendiumData(compendium)
|
||||
return compendiumData.filter(filter)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static pushCombatOptions(html, options) {
|
||||
options.push({ name: "Reset Progression", condition: true, icon: '<i class="fas fa-rotate-right"></i>', callback: target => { game.combat.resetProgression(target.data('combatant-id')); } })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static setHookListeners() {
|
||||
|
||||
Hooks.on('renderTokenHUD', async (hud, html, token) => {
|
||||
const lossHPButton = await renderTemplate('systems/fvtt-lethal-fantasy/templates/loss-hp-hud.hbs', {} )
|
||||
html.find('div.left').append(lossHPButton);
|
||||
html.find('img.lethal-hp-loss-hud').click((event) => {
|
||||
event.preventDefault();
|
||||
let hpMenu = html.find('.hp-loss-wrap')[0]
|
||||
if (hpMenu.classList.contains("hp-loss-hud-disabled")) {
|
||||
html.find('.hp-loss-wrap')[0].classList.add('hp-loss-hud-active');
|
||||
html.find('.hp-loss-wrap')[0].classList.remove('hp-loss-hud-disabled');
|
||||
html.find('.hp-loss-wrap')[1].classList.add('hp-loss-hud-active');
|
||||
html.find('.hp-loss-wrap')[1].classList.remove('hp-loss-hud-disabled');
|
||||
html.find('.hp-loss-wrap')[2].classList.add('hp-loss-hud-active');
|
||||
html.find('.hp-loss-wrap')[2].classList.remove('hp-loss-hud-disabled');
|
||||
} else {
|
||||
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')[1].classList.remove('hp-loss-hud-active');
|
||||
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.add('hp-loss-hud-disabled');
|
||||
}
|
||||
})
|
||||
html.find('.loss-hp-hud-click').click((event) => {
|
||||
event.preventDefault();
|
||||
let hpLoss = event.currentTarget.dataset.hpValue;
|
||||
if (token) {
|
||||
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.add('hp-loss-hud-disabled');
|
||||
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')[2].classList.remove('hp-loss-hud-active');
|
||||
html.find('.hp-loss-wrap')[2].classList.add('hp-loss-hud-disabled');
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static handleSocketEvent(msg = {}) {
|
||||
console.log(`handleSocketEvent !`, msg)
|
||||
let actor
|
||||
switch (msg.type) {
|
||||
case "rollInitiative":
|
||||
actor = game.actors.get(msg.actorId)
|
||||
actor.system.rollInitiative(msg.combatId, msg.combatantId)
|
||||
break
|
||||
case "rollProgressionDice":
|
||||
actor = game.actors.get(msg.actorId)
|
||||
actor.system.rollProgressionDice(msg.combatId, msg.combatantId, msg.rollProgressionCount)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
static registerHandlebarsHelpers() {
|
||||
|
||||
Handlebars.registerHelper('isNull', function (val) {
|
||||
return val == null;
|
||||
});
|
||||
Handlebars.registerHelper('match', function (val, search) {
|
||||
if (val && search) {
|
||||
return val?.match(search);
|
||||
}
|
||||
return false
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('exists', function (val) {
|
||||
return val != null && val !== undefined;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('isEmpty', function (list) {
|
||||
if (list) return list.length === 0;
|
||||
else return false;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('notEmpty', function (list) {
|
||||
return list.length > 0;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('isNegativeOrNull', function (val) {
|
||||
return val <= 0;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('isNegative', function (val) {
|
||||
return val < 0;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('isPositive', function (val) {
|
||||
return val > 0;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('equals', function (val1, val2) {
|
||||
return val1 === val2;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('neq', function (val1, val2) {
|
||||
return val1 !== val2;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('gt', function (val1, val2) {
|
||||
return val1 > val2;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('lt', function (val1, val2) {
|
||||
return val1 < val2;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('gte', function (val1, val2) {
|
||||
return val1 >= val2;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('lte', function (val1, val2) {
|
||||
return val1 <= val2;
|
||||
})
|
||||
Handlebars.registerHelper('and', function (val1, val2) {
|
||||
return val1 && val2;
|
||||
})
|
||||
Handlebars.registerHelper('or', function (val1, val2) {
|
||||
return val1 || val2;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('or3', function (val1, val2, val3) {
|
||||
return val1 || val2 || val3;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('for', function (from, to, incr, block) {
|
||||
let accum = '';
|
||||
for (let i = from; i < to; i += incr)
|
||||
accum += block.fn(i);
|
||||
return accum;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('not', function (cond) {
|
||||
return !cond;
|
||||
})
|
||||
Handlebars.registerHelper('count', function (list) {
|
||||
return list.length;
|
||||
})
|
||||
Handlebars.registerHelper('countKeys', function (obj) {
|
||||
return Object.keys(obj).length;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('isEnabled', function (configKey) {
|
||||
return game.settings.get("bol", configKey);
|
||||
})
|
||||
Handlebars.registerHelper('split', function (str, separator, keep) {
|
||||
return str.split(separator)[keep];
|
||||
})
|
||||
|
||||
// If you need to add Handlebars helpers, here are a few useful examples:
|
||||
Handlebars.registerHelper('concat', function () {
|
||||
let outStr = '';
|
||||
for (let arg in arguments) {
|
||||
if (typeof arguments[arg] != 'object') {
|
||||
outStr += arguments[arg];
|
||||
}
|
||||
}
|
||||
return outStr;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('add', function (a, b) {
|
||||
return parseInt(a) + parseInt(b);
|
||||
});
|
||||
Handlebars.registerHelper('mul', function (a, b) {
|
||||
return parseInt(a) * parseInt(b);
|
||||
})
|
||||
Handlebars.registerHelper('sub', function (a, b) {
|
||||
return parseInt(a) - parseInt(b);
|
||||
})
|
||||
Handlebars.registerHelper('abbrev2', function (a) {
|
||||
return a.substring(0, 2);
|
||||
})
|
||||
Handlebars.registerHelper('abbrev3', function (a) {
|
||||
return a.substring(0, 3);
|
||||
})
|
||||
Handlebars.registerHelper('valueAtIndex', function (arr, idx) {
|
||||
return arr[idx];
|
||||
})
|
||||
Handlebars.registerHelper('includesKey', function (items, type, key) {
|
||||
return items.filter(i => i.type === type).map(i => i.system.key).includes(key);
|
||||
})
|
||||
Handlebars.registerHelper('includes', function (array, val) {
|
||||
return array.includes(val);
|
||||
})
|
||||
Handlebars.registerHelper('eval', function (expr) {
|
||||
return eval(expr);
|
||||
})
|
||||
Handlebars.registerHelper('isOwnerOrGM', function (actor) {
|
||||
console.log("Testing actor", actor.isOwner, game.userId)
|
||||
return actor.isOwner || game.isGM;
|
||||
})
|
||||
Handlebars.registerHelper('upperCase', function (text) {
|
||||
if (typeof text !== 'string') return text
|
||||
return text.toUpperCase()
|
||||
})
|
||||
Handlebars.registerHelper('upperFirst', function (text) {
|
||||
if (typeof text !== 'string') return text
|
||||
return text.charAt(0).toUpperCase() + text.slice(1)
|
||||
})
|
||||
Handlebars.registerHelper('upperFirstOnly', function (text) {
|
||||
if (typeof text !== 'string') return text
|
||||
return text.charAt(0).toUpperCase()
|
||||
})
|
||||
|
||||
// Handle v12 removal of this helper
|
||||
Handlebars.registerHelper('select', function (selected, options) {
|
||||
const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected));
|
||||
const rgx = new RegExp(' value=[\"\']' + escapedValue + '[\"\']');
|
||||
const html = options.fn(this);
|
||||
return html.replace(rgx, "$& selected");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
static getLethargyDice(level) {
|
||||
for (let s of SYSTEM.SPELL_LETHARGY_DICE) {
|
||||
if (Number(level) <= s.maxLevel) {
|
||||
return s.dice
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static loadCompendiumData = loadCompendiumData
|
||||
static loadCompendium = loadCompendium
|
||||
static pushCombatOptions = pushCombatOptions
|
||||
static setHookListeners = setHookListeners
|
||||
static registerHandlebarsHelpers = registerHandlebarsHelpers
|
||||
static getLethargyDice = getLethargyDice
|
||||
static hasD30Reroll = hasD30Reroll
|
||||
static processD30BonusDice = processD30BonusDice
|
||||
static _rollD30BonusDie = _rollD30BonusDie
|
||||
static _buildSpecialName = _buildSpecialName
|
||||
static handleSocketEvent = handleSocketEvent
|
||||
static handleAttackerGritOffer = handleAttackerGritOffer
|
||||
static handleAttackBoosted = handleAttackBoosted
|
||||
static showDefenseRequest = showDefenseRequest
|
||||
static compareAttackDefense = compareAttackDefense
|
||||
static applyDamage = applyDamage
|
||||
static offerAttackerGritBonus = offerAttackerGritBonus
|
||||
static getCombatBonusDiceChoices = getCombatBonusDiceChoices
|
||||
static getShieldReactionData = getShieldReactionData
|
||||
static buildDefenseReactionButtons = buildDefenseReactionButtons
|
||||
static promptCombatBonusDie = promptCombatBonusDie
|
||||
static promptAdHocShield = promptAdHocShield
|
||||
static rollBonusDie = rollBonusDie
|
||||
static rerollConfiguredRoll = rerollConfiguredRoll
|
||||
}
|
||||
|
||||
@@ -0,0 +1,909 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
import { log } from "./helpers.mjs"
|
||||
import { processD30BonusDice } from "./d30.mjs"
|
||||
|
||||
export async function handleSocketEvent(msg = {}) {
|
||||
log(`handleSocketEvent !`, msg)
|
||||
let actor
|
||||
switch (msg.type) {
|
||||
case "applyDamage":
|
||||
if (game.user.isGM) {
|
||||
// Prefer the specific token actor (correct for unlinked monsters); fall back to world actor.
|
||||
actor = msg.tokenId
|
||||
? canvas.tokens?.placeables?.find(t => t.id === msg.tokenId)?.actor
|
||||
: (game.combat?.combatants?.find(c => c.actorId === msg.actorId)?.actor
|
||||
?? game.actors.get(msg.actorId))
|
||||
if (actor) await actor.applyDamage(msg.damage)
|
||||
}
|
||||
break
|
||||
case "rollInitiative":
|
||||
if (msg.userId && msg.userId !== game.user.id) break
|
||||
actor = game.actors.get(msg.actorId)
|
||||
await actor.system.rollInitiative(msg.combatId, msg.combatantId)
|
||||
break
|
||||
case "rollProgressionDice":
|
||||
if (msg.userId && msg.userId !== game.user.id) break
|
||||
actor = game.actors.get(msg.actorId)
|
||||
await actor.system.rollProgressionDice(msg.combatId, msg.combatantId, msg.rollProgressionCount)
|
||||
break
|
||||
case "requestDefense":
|
||||
// Vérifier si le message est destiné à cet utilisateur
|
||||
if (msg.userId === game.user.id) {
|
||||
showDefenseRequest(msg)
|
||||
}
|
||||
break
|
||||
case "offerAttackerGrit":
|
||||
// Vérifier si le message est destiné à cet utilisateur
|
||||
if (msg.userId === game.user.id) {
|
||||
handleAttackerGritOffer(msg)
|
||||
}
|
||||
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) {
|
||||
handleAttackBoosted(msg)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
export async function handleAttackerGritOffer(msg) {
|
||||
const { attackerId, attackRoll, defenseRoll, attackerName, defenderName, attackWeaponId, attackRollType, attackRollKey, defenderId } = msg
|
||||
|
||||
const attacker = game.actors.get(attackerId)
|
||||
if (!attacker) {
|
||||
console.warn("Attacker not found:", attackerId)
|
||||
return
|
||||
}
|
||||
|
||||
const attackBonus = await offerAttackerGritBonus(
|
||||
attacker,
|
||||
attackRoll,
|
||||
defenseRoll,
|
||||
attackerName,
|
||||
defenderName
|
||||
)
|
||||
|
||||
const attackRollFinal = attackRoll + attackBonus
|
||||
|
||||
// Maintenant créer le message de comparaison
|
||||
await compareAttackDefense({
|
||||
attackerName,
|
||||
attackerId,
|
||||
attackRoll: attackRollFinal,
|
||||
attackWeaponId,
|
||||
attackRollType,
|
||||
attackRollKey,
|
||||
defenderName,
|
||||
defenderId,
|
||||
defenseRoll
|
||||
})
|
||||
}
|
||||
|
||||
export async function 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 processD30BonusDice(defenseD30message, "defense", null, defender, true)
|
||||
if (d30Result.modifier) {
|
||||
updatedDefenseRoll += d30Result.modifier
|
||||
if (d30Result.modifier > 0) {
|
||||
const msg = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {type:"d30Bonus", actorName:defenderName, value:d30Result.modifier, side:"defense"})
|
||||
await ChatMessage.create({content: msg, speaker: ChatMessage.getSpeaker({actor: defender})})
|
||||
}
|
||||
}
|
||||
if (d30Result.specialEffect === "flag") {
|
||||
const msg = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {type:"d30Flag", actorName:defenderName, specialName:d30Result.specialName || "Special Effect"})
|
||||
await ChatMessage.create({content: msg, speaker: ChatMessage.getSpeaker({actor: defender})})
|
||||
}
|
||||
if (d30Result.specialEffect === "drMultiplier") {
|
||||
defenseDrMultiplier = d30Result.multiplier
|
||||
const msg = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {type:"d30DRMultiplier", actorName:defenderName, value:d30Result.multiplier})
|
||||
await ChatMessage.create({content: msg, speaker: ChatMessage.getSpeaker({actor: defender})})
|
||||
}
|
||||
}
|
||||
|
||||
// Show the defense reaction dialog — while-loop for multiple reactions
|
||||
if (defender) {
|
||||
while (updatedDefenseRoll < attackRollFinal) {
|
||||
const shieldData = canShieldReact ? { label: shieldLabel, formula: shieldFormula, damageReduction: shieldDr } : null
|
||||
const buttons = buildDefenseReactionButtons(defender, { canRerollDefense: false, shieldData, canShieldReact, canAdHocShield: canAdHoc })
|
||||
|
||||
const choice = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Defense reactions — attack boosted" },
|
||||
classes: ["lethalfantasy"],
|
||||
content: await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/dialogs/defense-reaction.hbs", {
|
||||
attackerName,
|
||||
attackRoll: attackRollFinal,
|
||||
attackStatus: "boosted attack to",
|
||||
defenderName,
|
||||
defenseRoll: updatedDefenseRoll,
|
||||
defenseStatus: "currently has",
|
||||
d30message: null,
|
||||
offerText: "The attack was boosted! Choose how to improve the defense."
|
||||
}),
|
||||
buttons,
|
||||
rejectClose: false
|
||||
})
|
||||
|
||||
if (!choice || choice === "continue") break
|
||||
|
||||
if (choice === "grit") {
|
||||
const bonusRoll = await rollBonusDie("1d6", defender)
|
||||
updatedDefenseRoll += bonusRoll
|
||||
await defender.update({ "system.grit.current": Math.max(0, (Number(defender.system?.grit?.current) || 0) - 1) })
|
||||
const gritRmContent = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {type:"grit", actorName:defenderName, resource:"Grit", value:bonusRoll, side:"defense"})
|
||||
await ChatMessage.create({content: gritRmContent, speaker: ChatMessage.getSpeaker({actor: defender})})
|
||||
} else if (choice === "luck") {
|
||||
const bonusRoll = await rollBonusDie("1d6", defender)
|
||||
updatedDefenseRoll += bonusRoll
|
||||
await defender.update({ "system.luck.current": Math.max(0, (Number(defender.system?.luck?.current) || 0) - 1) })
|
||||
const luckRmContent = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {type:"luck", actorName:defenderName, resource:"Luck", value:bonusRoll, side:"defense"})
|
||||
await ChatMessage.create({content: luckRmContent, speaker: ChatMessage.getSpeaker({actor: defender})})
|
||||
} else if (choice === "bonusDie") {
|
||||
const bonusDie = await promptCombatBonusDie(defenderName, "attack", updatedDefenseRoll, attackRollFinal)
|
||||
if (bonusDie) {
|
||||
const bonusRoll = await rollBonusDie(bonusDie, defender)
|
||||
updatedDefenseRoll += bonusRoll
|
||||
const bonusRmContent = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {type:"bonusDie", actorName:defenderName, formula:bonusDie.toUpperCase(), value:bonusRoll, side:"defense"})
|
||||
await ChatMessage.create({content: bonusRmContent, speaker: ChatMessage.getSpeaker({actor: defender})})
|
||||
}
|
||||
} else if (choice === "shieldReact" && canShieldReact) {
|
||||
const shieldBonus = await rollBonusDie(shieldFormula, defender)
|
||||
const newDefenseTotal = updatedDefenseRoll + shieldBonus
|
||||
updatedDefenseRoll = newDefenseTotal
|
||||
canShieldReact = false
|
||||
if (newDefenseTotal >= attackRollFinal) {
|
||||
shieldBlocked = true
|
||||
shieldReaction = { damageReduction: shieldDr, label: shieldLabel, bonus: shieldBonus }
|
||||
const shieldBlockContent = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {type:"shieldBlock", actorName:defenderName, shieldLabel, shieldBonus, newTotal:newDefenseTotal, opposingRoll:attackRollFinal, shieldDR:shieldDr})
|
||||
await ChatMessage.create({
|
||||
content: shieldBlockContent,
|
||||
speaker: ChatMessage.getSpeaker({ actor: defender })
|
||||
})
|
||||
} else {
|
||||
const shieldFailContent = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {type:"shieldFail", actorName:defenderName, shieldLabel, shieldBonus, newTotal:newDefenseTotal, opposingRoll:attackRollFinal})
|
||||
await ChatMessage.create({
|
||||
content: shieldFailContent,
|
||||
speaker: ChatMessage.getSpeaker({ actor: defender })
|
||||
})
|
||||
}
|
||||
} else if (choice === "adHocShield" && canAdHoc) {
|
||||
const adHoc = await promptAdHocShield(defenderName, attackRollFinal, updatedDefenseRoll)
|
||||
if (adHoc) {
|
||||
const shieldBonus = await 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 }
|
||||
const adHocShieldBlockContent = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {type:"shieldBlock", actorName:defenderName, shieldLabel: `${adHoc.formula.toUpperCase()} shield`, shieldBonus, newTotal:newDefenseTotal, opposingRoll:attackRollFinal, shieldDR:adHoc.damageReduction})
|
||||
await ChatMessage.create({
|
||||
content: adHocShieldBlockContent,
|
||||
speaker: ChatMessage.getSpeaker({ actor: defender })
|
||||
})
|
||||
} else {
|
||||
const adHocShieldFailContent = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {type:"shieldFail", actorName:defenderName, shieldLabel: `${adHoc.formula.toUpperCase()} shield`, shieldBonus, newTotal:newDefenseTotal, opposingRoll:attackRollFinal})
|
||||
await ChatMessage.create({
|
||||
content: adHocShieldFailContent,
|
||||
speaker: ChatMessage.getSpeaker({ actor: defender })
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const finalShieldDR = shieldBlocked ? (shieldReaction?.damageReduction || 0) : 0
|
||||
const outcome = shieldBlocked ? "shielded-hit" : (updatedDefenseRoll >= attackRollFinal ? "miss" : "hit")
|
||||
|
||||
await 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
|
||||
})
|
||||
}
|
||||
|
||||
export async function showDefenseRequest(msg) {
|
||||
const attackerName = msg.attackerName
|
||||
const attackerId = msg.attackerId
|
||||
const defenderName = msg.defenderName
|
||||
const weaponName = msg.weaponName || "attack"
|
||||
const attackRoll = msg.attackRoll
|
||||
const attackWeaponId = msg.attackWeaponId
|
||||
const attackRollType = msg.attackRollType
|
||||
const attackRollKey = msg.attackRollKey
|
||||
const attackD30result = msg.attackD30result
|
||||
const attackD30message = msg.attackD30message
|
||||
const attackRerollContext = msg.attackRerollContext
|
||||
const combatantId = msg.combatantId
|
||||
const tokenId = msg.tokenId
|
||||
|
||||
// Récupérer le défenseur - essayer d'abord depuis le combat, puis depuis le token
|
||||
let defender = null
|
||||
|
||||
if (game.combat && combatantId) {
|
||||
const combatant = game.combat.combatants.get(combatantId)
|
||||
if (combatant) {
|
||||
defender = combatant.actor
|
||||
}
|
||||
}
|
||||
|
||||
// Si pas trouvé dans le combat, chercher le token directement
|
||||
if (!defender && tokenId) {
|
||||
const token = canvas.tokens.get(tokenId)
|
||||
if (token) {
|
||||
defender = token.actor
|
||||
}
|
||||
}
|
||||
|
||||
if (!defender) {
|
||||
ui.notifications.error("Defender actor not found")
|
||||
return
|
||||
}
|
||||
|
||||
// Resolve the specific token ID now while we still have combatant/token context.
|
||||
// This is passed through to the damage roll so the GM-side socket handler can find the
|
||||
// correct synthetic actor for unlinked tokens (avoids wrong-instance damage with multiple
|
||||
// unlinked copies of the same monster).
|
||||
const defenderTokenId = (() => {
|
||||
if (game.combat && combatantId) {
|
||||
const cbt = game.combat.combatants.get(combatantId)
|
||||
if (cbt?.token?.id) return cbt.token.id
|
||||
}
|
||||
return tokenId ?? canvas.tokens?.placeables?.find(t => t.actor?.id === defender.id)?.id ?? null
|
||||
})()
|
||||
|
||||
const isMonster = defender.type === "monster"
|
||||
|
||||
const _storeNextDefenseData = (opts = {}) => {
|
||||
game.lethalFantasy = game.lethalFantasy || {}
|
||||
game.lethalFantasy.nextDefenseData = {
|
||||
attackerId, attackRoll, attackerName, defenderName,
|
||||
attackWeaponId, attackRollType, attackRollKey,
|
||||
attackD30result, attackD30message, attackRerollContext,
|
||||
damageTier: msg.damageTier,
|
||||
defenderId: defender.id, defenderTokenId,
|
||||
...(msg.attackNaturalRoll !== undefined && { attackNaturalRoll: msg.attackNaturalRoll }),
|
||||
...(opts.isRanged !== undefined && { isRanged: opts.isRanged })
|
||||
}
|
||||
}
|
||||
|
||||
log(`[LF] showDefenseRequest | attackRollType=${attackRollType} isMonster=${isMonster} defender=${defender?.name}`)
|
||||
|
||||
// Spell/miracle attacks use saving throws instead of weapon defense
|
||||
const isSpellAttack = attackRollType === "spell-attack" || attackRollType === "miracle-attack"
|
||||
if (isSpellAttack) {
|
||||
const savesConfig = isMonster ? SYSTEM.MONSTER_SAVES : SYSTEM.SAVES
|
||||
const combatSaves = ["will", "dodge", "toughness"]
|
||||
const savesList = Object.values(savesConfig)
|
||||
.filter(s => combatSaves.includes(s.id))
|
||||
.map(s => ({id: s.id, label: game.i18n.localize(s.label)}))
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/dialogs/defense-request-save.hbs", {
|
||||
attackerName, defenderName, weaponName, attackRoll, saves: savesList
|
||||
})
|
||||
|
||||
const result = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Saving Throw vs Spell" },
|
||||
classes: ["lethalfantasy"],
|
||||
content,
|
||||
buttons: [
|
||||
{
|
||||
action: "rollSave",
|
||||
type: "button",
|
||||
label: "Roll Save",
|
||||
icon: "fa-solid fa-person-running",
|
||||
callback: (event, button) => button.form.elements.saveKey.value,
|
||||
},
|
||||
],
|
||||
rejectClose: false
|
||||
})
|
||||
|
||||
if (result) {
|
||||
game.lethalFantasy = game.lethalFantasy || {}
|
||||
game.lethalFantasy.spellDefense = true // pré-cocher "Save against spell" dans le dialog
|
||||
_storeNextDefenseData()
|
||||
if (isMonster) {
|
||||
await defender.system.prepareMonsterRoll("save", result)
|
||||
} else {
|
||||
await defender.prepareRoll("save", result)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Pour les monstres, récupérer les attaques activées
|
||||
if (isMonster) {
|
||||
const attacksSet = defender.system.attackMode === "ranged" ? defender.system.rangedAttacks : defender.system.attacks
|
||||
const enabledAttacks = Object.entries(attacksSet).filter(([key, attack]) => attack.enabled)
|
||||
|
||||
if (enabledAttacks.length === 0) {
|
||||
ui.notifications.warn("No enabled attacks available for defense")
|
||||
return
|
||||
}
|
||||
|
||||
// Créer le contenu du dialogue pour monstre
|
||||
const attacksList = enabledAttacks.map(([key, attack]) => ({key, name: attack.name}))
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/dialogs/defense-request-monster.hbs", {
|
||||
attackerName, defenderName, weaponName, attackRoll, attacks: attacksList
|
||||
})
|
||||
|
||||
// Afficher le dialogue
|
||||
const result = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: msg.isRanged ? "Ranged Defense Roll" : "Defense Roll" },
|
||||
classes: ["lethalfantasy"],
|
||||
content,
|
||||
buttons: [
|
||||
{
|
||||
action: "rangeDefense",
|
||||
type: "button",
|
||||
label: "Roll Defense",
|
||||
icon: "fa-solid fa-shield",
|
||||
callback: (event, button, dialog) => {
|
||||
const attackKey = button.form.elements.attackKey.value
|
||||
return attackKey
|
||||
},
|
||||
},
|
||||
],
|
||||
rejectClose: false
|
||||
})
|
||||
|
||||
// Si l'utilisateur a validé, lancer le jet de défense
|
||||
if (result) {
|
||||
_storeNextDefenseData({ isRanged: msg.isRanged })
|
||||
|
||||
await defender.system.prepareMonsterRoll("monster-defense", result)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Pour les personnages, récupérer les armes équipées
|
||||
// Si l'attaque est une attaque à distance, utiliser le dialogue de défense à distance
|
||||
if (msg.isRanged) {
|
||||
const { default: LethalFantasyRoll } = await import("../documents/roll.mjs")
|
||||
const roll = await LethalFantasyRoll.promptRangedDefense({
|
||||
actorId: defender.id,
|
||||
actorName: defender.name,
|
||||
actorImage: defender.img,
|
||||
})
|
||||
if (roll) {
|
||||
_storeNextDefenseData({ isRanged: true })
|
||||
await roll.toMessage({}, { messageMode: roll.options.rollMode })
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Pour les personnages, récupérer les armes équipées
|
||||
const equippedWeapons = defender.items.filter(i =>
|
||||
i.type === "weapon" && i.system.equipped === true
|
||||
)
|
||||
|
||||
if (equippedWeapons.length === 0) {
|
||||
ui.notifications.warn("No equipped weapons for defense")
|
||||
return
|
||||
}
|
||||
|
||||
// Créer le contenu du dialogue pour personnage
|
||||
const weaponsList = equippedWeapons.map(w => ({id: w.id, name: w.name}))
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/dialogs/defense-request-character.hbs", {
|
||||
attackerName, defenderName, weaponName, attackRoll, weapons: weaponsList
|
||||
})
|
||||
|
||||
// Afficher le dialogue
|
||||
const result = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Defense Roll" },
|
||||
classes: ["lethalfantasy"],
|
||||
content,
|
||||
buttons: [
|
||||
{
|
||||
action: "defenseRoll",
|
||||
type: "button",
|
||||
label: "Roll Defense",
|
||||
icon: "fa-solid fa-shield",
|
||||
callback: (event, button, dialog) => {
|
||||
const weaponId = button.form.elements.weaponId.value
|
||||
return weaponId
|
||||
},
|
||||
},
|
||||
],
|
||||
rejectClose: false
|
||||
})
|
||||
|
||||
// Si l'utilisateur a validé, lancer le jet de défense
|
||||
if (result) {
|
||||
_storeNextDefenseData({ isRanged: msg.isRanged })
|
||||
|
||||
log("Storing defense data for character:", defender.id)
|
||||
|
||||
await defender.prepareRoll("weapon-defense", result)
|
||||
}
|
||||
}
|
||||
|
||||
export function buildDefenseReactionButtons(defender, { canRerollDefense = false, shieldData = null, canShieldReact = false, canAdHocShield = false } = {}) {
|
||||
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 (canRerollDefense) {
|
||||
buttons.push({ action: "rerollDefense", type: "button", label: "Re-roll defense (Mulligan)", icon: "fa-solid fa-rotate-right", callback: () => "rerollDefense" })
|
||||
}
|
||||
if (canShieldReact && shieldData) {
|
||||
buttons.push({ action: "shieldReact", type: "button", label: `Roll shield (${shieldData.label})`, icon: "fa-solid fa-shield", callback: () => "shieldReact" })
|
||||
} else if (canAdHocShield) {
|
||||
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" })
|
||||
return buttons
|
||||
}
|
||||
|
||||
export function getCombatBonusDiceChoices() {
|
||||
return ["1d4", "1d6", "1d8", "1d10", "1d12", "1d20", "1d20e"]
|
||||
}
|
||||
|
||||
export function getShieldReactionData(actor) {
|
||||
if (!actor) return null
|
||||
if (actor.type === "monster") {
|
||||
const formula = actor.system.combat?.shieldDefenseDice
|
||||
const damageReduction = actor.getShieldDR()
|
||||
if (!formula || damageReduction <= 0) return null
|
||||
return {
|
||||
label: game.i18n.localize("LETHALFANTASY.Label.shieldDefenseDice"),
|
||||
formula,
|
||||
damageReduction
|
||||
}
|
||||
}
|
||||
|
||||
const equippedShields = actor.items.filter(item => item.type === "shield" && item.system.equipped)
|
||||
if (equippedShields.length === 0) return null
|
||||
|
||||
const shield = equippedShields[0]
|
||||
return {
|
||||
label: shield.name,
|
||||
formula: shield.system.defense,
|
||||
damageReduction: actor.getShieldDR(),
|
||||
shieldId: shield.id
|
||||
}
|
||||
}
|
||||
|
||||
export async function promptCombatBonusDie(actorName, sideLabel, currentRoll, opposingRoll) {
|
||||
const choicesList = getCombatBonusDiceChoices()
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/dialogs/bonus-die-select.hbs", {
|
||||
actorName, currentRoll, opposingRoll, sideLabel, choices: choicesList
|
||||
})
|
||||
|
||||
return await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Add Bonus Die" },
|
||||
classes: ["lethalfantasy"],
|
||||
content,
|
||||
buttons: [
|
||||
{
|
||||
action: "roll",
|
||||
type: "button",
|
||||
label: "Roll Bonus Die",
|
||||
icon: "fa-solid fa-dice",
|
||||
callback: (event, button) => {
|
||||
const sel = button.form?.elements?.bonusDie ?? button.closest("form")?.elements?.bonusDie
|
||||
return sel?.value ?? choicesList[0]
|
||||
}
|
||||
},
|
||||
{
|
||||
action: "cancel",
|
||||
type: "button",
|
||||
label: "Cancel",
|
||||
icon: "fa-solid fa-xmark",
|
||||
callback: () => null
|
||||
}
|
||||
],
|
||||
rejectClose: false
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt the GM or player to choose an ad-hoc shield dice and DR value.
|
||||
* Used when the defender has no pre-configured shield equipment.
|
||||
* @param {string} defenderName
|
||||
* @param {number} attackRoll
|
||||
* @param {number} defenseRoll
|
||||
* @returns {Promise<{formula: string, damageReduction: number}|null>}
|
||||
*/
|
||||
export async function promptAdHocShield(defenderName, attackRoll, defenseRoll) {
|
||||
const choicesList = getCombatBonusDiceChoices()
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/dialogs/ad-hoc-shield.hbs", {
|
||||
defenderName, attackRoll, defenseRoll, choices: choicesList
|
||||
})
|
||||
|
||||
const raw = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Ad-hoc Shield Roll" },
|
||||
classes: ["lethalfantasy"],
|
||||
content,
|
||||
buttons: [
|
||||
{
|
||||
action: "roll",
|
||||
type: "button",
|
||||
label: "Roll Shield",
|
||||
icon: "fa-solid fa-shield",
|
||||
callback: (event, button) => {
|
||||
const shieldDice = button.form?.elements?.shieldDice ?? button.closest("form")?.elements?.shieldDice
|
||||
const shieldDR = button.form?.elements?.shieldDR ?? button.closest("form")?.elements?.shieldDR
|
||||
return {
|
||||
formula: shieldDice?.value ?? "1d6",
|
||||
damageReduction: Number(shieldDR?.value) || 0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
action: "cancel",
|
||||
type: "button",
|
||||
label: "Cancel",
|
||||
icon: "fa-solid fa-xmark",
|
||||
callback: () => null
|
||||
}
|
||||
],
|
||||
rejectClose: false
|
||||
})
|
||||
|
||||
return raw ?? null
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll a bonus die formula, optionally showing Dice So Nice animation.
|
||||
* @param {string} formula
|
||||
* @param {Actor} actor
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
export async function rollBonusDie(formula, actor) {
|
||||
const roll = new Roll(formula)
|
||||
await roll.evaluate()
|
||||
if (game?.dice3d) {
|
||||
await game.dice3d.showForRoll(roll, game.user, true)
|
||||
}
|
||||
return roll.total
|
||||
}
|
||||
|
||||
export async function rerollConfiguredRoll(rerollContext = {}) {
|
||||
const RollClass = CONFIG.Dice.rolls.find(r => r.name === "LethalFantasyRoll")
|
||||
if (typeof RollClass?.prompt !== "function") {
|
||||
ui.notifications.error("Lethal Fantasy roll class not available for reroll")
|
||||
return null
|
||||
}
|
||||
|
||||
return await RollClass.prompt({
|
||||
...foundry.utils.duplicate(rerollContext),
|
||||
rollContext: foundry.utils.duplicate(rerollContext.rollContext || {}),
|
||||
hasTarget: false,
|
||||
target: false
|
||||
})
|
||||
}
|
||||
|
||||
export async function offerAttackerGritBonus(attacker, currentAttackRoll, defenseRoll, attackerName, defenderName) {
|
||||
let totalBonus = 0
|
||||
let keepOffering = true
|
||||
|
||||
while (keepOffering && currentAttackRoll + totalBonus <= defenseRoll) {
|
||||
const currentGrit = attacker.system.grit.current
|
||||
|
||||
if (currentGrit <= 0) {
|
||||
break
|
||||
}
|
||||
|
||||
const buttons = [
|
||||
{
|
||||
action: "grit",
|
||||
type: "button",
|
||||
label: `Spend 1 Grit (+1D6) [${currentGrit} left]`,
|
||||
icon: "fa-solid fa-fist-raised",
|
||||
callback: () => "grit"
|
||||
},
|
||||
{
|
||||
action: "continue",
|
||||
type: "button",
|
||||
label: "Continue (no bonus)",
|
||||
icon: "fa-solid fa-forward",
|
||||
callback: () => "continue"
|
||||
}
|
||||
]
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/dialogs/attack-grit.hbs", {
|
||||
attackerName,
|
||||
currentAttackRollWithBonus: currentAttackRoll + totalBonus,
|
||||
defenderName,
|
||||
defenseRoll,
|
||||
totalBonus
|
||||
})
|
||||
|
||||
const choice = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Attack with Grit" },
|
||||
classes: ["lethalfantasy"],
|
||||
content,
|
||||
buttons,
|
||||
rejectClose: false
|
||||
})
|
||||
|
||||
if (!choice || choice === "continue") {
|
||||
keepOffering = false
|
||||
break
|
||||
}
|
||||
|
||||
const bonusRoll = new Roll("1d6")
|
||||
await bonusRoll.evaluate()
|
||||
|
||||
if (game?.dice3d) {
|
||||
await game.dice3d.showForRoll(bonusRoll, game.user, true)
|
||||
}
|
||||
|
||||
totalBonus += bonusRoll.total
|
||||
|
||||
await attacker.update({ "system.grit.current": currentGrit - 1 })
|
||||
const gritRm = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {type:"grit", actorName:attackerName, resource:"Grit", value:bonusRoll.total, side:"attack"})
|
||||
await ChatMessage.create({content: gritRm, speaker: ChatMessage.getSpeaker({actor: attacker})})
|
||||
}
|
||||
|
||||
return totalBonus
|
||||
}
|
||||
|
||||
export async function compareAttackDefense(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 shieldDamageReduction = data.shieldDamageReduction || 0
|
||||
const outcome = data.outcome || (data.attackRoll > data.defenseRoll ? "hit" : "miss")
|
||||
const isAttackWin = outcome !== "miss"
|
||||
log("isAttackWin:", isAttackWin, "attackRoll:", data.attackRoll, "defenseRoll:", data.defenseRoll)
|
||||
|
||||
let damageButton = ""
|
||||
if (isAttackWin && (data.attackWeaponId || data.attackRollKey)) {
|
||||
log("Creating damage button. defenderId:", data.defenderId)
|
||||
// Déterminer le type de dégâts à lancer
|
||||
if (data.attackRollType === "weapon-attack") {
|
||||
damageButton = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/damage-button.hbs", {
|
||||
type: "weapon",
|
||||
attackerId: data.attackerId,
|
||||
defenderId: data.defenderId,
|
||||
defenderTokenId: data.defenderTokenId || "",
|
||||
shieldDamageReduction: shieldDamageReduction,
|
||||
attackWeaponId: data.attackWeaponId,
|
||||
d30Bleed,
|
||||
d30DamageMultiplier,
|
||||
d30DrMultiplier
|
||||
})
|
||||
} else if (data.attackRollType === "monster-attack") {
|
||||
damageButton = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/damage-button.hbs", {
|
||||
type: "monster",
|
||||
attackerId: data.attackerId,
|
||||
defenderId: data.defenderId,
|
||||
defenderTokenId: data.defenderTokenId || "",
|
||||
shieldDamageReduction: shieldDamageReduction,
|
||||
attackRollKey: data.attackRollKey,
|
||||
d30Bleed,
|
||||
d30DamageMultiplier,
|
||||
d30DrMultiplier
|
||||
})
|
||||
} else if (data.attackRollType === "spell-attack" || data.attackRollType === "miracle-attack") {
|
||||
const attacker = game.actors.get(data.attackerId)
|
||||
const spell = attacker?.items.get(data.attackWeaponId || data.attackRollKey)
|
||||
const chosenTier = data.damageTier || "standard"
|
||||
const allTiers = [
|
||||
{ id: "standard", formula: spell?.system?.damageDice, label: "Standard" },
|
||||
{ id: "overpowered", formula: spell?.system?.damageDiceOverpowered, label: "Overpowered" },
|
||||
{ id: "overpowered2", formula: spell?.system?.damageDiceOverpowered2, label: "Overpowered 2" },
|
||||
]
|
||||
const tierData = allTiers.filter(t => t.id === chosenTier && t.formula).map(t => ({
|
||||
formula: Handlebars.escapeExpression(t.formula),
|
||||
label: t.label
|
||||
}))
|
||||
if (tierData.length) {
|
||||
damageButton = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/damage-button.hbs", {
|
||||
type: "spell",
|
||||
attackerId: data.attackerId,
|
||||
defenderId: data.defenderId,
|
||||
defenderTokenId: data.defenderTokenId || "",
|
||||
tiers: tierData,
|
||||
d30Bleed,
|
||||
d30DamageMultiplier,
|
||||
d30DrMultiplier
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const resultMessage = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/combat-result.hbs", {
|
||||
isAttackWin,
|
||||
outcome,
|
||||
attackerName: data.attackerName,
|
||||
defenderName: data.defenderName,
|
||||
attackRoll: data.attackRoll,
|
||||
defenseRoll: data.defenseRoll,
|
||||
shieldDamageReduction: shieldDamageReduction,
|
||||
damageButton
|
||||
})
|
||||
|
||||
log("Creating combat result message...")
|
||||
await ChatMessage.create({
|
||||
content: resultMessage,
|
||||
speaker: { alias: "Combat System" }
|
||||
})
|
||||
log("Combat result message created!")
|
||||
}
|
||||
|
||||
export async function applyDamage(message, event) {
|
||||
// Récupérer les données du message
|
||||
let combatantId = event.currentTarget.dataset.combatantId
|
||||
if (!combatantId) {
|
||||
ui.notifications.error("No combatant selected")
|
||||
return
|
||||
}
|
||||
|
||||
// Try to find the target: first as a combat combatant, then as a scene token
|
||||
let targetActor = null
|
||||
if (game.combat) {
|
||||
const combatant = game.combat.combatants.get(combatantId)
|
||||
if (combatant) {
|
||||
targetActor = combatant.token?.actor || game.actors.get(combatant.actorId)
|
||||
}
|
||||
}
|
||||
if (!targetActor) {
|
||||
// Fall back to scene token lookup (non-combat tokens use tokenId as their combatantId)
|
||||
const token = canvas.tokens?.placeables?.find(t => t.id === combatantId)
|
||||
targetActor = token?.actor
|
||||
}
|
||||
if (!targetActor) {
|
||||
ui.notifications.error("Target actor not found")
|
||||
return
|
||||
}
|
||||
|
||||
// Récupérer les données de dégâts du message
|
||||
// Use options.rollTotal (includes weapon modifier bonus) rather than roll.total (dice formula only)
|
||||
let damageTotal = message.rolls[0]?.options?.rollTotal ?? message.rolls[0]?.total ?? 0
|
||||
let weaponName = message.rolls[0]?.options?.rollName || "Unknown Weapon"
|
||||
|
||||
// Calculer les DR
|
||||
let armorDR = targetActor.computeDamageReduction() || 0
|
||||
let shieldDR = targetActor.getShieldDR() || 0
|
||||
let totalDR = armorDR + shieldDR
|
||||
|
||||
// Créer le dialogue
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-lethal-fantasy/templates/apply-damage-dialog.hbs",
|
||||
{
|
||||
targetName: targetActor.name,
|
||||
weaponName: weaponName,
|
||||
damageTotal: damageTotal,
|
||||
armorDR: armorDR,
|
||||
shieldDR: shieldDR,
|
||||
totalDR: totalDR,
|
||||
damageNoDR: damageTotal,
|
||||
damageWithArmor: Math.max(0, damageTotal - armorDR),
|
||||
damageWithAll: Math.max(0, damageTotal - totalDR)
|
||||
}
|
||||
)
|
||||
|
||||
const result = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Apply Damage" },
|
||||
classes: ["lethalfantasy"],
|
||||
position: { width: 280 },
|
||||
content,
|
||||
buttons: [
|
||||
{
|
||||
action: "noDR",
|
||||
type: "button",
|
||||
label: "No DR",
|
||||
callback: () => ({ drType: "none", damage: damageTotal })
|
||||
},
|
||||
{
|
||||
action: "armorDR",
|
||||
type: "button",
|
||||
label: "With Armor DR",
|
||||
callback: () => ({ drType: "armor", damage: Math.max(0, damageTotal - armorDR) })
|
||||
},
|
||||
{
|
||||
action: "allDR",
|
||||
type: "button",
|
||||
label: "With Armor + Shield DR",
|
||||
callback: () => ({ drType: "all", damage: Math.max(0, damageTotal - totalDR) })
|
||||
},
|
||||
{
|
||||
action: "cancel",
|
||||
type: "button",
|
||||
label: "Cancel",
|
||||
callback: () => null
|
||||
}
|
||||
],
|
||||
rejectClose: false
|
||||
})
|
||||
|
||||
if (result && result.damage !== undefined) {
|
||||
await targetActor.applyDamage(-result.damage)
|
||||
|
||||
// Message de confirmation
|
||||
let drText = ""
|
||||
if (result.drType === "armor") {
|
||||
drText = `Armor DR: ${armorDR}`
|
||||
} else if (result.drType === "all") {
|
||||
drText = `Total DR: ${totalDR}`
|
||||
}
|
||||
|
||||
const messageContent = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-lethal-fantasy/templates/damage-applied-message.hbs",
|
||||
{
|
||||
targetName: targetActor.name,
|
||||
damage: result.damage,
|
||||
drText: drText,
|
||||
weaponName: weaponName
|
||||
}
|
||||
)
|
||||
|
||||
await ChatMessage.create({
|
||||
user: game.user.id,
|
||||
speaker: { alias: targetActor.name },
|
||||
mode: "gm",
|
||||
content: messageContent
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
export { log } from "./helpers.mjs"
|
||||
|
||||
export function hasD30Reroll(d30Message) {
|
||||
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}>}
|
||||
*/
|
||||
export async function 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 _rollD30BonusDie(d30Message.dice, actor, !canDialog)
|
||||
return { modifier, specialEffect: null, specialName: null }
|
||||
}
|
||||
|
||||
// ── Choice type ── auto-roll bonus dice, alert about special effects
|
||||
if (d30Message.type === "choice") {
|
||||
// Non-controlling client can't roll dice here — the controlling client
|
||||
// sends the updated values via socket.
|
||||
if (!canDialog) {
|
||||
return { modifier: 0, specialEffect: null, specialName: null }
|
||||
}
|
||||
|
||||
// Auto-roll bonus dice (like d6E on 27 — no dialog)
|
||||
const bonusChoice = d30Message.choices.find(c => c.type === "bonus_dice")
|
||||
let modifier = 0
|
||||
if (bonusChoice) {
|
||||
modifier = await _rollD30BonusDie(bonusChoice.dice, actor)
|
||||
}
|
||||
|
||||
// Inform about special strike/defense or other effects (informational only)
|
||||
const specialChoice = d30Message.choices.find(c => c.type === "special_strike" || c.type === "special_defense")
|
||||
if (specialChoice) {
|
||||
return { modifier, specialEffect: "flag", specialName: _buildSpecialName(specialChoice, naturalRoll) }
|
||||
}
|
||||
|
||||
// Non-standard choice (spell_calamity, etc.) — report it
|
||||
const nonStandardChoice = d30Message.choices.find(c => c.type !== "bonus_dice")
|
||||
if (nonStandardChoice) {
|
||||
return { modifier, specialEffect: "flag", specialName: _buildSpecialName(nonStandardChoice, naturalRoll) }
|
||||
}
|
||||
|
||||
return { modifier, specialEffect: null, specialName: null }
|
||||
}
|
||||
|
||||
// ── 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
|
||||
*/
|
||||
export async function _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: await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/chat/reaction-message.hbs", {type:"d30BonusRoll", formula: cleaned.toUpperCase(), value: roll.total}),
|
||||
speaker: ChatMessage.getSpeaker({ actor })
|
||||
})
|
||||
}
|
||||
return roll.total
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export function _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 specialChoice.type.replace(/_/g, " ").replace(/\b\w/g, l => l.toUpperCase())
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
|
||||
export function log(...args) {
|
||||
if (game?.settings?.get(game.system.id, "debug")) {
|
||||
console.log(...args)
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadCompendiumData(compendium) {
|
||||
const pack = game.packs.get(compendium)
|
||||
return await pack?.getDocuments() ?? []
|
||||
}
|
||||
|
||||
export async function loadCompendium(compendium, filter = item => true) {
|
||||
let compendiumData = await loadCompendiumData(compendium)
|
||||
return compendiumData.filter(filter)
|
||||
}
|
||||
|
||||
export function pushCombatOptions(html, options) {
|
||||
options.push({ name: "Reset Progression", condition: true, icon: '<i class="fas fa-rotate-right"></i>', callback: target => { game.combat.resetProgression(target.data('combatant-id')); } })
|
||||
}
|
||||
|
||||
export function setHookListeners() {
|
||||
|
||||
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
|
||||
const _toggleHudWraps = (prefix) => {
|
||||
const enable = $(html).find(`.${prefix}-wrap`)[0].classList.contains(`${prefix}-hud-disabled`)
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const w = $(html).find(`.${prefix}-wrap`)[i]
|
||||
w.classList.toggle(`${prefix}-hud-active`, enable)
|
||||
w.classList.toggle(`${prefix}-hud-disabled`, !enable)
|
||||
}
|
||||
}
|
||||
const _disableHudWraps = (prefix) => {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const w = $(html).find(`.${prefix}-wrap`)[i]
|
||||
w.classList.remove(`${prefix}-hud-active`)
|
||||
w.classList.add(`${prefix}-hud-disabled`)
|
||||
}
|
||||
}
|
||||
|
||||
// HP Loss Button
|
||||
const lossHPButton = await foundry.applications.handlebars.renderTemplate('systems/fvtt-lethal-fantasy/templates/loss-hp-hud.hbs', {})
|
||||
$(html).find('div.left').append(lossHPButton);
|
||||
$(html).find('img.lethal-hp-loss-hud').click((event) => {
|
||||
event.preventDefault();
|
||||
_toggleHudWraps("hp-loss")
|
||||
})
|
||||
$(html).find('.loss-hp-hud-click').click(async (event) => {
|
||||
event.preventDefault();
|
||||
await hudActor.applyDamage(Number(event.currentTarget.dataset.hpValue));
|
||||
_disableHudWraps("hp-loss")
|
||||
})
|
||||
|
||||
// HP Gain Button
|
||||
const gainHPButton = await foundry.applications.handlebars.renderTemplate('systems/fvtt-lethal-fantasy/templates/gain-hp-hud.hbs', {})
|
||||
$(html).find('div.left').append(gainHPButton);
|
||||
$(html).find('img.lethal-hp-gain-hud').click((event) => {
|
||||
event.preventDefault();
|
||||
_toggleHudWraps("hp-gain")
|
||||
})
|
||||
$(html).find('.gain-hp-hud-click').click(async (event) => {
|
||||
event.preventDefault();
|
||||
await hudActor.applyDamage(Number(event.currentTarget.dataset.hpValue));
|
||||
// Clear bleeding wounds on heal
|
||||
const wounds = foundry.utils.duplicate(hudActor.system.hp.wounds || [])
|
||||
if (wounds.some(w => w.description === "Bleeding")) {
|
||||
await hudActor.update({
|
||||
"system.hp.wounds": wounds.map(w =>
|
||||
w.description === "Bleeding" ? { value: 0, duration: 0 } : w
|
||||
)
|
||||
})
|
||||
}
|
||||
_disableHudWraps("hp-gain")
|
||||
})
|
||||
|
||||
// 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');
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function registerHandlebarsHelpers() {
|
||||
|
||||
Handlebars.registerHelper('isNull', function (val) {
|
||||
return val == null;
|
||||
});
|
||||
Handlebars.registerHelper('match', function (val, search) {
|
||||
if (val && search) {
|
||||
return val?.match(search);
|
||||
}
|
||||
return false
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('exists', function (val) {
|
||||
return val != null && val !== undefined;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('isEmpty', function (list) {
|
||||
if (list) return list.length === 0;
|
||||
else return false;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('notEmpty', function (list) {
|
||||
return list.length > 0;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('isNegativeOrNull', function (val) {
|
||||
return val <= 0;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('isNegative', function (val) {
|
||||
return val < 0;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('isPositive', function (val) {
|
||||
return val > 0;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('equals', function (val1, val2) {
|
||||
return val1 === val2;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('neq', function (val1, val2) {
|
||||
return val1 !== val2;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('gt', function (val1, val2) {
|
||||
return val1 > val2;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('lt', function (val1, val2) {
|
||||
return val1 < val2;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('gte', function (val1, val2) {
|
||||
return val1 >= val2;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('lte', function (val1, val2) {
|
||||
return val1 <= val2;
|
||||
})
|
||||
Handlebars.registerHelper('and', function (val1, val2) {
|
||||
return val1 && val2;
|
||||
})
|
||||
Handlebars.registerHelper('or', function (val1, val2) {
|
||||
return val1 || val2;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('or3', function (val1, val2, val3) {
|
||||
return val1 || val2 || val3;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('for', function (from, to, incr, block) {
|
||||
let accum = '';
|
||||
for (let i = from; i < to; i += incr)
|
||||
accum += block.fn(i);
|
||||
return accum;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('not', function (cond) {
|
||||
return !cond;
|
||||
})
|
||||
Handlebars.registerHelper('count', function (list) {
|
||||
return list.length;
|
||||
})
|
||||
Handlebars.registerHelper('countKeys', function (obj) {
|
||||
return Object.keys(obj).length;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('isEnabled', function (configKey) {
|
||||
return game.settings.get("bol", configKey);
|
||||
})
|
||||
Handlebars.registerHelper('split', function (str, separator, keep) {
|
||||
return str.split(separator)[keep];
|
||||
})
|
||||
|
||||
// If you need to add Handlebars helpers, here are a few useful examples:
|
||||
Handlebars.registerHelper('concat', function () {
|
||||
let outStr = '';
|
||||
for (let arg in arguments) {
|
||||
if (typeof arguments[arg] != 'object') {
|
||||
outStr += arguments[arg];
|
||||
}
|
||||
}
|
||||
return outStr;
|
||||
})
|
||||
|
||||
Handlebars.registerHelper('add', function (a, b) {
|
||||
return parseInt(a) + parseInt(b);
|
||||
});
|
||||
Handlebars.registerHelper('mul', function (a, b) {
|
||||
return parseInt(a) * parseInt(b);
|
||||
})
|
||||
Handlebars.registerHelper('sub', function (a, b) {
|
||||
return parseInt(a) - parseInt(b);
|
||||
})
|
||||
Handlebars.registerHelper('abbrev2', function (a) {
|
||||
return a.substring(0, 2);
|
||||
})
|
||||
Handlebars.registerHelper('abbrev3', function (a) {
|
||||
return a.substring(0, 3);
|
||||
})
|
||||
Handlebars.registerHelper('valueAtIndex', function (arr, idx) {
|
||||
return arr[idx];
|
||||
})
|
||||
Handlebars.registerHelper('includesKey', function (items, type, key) {
|
||||
return items.filter(i => i.type === type).map(i => i.system.key).includes(key);
|
||||
})
|
||||
Handlebars.registerHelper('includes', function (array, val) {
|
||||
return array.includes(val);
|
||||
})
|
||||
Handlebars.registerHelper('eval', function (expr) {
|
||||
return eval(expr);
|
||||
})
|
||||
Handlebars.registerHelper('isOwnerOrGM', function (actor) {
|
||||
log("Testing actor", actor.isOwner, game.userId)
|
||||
return actor.isOwner || game.isGM;
|
||||
})
|
||||
Handlebars.registerHelper('upperCase', function (text) {
|
||||
if (typeof text !== 'string') return text
|
||||
return text.toUpperCase()
|
||||
})
|
||||
Handlebars.registerHelper('upperFirst', function (text) {
|
||||
if (typeof text !== 'string') return text
|
||||
return text.charAt(0).toUpperCase() + text.slice(1)
|
||||
})
|
||||
Handlebars.registerHelper('upperFirstOnly', function (text) {
|
||||
if (typeof text !== 'string') return text
|
||||
return text.charAt(0).toUpperCase()
|
||||
})
|
||||
|
||||
// Handle v12 removal of this helper
|
||||
Handlebars.registerHelper('select', function (selected, options) {
|
||||
const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected));
|
||||
const rgx = new RegExp(' value=[\"\']' + escapedValue + '[\"\']');
|
||||
const html = options.fn(this);
|
||||
return html.replace(rgx, "$& selected");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export function getLethargyDice(level) {
|
||||
for (let s of SYSTEM.SPELL_LETHARGY_DICE) {
|
||||
if (Number(level) <= s.maxLevel) {
|
||||
return s.dice
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
MANIFEST-000303
|
||||
@@ -1,8 +0,0 @@
|
||||
2025/05/06-10:52:19.288970 7fc4e7fff6c0 Recovering log #300
|
||||
2025/05/06-10:52:19.300271 7fc4e7fff6c0 Delete type=3 #298
|
||||
2025/05/06-10:52:19.300323 7fc4e7fff6c0 Delete type=0 #300
|
||||
2025/05/06-10:53:10.017977 7fc4e73ff6c0 Level-0 table #306: started
|
||||
2025/05/06-10:53:10.018020 7fc4e73ff6c0 Level-0 table #306: 0 bytes OK
|
||||
2025/05/06-10:53:10.024080 7fc4e73ff6c0 Delete type=0 #304
|
||||
2025/05/06-10:53:10.044191 7fc4e73ff6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
|
||||
2025/05/06-10:53:10.044277 7fc4e73ff6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
|
||||
@@ -1,15 +0,0 @@
|
||||
2025/05/06-10:45:53.342160 7fc4ecbf86c0 Recovering log #296
|
||||
2025/05/06-10:45:53.353010 7fc4ecbf86c0 Delete type=3 #294
|
||||
2025/05/06-10:45:53.353081 7fc4ecbf86c0 Delete type=0 #296
|
||||
2025/05/06-10:51:12.708848 7fc4e73ff6c0 Level-0 table #301: started
|
||||
2025/05/06-10:51:12.714248 7fc4e73ff6c0 Level-0 table #301: 213746 bytes OK
|
||||
2025/05/06-10:51:12.720525 7fc4e73ff6c0 Delete type=0 #299
|
||||
2025/05/06-10:51:12.748598 7fc4e73ff6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
|
||||
2025/05/06-10:51:12.748667 7fc4e73ff6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at '!items!zw9RQocTdz3HRjZK' @ 564 : 1
|
||||
2025/05/06-10:51:12.748677 7fc4e73ff6c0 Compacting 1@1 + 1@2 files
|
||||
2025/05/06-10:51:12.755813 7fc4e73ff6c0 Generated table #302@1: 485 keys, 214492 bytes
|
||||
2025/05/06-10:51:12.755833 7fc4e73ff6c0 Compacted 1@1 + 1@2 files => 214492 bytes
|
||||
2025/05/06-10:51:12.761728 7fc4e73ff6c0 compacted to: files[ 0 0 1 0 0 0 0 ]
|
||||
2025/05/06-10:51:12.761886 7fc4e73ff6c0 Delete type=2 #289
|
||||
2025/05/06-10:51:12.762144 7fc4e73ff6c0 Delete type=2 #301
|
||||
2025/05/06-10:51:12.795034 7fc4e73ff6c0 Manual compaction at level-1 from '!items!zw9RQocTdz3HRjZK' @ 564 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
MANIFEST-000302
|
||||
@@ -1,8 +0,0 @@
|
||||
2025/05/06-10:52:19.304583 7fc4ed3f96c0 Recovering log #299
|
||||
2025/05/06-10:52:19.314806 7fc4ed3f96c0 Delete type=3 #297
|
||||
2025/05/06-10:52:19.314910 7fc4ed3f96c0 Delete type=0 #299
|
||||
2025/05/06-10:53:10.030599 7fc4e73ff6c0 Level-0 table #305: started
|
||||
2025/05/06-10:53:10.030635 7fc4e73ff6c0 Level-0 table #305: 0 bytes OK
|
||||
2025/05/06-10:53:10.036964 7fc4e73ff6c0 Delete type=0 #303
|
||||
2025/05/06-10:53:10.044214 7fc4e73ff6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
|
||||
2025/05/06-10:53:10.044269 7fc4e73ff6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
|
||||
@@ -1,15 +0,0 @@
|
||||
2025/05/06-10:45:53.355849 7fc4edbfa6c0 Recovering log #295
|
||||
2025/05/06-10:45:53.366571 7fc4edbfa6c0 Delete type=3 #293
|
||||
2025/05/06-10:45:53.366637 7fc4edbfa6c0 Delete type=0 #295
|
||||
2025/05/06-10:51:12.732133 7fc4e73ff6c0 Level-0 table #300: started
|
||||
2025/05/06-10:51:12.736129 7fc4e73ff6c0 Level-0 table #300: 15304 bytes OK
|
||||
2025/05/06-10:51:12.742079 7fc4e73ff6c0 Delete type=0 #298
|
||||
2025/05/06-10:51:12.748632 7fc4e73ff6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
|
||||
2025/05/06-10:51:12.771871 7fc4e73ff6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at '!items!zjvGljrLk5SshC9D' @ 65 : 1
|
||||
2025/05/06-10:51:12.771882 7fc4e73ff6c0 Compacting 1@1 + 1@2 files
|
||||
2025/05/06-10:51:12.776442 7fc4e73ff6c0 Generated table #301@1: 31 keys, 15417 bytes
|
||||
2025/05/06-10:51:12.776461 7fc4e73ff6c0 Compacted 1@1 + 1@2 files => 15417 bytes
|
||||
2025/05/06-10:51:12.782727 7fc4e73ff6c0 compacted to: files[ 0 0 1 0 0 0 0 ]
|
||||
2025/05/06-10:51:12.782835 7fc4e73ff6c0 Delete type=2 #288
|
||||
2025/05/06-10:51:12.782952 7fc4e73ff6c0 Delete type=2 #300
|
||||
2025/05/06-10:51:12.795077 7fc4e73ff6c0 Manual compaction at level-1 from '!items!zjvGljrLk5SshC9D' @ 65 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
MANIFEST-000302
|
||||
@@ -1,8 +0,0 @@
|
||||
2025/05/06-10:52:19.275594 7fc4ecbf86c0 Recovering log #299
|
||||
2025/05/06-10:52:19.285984 7fc4ecbf86c0 Delete type=3 #297
|
||||
2025/05/06-10:52:19.286069 7fc4ecbf86c0 Delete type=0 #299
|
||||
2025/05/06-10:53:10.024277 7fc4e73ff6c0 Level-0 table #305: started
|
||||
2025/05/06-10:53:10.024336 7fc4e73ff6c0 Level-0 table #305: 0 bytes OK
|
||||
2025/05/06-10:53:10.030435 7fc4e73ff6c0 Delete type=0 #303
|
||||
2025/05/06-10:53:10.044204 7fc4e73ff6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
|
||||
2025/05/06-10:53:10.044252 7fc4e73ff6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
|
||||
@@ -1,15 +0,0 @@
|
||||
2025/05/06-10:45:53.317135 7fc4e7fff6c0 Recovering log #295
|
||||
2025/05/06-10:45:53.339293 7fc4e7fff6c0 Delete type=3 #293
|
||||
2025/05/06-10:45:53.339350 7fc4e7fff6c0 Delete type=0 #295
|
||||
2025/05/06-10:51:12.783010 7fc4e73ff6c0 Level-0 table #300: started
|
||||
2025/05/06-10:51:12.787977 7fc4e73ff6c0 Level-0 table #300: 154604 bytes OK
|
||||
2025/05/06-10:51:12.794741 7fc4e73ff6c0 Delete type=0 #298
|
||||
2025/05/06-10:51:12.795090 7fc4e73ff6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
|
||||
2025/05/06-10:51:12.795140 7fc4e73ff6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at '!items!zt8s7564ep1La4XQ' @ 281 : 1
|
||||
2025/05/06-10:51:12.795156 7fc4e73ff6c0 Compacting 1@1 + 1@2 files
|
||||
2025/05/06-10:51:12.800410 7fc4e73ff6c0 Generated table #301@1: 95 keys, 121769 bytes
|
||||
2025/05/06-10:51:12.800436 7fc4e73ff6c0 Compacted 1@1 + 1@2 files => 121769 bytes
|
||||
2025/05/06-10:51:12.806480 7fc4e73ff6c0 compacted to: files[ 0 0 1 0 0 0 0 ]
|
||||
2025/05/06-10:51:12.806620 7fc4e73ff6c0 Delete type=2 #288
|
||||
2025/05/06-10:51:12.806871 7fc4e73ff6c0 Delete type=2 #300
|
||||
2025/05/06-10:51:12.827417 7fc4e73ff6c0 Manual compaction at level-1 from '!items!zt8s7564ep1La4XQ' @ 281 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
MANIFEST-000002
|
||||
@@ -1,5 +0,0 @@
|
||||
2025/05/06-10:52:19.344307 7fc4e7fff6c0 Delete type=3 #1
|
||||
2025/05/06-10:53:10.044408 7fc4e73ff6c0 Level-0 table #5: started
|
||||
2025/05/06-10:53:10.051976 7fc4e73ff6c0 Level-0 table #5: 433603 bytes OK
|
||||
2025/05/06-10:53:10.058524 7fc4e73ff6c0 Delete type=0 #3
|
||||
2025/05/06-10:53:10.078387 7fc4e73ff6c0 Manual compaction at level-0 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
MANIFEST-000302
|
||||
@@ -1,8 +0,0 @@
|
||||
2025/05/06-10:52:19.317853 7fc4edbfa6c0 Recovering log #299
|
||||
2025/05/06-10:52:19.327788 7fc4edbfa6c0 Delete type=3 #297
|
||||
2025/05/06-10:52:19.327923 7fc4edbfa6c0 Delete type=0 #299
|
||||
2025/05/06-10:53:10.037095 7fc4e73ff6c0 Level-0 table #305: started
|
||||
2025/05/06-10:53:10.037121 7fc4e73ff6c0 Level-0 table #305: 0 bytes OK
|
||||
2025/05/06-10:53:10.044101 7fc4e73ff6c0 Delete type=0 #303
|
||||
2025/05/06-10:53:10.044224 7fc4e73ff6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
|
||||
2025/05/06-10:53:10.044260 7fc4e73ff6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
|
||||
@@ -1,15 +0,0 @@
|
||||
2025/05/06-10:45:53.369722 7fc4ed3f96c0 Recovering log #295
|
||||
2025/05/06-10:45:53.379868 7fc4ed3f96c0 Delete type=3 #293
|
||||
2025/05/06-10:45:53.379989 7fc4ed3f96c0 Delete type=0 #295
|
||||
2025/05/06-10:51:12.720972 7fc4e73ff6c0 Level-0 table #300: started
|
||||
2025/05/06-10:51:12.724909 7fc4e73ff6c0 Level-0 table #300: 20719 bytes OK
|
||||
2025/05/06-10:51:12.731912 7fc4e73ff6c0 Delete type=0 #298
|
||||
2025/05/06-10:51:12.748619 7fc4e73ff6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
|
||||
2025/05/06-10:51:12.762241 7fc4e73ff6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at '!items!zkK6ixtCsCw3RH9X' @ 62 : 1
|
||||
2025/05/06-10:51:12.762247 7fc4e73ff6c0 Compacting 1@1 + 1@2 files
|
||||
2025/05/06-10:51:12.765506 7fc4e73ff6c0 Generated table #301@1: 27 keys, 20869 bytes
|
||||
2025/05/06-10:51:12.765523 7fc4e73ff6c0 Compacted 1@1 + 1@2 files => 20869 bytes
|
||||
2025/05/06-10:51:12.771435 7fc4e73ff6c0 compacted to: files[ 0 0 1 0 0 0 0 ]
|
||||
2025/05/06-10:51:12.771569 7fc4e73ff6c0 Delete type=2 #288
|
||||
2025/05/06-10:51:12.771746 7fc4e73ff6c0 Delete type=2 #300
|
||||
2025/05/06-10:51:12.795060 7fc4e73ff6c0 Manual compaction at level-1 from '!items!zkK6ixtCsCw3RH9X' @ 62 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
|
||||
Binary file not shown.
+23
-17
@@ -45,7 +45,7 @@
|
||||
min-width: 2.2rem;
|
||||
max-width: 2.2rem;
|
||||
margin-left: 4px;
|
||||
font-size: calc(var(--font-size-standard) * 1.0);
|
||||
font-size: calc(var(--font-size-standard) * 1);
|
||||
}
|
||||
.character-hp-max {
|
||||
clear: both;
|
||||
@@ -57,7 +57,7 @@
|
||||
input {
|
||||
width: 3.2rem;
|
||||
text-align: center;
|
||||
font-size: calc(var(--font-size-standard) * 1.0);
|
||||
font-size: calc(var(--font-size-standard) * 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,10 @@
|
||||
.character-characteristic {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
span {
|
||||
min-width: 2.2rem;
|
||||
max-width: 2.2rem;
|
||||
}
|
||||
.rollable:hover,
|
||||
.rollable:focus {
|
||||
text-shadow: 0 0 8px var(--color-shadow-primary);
|
||||
@@ -218,7 +222,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.tab.character-biography {
|
||||
.tab.character-biography .main-div {
|
||||
.biodata {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
@@ -248,7 +252,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.tab.character-skills {
|
||||
.tab.character-skills .main-div {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
legend {
|
||||
@@ -310,7 +314,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.tab.character-equipment {
|
||||
.tab.character-equipment .main-div {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
legend {
|
||||
@@ -349,7 +353,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.tab.character-combat {
|
||||
.tab.character-combat .main-div {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
legend {
|
||||
@@ -371,6 +375,9 @@
|
||||
min-width: 2.5rem;
|
||||
max-width: 2.5rem;
|
||||
}
|
||||
.ranged-attack-button {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
button {
|
||||
min-width: 9rem;
|
||||
}
|
||||
@@ -380,11 +387,11 @@
|
||||
min-width: 6rem;
|
||||
max-width: 6rem;
|
||||
}
|
||||
min-width: 10rem;
|
||||
max-width: 10rem;
|
||||
min-width: 11rem;
|
||||
max-width: 11rem;
|
||||
.input {
|
||||
min-width: 2.5rem;
|
||||
max-width: 2.5rem;
|
||||
min-width: 3.5rem;
|
||||
max-width: 3.5rem;
|
||||
}
|
||||
}
|
||||
.granted {
|
||||
@@ -469,7 +476,7 @@
|
||||
min-width: 12rem;
|
||||
}
|
||||
.item-detail {
|
||||
min-width:2rem;
|
||||
min-width: 2rem;
|
||||
}
|
||||
}
|
||||
.shields {
|
||||
@@ -488,16 +495,15 @@
|
||||
}
|
||||
}
|
||||
.item-detail {
|
||||
min-width:2.5rem;
|
||||
min-width: 2.5rem;
|
||||
}
|
||||
.name {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.tab.character-spells {
|
||||
.tab.character-spells .main-div {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
legend {
|
||||
@@ -530,7 +536,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.spells {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
@@ -541,7 +546,8 @@
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
.item-img {
|
||||
width: 24px;
|
||||
min-width: 24px;
|
||||
max-width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
.name {
|
||||
@@ -558,7 +564,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.tab.character-miracles {
|
||||
.tab.character-miracles .main-div {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
legend {
|
||||
|
||||
+361
-28
@@ -1,33 +1,34 @@
|
||||
&.fortune {
|
||||
img {
|
||||
border: 0px;
|
||||
}
|
||||
.intro-chat {
|
||||
border-radius: 20px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
.intro-img {
|
||||
padding: 5px;
|
||||
width: 80px;
|
||||
align-self: center;
|
||||
}
|
||||
.intro-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.introText {
|
||||
font-family: var(--font-secondary);
|
||||
font-size: calc(var(--font-size-standard) * 1.2);
|
||||
width: 210px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
.button.control, .fortune-accepted {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: calc(var(--font-size-standard) * 1.3);
|
||||
img {
|
||||
border: 0px;
|
||||
}
|
||||
.intro-chat {
|
||||
border-radius: 20px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
.intro-img {
|
||||
padding: 5px;
|
||||
width: 80px;
|
||||
align-self: center;
|
||||
}
|
||||
.intro-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.introText {
|
||||
font-family: var(--font-secondary);
|
||||
font-size: calc(var(--font-size-standard) * 1.2);
|
||||
width: 210px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
.button.control,
|
||||
.fortune-accepted {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: calc(var(--font-size-standard) * 1.3);
|
||||
}
|
||||
}
|
||||
|
||||
&.ask-roll {
|
||||
@@ -38,3 +39,335 @@
|
||||
font-family: var(--font-secondary);
|
||||
font-size: calc(var(--font-size-standard) * 1.2);
|
||||
}
|
||||
.defense-request {
|
||||
padding: 12px;
|
||||
background: linear-gradient(to bottom, #3a3930 0%, #2a2920 100%);
|
||||
border: 2px solid #d4af37;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
|
||||
|
||||
h3 {
|
||||
margin: 0 0 10px 0;
|
||||
color: #d4af37;
|
||||
font-size: calc(var(--font-size-standard) * 1.1);
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
|
||||
i {
|
||||
margin-right: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 8px 0;
|
||||
color: #f0e6d2;
|
||||
font-size: calc(var(--font-size-standard) * 0.95);
|
||||
line-height: 1.4;
|
||||
|
||||
strong {
|
||||
color: #d4af37;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.defense-prompt {
|
||||
margin-top: 12px;
|
||||
padding: 8px;
|
||||
background: rgba(212, 175, 55, 0.1);
|
||||
border-left: 3px solid #d4af37;
|
||||
border-radius: 4px;
|
||||
font-weight: 600;
|
||||
color: #d4af37;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.defense-request-dialog {
|
||||
.attack-info {
|
||||
padding: 12px;
|
||||
background: linear-gradient(to bottom, rgba(42, 41, 32, 0.8) 0%, rgba(26, 25, 16, 0.9) 100%);
|
||||
border: 1px solid rgba(212, 175, 55, 0.5);
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
p {
|
||||
margin: 6px 0;
|
||||
color: #f0e6d2;
|
||||
font-size: calc(var(--font-size-standard) * 0.95);
|
||||
|
||||
strong {
|
||||
color: #d4af37;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.weapon-selection {
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: #d4af37;
|
||||
font-weight: 600;
|
||||
font-size: calc(var(--font-size-standard) * 0.95);
|
||||
}
|
||||
|
||||
select {
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
background: #3a3930 !important;
|
||||
border: 1px solid #d4af37;
|
||||
border-radius: 4px;
|
||||
color: #ffffff !important;
|
||||
font-size: calc(var(--font-size-standard) * 0.95);
|
||||
cursor: pointer;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: #f0e6d2;
|
||||
box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.3);
|
||||
}
|
||||
|
||||
option {
|
||||
background: #3a3930 !important;
|
||||
color: #ffffff !important;
|
||||
padding: 6px;
|
||||
|
||||
&:checked,
|
||||
&:hover {
|
||||
background: #4a4940 !important;
|
||||
color: #ffffff !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.grit-luck-dialog {
|
||||
color: var(--color-text-dark-primary, #191813);
|
||||
|
||||
.combat-status {
|
||||
padding: 12px;
|
||||
background: linear-gradient(to bottom, rgba(42, 41, 32, 0.88) 0%, rgba(26, 25, 16, 0.95) 100%);
|
||||
border: 1px solid rgba(212, 175, 55, 0.5);
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
p {
|
||||
margin: 6px 0;
|
||||
color: #f0e6d2;
|
||||
font-size: calc(var(--font-size-standard) * 0.95);
|
||||
|
||||
strong {
|
||||
color: #d4af37;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.bonus-info {
|
||||
color: #90EE90;
|
||||
font-style: italic;
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.offer-text {
|
||||
color: var(--color-text-dark-primary, #191813);
|
||||
font-size: calc(var(--font-size-standard) * 1);
|
||||
text-align: center;
|
||||
font-weight: 600;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.shield-warning {
|
||||
color: #7a4000;
|
||||
background: rgba(255, 160, 0, 0.12);
|
||||
border: 1px solid rgba(255, 160, 0, 0.4);
|
||||
border-radius: 5px;
|
||||
font-size: calc(var(--font-size-standard) * 0.88);
|
||||
padding: 6px 10px;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
|
||||
i {
|
||||
color: #c07000;
|
||||
margin-right: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.attack-result {
|
||||
padding: 16px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
|
||||
margin: 8px 0;
|
||||
|
||||
&.attack-success {
|
||||
background: linear-gradient(to bottom, rgba(139, 0, 0, 0.2) 0%, rgba(100, 0, 0, 0.3) 100%);
|
||||
border: 2px solid rgba(220, 20, 60, 0.6);
|
||||
}
|
||||
|
||||
&.attack-failure {
|
||||
background: linear-gradient(to bottom, rgba(0, 100, 139, 0.2) 0%, rgba(0, 70, 100, 0.3) 100%);
|
||||
border: 2px solid rgba(70, 130, 180, 0.6);
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 0 0 16px 0;
|
||||
color: #d4af37;
|
||||
font-size: calc(var(--font-size-standard) * 1.2);
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
|
||||
i {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.combat-comparison {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
margin-bottom: 16px;
|
||||
padding: 12px;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
border-radius: 6px;
|
||||
|
||||
.combat-side {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
|
||||
&.winner {
|
||||
background: rgba(0, 255, 0, 0.1);
|
||||
border: 2px solid rgba(0, 255, 0, 0.4);
|
||||
}
|
||||
|
||||
&.loser {
|
||||
background: rgba(255, 0, 0, 0.1);
|
||||
border: 2px solid rgba(255, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.side-label {
|
||||
font-size: calc(var(--font-size-standard) * 0.8);
|
||||
color: #aaa;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.side-name {
|
||||
font-size: calc(var(--font-size-standard) * 1);
|
||||
color: #f0e6d2;
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.side-roll {
|
||||
font-size: calc(var(--font-size-standard) * 1.5);
|
||||
color: #d4af37;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
.combat-vs {
|
||||
font-size: calc(var(--font-size-standard) * 1.2);
|
||||
color: #d4af37;
|
||||
font-weight: 700;
|
||||
padding: 0 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.combat-result-text {
|
||||
text-align: center;
|
||||
font-size: calc(var(--font-size-standard) * 1.1);
|
||||
color: #f0e6d2;
|
||||
margin-bottom: 16px;
|
||||
padding: 12px;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
border-radius: 6px;
|
||||
|
||||
i {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
strong {
|
||||
color: #d4af37;
|
||||
}
|
||||
}
|
||||
|
||||
.attack-result-damage {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 8px;
|
||||
|
||||
&.single-btn {
|
||||
grid-template-columns: 1fr;
|
||||
max-width: 280px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
&.spell-damage {
|
||||
grid-template-columns: 1fr;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.roll-damage-btn {
|
||||
padding: 10px 14px;
|
||||
background: linear-gradient(to bottom, #8b0000 0%, #660000 100%);
|
||||
border: 1px solid #4b0000;
|
||||
border-radius: 6px;
|
||||
color: #f0e6d2;
|
||||
font-weight: 600;
|
||||
font-size: calc(var(--font-size-standard) * 0.9);
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
|
||||
transition: left 0.5s;
|
||||
}
|
||||
|
||||
&:hover::before {
|
||||
left: 100%;
|
||||
}
|
||||
|
||||
i {
|
||||
font-size: calc(var(--font-size-standard) * 1.1);
|
||||
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(to bottom, #a00000 0%, #7b0000 100%);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
|
||||
transform: translateY(-2px);
|
||||
border-color: #5b0000;
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 3px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -5,6 +5,5 @@
|
||||
|
||||
@font-face {
|
||||
font-family: "BaskervilleBold";
|
||||
src: url("../fonts/baskerville-bold.ttf") format("truetype");
|
||||
src: url("../assets/fonts/baskerville-bold.ttf") format("truetype");
|
||||
}
|
||||
|
||||
|
||||
+14
-3
@@ -6,6 +6,17 @@
|
||||
--logo-standard: url("../assets/ui/lf_logo_small_02.webp");
|
||||
}
|
||||
|
||||
.initiative-area {
|
||||
min-width: 8rem;
|
||||
max-width: 8rem;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
input {
|
||||
min-width: 3rem;
|
||||
max-width: 3rem;
|
||||
}
|
||||
}
|
||||
|
||||
#logo {
|
||||
content: var(--logo-standard);
|
||||
width: 50px;
|
||||
@@ -36,7 +47,7 @@ i.lethalfantasy {
|
||||
|
||||
.application.dialog.lethalfantasy {
|
||||
font-family: var(--font-primary);
|
||||
font-size: calc(var(--font-size-standard) * 1.0);
|
||||
font-size: calc(var(--font-size-standard) * 1);
|
||||
background-image: var(--background-image-base);
|
||||
button:hover {
|
||||
background: var(--color-dark-6);
|
||||
@@ -59,12 +70,12 @@ i.lethalfantasy {
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.combat-sidebar li.combatant .token-initiative .initiative{
|
||||
.combat-sidebar li.combatant .token-initiative .initiative {
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
.combat-sidebar li.combatant .token-initiative {
|
||||
flex:none;
|
||||
flex: none;
|
||||
}
|
||||
.initiative-minus {
|
||||
margin-right: 8px;
|
||||
|
||||
+355
-2
@@ -35,9 +35,362 @@
|
||||
padding-bottom: 0;
|
||||
width: max-content;
|
||||
margin: 0;
|
||||
color: #252424;
|
||||
}
|
||||
|
||||
#token-hud .hp-loss-wrap .hud-loss-hp-button-select {
|
||||
#token-hud .hp-loss-wrap .hud-loss-hp-button-select {
|
||||
padding-left: 8px;
|
||||
font-size: 0.7rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
/* HP Gain Styles */
|
||||
#token-hud .hp-gain-wrap {
|
||||
position: absolute;
|
||||
left: 75px;
|
||||
display: none;
|
||||
top: 50%;
|
||||
width: 48px;
|
||||
text-align: start;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
#token-hud .hp-gain-wrap-col1 {
|
||||
transform: translate(-200%, -50%);
|
||||
}
|
||||
|
||||
#token-hud .hp-gain-wrap-col2 {
|
||||
transform: translate(-300%, -50%);
|
||||
}
|
||||
|
||||
#token-hud .hp-gain-wrap-col3 {
|
||||
transform: translate(-400%, -50%);
|
||||
}
|
||||
|
||||
#token-hud .hp-gain-hud-active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#token-hud .hp-gain-hud-disabled {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#token-hud .hud-gain-hp-button-select {
|
||||
max-width: 40px;
|
||||
background-image: var(--background-image-base);
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
width: max-content;
|
||||
margin: 0;
|
||||
color: #252424;
|
||||
}
|
||||
|
||||
#token-hud .hp-gain-wrap .hud-gain-hp-button-select {
|
||||
padding-left: 8px;
|
||||
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 */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
.lf-dice-tray {
|
||||
padding: 6px 8px;
|
||||
background:
|
||||
linear-gradient(135deg, rgba(245, 232, 200, 0.97) 0%, rgba(238, 222, 185, 0.97) 100%),
|
||||
url("/systems/fvtt-lethal-fantasy/assets/ui/lethal_fantasy_background.webp") center / cover;
|
||||
border-top: 2px solid rgba(139, 69, 19, 0.5);
|
||||
border-bottom: 1px solid rgba(139, 69, 19, 0.25);
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
pointer-events: all;
|
||||
|
||||
.lf-dt-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.lf-dt-label {
|
||||
color: #3a2a10;
|
||||
font-size: 15px;
|
||||
flex-shrink: 0;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.lf-dt-count {
|
||||
width: 44px;
|
||||
flex-shrink: 0;
|
||||
padding: 3px 4px;
|
||||
background: rgba(139, 69, 19, 0.15);
|
||||
border: 1px solid rgba(139, 69, 19, 0.45);
|
||||
border-radius: 4px;
|
||||
color: #2a1a08;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
|
||||
option { background: #f5ead0; color: #2a1a08; }
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: rgba(139, 69, 19, 0.7);
|
||||
box-shadow: 0 0 4px rgba(139, 69, 19, 0.25);
|
||||
}
|
||||
}
|
||||
|
||||
.lf-dt-dice {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 3px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.lf-dt-die-btn {
|
||||
padding: 3px 7px;
|
||||
background: rgba(139, 69, 19, 0.15);
|
||||
border: 1px solid rgba(139, 69, 19, 0.4);
|
||||
border-radius: 4px;
|
||||
color: #2a1a08;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
|
||||
line-height: 1.5;
|
||||
letter-spacing: 0.3px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(139, 69, 19, 0.35);
|
||||
border-color: rgba(139, 69, 19, 0.7);
|
||||
color: #5a2a00;
|
||||
box-shadow: 0 0 5px rgba(139, 69, 19, 0.3);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: none;
|
||||
background: rgba(139, 69, 19, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
.lf-dt-explode-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
cursor: pointer;
|
||||
color: rgba(160, 80, 20, 0.7);
|
||||
font-size: 14px;
|
||||
flex-shrink: 0;
|
||||
padding: 3px 6px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 4px;
|
||||
transition: color 0.15s, border-color 0.15s, background 0.15s;
|
||||
|
||||
&:hover {
|
||||
color: rgba(200, 100, 30, 0.9);
|
||||
border-color: rgba(139, 69, 19, 0.45);
|
||||
background: rgba(139, 69, 19, 0.12);
|
||||
}
|
||||
|
||||
input[type="checkbox"] {
|
||||
appearance: none;
|
||||
width: 0;
|
||||
height: 0;
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
|
||||
&:checked ~ i {
|
||||
color: #cc4400;
|
||||
filter: drop-shadow(0 0 4px rgba(200, 80, 0, 0.6));
|
||||
}
|
||||
}
|
||||
|
||||
&:has(input:checked) {
|
||||
color: #cc4400;
|
||||
border-color: rgba(139, 69, 19, 0.55);
|
||||
background: rgba(139, 60, 10, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Free roll chat card — styled to match regular system roll cards */
|
||||
.lf-free-roll-card {
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
|
||||
.lf-frc-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 8px;
|
||||
background: linear-gradient(135deg, rgba(40, 30, 20, 0.7) 0%, rgba(30, 22, 15, 0.9) 100%);
|
||||
border-bottom: 2px solid rgba(139, 69, 19, 0.4);
|
||||
|
||||
i { color: #c9b896; font-size: calc(var(--font-size-standard, 14px) * 1.1); }
|
||||
|
||||
.lf-frc-title-text {
|
||||
font-size: calc(var(--font-size-standard, 14px) * 0.85);
|
||||
color: #c9b896;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.lf-frc-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 8px;
|
||||
background: rgba(139, 69, 19, 0.3);
|
||||
border: 1px solid rgba(139, 69, 19, 0.5);
|
||||
border-radius: 10px;
|
||||
font-size: calc(var(--font-size-standard, 14px) * 0.85);
|
||||
font-weight: 600;
|
||||
color: #d4c5a9;
|
||||
}
|
||||
}
|
||||
|
||||
.lf-frc-dice {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
padding: 6px 8px;
|
||||
background: rgba(0, 0, 0, 0.15);
|
||||
border: 1px solid rgba(139, 69, 19, 0.3);
|
||||
border-top: none;
|
||||
|
||||
.lf-frc-die-chip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 3px 8px;
|
||||
background: rgba(139, 69, 19, 0.2);
|
||||
border: 1px solid rgba(139, 69, 19, 0.3);
|
||||
border-radius: 4px;
|
||||
|
||||
.lf-frc-die-type {
|
||||
font-size: calc(var(--font-size-standard, 14px) * 0.85);
|
||||
font-weight: 600;
|
||||
color: #2a2a1a;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.lf-frc-die-sep {
|
||||
color: rgba(0, 0, 0, 0.35);
|
||||
font-weight: 300;
|
||||
font-size: calc(var(--font-size-standard, 14px) * 0.8);
|
||||
}
|
||||
|
||||
.lf-frc-die-val {
|
||||
font-weight: bold;
|
||||
color: #ffd700;
|
||||
font-size: calc(var(--font-size-standard, 14px) * 0.95);
|
||||
|
||||
.lf-dt-explode-icon {
|
||||
font-size: 8px;
|
||||
color: #ffcc00;
|
||||
margin-left: 2px;
|
||||
vertical-align: super;
|
||||
text-shadow: 0 0 4px rgba(255, 200, 0, 0.8);
|
||||
}
|
||||
}
|
||||
|
||||
&.lf-frc-max {
|
||||
background: rgba(139, 90, 19, 0.35);
|
||||
border-color: rgba(200, 116, 42, 0.6);
|
||||
.lf-frc-die-val { color: #ff9a40; text-shadow: 0 0 6px rgba(200, 116, 42, 0.6); }
|
||||
}
|
||||
|
||||
&.lf-frc-min {
|
||||
background: rgba(139, 20, 20, 0.25);
|
||||
border-color: rgba(139, 34, 34, 0.5);
|
||||
.lf-frc-die-val { color: #ff6b6b; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.lf-frc-total-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 6px 10px;
|
||||
background: linear-gradient(135deg, rgba(40, 30, 20, 0.6) 0%, rgba(20, 15, 10, 0.8) 100%);
|
||||
border: 2px solid rgba(139, 69, 19, 0.5);
|
||||
|
||||
.lf-frc-total-label {
|
||||
font-size: calc(var(--font-size-standard, 14px) * 0.85);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: #c9b896;
|
||||
}
|
||||
|
||||
.lf-frc-total-value {
|
||||
font-family: var(--font-primary, serif);
|
||||
font-size: calc(var(--font-size-standard, 14px) * 1.6);
|
||||
font-weight: bold;
|
||||
color: #e8d5a0;
|
||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+35
-7
@@ -6,6 +6,14 @@
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% 100%;
|
||||
|
||||
nav.tabs [data-tab] {
|
||||
color: #636060;
|
||||
}
|
||||
|
||||
nav.tabs [data-tab].active {
|
||||
color: #252424;
|
||||
}
|
||||
|
||||
input:disabled,
|
||||
select:disabled {
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
@@ -39,11 +47,11 @@
|
||||
input,
|
||||
select {
|
||||
text-align: center;
|
||||
font-size: calc(var(--font-size-standard) * 1.0);
|
||||
font-size: calc(var(--font-size-standard) * 1);
|
||||
}
|
||||
select {
|
||||
font-family: var(--font-secondary);
|
||||
font-size: calc(var(--font-size-standard) * 1.0);
|
||||
font-size: calc(var(--font-size-standard) * 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,9 +75,33 @@
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
overflow: auto;
|
||||
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: row;
|
||||
label {
|
||||
align-content: center;
|
||||
min-width: 10rem;
|
||||
max-width: 10rem;
|
||||
}
|
||||
select,
|
||||
input {
|
||||
text-align: left;
|
||||
min-width: 12rem;
|
||||
max-width: 12rem;
|
||||
}
|
||||
input[type="checkbox"] {
|
||||
min-width: 1.2rem;
|
||||
max-width: 1.2rem;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
label {
|
||||
font-family: var(--font-secondary);
|
||||
font-size: calc(var(--font-size-standard) * 1.0);
|
||||
font-size: calc(var(--font-size-standard) * 1);
|
||||
flex: 50%;
|
||||
}
|
||||
|
||||
@@ -77,10 +109,6 @@
|
||||
align-self: flex-start;
|
||||
padding: 0.1rem;
|
||||
margin-right: 0.2rem;
|
||||
/*border-color: black;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-radius: 2%;*/
|
||||
}
|
||||
|
||||
.shift-right {
|
||||
|
||||
+57
-13
@@ -25,7 +25,6 @@
|
||||
gap: 10px;
|
||||
flex: 1;
|
||||
|
||||
|
||||
.monster-hp {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
@@ -46,7 +45,7 @@
|
||||
min-width: 2.2rem;
|
||||
max-width: 2.2rem;
|
||||
margin-left: 4px;
|
||||
font-size: calc(var(--font-size-standard) * 1.0);
|
||||
font-size: calc(var(--font-size-standard) * 1);
|
||||
}
|
||||
.character-hp-max {
|
||||
clear: both;
|
||||
@@ -58,7 +57,7 @@
|
||||
input {
|
||||
width: 3.2rem;
|
||||
text-align: center;
|
||||
font-size: calc(var(--font-size-standard) * 1.0);
|
||||
font-size: calc(var(--font-size-standard) * 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,6 +98,10 @@
|
||||
text-shadow: 0 0 8px var(--color-shadow-primary);
|
||||
cursor: pointer;
|
||||
}
|
||||
span {
|
||||
min-width: 2.2rem;
|
||||
max-width: 2.2rem;
|
||||
}
|
||||
.form-group {
|
||||
flex: 1;
|
||||
padding-left: 4px;
|
||||
@@ -117,9 +120,11 @@
|
||||
flex: 1;
|
||||
|
||||
.monster-skill {
|
||||
display: flex;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, auto 2.5rem);
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
margin-right: 0.5rem;
|
||||
|
||||
.rollable:hover,
|
||||
.rollable:focus {
|
||||
text-shadow: 0 0 8px var(--color-shadow-primary);
|
||||
@@ -130,12 +135,9 @@
|
||||
max-width: 2.5rem;
|
||||
}
|
||||
.name {
|
||||
flex: 1;
|
||||
min-width: 3.2rem;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.form-group {
|
||||
flex: 1;
|
||||
padding-left: 4px;
|
||||
.form-fields {
|
||||
flex: none;
|
||||
@@ -153,8 +155,9 @@
|
||||
|
||||
.monster-movement {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 0.5rem;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
|
||||
.rollable:hover,
|
||||
.rollable:focus {
|
||||
text-shadow: 0 0 8px var(--color-shadow-primary);
|
||||
@@ -223,7 +226,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.tab.monster-biography {
|
||||
.tab.monster-biography .main-div {
|
||||
.biodata {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
@@ -248,7 +251,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.tab.monster-skills {
|
||||
.tab.monster-skills .main-div {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
legend {
|
||||
@@ -407,6 +410,48 @@
|
||||
}
|
||||
}
|
||||
|
||||
.ranged-attacks {
|
||||
grid-template-columns: 1fr;
|
||||
.attack {
|
||||
.name {
|
||||
min-width: 10rem;
|
||||
max-width: 10rem;
|
||||
}
|
||||
.damage-dice {
|
||||
width: 5rem;
|
||||
max-width: 5rem;
|
||||
}
|
||||
}
|
||||
.ranged-weapon-range {
|
||||
margin-top: 8px;
|
||||
border-top: 1px solid var(--color-border-light-tertiary, #ccc);
|
||||
padding-top: 6px;
|
||||
> label {
|
||||
font-weight: bold;
|
||||
margin-bottom: 4px;
|
||||
display: block;
|
||||
}
|
||||
.range-fields {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
.range-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
label {
|
||||
font-size: 0.7rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
input {
|
||||
width: 3.5rem;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.armors {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
@@ -462,4 +507,3 @@
|
||||
min-height: 150px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1240
-36
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user