Compare commits

...

22 Commits

Author SHA1 Message Date
uberwald db3e8b5d35 Improve init for monsters and some fixwes around shields
Release Creation / build (release) Successful in 48s
2026-05-17 13:22:29 +02:00
uberwald 54421e4a83 MAnage spell/miracle spending points and favor/disfavor for shield rolls
Release Creation / build (release) Successful in 43s
2026-05-10 17:49:53 +02:00
uberwald ac44419b7a Corredction sur attack ranged 2026-05-03 15:12:25 +02:00
uberwald a3fc0a42b9 Corredction sur attack ranged
Release Creation / build (release) Successful in 1m19s
2026-05-03 10:06:44 +02:00
uberwald c8ce840e98 Fix ranged defense + HTH attacks
Release Creation / build (release) Successful in 1m17s
2026-05-02 08:35:22 +02:00
uberwald 55a040062a Fix ranged defense + HTH attacks
Release Creation / build (release) Successful in 1m19s
2026-05-01 23:55:29 +02:00
uberwald 1818a76499 Fix ranged defense + HTH attacks
Release Creation / build (release) Successful in 1m19s
2026-05-01 23:34:05 +02:00
uberwald 55d1b41ca4 Fix ranged defense + HTH attacks 2026-05-01 23:32:53 +02:00
uberwald 841ed82277 Fix for ranged monsters attack
Release Creation / build (release) Successful in 1m2s
2026-05-01 01:12:56 +02:00
uberwald 968d156d09 Upgrade to r14
Release Creation / build (release) Successful in 48s
2026-04-30 14:38:56 +02:00
uberwald 59ff098fca Add ranged attacks for monsters 2026-04-29 20:27:20 +02:00
uberwald b8174d5e22 Fix E dice in dice Tray
Release Creation / build (release) Successful in 55s
2026-04-17 23:21:49 +02:00
uberwald 7f15450566 Add specific diceTray and enhance message styles
Release Creation / build (release) Successful in 49s
2026-04-17 17:32:46 +02:00
uberwald 28fdaff2ec Add specific diceTray and enhance message styles 2026-04-17 17:32:32 +02:00
uberwald 81584ed5d6 Update D30 descriptions and add simple shield option for NPCs 2026-04-16 23:42:24 +02:00
uberwald 8c9a13faf1 Fixes around D30 managemen 2026-04-16 21:39:51 +02:00
uberwald 6c6c473147 Fixes regarding shields usage and spells
Release Creation / build (release) Successful in 52s
2026-04-14 21:31:17 +02:00
uberwald 2e2a917a45 Fixes regarding shields usage and spells 2026-04-14 21:31:03 +02:00
uberwald 343abc32e2 FIx init à 1 again
Release Creation / build (release) Successful in 50s
2026-04-12 11:08:19 +02:00
uberwald c37d92af25 Various initiative fixes + shield management messages
Release Creation / build (release) Successful in 46s
2026-04-12 01:07:58 +02:00
uberwald 42945d33db ATtempt to fix init rolls
Release Creation / build (release) Successful in 52s
2026-04-07 20:44:13 +02:00
uberwald 1bf88bac06 ATtempt to fix init rolls 2026-04-07 20:43:15 +02:00
54 changed files with 2866 additions and 595 deletions
+1 -1
View File
@@ -60,4 +60,4 @@ jobs:
manifest: "https://www.uberwald.me/gitea/${{gitea.repository}}/releases/download/${{github.event.release.tag_name}}/system.json"
notes: "https://www.uberwald.me/gitea/public/fvtt-lethal-fantasy/raw/branch/main/changelog.md"
compatibility-minimum: "13"
compatibility-verified: "13"
compatibility-verified: "14"
Binary file not shown.
+266 -4
View File
@@ -1178,6 +1178,45 @@ i.lethalfantasy {
margin-left: 4px;
margin-right: 4px;
}
.lethalfantasy .tab.monster-combat .ranged-attacks {
grid-template-columns: 1fr;
}
.lethalfantasy .tab.monster-combat .ranged-attacks .attack .name {
min-width: 10rem;
max-width: 10rem;
}
.lethalfantasy .tab.monster-combat .ranged-attacks .attack .damage-dice {
width: 5rem;
max-width: 5rem;
}
.lethalfantasy .tab.monster-combat .ranged-attacks .ranged-weapon-range {
margin-top: 8px;
border-top: 1px solid var(--color-border-light-tertiary, #ccc);
padding-top: 6px;
}
.lethalfantasy .tab.monster-combat .ranged-attacks .ranged-weapon-range > label {
font-weight: bold;
margin-bottom: 4px;
display: block;
}
.lethalfantasy .tab.monster-combat .ranged-attacks .ranged-weapon-range .range-fields {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.lethalfantasy .tab.monster-combat .ranged-attacks .ranged-weapon-range .range-fields .range-field {
display: flex;
flex-direction: column;
align-items: center;
}
.lethalfantasy .tab.monster-combat .ranged-attacks .ranged-weapon-range .range-fields .range-field label {
font-size: 0.7rem;
white-space: nowrap;
}
.lethalfantasy .tab.monster-combat .ranged-attacks .ranged-weapon-range .range-fields .range-field input {
width: 3.5rem;
text-align: center;
}
.lethalfantasy .tab.monster-combat .armors {
display: grid;
grid-template-columns: repeat(3, 1fr);
@@ -2974,7 +3013,7 @@ i.lethalfantasy {
.message.fvtt-lethal-fantasy.dice-roll .result-section .d30-result .d30-header .d30-label {
flex-grow: 1;
font-weight: bold;
color: #e0d5f0;
color: #2a1a3a;
text-transform: uppercase;
letter-spacing: 0.5px;
font-size: calc(var(--font-size-standard) * 0.9);
@@ -2986,11 +3025,11 @@ i.lethalfantasy {
font-family: var(--font-primary);
font-size: calc(var(--font-size-standard) * 1.5);
font-weight: bold;
color: #ff69b4;
background: rgba(255, 105, 180, 0.1);
color: #3d006e;
background: rgba(255, 255, 255, 0.35);
padding: 4px 12px;
border-radius: 12px;
border: 1px solid rgba(255, 105, 180, 0.3);
border: 1px solid rgba(138, 43, 226, 0.4);
}
.lethalfantasy.dice-roll .result-section .d30-result .d30-message,
.fvtt-lethal-fantasy.dice-roll .result-section .d30-result .d30-message,
@@ -3994,3 +4033,226 @@ i.lethalfantasy {
padding-left: 8px;
font-size: 0.9rem;
}
/* -------------------------------------------------- */
/* 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-dice-tray .lf-dt-row {
display: flex;
align-items: center;
gap: 5px;
flex-wrap: wrap;
}
.lf-dice-tray .lf-dt-label {
color: #3a2a10;
font-size: 15px;
flex-shrink: 0;
opacity: 0.7;
}
.lf-dice-tray .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;
}
.lf-dice-tray .lf-dt-count option {
background: #f5ead0;
color: #2a1a08;
}
.lf-dice-tray .lf-dt-count:focus {
outline: none;
border-color: rgba(139, 69, 19, 0.7);
box-shadow: 0 0 4px rgba(139, 69, 19, 0.25);
}
.lf-dice-tray .lf-dt-dice {
display: flex;
flex-wrap: wrap;
gap: 3px;
flex: 1;
}
.lf-dice-tray .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;
}
.lf-dice-tray .lf-dt-die-btn: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);
}
.lf-dice-tray .lf-dt-die-btn:active {
transform: translateY(0);
box-shadow: none;
background: rgba(139, 69, 19, 0.5);
}
.lf-dice-tray .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;
}
.lf-dice-tray .lf-dt-explode-label:hover {
color: rgba(200, 100, 30, 0.9);
border-color: rgba(139, 69, 19, 0.45);
background: rgba(139, 69, 19, 0.12);
}
.lf-dice-tray .lf-dt-explode-label input[type="checkbox"] {
appearance: none;
width: 0;
height: 0;
position: absolute;
opacity: 0;
}
.lf-dice-tray .lf-dt-explode-label input[type="checkbox"]:checked ~ i {
color: #cc4400;
filter: drop-shadow(0 0 4px rgba(200, 80, 0, 0.6));
}
.lf-dice-tray .lf-dt-explode-label: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-free-roll-card .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);
}
.lf-free-roll-card .lf-frc-header i {
color: #c9b896;
font-size: calc(var(--font-size-standard, 14px) * 1.1);
}
.lf-free-roll-card .lf-frc-header .lf-frc-title-text {
font-size: calc(var(--font-size-standard, 14px) * 0.85);
color: #c9b896;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.lf-free-roll-card .lf-frc-header .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-free-roll-card .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-free-roll-card .lf-frc-dice .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-free-roll-card .lf-frc-dice .lf-frc-die-chip .lf-frc-die-type {
font-size: calc(var(--font-size-standard, 14px) * 0.85);
font-weight: 600;
color: #2a2a1a;
text-transform: uppercase;
}
.lf-free-roll-card .lf-frc-dice .lf-frc-die-chip .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-free-roll-card .lf-frc-dice .lf-frc-die-chip .lf-frc-die-val {
font-weight: bold;
color: #ffd700;
font-size: calc(var(--font-size-standard, 14px) * 0.95);
}
.lf-free-roll-card .lf-frc-dice .lf-frc-die-chip .lf-frc-die-val .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-free-roll-card .lf-frc-dice .lf-frc-die-chip.lf-frc-max {
background: rgba(139, 90, 19, 0.35);
border-color: rgba(200, 116, 42, 0.6);
}
.lf-free-roll-card .lf-frc-dice .lf-frc-die-chip.lf-frc-max .lf-frc-die-val {
color: #ff9a40;
text-shadow: 0 0 6px rgba(200, 116, 42, 0.6);
}
.lf-free-roll-card .lf-frc-dice .lf-frc-die-chip.lf-frc-min {
background: rgba(139, 20, 20, 0.25);
border-color: rgba(139, 34, 34, 0.5);
}
.lf-free-roll-card .lf-frc-dice .lf-frc-die-chip.lf-frc-min .lf-frc-die-val {
color: #ff6b6b;
}
.lf-free-roll-card .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-free-roll-card .lf-frc-total-bar .lf-frc-total-label {
font-size: calc(var(--font-size-standard, 14px) * 0.85);
text-transform: uppercase;
letter-spacing: 0.5px;
color: #c9b896;
}
.lf-free-roll-card .lf-frc-total-bar .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);
}
+136 -15
View File
@@ -1,8 +1,8 @@
{
"COMBAT": {
"Round": "Second {round}",
"Rounds": "Seconds",
"RoundNext": "Next second"
"Round": "Second {round}",
"Rounds": "Seconds",
"RoundNext": "Next second"
},
"LETHALFANTASY": {
"Armor": {
@@ -152,6 +152,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": {
@@ -250,6 +301,21 @@
"wis": {
"label": "Wisdom"
}
},
"perception": {
"label": "Perception"
},
"resistIntimidation": {
"label": "Resist Intimidation"
},
"resistPerformance": {
"label": "Resist Performance"
},
"resistTorture": {
"label": "Resist Torture"
},
"stealth": {
"label": "Stealth"
}
},
"Delete": "Delete",
@@ -294,13 +360,13 @@
"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",
@@ -316,11 +382,14 @@
"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",
@@ -393,6 +462,13 @@
"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",
"rangedAttackDefense": "Ranged attack defense",
@@ -428,7 +504,10 @@
"weapons": "Weapons",
"wis": "WIS",
"weapon-damage-medium": "Weapon damage medium",
"weapon-damage-small": "Weapon damage small"
"weapon-damage-small": "Weapon damage small",
"combatProgressionStart": "Combat start threshold",
"miracle": "Miracle",
"titleStandard": "Standard Roll"
},
"Miracle": {
"FIELDS": {
@@ -518,7 +597,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": {
@@ -660,6 +741,9 @@
"weaponClass": {
"label": "Class"
}
},
"error": {
"weaponBonus": "Weapon bonus exceeds the allowed maximum (skill total / 10)"
}
},
"Spell": {
@@ -722,14 +806,29 @@
},
"catalyst": {
"label": "Catalyst"
},
"damageDice": {
"label": "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": {
@@ -888,6 +987,28 @@
"cannotAct": "cannot act this second",
"diceResult": "Dice result",
"progressionCount": "Progression count:"
},
"Combat": {
"RollMonsters": "Roll Monsters"
},
"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": {
+613 -223
View File
@@ -129,255 +129,290 @@ Hooks.once("ready", function () {
}
})
// Test if version below 13
let hookName = "renderChatMessage"
if (foundry.utils.isNewerVersion(game.version, "12.0",)) {
hookName = "renderChatMessageHTML"
}
Hooks.on(hookName, (message, html, data) => {
Hooks.on("renderChatMessageHTML", (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) => {
for (const btn of html.querySelectorAll(".ask-roll-dice")) {
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)
})
for (const btn of html.querySelectorAll(".ask-roll-dice")) {
btn.addEventListener("click", () => {
const type = btn.dataset.type
const value = btn.dataset.value
const avantage = btn.dataset.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)
})
}
}
}
// Gestion du survol et du clic sur les boutons de dégâts pour les GMs
if (game.user.isGM) {
// Show damage buttons only for GM
$(html).find(".li-apply-wounds").each((i, btn) => {
for (const btn of html.querySelectorAll(".li-apply-wounds")) {
btn.style.display = "block"
})
}
$(html).find(".apply-wounds-btn").hover(
function (event) {
// Mouse enter - select the token and pan to it
let combatantId = $(this).data("combatant-id")
for (const btn of html.querySelectorAll(".apply-wounds-btn")) {
btn.addEventListener("mouseenter", () => {
const combatantId = btn.dataset.combatantId
if (combatantId && game.combat) {
let combatant = game.combat.combatants.get(combatantId)
const combatant = game.combat.combatants.get(combatantId)
if (combatant?.token) {
let token = canvas.tokens.get(combatant.token.id)
const token = canvas.tokens.get(combatant.token.id)
if (token) {
token.control({ releaseOthers: true })
canvas.animatePan(token.center)
}
}
}
},
function (event) {
// Mouse leave - release selection
canvas.tokens.releaseAll()
}
)
$(html).find(".apply-wounds-btn").click((event) => {
LethalFantasyUtils.applyDamage(message, event)
})
})
btn.addEventListener("mouseleave", () => canvas.tokens.releaseAll())
btn.addEventListener("click", event => LethalFantasyUtils.applyDamage(message, event))
}
}
// Gestion du survol et du clic sur les boutons de défense
$(html).find(".request-defense-btn").hover(
function (event) {
// Mouse enter - select the token and pan to it
let tokenId = $(this).data("token-id")
for (const btn of html.querySelectorAll(".request-defense-btn")) {
btn.addEventListener("mouseenter", () => {
const tokenId = btn.dataset.tokenId
if (tokenId) {
let token = canvas.tokens.get(tokenId)
const token = canvas.tokens.get(tokenId)
if (token) {
token.control({ releaseOthers: true })
canvas.animatePan(token.center)
}
}
},
function (event) {
// Mouse leave - release selection
canvas.tokens.releaseAll()
}
)
})
btn.addEventListener("mouseleave", () => canvas.tokens.releaseAll())
// Gestionnaire pour les boutons de demande de défense
$(html).find(".request-defense-btn").off("click").on("click", (event) => {
event.preventDefault()
event.stopPropagation()
// Gestionnaire pour les boutons de demande de défense
btn.addEventListener("click", event => {
event.preventDefault()
event.stopPropagation()
const button = $(event.currentTarget)
const combatantId = button.data("combatant-id")
const tokenId = button.data("token-id")
const combatantId = btn.dataset.combatantId
const tokenId = btn.dataset.tokenId
// Récupérer le combattant soit du combat, soit directement du token
let combatant = null
let token = null
// Récupérer le combattant soit du combat, soit directement du token
let combatant = null
let token = null
if (game.combat && combatantId) {
combatant = game.combat.combatants.get(combatantId)
}
if (game.combat && combatantId) {
combatant = game.combat.combatants.get(combatantId)
}
// Si pas de combattant trouvé, chercher le token directement
if (!combatant && tokenId) {
token = canvas.tokens.get(tokenId)
if (token) {
// Créer un pseudo-combattant avec les infos du token
combatant = {
actor: token.actor,
name: token.name,
token: token,
actorId: token.actorId
// Si pas de combattant trouvé, chercher le token directement
if (!combatant && tokenId) {
token = canvas.tokens.get(tokenId)
if (token) {
// Créer un pseudo-combattant avec les infos du token
combatant = {
actor: token.actor,
name: token.name,
token: token,
actorId: token.actorId
}
}
}
}
if (!combatant) return
if (!combatant) return
// Récupérer les informations de l'attaquant depuis le message
const attackerName = message.rolls[0]?.actorName || "Unknown"
const attackerId = message.rolls[0]?.actorId
const weaponName = message.rolls[0]?.rollName || "weapon"
const attackRoll = message.rolls[0]?.rollTotal || 0
const defenderName = combatant.name
const attackWeaponId = message.rolls[0]?.rollTarget?.weapon?.id || message.rolls[0]?.rollTarget?.weapon?._id
const attackRollType = message.rolls[0]?.type
const attackRollKey = message.rolls[0]?.rollTarget?.rollKey
// Récupérer les informations de l'attaquant depuis le message
const attackerName = message.rolls[0]?.actorName || "Unknown"
const attackerId = message.rolls[0]?.actorId
const weaponName = message.rolls[0]?.rollName || "weapon"
const attackRoll = message.rolls[0]?.rollTotal || 0
const defenderName = combatant.name
const attackWeaponId = message.rolls[0]?.rollTarget?.weapon?.id || message.rolls[0]?.rollTarget?.weapon?._id
const attackRollType = message.rolls[0]?.type
const attackRollKey = message.rolls[0]?.rollTarget?.rollKey
console.log(`[LF] request-defense-btn | attackRollType=${attackRollType} defender=${defenderName} defenderType=${combatant.actor?.type}`)
const attackD30result = message.rolls[0]?.options?.D30result || null
const attackD30message = message.rolls[0]?.options?.D30message || null
const attackRerollContext = {
rollType: message.rolls[0]?.options?.rollType,
rollTarget: foundry.utils.duplicate(message.rolls[0]?.options?.rollTarget ?? {}),
actorId: message.rolls[0]?.options?.actorId,
actorName: message.rolls[0]?.options?.actorName,
actorImage: message.rolls[0]?.options?.actorImage,
defenderId: combatant.actor?.id || null,
defenderTokenId: tokenId || combatant.token?.id || null,
rollContext: foundry.utils.duplicate(message.rolls[0]?.options?.rollData ?? {})
}
// Préparer le message de demande de défense
const defenseMsg = {
type: "requestDefense",
attackerName: attackerName,
attackerId: attackerId,
defenderName: defenderName,
weaponName: weaponName,
attackRoll: attackRoll,
attackWeaponId: attackWeaponId,
attackRollType: attackRollType,
attackRollKey: attackRollKey,
combatantId: combatantId,
tokenId: tokenId
}
// Préparer le message de demande de défense
// isRanged: true si le monstre était en mode ranged (via rollTarget.attackMode stocké dans le roll)
// OU si l'attaquant utilisait une arme ranged (weapon-attack avec weaponType === "ranged")
const attacker = game.actors.get(attackerId)
const rollTargetOptions = message.rolls[0]?.options?.rollTarget
const attackerWeapon = rollTargetOptions?.weapon
const isRangedAttack = (rollTargetOptions?.attackMode === "ranged")
|| (attacker?.type === "monster" && attacker.system.attackMode === "ranged")
|| (attackerWeapon?.system?.weaponType === "ranged")
// Envoyer le message socket à l'utilisateur contrôlant le combatant
// Only consider active (online) users; fall back to any active GM for unowned/GM monsters.
let owners = game.users.filter(u =>
u.active && combatant.actor.testUserPermission(u, "OWNER")
)
if (owners.length === 0) {
owners = game.users.filter(u => u.active && u.isGM)
}
const defenseMsg = {
type: "requestDefense",
attackerName,
attackerId,
defenderName,
weaponName,
attackRoll,
attackWeaponId,
attackRollType,
attackRollKey,
attackD30result,
attackD30message,
attackRerollContext,
combatantId,
tokenId,
isRanged: isRangedAttack
}
// Récupérer l'acteur attaquant pour vérifier qui l'a lancé
const attacker = game.actors.get(attackerId)
const attackerOwners = attacker ? game.users.filter(u => attacker.testUserPermission(u, "OWNER")).map(u => u.id) : []
// Envoyer le message socket à l'utilisateur contrôlant le combatant
// Only consider active (online) users; fall back to any active GM for unowned/GM monsters.
let owners = game.users.filter(u => u.active && combatant.actor.testUserPermission(u, "OWNER"))
if (owners.length === 0) {
owners = game.users.filter(u => u.active && u.isGM)
}
let messageSent = false
owners.forEach(owner => {
// Ne pas afficher le dialogue à l'attaquant lui-même s'il contrôle aussi le défenseur
if (attackerOwners.includes(owner.id) && owner.id === game.user.id) {
// Ne rien faire - on ne veut pas que l'attaquant se défende contre lui-même
// Récupérer l'acteur attaquant pour vérifier qui l'a lancé
const attackerOwners = attacker ? game.users.filter(u => attacker.testUserPermission(u, "OWNER")).map(u => u.id) : []
// Monsters always need their owner (usually the GM) to roll a save/defense,
// even if that owner also controls the attacker. Only skip for same-player PC-vs-PC.
const defenderIsMonster = combatant.actor?.type === "monster"
let messageSent = false
owners.forEach(owner => {
// Don't let a player be both attacker and defender for their own PC, unless defending a monster.
if (attackerOwners.includes(owner.id) && owner.id === game.user.id && !defenderIsMonster) {
// Ne rien faire - on ne veut pas que l'attaquant se défende contre lui-même
return
}
if (owner.id === game.user.id) {
// Si l'utilisateur actuel est le propriétaire du défenseur (mais pas l'attaquant), appeler directement
LethalFantasyUtils.showDefenseRequest({ ...defenseMsg, userId: owner.id })
messageSent = true
} else {
// Sinon, envoyer via socket
game.socket.emit(`system.${SYSTEM.id}`, { ...defenseMsg, userId: owner.id })
messageSent = true
}
})
// Notification pour l'attaquant
if (messageSent) {
ui.notifications.info(`Defense request sent to ${defenderName}'s controller`)
}
})
}
// Gestionnaire pour les boutons de jet de dégâts (armes et résultats de combat)
for (const btn of html.querySelectorAll(".damage-roll-btn, .roll-damage-btn")) {
btn.addEventListener("click", async event => {
event.preventDefault()
event.stopPropagation()
const weaponId = btn.dataset.weaponId
const attackKey = btn.dataset.attackKey
const attackerId = btn.dataset.attackerId
const defenderId = btn.dataset.defenderId
const defenderTokenId = btn.dataset.defenderTokenId || null
const extraShieldDr = Number(btn.dataset.extraShieldDr || 0)
const damageType = btn.dataset.damageType
const damageFormula = btn.dataset.damageFormula
const damageModifier = btn.dataset.damageModifier
const isMonster = btn.dataset.isMonster
// Récupérer l'acteur (soit depuis le message, soit depuis attackerId)
const actor = attackerId ? game.actors.get(attackerId) : game.actors.get(message.rolls[0]?.actorId)
if (!actor) {
ui.notifications.error("Actor not found")
return
}
if (owner.id === game.user.id) {
// Si l'utilisateur actuel est le propriétaire du défenseur (mais pas l'attaquant), appeler directement
LethalFantasyUtils.showDefenseRequest({ ...defenseMsg, userId: owner.id })
messageSent = true
} else {
// Sinon, envoyer via socket
game.socket.emit(`system.${SYSTEM.id}`, {
...defenseMsg,
userId: owner.id
// Pour les sorts, rouler les dés de dégâts avec option bypass DR
if (damageType === "spell" && damageFormula) {
const bypassArmor = await foundry.applications.api.DialogV2.confirm({
window: { title: "Spell Damage" },
classes: ["lethalfantasy"],
content: "<p>Does this spell's damage bypass armor DR?</p>",
yes: { label: "Yes (ignore armor)", icon: "fa-solid fa-wand-magic-sparkles" },
no: { label: "No (apply armor DR)", icon: "fa-solid fa-shield" }
})
messageSent = true
const rollOpts = {
type: "spell-damage",
rollType: "spell-damage",
rollName: damageFormula,
isDamage: true,
rollData: { isDamage: true },
bypassArmor: bypassArmor ?? false,
defenderId,
defenderTokenId,
actorId: actor.id,
actorName: actor.name,
actorImage: actor.img
}
const roll = new LethalFantasyRoll(damageFormula, {}, rollOpts)
await roll.evaluate()
roll.options.rollTotal = roll.total
if (game?.dice3d) await game.dice3d.showForRoll(roll, game.user, true)
await roll.toMessage()
return
}
// Pour les boutons de résultat de combat (monster damage)
if (damageType === "monster" && attackKey) {
await actor.system.prepareMonsterRoll("monster-damage", attackKey, undefined, undefined, undefined, defenderId, defenderTokenId, extraShieldDr)
return
}
// Pour les monstres, utiliser prepareMonsterRoll
if (isMonster || actor.type === "monster") {
await actor.system.prepareMonsterRoll("monster-damage", weaponId, undefined, undefined, damageModifier)
return
}
// Pour les personnages, récupérer l'arme
const weapon = actor.items.get(weaponId)
if (!weapon) {
ui.notifications.error("Weapon not found")
return
}
// Lancer les dégâts avec la bonne méthode
const rollType = damageType === "small" ? "weapon-damage-small" : "weapon-damage-medium"
await actor.prepareRoll(rollType, weaponId, undefined, defenderId, defenderTokenId, extraShieldDr)
})
// Notification pour l'attaquant
if (messageSent) {
ui.notifications.info(`Defense request sent to ${defenderName}'s controller`)
}
})
// Gestionnaire pour les boutons de jet de dégâts (armes et résultats de combat)
$(html).find(".damage-roll-btn, .roll-damage-btn").off("click").on("click", async (event) => {
event.preventDefault()
event.stopPropagation()
const button = $(event.currentTarget)
const weaponId = button.data("weapon-id")
const attackKey = button.data("attack-key")
let attackerId = button.data("attacker-id")
const defenderId = button.data("defender-id")
const damageType = button.data("damage-type")
const damageFormula = button.data("damage-formula")
const damageModifier = button.data("damage-modifier")
const isMonster = button.data("is-monster")
// Récupérer l'acteur (soit depuis le message, soit depuis attackerId)
let actor = attackerId ? game.actors.get(attackerId) : game.actors.get(message.rolls[0]?.actorId)
if (!actor) {
ui.notifications.error("Actor not found")
return
}
// Pour les boutons de résultat de combat (monster damage)
if (damageType === "monster" && attackKey) {
await actor.system.prepareMonsterRoll("monster-damage", attackKey, undefined, undefined, undefined, defenderId)
return
}
// Pour les monstres, utiliser prepareMonsterRoll
if (isMonster || actor.type === "monster") {
await actor.system.prepareMonsterRoll("monster-damage", weaponId, undefined, undefined, damageModifier)
return
}
// Pour les personnages, récupérer l'arme
const weapon = actor.items.get(weaponId)
if (!weapon) {
ui.notifications.error("Weapon not found")
return
}
// Lancer les dégâts avec la bonne méthode
const rollType = damageType === "small" ? "weapon-damage-small" : "weapon-damage-medium"
await actor.prepareRoll(rollType, weaponId, undefined, defenderId)
})
}
// Masquer les boutons de dommages dans les messages de résultat de combat si l'utilisateur n'est pas l'attaquant
$(html).find(".roll-damage-btn").each(function() {
const button = $(this)
const attackerId = button.data("attacker-id")
for (const btn of html.querySelectorAll(".roll-damage-btn")) {
const attackerId = btn.dataset.attackerId
if (attackerId) {
const attacker = game.actors.get(attackerId)
// Masquer le bouton si l'utilisateur n'est pas GM et ne possède pas l'attaquant
if (!game.user.isGM && !attacker?.testUserPermission(game.user, "OWNER")) {
button.hide()
btn.style.display = "none"
}
}
})
}
})
Hooks.on("getCombatTrackerEntryContext", (html, options) => {
LethalFantasyUtils.pushCombatOptions(html, options);
});
// Hook pour ajouter les données d'attaque au message de défense
Hooks.on("preCreateChatMessage", (message) => {
const rollType = message.rolls[0]?.options?.rollType
// Si c'est un message de défense et qu'on a des données en attente
if ((rollType === "weapon-defense" || rollType === "monster-defense") && game.lethalFantasy?.nextDefenseData) {
if ((rollType === "weapon-defense" || rollType === "monster-defense" || rollType === "save") && game.lethalFantasy?.nextDefenseData) {
// Ajouter les données dans les flags du message
message.updateSource({
[`flags.${SYSTEM.id}.attackData`]: game.lethalFantasy.nextDefenseData
@@ -397,7 +432,7 @@ Hooks.on("createChatMessage", async (message) => {
console.log("Defense hook checking message, rollType:", rollType)
// Vérifier si c'est un message de défense
if (rollType !== "weapon-defense" && rollType !== "monster-defense") return
if (rollType !== "weapon-defense" && rollType !== "monster-defense" && rollType !== "save") return
// Récupérer les données d'attaque depuis les flags
const attackData = message.flags?.[SYSTEM.id]?.attackData
@@ -409,8 +444,21 @@ Hooks.on("createChatMessage", async (message) => {
return
}
const { attackerId, attackRoll, attackerName, defenderName, attackWeaponId, attackRollType, attackRollKey, defenderId } = attackData
const {
attackerId,
attackRoll,
attackerName,
defenderName,
attackWeaponId,
attackRollType,
attackRollKey,
attackD30message,
attackRerollContext,
defenderId,
defenderTokenId
} = attackData
let defenseRoll = message.rolls[0]?.options?.rollTotal || message.rolls[0]?.total || 0
const defenseD30message = message.rolls[0]?.options?.D30message || null
console.log("Processing defense:", { attackRoll, defenseRoll, attackerId, defenderId })
@@ -422,26 +470,216 @@ Hooks.on("createChatMessage", async (message) => {
// Récupérer le défenseur et l'attaquant
const defender = game.actors.get(defenderId)
const attacker = game.actors.get(attackerId)
const defenseRerollContext = {
rollType: message.rolls[0]?.options?.rollType,
rollTarget: foundry.utils.duplicate(message.rolls[0]?.options?.rollTarget ?? {}),
actorId: message.rolls[0]?.options?.actorId,
actorName: message.rolls[0]?.options?.actorName,
actorImage: message.rolls[0]?.options?.actorImage,
defenderId,
defenderTokenId,
rollContext: foundry.utils.duplicate(message.rolls[0]?.options?.rollData ?? {})
}
const isPrimaryController = actor => {
if (!actor) return false
const activePlayerOwners = game.users.filter(u => u.active && !u.isGM && actor.testUserPermission(u, "OWNER"))
if (activePlayerOwners.length > 0) {
return activePlayerOwners[0].id === game.user.id
}
return game.user.isGM
}
const createReactionMessage = async (actorDocument, content) => {
await ChatMessage.create({
content,
speaker: ChatMessage.getSpeaker({ actor: actorDocument })
})
}
// Si le défenseur est un personnage qui perd, proposer Grit/Luck (seulement s'il a des points)
// Seulement si l'utilisateur actuel est le propriétaire du défenseur
let defenderHandledBonus = false
if (defender?.type === "character" && defenseRoll < attackRoll && !game.user.isGM && defender.isOwner) {
const hasGritOrLuck = (defender.system.grit.current > 0) || (defender.system.luck.current > 0)
let shieldReaction = null
let shieldBlocked = false
const isSpellOrMiracle = attackRollType === "spell-attack" || attackRollType === "miracle-attack"
if (defender && defenseRoll < attackRoll && isPrimaryController(defender) && !isSpellOrMiracle) {
const shieldData = LethalFantasyUtils.getShieldReactionData(defender)
let canRerollDefense = LethalFantasyUtils.hasD30Reroll(defenseD30message)
let canShieldReact = !!shieldData
let canAdHocShield = !shieldData
if (hasGritOrLuck) {
const bonusRoll = await LethalFantasyUtils.offerGritLuckBonus(
defender,
attackRoll,
defenseRoll,
attackerName,
defenderName
)
if (bonusRoll > 0) {
while (defenseRoll < attackRoll) {
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",
label: `Spend 1 Grit (+1D6) [${currentGrit} left]`,
icon: "fa-solid fa-fist-raised",
callback: () => "grit"
})
}
if (currentLuck > 0) {
buttons.push({
action: "luck",
label: `Spend 1 Luck (+1D6) [${currentLuck} left]`,
icon: "fa-solid fa-clover",
callback: () => "luck"
})
}
buttons.push({
action: "bonusDie",
label: "Add bonus die",
icon: "fa-solid fa-dice",
callback: () => "bonusDie"
})
if (canRerollDefense) {
buttons.push({
action: "rerollDefense",
label: "Re-roll defense",
icon: "fa-solid fa-rotate-right",
callback: () => "rerollDefense"
})
}
if (canShieldReact) {
buttons.push({
action: "shieldReact",
label: `Roll shield (${shieldData.label})`,
icon: "fa-solid fa-shield",
callback: () => "shieldReact"
})
} else if (canAdHocShield) {
// No pre-configured shield — offer ad-hoc shield option (useful for monsters)
buttons.push({
action: "adHocShield",
label: "Roll ad-hoc shield (choose dice + DR)",
icon: "fa-solid fa-shield-halved",
callback: () => "adHocShield"
})
}
buttons.push({
action: "continue",
label: "Continue (no defense bonus)",
icon: "fa-solid fa-forward",
callback: () => "continue"
})
const choice = await foundry.applications.api.DialogV2.wait({
window: { title: "Defense reactions" },
classes: ["lethalfantasy"],
content: `
<div class="grit-luck-dialog">
<div class="combat-status">
<p><strong>${attackerName}</strong> rolled <strong>${attackRoll}</strong></p>
<p><strong>${defenderName}</strong> currently has <strong>${defenseRoll}</strong></p>
${defenseD30message ? `<p class="bonus-info">D30 special: ${defenseD30message.description}</p>` : ""}
</div>
<p class="offer-text">Choose how to improve the defense before resolving the hit.</p>
</div>
`,
buttons,
rejectClose: false
})
if (!choice || choice === "continue") break
defenderHandledBonus = true
if (choice === "grit") {
const bonusRoll = await LethalFantasyUtils.rollBonusDie("1d6", defender, (total) => `<p><strong>${defenderName}</strong> spends 1 Grit and rolls <strong>${total}</strong> for defense.</p>`)
defenseRoll += bonusRoll
await defender.update({ "system.grit.current": currentGrit - 1 })
continue
}
if (choice === "luck") {
const bonusRoll = await LethalFantasyUtils.rollBonusDie("1d6", defender, (total) => `<p><strong>${defenderName}</strong> spends 1 Luck and rolls <strong>${total}</strong> for defense.</p>`)
defenseRoll += bonusRoll
await defender.update({ "system.luck.current": currentLuck - 1 })
continue
}
if (choice === "bonusDie") {
const bonusDie = await LethalFantasyUtils.promptCombatBonusDie(defenderName, "attack", defenseRoll, attackRoll)
if (!bonusDie) continue
const bonusRoll = await LethalFantasyUtils.rollBonusDie(bonusDie, defender, (total, formula) => `<p><strong>${defenderName}</strong> adds <strong>${formula.toUpperCase()}</strong> and rolls <strong>${total}</strong> for defense.</p>`)
defenseRoll += bonusRoll
continue
}
if (choice === "rerollDefense" && canRerollDefense) {
const oldDefenseRoll = defenseRoll
const reroll = await LethalFantasyUtils.rerollConfiguredRoll(defenseRerollContext)
canRerollDefense = false
if (!reroll) continue
defenseRoll = reroll.options?.rollTotal || reroll.total || oldDefenseRoll
await createReactionMessage(defender, `<p><strong>${defenderName}</strong> uses Mulligan and re-rolls defense: <strong>${oldDefenseRoll}</strong> → <strong>${defenseRoll}</strong>.</p>`)
continue
}
if (choice === "shieldReact" && canShieldReact) {
const shieldBonus = await LethalFantasyUtils.rollBonusDie(shieldData.formula, defender)
const newDefenseTotal = defenseRoll + shieldBonus
defenseRoll = newDefenseTotal
canShieldReact = false
if (newDefenseTotal >= attackRoll) {
shieldBlocked = true
shieldReaction = {
damageReduction: shieldData.damageReduction,
label: shieldData.label,
bonus: shieldBonus
}
await createReactionMessage(
defender,
`<p><strong>${defenderName}</strong> rolls <strong>${shieldData.label}</strong> and adds <strong>${shieldBonus}</strong> to defense (${newDefenseTotal}${attackRoll}). <strong>Shield blocked the attack!</strong> Both armor DR and shield DR <strong>${shieldData.damageReduction}</strong> will apply to damage.</p>`
)
} else {
shieldReaction = null
await createReactionMessage(
defender,
`<p><strong>${defenderName}</strong> rolls <strong>${shieldData.label}</strong> and adds <strong>${shieldBonus}</strong> to defense (${newDefenseTotal} < ${attackRoll}). Shield did not block — normal hit, armor DR only.</p>`
)
}
}
if (choice === "adHocShield") {
const adHoc = await LethalFantasyUtils.promptAdHocShield(defenderName, attackRoll, defenseRoll)
if (!adHoc) continue
const shieldBonus = await LethalFantasyUtils.rollBonusDie(adHoc.formula, defender)
const newDefenseTotal = defenseRoll + shieldBonus
defenseRoll = newDefenseTotal
canShieldReact = false
canAdHocShield = false
if (newDefenseTotal >= attackRoll) {
shieldBlocked = true
shieldReaction = {
damageReduction: adHoc.damageReduction,
label: `${adHoc.formula.toUpperCase()} shield`,
bonus: shieldBonus
}
await createReactionMessage(
defender,
`<p><strong>${defenderName}</strong> rolls <strong>${adHoc.formula.toUpperCase()}</strong> shield and adds <strong>${shieldBonus}</strong> to defense (${newDefenseTotal}${attackRoll}). <strong>Shield blocked the attack!</strong> Both armor DR and shield DR <strong>${adHoc.damageReduction}</strong> will apply to damage.</p>`
)
} else {
shieldReaction = null
await createReactionMessage(
defender,
`<p><strong>${defenderName}</strong> rolls <strong>${adHoc.formula.toUpperCase()}</strong> shield and adds <strong>${shieldBonus}</strong> to defense (${newDefenseTotal} < ${attackRoll}). Shield did not block — normal hit, armor DR only.</p>`
)
}
}
}
defenderHandledBonus = true
}
let attackRollFinal = attackRoll
@@ -449,31 +687,98 @@ Hooks.on("createChatMessage", async (message) => {
// Si l'attaquant est un personnage qui perd et a du Grit
// Seulement si l'utilisateur actuel est le propriétaire de l'attaquant (pas le MJ)
if (attacker?.type === "character" && attackRollFinal <= defenseRoll && attacker.system.grit.current > 0) {
// Vérifier si l'utilisateur est un propriétaire non-GM de l'attaquant
const isAttackerOwner = !game.user.isGM && attacker.testUserPermission(game.user, "OWNER")
if (!defenderHandledBonus && attacker && attackRollFinal <= defenseRoll && isPrimaryController(attacker)) {
let canRerollAttack = LethalFantasyUtils.hasD30Reroll(attackD30message)
if (isAttackerOwner) {
console.log("Offering Grit to attacker")
while (attackRollFinal <= defenseRoll) {
const currentGrit = Number(attacker.system?.grit?.current) || 0
const buttons = []
const attackBonus = await LethalFantasyUtils.offerAttackerGritBonus(
attacker,
attackRollFinal,
defenseRoll,
attackerName,
defenderName
)
if (currentGrit > 0) {
buttons.push({
action: "grit",
label: `Spend 1 Grit (+1D6) [${currentGrit} left]`,
icon: "fa-solid fa-fist-raised",
callback: () => "grit"
})
}
buttons.push({
action: "bonusDie",
label: "Add bonus die",
icon: "fa-solid fa-dice",
callback: () => "bonusDie"
})
if (canRerollAttack && attackRerollContext) {
buttons.push({
action: "rerollAttack",
label: "Re-roll attack",
icon: "fa-solid fa-rotate-right",
callback: () => "rerollAttack"
})
}
buttons.push({
action: "continue",
label: "Continue (no attack bonus)",
icon: "fa-solid fa-forward",
callback: () => "continue"
})
const choice = await foundry.applications.api.DialogV2.wait({
window: { title: "Attack reactions" },
classes: ["lethalfantasy"],
content: `
<div class="grit-luck-dialog">
<div class="combat-status">
<p><strong>${attackerName}</strong> currently has <strong>${attackRollFinal}</strong></p>
<p><strong>${defenderName}</strong> rolled <strong>${defenseRoll}</strong></p>
${attackD30message ? `<p class="bonus-info">D30 special: ${attackD30message.description}</p>` : ""}
</div>
<p class="offer-text">Choose how to improve the attack before resolving the combat result.</p>
</div>
`,
buttons,
rejectClose: false
})
if (!choice || choice === "continue") break
attackRollFinal += attackBonus
attackerHandledBonus = true
} else {
console.log("Not attacker owner or is GM, skipping Grit offer")
if (choice === "grit") {
const attackBonus = await LethalFantasyUtils.rollBonusDie("1d6", attacker, (total) => `<p><strong>${attackerName}</strong> spends 1 Grit and rolls <strong>${total}</strong> for attack.</p>`)
attackRollFinal += attackBonus
await attacker.update({ "system.grit.current": currentGrit - 1 })
continue
}
if (choice === "bonusDie") {
const bonusDie = await LethalFantasyUtils.promptCombatBonusDie(attackerName, "defense", attackRollFinal, defenseRoll)
if (!bonusDie) continue
const attackBonus = await LethalFantasyUtils.rollBonusDie(bonusDie, attacker, (total, formula) => `<p><strong>${attackerName}</strong> adds <strong>${formula.toUpperCase()}</strong> and rolls <strong>${total}</strong> for attack.</p>`)
attackRollFinal += attackBonus
continue
}
if (choice === "rerollAttack" && canRerollAttack && attackRerollContext) {
const oldAttackRoll = attackRollFinal
const reroll = await LethalFantasyUtils.rerollConfiguredRoll(attackRerollContext)
canRerollAttack = false
if (!reroll) continue
attackRollFinal = reroll.options?.rollTotal || reroll.total || oldAttackRoll
await createReactionMessage(attacker, `<p><strong>${attackerName}</strong> uses Mulligan and re-rolls attack: <strong>${oldAttackRoll}</strong> → <strong>${attackRollFinal}</strong>.</p>`)
}
}
}
const shieldDamageReduction = shieldBlocked ? shieldReaction.damageReduction : 0
const outcome = shieldBlocked ? "shielded-hit" : (attackRollFinal > defenseRoll ? "hit" : "miss")
// Créer le message de comparaison - uniquement par le client qui a géré le dernier bonus
// Priorité: attaquant si il a géré le bonus, sinon défenseur si il a géré le bonus, sinon défenseur
const shouldCreateMessage = attackerHandledBonus || (!attackerHandledBonus && defenderHandledBonus) || (!attackerHandledBonus && !defenderHandledBonus && defender.isOwner)
const shouldCreateMessage = attackerHandledBonus || (!attackerHandledBonus && defenderHandledBonus) || (!attackerHandledBonus && !defenderHandledBonus && isPrimaryController(defender))
if (shouldCreateMessage) {
console.log("Creating comparison message", { attackerHandledBonus, defenderHandledBonus, isDefenderOwner: defender.isOwner })
@@ -487,13 +792,83 @@ Hooks.on("createChatMessage", async (message) => {
attackRollKey,
defenderName,
defenderId,
defenseRoll
defenderTokenId,
defenseRoll,
outcome,
shieldDamageReduction
})
} else {
console.log("Skipping message creation", { attackerHandledBonus, defenderHandledBonus })
}
})
// Hook: deduct aether when a spell-attack or spell-power roll is posted to chat
Hooks.on("createChatMessage", async (message) => {
if (!["spell-attack", "spell-power"].includes(message.rolls[0]?.options?.rollType)) return
const actorId = message.rolls[0]?.options?.actorId
if (!actorId) return
const actor = game.actors.get(actorId)
if (!actor) return
// Only the primary controller (player owner or GM) handles this
const activePlayerOwners = game.users.filter(u => u.active && !u.isGM && actor.testUserPermission(u, "OWNER"))
const isPrimary = activePlayerOwners.length > 0
? activePlayerOwners[0].id === game.user.id
: game.user.isGM
if (!isPrimary) return
const rollTarget = message.rolls[0]?.options?.rollTarget
const spellId = rollTarget?.id || rollTarget?._id
const spell = spellId ? actor.items.get(spellId) : null
if (!spell || spell.type !== "spell") return
const cost = Number(spell.system?.cost) || 0
if (cost <= 0) return
const currentAether = Number(actor.system.aetherPoints?.value) || 0
const newAether = Math.max(0, currentAether - cost)
await actor.update({ "system.aetherPoints.value": newAether })
await ChatMessage.create({
content: `<p>🔮 <strong>${actor.name}</strong> casts <em>${spell.name}</em> — spends <strong>${cost}</strong> Aether <span style="color:#888;">(${currentAether}${newAether})</span>.</p>`,
speaker: ChatMessage.getSpeaker({ actor })
})
})
// Hook: deduct grace when a miracle-attack or miracle-power roll is posted to chat
Hooks.on("createChatMessage", async (message) => {
if (!["miracle-attack", "miracle-power"].includes(message.rolls[0]?.options?.rollType)) return
const actorId = message.rolls[0]?.options?.actorId
if (!actorId) return
const actor = game.actors.get(actorId)
if (!actor) return
const activePlayerOwners = game.users.filter(u => u.active && !u.isGM && actor.testUserPermission(u, "OWNER"))
const isPrimary = activePlayerOwners.length > 0
? activePlayerOwners[0].id === game.user.id
: game.user.isGM
if (!isPrimary) return
const rollTarget = message.rolls[0]?.options?.rollTarget
const miracleId = rollTarget?.id || rollTarget?._id
const miracle = miracleId ? actor.items.get(miracleId) : null
if (!miracle || miracle.type !== "miracle") return
const cost = Number(miracle.system?.level) || 0
if (cost <= 0) return
const currentGrace = Number(actor.system.divinityPoints?.value) || 0
const newGrace = Math.max(0, currentGrace - cost)
await actor.update({ "system.divinityPoints.value": newGrace })
await ChatMessage.create({
content: `<p>✨ <strong>${actor.name}</strong> invokes <em>${miracle.name}</em> — spends <strong>${cost}</strong> Grace <span style="color:#888;">(${currentGrace}${newGrace})</span>.</p>`,
speaker: ChatMessage.getSpeaker({ actor })
})
})
// Hook pour appliquer automatiquement les dégâts si une cible est définie
Hooks.on("createChatMessage", async (message) => {
// Vérifier si c'est un message de dégâts avec un defenderId
@@ -512,7 +887,7 @@ Hooks.on("createChatMessage", async (message) => {
// 1. Si l'attaquant a un propriétaire joueur, seul ce joueur applique
// 2. Si l'attaquant n'a que le MJ comme propriétaire (monstre), seul le MJ applique
const attackerOwners = attacker ? game.users.filter(u =>
!u.isGM && attacker.testUserPermission(u, "OWNER")
u.active && !u.isGM && attacker.testUserPermission(u, "OWNER")
) : []
let shouldApplyDamage = false
@@ -549,14 +924,19 @@ Hooks.on("createChatMessage", async (message) => {
const attackerName = message.rolls[0]?.options?.actorName || "Unknown Attacker"
// Calculer les DR
const armorDR = defender.computeDamageReduction() || 0
const finalDamage = Math.max(0, damageTotal - armorDR)
const bypassArmor = message.rolls[0]?.options?.bypassArmor || false
const armorDR = bypassArmor ? 0 : (defender.computeDamageReduction() || 0)
const extraShieldDr = Number(message.rolls[0]?.options?.extraShieldDr) || 0
const totalDR = armorDR + extraShieldDr
const finalDamage = Math.max(0, damageTotal - totalDR)
// For unlinked tokens (default for monsters), we need the specific token actor, not the base
// world actor — otherwise applyDamage would modify the base actor and affect every unlinked
// copy of that monster. Prefer the combatant actor, fall back to canvas scan.
// Prefer the token ID stored in roll options (set at attack time when the exact token is known).
// For unlinked tokens (default for monsters), this ensures we target the right instance even
// when multiple unlinked copies of the same monster type are in combat.
const rollDefenderTokenId = message.rolls[0]?.options?.defenderTokenId
const defenderCombatant = game.combat?.combatants?.find(c => c.actorId === defender.id)
const defenderTokenId = defenderCombatant?.token?.id
const defenderTokenId = rollDefenderTokenId
?? defenderCombatant?.token?.id
?? canvas.tokens?.placeables?.find(t => t.actor?.id === defender.id)?.id
?? null
@@ -564,7 +944,11 @@ Hooks.on("createChatMessage", async (message) => {
// route the HP update to the GM via socket. The confirmation message is still created here
// since all users can create chat messages.
if (defender.isOwner) {
const tokenActor = defenderCombatant?.actor ?? defender
// Resolve the token actor: prefer lookup by token ID (exact match for unlinked monsters),
// fall back to combatant actor, then base world actor.
const tokenActor = (defenderTokenId
? canvas.tokens?.placeables?.find(t => t.id === defenderTokenId)?.actor
: defenderCombatant?.actor) ?? defender
await tokenActor.applyDamage(-finalDamage)
} else {
game.socket.emit(`system.${SYSTEM.id}`, { type: "applyDamage", actorId: defender.id, tokenId: defenderTokenId, damage: -finalDamage })
@@ -576,7 +960,7 @@ Hooks.on("createChatMessage", async (message) => {
{
targetName: defender.name,
damage: finalDamage,
drText: armorDR > 0 ? `Armor DR: ${armorDR}` : "",
drText: bypassArmor ? "Armor DR bypassed (spell)" : (totalDR > 0 ? `Armor DR: ${armorDR}${extraShieldDr > 0 ? ` + Shield DR: ${extraShieldDr}` : ""}` : ""),
weaponName: weaponName,
attackerName: attackerName,
rawDamage: damageTotal
@@ -604,6 +988,12 @@ Hooks.on("hotbarDrop", (bar, data, slot) => {
}
})
/* -------------------------------------------- */
/**
* Inject the Lethal Fantasy dice tray into the chat sidebar.
*/
Hooks.on("renderChatLog", (_chatLog, html) => applications.injectDiceTray(_chatLog, html))
/**
* Register world usage statistics
* @param {string} registerKey
+1
View File
@@ -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"
+38 -10
View File
@@ -18,6 +18,7 @@ export class LethalFantasyCombatTracker extends foundry.applications.sidebar.tab
actions: {
initiativePlus: LethalFantasyCombatTracker.#initiativePlus,
initiativeMinus: LethalFantasyCombatTracker.#initiativeMinus,
rollMonsterProgression: LethalFantasyCombatTracker.#rollMonsterProgression,
},
});
@@ -49,6 +50,15 @@ export class LethalFantasyCombatTracker extends foundry.applications.sidebar.tab
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();
}
activateListeners(html) {
super.activateListeners(html);
// Display Combat settings
@@ -100,6 +110,14 @@ 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);
@@ -110,19 +128,29 @@ export class LethalFantasyCombat extends Combat {
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) {
const playerOwner = game.users.find(u => u.active && !u.isGM && u.character?.id === c.actor.id);
if (game.user.isGM && playerOwner) {
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 });
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;
}
/** Roll progression dice for all eligible monster combatants this round. Called manually by the GM. */
async rollMonsterProgression() {
const currentRound = this.round;
for (let c of this.combatants) {
if (c.actor.type !== "monster") continue;
if (c.initiative !== null && currentRound >= c.initiative) {
await c.actor.system.rollProgressionDice(this.id, c.id);
}
}
}
resetProgression(cId) {
let c = this.combatants.get(cId);
c.update({ 'system.progressionCount': 0 });
@@ -196,12 +224,12 @@ export class LethalFantasyCombat extends Combat {
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 (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);
}
}
}
+152
View File
@@ -0,0 +1,152 @@
/**
* Free Dice Tray — injected into the Foundry chat sidebar.
*
* Provides a compact bar for GM and players to roll any standard die (d4d30)
* or its exploding variant (dXx) without needing an actor sheet.
* Supports selecting how many dice to roll (19).
*/
/** 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 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 =>
`<button type="button" class="lf-dt-die-btn" data-die="${d}" title="${d.toUpperCase()}">${d.toUpperCase()}</button>`
).join("")
const countOptions = Array.from({ length: 9 }, (_, i) =>
`<option value="${i + 1}">${i + 1}</option>`
).join("")
bar.innerHTML = `
<div class="lf-dt-row">
<span class="lf-dt-label"><i class="fa-solid fa-dice"></i></span>
<select class="lf-dt-count" title="${game.i18n.localize("LETHALFANTASY.DiceTray.CountTitle")}">
${countOptions}
</select>
<div class="lf-dt-dice">${diceButtons}</div>
<label class="lf-dt-explode-label" title="${game.i18n.localize("LETHALFANTASY.DiceTray.ExplodeTitle")}">
<input type="checkbox" class="lf-dt-explode" />
<i class="fa-solid fa-explosion"></i>
</label>
</div>
`
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 (19)
* @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 resultHtml = dieChips.map(chip => {
const isMax = !chip.exploded && chip.value === sides
const isMin = chip.value === 1
const explodeIcon = chip.exploded ? `<i class="fa-solid fa-burst lf-dt-explode-icon"></i>` : ""
const classes = ["lf-frc-die-chip", isMax ? "lf-frc-max" : "", isMin ? "lf-frc-min" : ""].filter(Boolean).join(" ")
return `<div class="${classes}">
<span class="lf-frc-die-type">${chip.label}</span>
<span class="lf-frc-die-sep">→</span>
<span class="lf-frc-die-val">${chip.value}${explodeIcon}</span>
</div>`
}).join("")
const totalLabel = game.i18n.localize("LETHALFANTASY.Label.total").toUpperCase()
const content = `
<div class="lf-free-roll-card">
<div class="lf-frc-header">
<i class="fa-solid fa-dice"></i>
<span class="lf-frc-title-text">${game.i18n.localize("LETHALFANTASY.DiceTray.ChatTitle")}</span>
<span class="lf-frc-badge">${label}</span>
</div>
<div class="lf-frc-dice">${resultHtml}</div>
<div class="lf-frc-total-bar">
<span class="lf-frc-total-label">${totalLabel}</span>
<span class="lf-frc-total-value">${total}</span>
</div>
</div>
`
const rollMode = game.settings.get("core", "rollMode")
const msgData = {
speaker: ChatMessage.getSpeaker(),
content,
sound: CONFIG.sounds.dice,
}
ChatMessage.applyMode(msgData, rollMode)
await ChatMessage.create(msgData)
}
@@ -172,7 +172,7 @@ 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) {
+1 -1
View File
@@ -111,7 +111,7 @@ 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) {
+581 -112
View File
@@ -1,152 +1,621 @@
{
"d30_dice_results": {
"30": {
"melee_attack": "Possible Lethal or Vital Strike or Add D20E to Attack",
"ranged_attack": "Possible Lethal or Vital Strike or Add D20E to Attack",
"melee_defense": "Possible Flawless or Legendary Defense or Add D20E to Defense",
"arcane_spell_attack": "Possible Lethal or Vital Magical Strike or Add D20E to Spell Attack",
"arcane_spell_defense": "Possible Spell Catastrophe or adds D20E to Spell Defense",
"skill_rolls": "Skill Succeeds Regardless of Opposing Roll / Success at highest level / Matching 30s cancel each other out"
"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"
},
"arcane_spell_defense": {
"type": "choice",
"choices": [
{
"type": "spell_calamity"
},
{
"type": "bonus_dice",
"dice": "D20E",
"target": "spell_defense"
}
],
"description": "Possible Spell Catastrophe or adds D20E to Spell Defense"
},
"skill_rolls": {
"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"
}
},
"29": {
"melee_attack": "Gain 1 Grit",
"ranged_attack": "Gain 1 Grit",
"melee_defense": "Gain 1 Grit",
"arcane_spell_attack": "Gain 1 Grit",
"arcane_spell_defense": "Gain 1 Grit",
"skill_rolls": "Gain 1 Grit"
"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"
},
"arcane_spell_defense": {
"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"
}
},
"28": {
"melee_attack": "Shield Destruction",
"ranged_attack": "empty",
"melee_defense": "empty",
"arcane_spell_attack": "empty",
"arcane_spell_defense": "empty",
"skill_rolls": "empty"
"melee_attack": {
"type": "shield_destruction",
"description": "Shield Destruction"
}
},
"27": {
"melee_attack": "Granted D6 (1-6) Attack Modifier for This Melee Attack",
"ranged_attack": "Granted D6 (1-6) Attack Modifier for This Ranged Attack",
"melee_defense": "Granted 1 Luck dice for Use in This Combat Only",
"arcane_spell_attack": "No Spell Lethargy (the Aether Approves)",
"arcane_spell_defense": "Caster Suffers Severe pain and will be under a flash of pain for 1D6E seconds",
"skill_rolls": "Granted D6 (1-6) Skill Modifier for this Skill Attempt"
"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"
},
"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"
},
"ranged_defense": {
"type": "luck_die",
"scope": "combat",
"description": "Granted 1 Luck dice for Use in This Combat Only"
}
},
"26": {
"melee_attack": "Shield Destruction",
"ranged_attack": "empty",
"melee_defense": "empty",
"arcane_spell_attack": "empty",
"arcane_spell_defense": "empty",
"skill_rolls": "empty"
"melee_attack": {
"type": "shield_destruction",
"description": "Shield Destruction"
}
},
"25": {
"melee_attack": "Bleed, Knock-Back on Hit",
"ranged_attack": "Bleed",
"melee_defense": "Kick, Punch or Shield Bash",
"arcane_spell_attack": "empty",
"arcane_spell_defense": "empty",
"skill_rolls": "Add 1 to Skill Roll"
"skill_rolls": {
"type": "bonus_flat",
"amount": 1,
"target": "skill",
"description": "Add 1 to Skill Roll"
}
},
"21": {
"melee_attack": "Hit Inflicts Flash of Pain 1D6E seconds",
"ranged_attack": "Hit Inflicts Flash of Pain 1D6E seconds",
"melee_defense": "Defender Recovers or ignores any flash of pain",
"arcane_spell_attack": "Magical Damage inflicts Flash of pain 1D6E seconds",
"arcane_spell_defense": "Caster Suffers Severe pain and will be under a flash of pain for 1D6E seconds",
"skill_rolls": "empty"
"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"
},
"arcane_spell_defense": {
"type": "flash_of_pain",
"duration_dice": "1D6E",
"target": "caster",
"description": "Caster Suffers Severe pain and will be under a flash of pain for 1D6E seconds"
},
"skill_rolls": {
"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"
}
},
"20": {
"melee_attack": "Possible Vicious Strike. Bleed, Knock-back on Hit",
"ranged_attack": "Possible Vicious Strike. Bleeding wound inflicted on hit.",
"melee_defense": "Possible 20/20 defense (avoids Any Attack Except a Lethal Strike). Grants a Kick, Punch or Shield Bash counter",
"arcane_spell_attack": "Possible Vicious Application of a Magical Attack",
"arcane_spell_defense": "Possible 20/20 Spell defense (Saves Against Any Magical Attack Except a Lethal Magical Strike)",
"skill_rolls": "20 Added to Skill Roll"
"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"
},
"arcane_spell_defense": {
"type": "choice",
"choices": [
{
"type": "special_defense",
"options": [
"perfect_spell"
]
},
{
"type": "bonus_dice",
"dice": "D12",
"target": "spell_defense"
}
],
"description": "Possible 20/20 Spell defense that Saves Against Any Magical Attack Except a Lethal Magical Strike or add D12 to defense"
},
"skill_rolls": {
"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"
}
},
"15": {
"melee_attack": "Bleed, Knock-back on Hit",
"ranged_attack": "Bleed",
"melee_defense": "Kick, Punch or Shield Bash",
"arcane_spell_attack": "empty",
"arcane_spell_defense": "empty",
"skill_rolls": "Add 1 to Skill Roll"
},
"13": {
"melee_attack": "empty",
"ranged_attack": "empty",
"melee_defense": "empty",
"arcane_spell_attack": "empty",
"arcane_spell_defense": "empty",
"skill_rolls": "empty"
"melee_attack": {
"type": "combo",
"effects": [
{
"type": "bleed"
},
{
"type": "knockback"
}
],
"description": "Bleed, Knock-back on Hit"
},
"ranged_attack": {
"type": "bleed",
"description": "Bleed"
},
"melee_defense": {
"type": "counter_attack",
"options": [
"kick",
"punch",
"shield_bash"
],
"description": "Kick, Punch or Shield Bash"
},
"skill_rolls": {
"type": "bonus_flat",
"amount": 1,
"target": "skill",
"description": "Add 1 to Skill Roll"
},
"ranged_defense": {
"type": "counter_attack",
"options": [
"kick",
"punch",
"shield_bash"
],
"description": "Kick, Punch or Shield Bash"
}
},
"13": {},
"11": {
"melee_attack": "Flurry Attack or Hit to Miss",
"ranged_attack": "Roll 2x Damage Dice",
"melee_defense": "empty",
"arcane_spell_attack": "empty",
"arcane_spell_defense": "empty",
"skill_rolls": "empty"
"melee_attack": {
"type": "flurry",
"condition": "hit_or_miss",
"description": "Flurry Attack or Hit to Miss"
},
"ranged_attack": {
"type": "double_damage_dice",
"description": "Roll 2x Damage Dice"
}
},
"10": {
"melee_attack": "Bleed, Knock-back on Hit",
"ranged_attack": "Bleed",
"melee_defense": "Kick, Punch or Shield Bash",
"arcane_spell_attack": "empty",
"arcane_spell_defense": "empty",
"skill_rolls": "Add 1 to Skill Roll"
"melee_attack": {
"type": "combo",
"effects": [
{
"type": "bleed"
},
{
"type": "knockback"
}
],
"description": "Bleed, Knock-back on Hit"
},
"ranged_attack": {
"type": "bleed",
"description": "Bleed"
},
"melee_defense": {
"type": "counter_attack",
"options": [
"kick",
"punch",
"shield_bash"
],
"description": "Kick, Punch or Shield Bash"
},
"skill_rolls": {
"type": "bonus_flat",
"amount": 1,
"target": "skill",
"description": "Add 1 to Skill Roll"
},
"ranged_defense": {
"type": "counter_attack",
"options": [
"kick",
"punch",
"shield_bash"
],
"description": "Kick, Punch or Shield Bash"
}
},
"8": {
"melee_attack": "Mulligan, Can Choose to Re-roll This Attack",
"ranged_attack": "Mulligan, Can Choose to Re-Roll This Attack",
"melee_defense": "Mulligan, Can Choose to Re-Roll This Defense",
"arcane_spell_attack": "Mulligan, Can Re-Roll This Spell Attack",
"arcane_spell_defense": "Mulligan, Can Re-Roll This Spell Defense",
"skill_rolls": "Mulligan, Can Re-Roll This Skill roll"
"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"
},
"arcane_spell_defense": {
"type": "mulligan",
"description": "Mulligan, Can Re-Roll This Spell Defense"
},
"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"
}
},
"7": {
"melee_attack": "Flurry Attack on Hit or Miss",
"ranged_attack": "Roll 2x Double Damage Dice",
"melee_defense": "empty",
"arcane_spell_attack": "empty",
"arcane_spell_defense": "empty",
"skill_rolls": "empty"
"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": "Bleed, Knock-back on Hit",
"ranged_attack": "Bleed",
"melee_defense": "Kick, Punch, or Shield Bash",
"arcane_spell_attack": "empty",
"arcane_spell_defense": "empty",
"skill_rolls": "Add 1 to Skill Roll"
"melee_attack": {
"type": "combo",
"effects": [
{
"type": "bleed"
},
{
"type": "knockback"
}
],
"description": "Bleed, Knock-back on Hit"
},
"ranged_attack": {
"type": "bleed",
"description": "Bleed"
},
"melee_defense": {
"type": "counter_attack",
"options": [
"kick",
"punch",
"shield_bash"
],
"description": "Kick, Punch, or Shield Bash"
},
"skill_rolls": {
"type": "bonus_flat",
"amount": 1,
"target": "skill",
"description": "Add 1 to Skill Roll"
},
"ranged_defense": {
"type": "counter_attack",
"options": [
"kick",
"punch",
"shield_bash"
],
"description": "Kick, Punch, or Shield Bash"
}
},
"3": {
"melee_attack": "Triple Damage",
"ranged_attack": "Triple Damage",
"melee_defense": "DR Tripled including Shield",
"arcane_spell_attack": "Triple Damage on Spell Damage",
"arcane_spell_defense": "D12 Added to Spell Defense Modifier",
"skill_rolls": "empty"
"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"
},
"arcane_spell_defense": {
"type": "bonus_dice",
"dice": "D12",
"target": "spell_defense",
"description": "D12 Added to Spell Defense Modifier"
},
"ranged_defense": {
"type": "dr_multiplier",
"multiplier": 3,
"includes_shield": true,
"description": "DR Tripled including Shield"
}
},
"2": {
"melee_attack": "Double Damage",
"ranged_attack": "Double Damage",
"melee_defense": "DR Doubled including Shield",
"arcane_spell_attack": "Double Damage on Spell Damage",
"arcane_spell_defense": "D6 Added to Spell Defense Modifier",
"skill_rolls": "empty"
"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"
},
"arcane_spell_defense": {
"type": "bonus_dice",
"dice": "D6",
"target": "spell_defense",
"description": "D6 Added to Spell Defense Modifier"
},
"ranged_defense": {
"type": "dr_multiplier",
"multiplier": 2,
"includes_shield": true,
"description": "DR Doubled including Shield"
}
},
"1": {
"melee_attack": "empty",
"ranged_attack": "Possible Fumble Ranged ammo is broken unrecoverable",
"melee_defense": "empty",
"arcane_spell_attack": "Possible Spell Calamity or Catastrophe",
"arcane_spell_defense": "empty",
"skill_rolls": "empty"
"ranged_attack": {
"type": "fumble",
"detail": "ranged_ammo_broken",
"description": "Possible Fumble Ranged ammo is broken unrecoverable"
},
"arcane_spell_attack": {
"type": "spell_calamity",
"description": "Possible Spell Calamity or Catastrophe"
}
}
},
"definitions": {
"flash_of_pain": "Causes the victim to defend with disfavor. They can only walk and cannot attack, cast spells, call miracles or perform skills.",
"shield_destruction_condition": "Occurs only if damage exceeds the shields DR."
"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."
}
}
+2
View File
@@ -193,6 +193,7 @@ export const DICE_VALUES = {
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 = {
@@ -304,6 +305,7 @@ export const SYSTEM = {
CHARACTERISTIC_ATTACK,
CHARACTERISTIC_RANGED_ATTACK,
CHARACTERISTIC_DEFENSE,
CHARACTERISTIC_RANGED_DEFENSE,
CHARACTERISTIC_DAMAGE,
INITIATIVE_DICE_CHOICES_PER_CLASS,
CHAR_CLASSES,
+20 -2
View File
@@ -153,7 +153,7 @@ export default class LethalFantasyActor extends Actor {
}
/* *************************************************/
async prepareRoll(rollType, rollKey, rollDice, defenderId) {
async prepareRoll(rollType, rollKey, rollDice, defenderId, defenderTokenId, extraShieldDr = 0) {
console.log("Preparing roll", rollType, rollKey, rollDice, defenderId)
let rollTarget
switch (rollType) {
@@ -198,6 +198,22 @@ export default class LethalFantasyActor extends Actor {
case "miracle-power":
rollTarget = this.items.find((i) => (i.type === "miracle" || i.type == "spell") && i.id === rollKey)
rollTarget.rollKey = rollKey
if (rollType === "spell-attack" || rollType === "spell-power") {
const cost = Number(rollTarget.system?.cost) || 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)
@@ -256,6 +272,8 @@ export default class LethalFantasyActor extends Actor {
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
@@ -268,7 +286,7 @@ export default class LethalFantasyActor extends Actor {
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, defenderId)
await this.system.roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr)
}
}
+26 -19
View File
@@ -22,6 +22,7 @@ export default class D30Roll {
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"
@@ -47,26 +48,26 @@ export default class D30Roll {
}
/**
* Récupère le résultat d'un jet de D30
* 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)
* @returns {string|null} Le résultat correspondant ou null si vide/non trouvé
* @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) {
static getResult(diceValue, rollType, weapon = null, options = {}) {
if (!this.resultsTable) {
console.warn("D30Roll | Results table is not initialized. Call D30Roll.initialize() first.")
return null
}
// Validation des paramètres
if (diceValue < 1 || diceValue > 30) {
console.warn(`D30Roll | Invalid dice value: ${diceValue}. Must be between 1 and 30.`)
return null
}
// Convert external rollType to internal rollType
const internalType = this.convertToInternalType(rollType, weapon)
const internalType = this.convertToInternalType(rollType, weapon, options)
if (!internalType) {
console.warn(`D30Roll | Could not convert roll type: ${rollType}`)
@@ -85,22 +86,27 @@ export default class D30Roll {
}
const result = resultEntry[internalType]
return result ?? null
}
// Retourne null si le résultat est "empty"
if (result === "empty" || !result) {
return null
}
return result
/**
* 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) {
static convertToInternalType(externalType, weapon = null, options = {}) {
// Attack types - need weapon to determine if melee or ranged
if (externalType === "weapon-attack") {
if (!weapon) {
@@ -123,7 +129,7 @@ export default class D30Roll {
// Defense types
if (externalType === "weapon-defense" || externalType === "monster-defense") {
return this.ROLL_TYPES.MELEE_DEFENSE
return options.isRanged ? this.ROLL_TYPES.RANGED_DEFENSE : this.ROLL_TYPES.MELEE_DEFENSE
}
// Spell types
@@ -177,11 +183,11 @@ export default class D30Roll {
/**
* Vérifie si un résultat est vide
* @param {string} result Le résultat à vérifier
* @param {Object|null} result Le résultat à vérifier
* @returns {boolean} True si le résultat est vide
*/
static isEmptyResult(result) {
return !result || result === "empty"
return !result || !result.type
}
/**
@@ -189,11 +195,12 @@ export default class D30Roll {
* @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) {
const result = this.getResult(diceValue, rollType, weapon)
const internalType = this.convertToInternalType(rollType, weapon)
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,
+113 -67
View File
@@ -182,6 +182,7 @@ export default class LethalFantasyRoll extends Roll {
} else {
options.rollTarget.value = options.rollTarget.defenseModifier
options.rollTarget.charModifier = 0
options.isRangedDefense = options.rollTarget.isRangedDefense ?? false
}
} else if (options.rollType === "monster-skill") {
@@ -219,8 +220,14 @@ export default class LethalFantasyRoll extends Roll {
options.rollTarget.charModifier = options.rollTarget.combat.rangedAttackModifier
}
} else {
options.rollTarget.value = options.rollTarget.combat.defenseModifier + options.rollTarget.weaponSkillModifier + options.rollTarget.weapon.system.bonuses.defenseBonus + options.rollTarget.armorDefense
options.rollTarget.charModifier = options.rollTarget.combat.defenseModifier
// 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") {
@@ -265,6 +272,7 @@ export default class LethalFantasyRoll extends Roll {
hasChangeDice = false
hasMaxValue = false
hasExplode = false
hasFavor = true
options.rollTarget.value = 0
} else if (options.rollType.includes("weapon-damage")) {
@@ -282,7 +290,11 @@ export default class LethalFantasyRoll extends Roll {
options.damageMedium = true
dice = options.rollTarget.weapon.system.damage.damageM
}
dice = dice.replace("E", "")
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")) {
@@ -295,6 +307,10 @@ export default class LethalFantasyRoll extends Roll {
dice = options.rollTarget.damageDice
dice = dice.replace("E", "")
baseFormula = dice
if (options.rollTarget.noExplode) {
hasMaxValue = false
hasExplode = false
}
}
@@ -304,7 +320,7 @@ export default class LethalFantasyRoll extends Roll {
hasModifier = false
}
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes);
console.log("Roll mode", rollModes)
const fieldRollMode = new foundry.data.fields.StringField({
@@ -346,58 +362,73 @@ export default class LethalFantasyRoll extends Roll {
favor: "none",
targetName
}
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/roll-dialog.hbs", dialogContext)
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
rollContext.visibility ||= rollContext.rollMode || game.settings.get("core", "rollMode")
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")
const rollContext = await foundry.applications.api.DialogV2.wait({
window: { title: "Roll dialog" },
classes: ["lethalfantasy"],
content,
position,
buttons: [
{
label: label,
callback: (event, button, dialog) => {
console.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
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: [
{
label: label,
callback: (event, button, dialog) => {
console.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, dialog) => {
hasGrantedDice = event.target.checked
},
"selectBeyondSkill": (event, button, dialog) => {
beyondSkill = button.checked
},
"selectPointBlank": (event, button, dialog) => {
pointBlank = button.checked
},
"selectLetItFly": (event, button, dialog) => {
letItFly = button.checked
},
"saveSpellCheck": (event, button, dialog) => {
saveSpell = button.checked
},
"gotoToken": (event, button, dialog) => {
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 });
],
actions: {
"selectGranted": (event, button, dialog) => {
hasGrantedDice = event.target.checked
},
"selectBeyondSkill": (event, button, dialog) => {
beyondSkill = button.checked
},
"selectPointBlank": (event, button, dialog) => {
pointBlank = button.checked
},
"selectLetItFly": (event, button, dialog) => {
letItFly = button.checked
},
"saveSpellCheck": (event, button, dialog) => {
saveSpell = button.checked
},
"gotoToken": (event, button, dialog) => {
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
})
},
rejectClose: false // Click on Close button will not launch an error
})
}
// If the user cancels the dialog, exit
if (rollContext === null) return
@@ -475,7 +506,8 @@ export default class LethalFantasyRoll extends Roll {
rollContext.favor = "none"
}
maxValue = Number(baseFormula.match(/\d+$/)[0]) // Update the max value agains
const maxMatch = baseFormula ? baseFormula.match(/\d+$/) : null
maxValue = maxMatch ? Number(maxMatch[0]) : 0
const rollData = {
type: options.rollType,
@@ -547,6 +579,10 @@ export default class LethalFantasyRoll extends Roll {
rollFavor = null
}
if (options.forceNoD30) {
hasD30 = false
}
if (hasD30) {
let rollD30 = await new Roll("1D30").evaluate()
if (game?.dice3d) {
@@ -558,7 +594,8 @@ export default class LethalFantasyRoll extends Roll {
const d30Message = D30Roll.getResult(
rollD30.total,
options.rollType,
options.rollTarget?.weapon
options.rollTarget?.weapon,
{ isRanged: options.isRangedDefense }
)
options.D30message = d30Message
}
@@ -620,6 +657,8 @@ export default class LethalFantasyRoll extends Roll {
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
/**
* A hook event that fires after the roll has been made.
@@ -637,7 +676,7 @@ export default class LethalFantasyRoll extends Roll {
/* ***********************************************************/
static async promptInitiative(options = {}) {
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes,
blank: false,
@@ -691,21 +730,21 @@ export default class LethalFantasyRoll extends Roll {
let initRoll = new Roll(formula, options.data)
await initRoll.evaluate()
let msg = await initRoll.toMessage({ flavor: `Initiative for ${options.actorName}` }, { rollMode: rollContext.visibility })
if (game?.dice3d) {
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 }])
await combat.updateEmbeddedDocuments("Combatant", [{ _id: options.combatantId, initiative: initRoll.total, 'system.progressionCount': 0, [`flags.${SYSTEM.id}.firstActionTaken`]: false }])
}
}
/* ***********************************************************/
static async promptCombatAction(options = {}) {
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes,
blank: false,
@@ -835,7 +874,11 @@ export default class LethalFantasyRoll extends Roll {
let selectedItem = combatant.actor.items.find(i => i.id === selectedChoice)
// Setup flag for combat action usage
let actionItem = foundry.utils.duplicate(selectedItem)
actionItem.progressionCount = 1
// 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
actionItem.castingTime = 1
actionItem.spellStatus = "castingTime"
@@ -958,7 +1001,7 @@ export default class LethalFantasyRoll extends Roll {
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}` }, { rollMode: rollContext.visibility })
let msg = await roll.toMessage({ flavor: `Progression Roll for ${currentAction.name}, progression count : ${currentAction.progressionCount}/${max}` }, { messageMode: rollContext.visibility })
if (game?.dice3d) {
await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
}
@@ -1000,7 +1043,7 @@ export default class LethalFantasyRoll extends Roll {
/* ***********************************************************/
static async promptRangedDefense(options = {}) {
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes);
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes);
const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes,
blank: false,
@@ -1080,6 +1123,7 @@ export default class LethalFantasyRoll extends Roll {
// Merge rollContext object into options object
options = { ...options, ...rollContext }
options.rollName = "Ranged Defense"
options.rollType = "weapon-defense"
const rollBase = new this(rollContext.movement, options.data, rollData)
const rollModifier = new Roll(modifierFormula, options.data, rollData)
@@ -1087,6 +1131,7 @@ export default class LethalFantasyRoll extends Roll {
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")) {
@@ -1129,6 +1174,7 @@ export default class LethalFantasyRoll extends Roll {
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)
@@ -1286,12 +1332,12 @@ export default class LethalFantasyRoll extends Roll {
*
* @param {Object} [messageData={}] Additional data to include in the message.
* @param {Object} options Options for message creation.
* @param {string} options.rollMode The mode of the roll (e.g., public, private).
* @param {string} options.messageMode The mode of the roll (e.g., public, private).
* @param {boolean} [options.create=true] Whether to create the message.
* @returns {Promise} - A promise that resolves when the message is created.
*/
async toMessage(messageData = {}, { rollMode, create = true } = {}) {
super.toMessage(
async toMessage(messageData = {}, { messageMode, create = true } = {}) {
return await super.toMessage(
{
isSave: this.isSave,
isChallenge: this.isChallenge,
@@ -1308,7 +1354,7 @@ export default class LethalFantasyRoll extends Roll {
rollData: this.rollData,
...messageData,
},
{ rollMode: rollMode },
{ messageMode, create },
)
}
+14 -4
View File
@@ -152,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) => {
@@ -258,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)
@@ -273,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, defenderId) {
async roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr = 0) {
const hasTarget = false
let roll = await LethalFantasyRoll.prompt({
rollType,
@@ -283,11 +291,13 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
actorImage: this.parent.img,
hasTarget,
target: false,
defenderId
defenderId,
defenderTokenId,
extraShieldDr
})
if (!roll) return null
await roll.toMessage({}, { rollMode: roll.options.rollMode })
await roll.toMessage({}, { messageMode: roll.options.rollMode })
}
async rollInitiative(combatId = undefined, combatantId = undefined) {
@@ -308,7 +318,7 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
})
if (!roll) return null
await roll.toMessage({}, { rollMode: roll.options.rollMode })
await roll.toMessage({}, { messageMode: roll.options.rollMode })
}
async rollProgressionDice(combatId, combatantId, rollProgressionCount) {
+47 -15
View File
@@ -64,7 +64,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
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}` }),
@@ -74,6 +74,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
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 })
}
@@ -123,10 +124,32 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
shieldDefenseDice: new fields.StringField({ required: true, nullable: false, initial: "d4" })
})
schema.combatHTH = new fields.SchemaField({
attack1: attackField("1"),
attack2: attackField("2")
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
}
@@ -141,7 +164,7 @@ 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, defenderId = undefined) {
async roll(rollType, rollTarget, defenderId = undefined, defenderTokenId = undefined, extraShieldDr = 0) {
const hasTarget = false
let roll = await LethalFantasyRoll.prompt({
rollType,
@@ -151,26 +174,34 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
actorImage: this.parent.img,
hasTarget,
target: false,
defenderId
defenderId,
defenderTokenId,
extraShieldDr
})
if (!roll) return null
await roll.toMessage({}, { rollMode: roll.options.rollMode })
await roll.toMessage({}, { messageMode: roll.options.rollMode })
}
async prepareMonsterRoll(rollType, rollKey, rollDice = undefined, tokenId = undefined, damageModifier = undefined, defenderId = undefined) {
async prepareMonsterRoll(rollType, rollKey, rollDice = undefined, tokenId = undefined, damageModifier = undefined, defenderId = undefined, defenderTokenId = undefined, extraShieldDr = 0) {
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":
@@ -239,7 +270,7 @@ 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)
@@ -254,7 +285,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
if (rollTarget) {
rollTarget.tokenId = tokenId
console.log(rollTarget)
await this.roll(rollType, rollTarget, defenderId)
await this.roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr)
}
}
@@ -274,7 +305,7 @@ 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) {
@@ -286,7 +317,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
return
}
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes)
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes)
const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes,
blank: false,
@@ -302,8 +333,9 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
}
let hasAttack = false
for (let key in this.attacks) {
let attack = this.attacks[key]
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
const messageContent = await foundry.applications.handlebars.renderTemplate(
+1
View File
@@ -39,6 +39,7 @@ 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: "" })
return schema
}
+355 -21
View File
@@ -124,10 +124,12 @@ export default class LethalFantasyUtils {
}
break
case "rollInitiative":
if (msg.userId && msg.userId !== game.user.id) break
actor = game.actors.get(msg.actorId)
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)
actor.system.rollProgressionDice(msg.combatId, msg.combatantId, msg.rollProgressionCount)
break
@@ -190,6 +192,9 @@ export default class LethalFantasyUtils {
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
@@ -216,11 +221,91 @@ export default class LethalFantasyUtils {
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"
console.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 savesHTML = Object.values(savesConfig)
.filter(s => combatSaves.includes(s.id))
.map(s => `<option value="${s.id}">${game.i18n.localize(s.label)}</option>`)
.join("")
const content = `
<div class="defense-request-dialog">
<div class="attack-info">
<p><strong>${attackerName}</strong> targets <strong>${defenderName}</strong> with <strong>${weaponName}</strong>!</p>
<p>Attack roll: <strong>${attackRoll}</strong></p>
</div>
<div class="weapon-selection">
<label for="save-type">Choose saving throw:</label>
<select id="save-type" name="saveKey" style="width: 100%; margin-top: 8px;">
${savesHTML}
</select>
</div>
</div>
`
const result = await foundry.applications.api.DialogV2.wait({
window: { title: "Saving Throw vs Spell" },
classes: ["lethalfantasy"],
content,
buttons: [
{
action: "rollSave",
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.nextDefenseData = {
attackerId,
attackRoll,
attackerName,
defenderName,
attackWeaponId,
attackRollType,
attackRollKey,
attackD30result,
attackD30message,
attackRerollContext,
defenderId: defender.id,
defenderTokenId
}
if (isMonster) {
defender.system.prepareMonsterRoll("save", result)
} else {
defender.prepareRoll("save", result)
}
}
return
}
// Pour les monstres, récupérer les attaques activées
if (isMonster) {
const enabledAttacks = Object.entries(defender.system.attacks).filter(([key, attack]) => attack.enabled)
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")
@@ -249,7 +334,7 @@ export default class LethalFantasyUtils {
// Afficher le dialogue
const result = await foundry.applications.api.DialogV2.wait({
window: { title: "Defense Roll" },
window: { title: msg.isRanged ? "Ranged Defense Roll" : "Defense Roll" },
classes: ["lethalfantasy"],
content,
buttons: [
@@ -277,16 +362,50 @@ export default class LethalFantasyUtils {
attackWeaponId,
attackRollType,
attackRollKey,
defenderId: defender.id
attackD30result,
attackD30message,
attackRerollContext,
defenderId: defender.id,
defenderTokenId,
isRanged: msg.isRanged
}
console.log("Storing defense data for monster:", defender.id)
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) {
game.lethalFantasy = game.lethalFantasy || {}
game.lethalFantasy.nextDefenseData = {
attackerId,
attackRoll,
attackerName,
defenderName,
attackWeaponId,
attackRollType,
attackRollKey,
attackD30result,
attackD30message,
attackRerollContext,
defenderId: defender.id,
defenderTokenId,
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
@@ -347,7 +466,12 @@ export default class LethalFantasyUtils {
attackWeaponId,
attackRollType,
attackRollKey,
defenderId: defender.id
attackD30result,
attackD30message,
attackRerollContext,
defenderId: defender.id,
defenderTokenId,
isRanged: msg.isRanged
}
console.log("Storing defense data for character:", defender.id)
@@ -356,6 +480,188 @@ export default class LethalFantasyUtils {
}
}
/* -------------------------------------------- */
static hasD30Reroll(d30Message) {
return d30Message?.type === "mulligan"
}
/* -------------------------------------------- */
static getCombatBonusDiceChoices() {
return ["1d4", "1d6", "1d8", "1d10", "1d12", "1d20", "1d20e"]
}
/* -------------------------------------------- */
static 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
}
}
/* -------------------------------------------- */
static async promptCombatBonusDie(actorName, sideLabel, currentRoll, opposingRoll) {
const choices = this.getCombatBonusDiceChoices()
const optionsHtml = choices.map(choice => `<option value="${choice}">${choice.toUpperCase()}</option>`).join("")
const content = `
<div class="grit-luck-dialog">
<div class="combat-status">
<p><strong>${actorName}</strong> currently has <strong>${currentRoll}</strong></p>
<p>Opposing ${sideLabel} roll: <strong>${opposingRoll}</strong></p>
</div>
<div class="weapon-selection">
<label for="bonus-die">Choose a bonus die:</label>
<select id="bonus-die" name="bonusDie" style="width: 100%; margin-top: 8px;">
${optionsHtml}
</select>
</div>
</div>
`
return await foundry.applications.api.DialogV2.wait({
window: { title: "Add Bonus Die" },
classes: ["lethalfantasy"],
content,
buttons: [
{
action: "roll",
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 ?? choices[0]
}
},
{
action: "cancel",
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>}
*/
static async promptAdHocShield(defenderName, attackRoll, defenseRoll) {
const choices = this.getCombatBonusDiceChoices()
const optionsHtml = choices.map(c => `<option value="${c}">${c.toUpperCase()}</option>`).join("")
const content = `
<div class="grit-luck-dialog">
<div class="combat-status">
<p><strong>${defenderName}</strong> uses a shield (not equipped)</p>
<p>Attack: <strong>${attackRoll}</strong> — Current defense: <strong>${defenseRoll}</strong></p>
</div>
<div class="weapon-selection" style="margin-top:8px;">
<label for="shield-dice">Shield dice:</label>
<select id="shield-dice" name="shieldDice" style="width: 100%; margin-top: 4px;">
${optionsHtml}
</select>
</div>
<div class="weapon-selection" style="margin-top:8px;">
<label for="shield-dr">Shield DR value:</label>
<input id="shield-dr" name="shieldDR" type="number" min="0" value="0" style="width: 100%; margin-top: 4px;" />
</div>
</div>
`
const raw = await foundry.applications.api.DialogV2.wait({
window: { title: "Ad-hoc Shield Roll" },
classes: ["lethalfantasy"],
content,
buttons: [
{
action: "roll",
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",
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 and posting a chat message.
* @param {string} formula
* @param {Actor} actor
* @param {Function} [messageContent]
* @returns {Promise<number>}
*/
static async rollBonusDie(formula, actor, messageContent) {
const roll = new Roll(formula)
await roll.evaluate()
if (game?.dice3d) {
await game.dice3d.showForRoll(roll, game.user, true)
}
if (messageContent) {
await ChatMessage.create({
content: messageContent(roll.total, formula),
speaker: ChatMessage.getSpeaker({ actor })
})
}
return roll.total
}
/* -------------------------------------------- */
static async 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 || {}),
forceNoD30: true,
hasTarget: false,
target: false
})
}
/* -------------------------------------------- */
static async offerGritLuckBonus(defender, attackRoll, currentDefenseRoll, attackerName, defenderName) {
let totalBonus = 0
@@ -526,7 +832,8 @@ export default class LethalFantasyUtils {
/* -------------------------------------------- */
static async compareAttackDefense(data) {
console.log("compareAttackDefense called with:", data)
const isAttackWin = data.attackRoll > data.defenseRoll
const outcome = data.outcome || (data.attackRoll > data.defenseRoll ? "hit" : "miss")
const isAttackWin = outcome !== "miss"
console.log("isAttackWin:", isAttackWin, "attackRoll:", data.attackRoll, "defenseRoll:", data.defenseRoll)
let damageButton = ""
@@ -536,10 +843,10 @@ export default class LethalFantasyUtils {
if (data.attackRollType === "weapon-attack") {
damageButton = `
<div class="attack-result-damage">
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-weapon-id="${data.attackWeaponId}" data-damage-type="small">
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-defender-token-id="${data.defenderTokenId || ""}" data-extra-shield-dr="${data.shieldDamageReduction || 0}" data-weapon-id="${data.attackWeaponId}" data-damage-type="small">
<i class="fa-solid fa-dice-d6"></i> Damage (Small)
</button>
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-weapon-id="${data.attackWeaponId}" data-damage-type="medium">
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-defender-token-id="${data.defenderTokenId || ""}" data-extra-shield-dr="${data.shieldDamageReduction || 0}" data-weapon-id="${data.attackWeaponId}" data-damage-type="medium">
<i class="fa-solid fa-dice-d20"></i> Damage (Medium)
</button>
</div>
@@ -547,11 +854,29 @@ export default class LethalFantasyUtils {
} else if (data.attackRollType === "monster-attack") {
damageButton = `
<div class="attack-result-damage">
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-attack-key="${data.attackRollKey}" data-damage-type="monster">
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-defender-token-id="${data.defenderTokenId || ""}" data-extra-shield-dr="${data.shieldDamageReduction || 0}" data-attack-key="${data.attackRollKey}" data-damage-type="monster">
<i class="fa-solid fa-burst"></i> Damage
</button>
</div>
`
} else if (data.attackRollType === "spell-attack" || data.attackRollType === "miracle-attack") {
const attacker = game.actors.get(data.attackerId)
const spell = attacker?.items.get(data.attackWeaponId)
const damageDice = spell?.system?.damageDice
if (damageDice) {
damageButton = `
<div class="attack-result-damage">
<button class="roll-damage-btn"
data-attacker-id="${data.attackerId}"
data-defender-id="${data.defenderId}"
data-defender-token-id="${data.defenderTokenId || ""}"
data-damage-type="spell"
data-damage-formula="${damageDice}">
<i class="fa-solid fa-wand-magic-sparkles"></i> Spell Damage (${damageDice})
</button>
</div>
`
}
}
}
@@ -576,9 +901,11 @@ export default class LethalFantasyUtils {
</div>
</div>
<div class="combat-result-text">
${isAttackWin ?
`<i class="fa-solid fa-circle-check"></i> <strong>${data.attackerName}</strong> hits <strong>${data.defenderName}</strong>!` :
`<i class="fa-solid fa-shield-halved"></i> <strong>${data.defenderName}</strong> parries the attack!`
${outcome === "shielded-hit"
? `<i class="fa-solid fa-shield"></i> <strong>${data.attackerName}</strong> hits <strong>${data.defenderName}</strong>, but the shield blocked — apply armor DR + shield DR <strong>${data.shieldDamageReduction || 0}</strong>.`
: isAttackWin
? `<i class="fa-solid fa-circle-check"></i> <strong>${data.attackerName}</strong> hits <strong>${data.defenderName}</strong>!`
: `<i class="fa-solid fa-shield-halved"></i> <strong>${data.defenderName}</strong> parries the attack!`
}
</div>
${damageButton}
@@ -765,25 +1092,32 @@ export default class LethalFantasyUtils {
static async applyDamage(message, event) {
// Récupérer les données du message
let combatantId = event.currentTarget.dataset.combatantId
if (!combatantId || !game.combat) {
if (!combatantId) {
ui.notifications.error("No combatant selected")
return
}
let combatant = game.combat.combatants.get(combatantId)
if (!combatant) {
ui.notifications.error("Combatant not found")
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
}
let targetActor = combatant.token?.actor || game.actors.get(combatant.actorId)
if (!targetActor) {
ui.notifications.error("Target actor not found")
return
}
// Récupérer les données de dégâts du message
let damageTotal = message.rolls[0]?.total || 0
// Use options.rollTotal (includes weapon modifier bonus) rather than roll.total (dice formula only)
let damageTotal = message.rolls[0]?.options?.rollTotal ?? message.rolls[0]?.total ?? 0
let weaponName = message.rolls[0]?.options?.rollName || "Unknown Weapon"
// Calculer les DR
+1 -1
View File
@@ -1 +1 @@
MANIFEST-000539
MANIFEST-000591
+8 -8
View File
@@ -1,8 +1,8 @@
2026/02/06-21:03:10.117032 7f71b6ffd6c0 Recovering log #537
2026/02/06-21:03:10.127068 7f71b6ffd6c0 Delete type=3 #535
2026/02/06-21:03:10.127128 7f71b6ffd6c0 Delete type=0 #537
2026/02/06-21:51:23.216143 7f71b67fc6c0 Level-0 table #542: started
2026/02/06-21:51:23.216190 7f71b67fc6c0 Level-0 table #542: 0 bytes OK
2026/02/06-21:51:23.251149 7f71b67fc6c0 Delete type=0 #540
2026/02/06-21:51:23.327713 7f71b67fc6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
2026/02/06-21:51:23.327750 7f71b67fc6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
2026/05/17-11:57:50.231387 7f16423fc6c0 Recovering log #589
2026/05/17-11:57:50.249229 7f16423fc6c0 Delete type=3 #587
2026/05/17-11:57:50.249281 7f16423fc6c0 Delete type=0 #589
2026/05/17-13:21:53.429711 7f1641bfb6c0 Level-0 table #594: started
2026/05/17-13:21:53.429759 7f1641bfb6c0 Level-0 table #594: 0 bytes OK
2026/05/17-13:21:53.437714 7f1641bfb6c0 Delete type=0 #592
2026/05/17-13:21:53.449134 7f1641bfb6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
2026/05/17-13:21:53.461721 7f1641bfb6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
+8 -8
View File
@@ -1,8 +1,8 @@
2026/02/04-08:49:16.805619 7f3bddbff6c0 Recovering log #533
2026/02/04-08:49:16.866468 7f3bddbff6c0 Delete type=3 #531
2026/02/04-08:49:16.866605 7f3bddbff6c0 Delete type=0 #533
2026/02/04-08:52:25.382505 7f3946fff6c0 Level-0 table #538: started
2026/02/04-08:52:25.382568 7f3946fff6c0 Level-0 table #538: 0 bytes OK
2026/02/04-08:52:25.390046 7f3946fff6c0 Delete type=0 #536
2026/02/04-08:52:25.403667 7f3946fff6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
2026/02/04-08:52:25.403757 7f3946fff6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
2026/05/02-08:40:55.892385 7fd7557ee6c0 Recovering log #585
2026/05/02-08:40:55.903385 7fd7557ee6c0 Delete type=3 #583
2026/05/02-08:40:55.903442 7fd7557ee6c0 Delete type=0 #585
2026/05/02-08:41:12.057856 7fd7477fe6c0 Level-0 table #590: started
2026/05/02-08:41:12.057882 7fd7477fe6c0 Level-0 table #590: 0 bytes OK
2026/05/02-08:41:12.121845 7fd7477fe6c0 Delete type=0 #588
2026/05/02-08:41:12.122077 7fd7477fe6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
2026/05/02-08:41:12.122121 7fd7477fe6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zw9RQocTdz3HRjZK' @ 0 : 0; will stop at (end)
+1 -1
View File
@@ -1 +1 @@
MANIFEST-000536
MANIFEST-000588
+8 -8
View File
@@ -1,8 +1,8 @@
2026/02/06-21:03:10.133019 7f71b7fff6c0 Recovering log #534
2026/02/06-21:03:10.144336 7f71b7fff6c0 Delete type=3 #532
2026/02/06-21:03:10.144427 7f71b7fff6c0 Delete type=0 #534
2026/02/06-21:51:23.291316 7f71b67fc6c0 Level-0 table #539: started
2026/02/06-21:51:23.291356 7f71b67fc6c0 Level-0 table #539: 0 bytes OK
2026/02/06-21:51:23.327518 7f71b67fc6c0 Delete type=0 #537
2026/02/06-21:51:23.327733 7f71b67fc6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
2026/02/06-21:51:23.327757 7f71b67fc6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
2026/05/17-11:57:50.260046 7f16433fe6c0 Recovering log #586
2026/05/17-11:57:50.276348 7f16433fe6c0 Delete type=3 #584
2026/05/17-11:57:50.276460 7f16433fe6c0 Delete type=0 #586
2026/05/17-13:21:53.474443 7f1641bfb6c0 Level-0 table #591: started
2026/05/17-13:21:53.474485 7f1641bfb6c0 Level-0 table #591: 0 bytes OK
2026/05/17-13:21:53.481502 7f1641bfb6c0 Delete type=0 #589
2026/05/17-13:21:53.490389 7f1641bfb6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
2026/05/17-13:21:53.512946 7f1641bfb6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
+8 -8
View File
@@ -1,8 +1,8 @@
2026/02/04-08:49:16.884043 7f3bdd3fe6c0 Recovering log #530
2026/02/04-08:49:16.942005 7f3bdd3fe6c0 Delete type=3 #528
2026/02/04-08:49:16.942138 7f3bdd3fe6c0 Delete type=0 #530
2026/02/04-08:52:25.418216 7f3946fff6c0 Level-0 table #535: started
2026/02/04-08:52:25.418276 7f3946fff6c0 Level-0 table #535: 0 bytes OK
2026/02/04-08:52:25.424939 7f3946fff6c0 Delete type=0 #533
2026/02/04-08:52:25.432353 7f3946fff6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
2026/02/04-08:52:25.432442 7f3946fff6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
2026/05/02-08:40:55.909564 7fd747fff6c0 Recovering log #582
2026/05/02-08:40:55.919159 7fd747fff6c0 Delete type=3 #580
2026/05/02-08:40:55.919214 7fd747fff6c0 Delete type=0 #582
2026/05/02-08:41:11.999050 7fd7477fe6c0 Level-0 table #587: started
2026/05/02-08:41:11.999076 7fd7477fe6c0 Level-0 table #587: 0 bytes OK
2026/05/02-08:41:12.057672 7fd7477fe6c0 Delete type=0 #585
2026/05/02-08:41:12.122063 7fd7477fe6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
2026/05/02-08:41:12.122111 7fd7477fe6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!x5gLtqlW4sdDmHTd' @ 0 : 0; will stop at (end)
+1 -1
View File
@@ -1 +1 @@
MANIFEST-000541
MANIFEST-000593
+8 -8
View File
@@ -1,8 +1,8 @@
2026/02/06-21:03:10.101791 7f71b77fe6c0 Recovering log #539
2026/02/06-21:03:10.111914 7f71b77fe6c0 Delete type=3 #537
2026/02/06-21:03:10.111991 7f71b77fe6c0 Delete type=0 #539
2026/02/06-21:51:23.251285 7f71b67fc6c0 Level-0 table #544: started
2026/02/06-21:51:23.251325 7f71b67fc6c0 Level-0 table #544: 0 bytes OK
2026/02/06-21:51:23.291180 7f71b67fc6c0 Delete type=0 #542
2026/02/06-21:51:23.327724 7f71b67fc6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2026/02/06-21:51:23.327764 7f71b67fc6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2026/05/17-11:57:50.206131 7f1643bff6c0 Recovering log #591
2026/05/17-11:57:50.222037 7f1643bff6c0 Delete type=3 #589
2026/05/17-11:57:50.222089 7f1643bff6c0 Delete type=0 #591
2026/05/17-13:21:53.292176 7f1641bfb6c0 Level-0 table #596: started
2026/05/17-13:21:53.292219 7f1641bfb6c0 Level-0 table #596: 0 bytes OK
2026/05/17-13:21:53.299322 7f1641bfb6c0 Delete type=0 #594
2026/05/17-13:21:53.306548 7f1641bfb6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2026/05/17-13:21:53.318889 7f1641bfb6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
+8 -8
View File
@@ -1,8 +1,8 @@
2026/02/04-08:49:16.723698 7f3bdcbfd6c0 Recovering log #535
2026/02/04-08:49:16.780187 7f3bdcbfd6c0 Delete type=3 #533
2026/02/04-08:49:16.780329 7f3bdcbfd6c0 Delete type=0 #535
2026/02/04-08:52:25.375521 7f3946fff6c0 Level-0 table #540: started
2026/02/04-08:52:25.375622 7f3946fff6c0 Level-0 table #540: 0 bytes OK
2026/02/04-08:52:25.382202 7f3946fff6c0 Delete type=0 #538
2026/02/04-08:52:25.403638 7f3946fff6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2026/02/04-08:52:25.403738 7f3946fff6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2026/05/02-08:40:55.873571 7fd747fff6c0 Recovering log #587
2026/05/02-08:40:55.883892 7fd747fff6c0 Delete type=3 #585
2026/05/02-08:40:55.883950 7fd747fff6c0 Delete type=0 #587
2026/05/02-08:41:11.870087 7fd7477fe6c0 Level-0 table #592: started
2026/05/02-08:41:11.870140 7fd7477fe6c0 Level-0 table #592: 0 bytes OK
2026/05/02-08:41:11.937524 7fd7477fe6c0 Delete type=0 #590
2026/05/02-08:41:12.122025 7fd7477fe6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2026/05/02-08:41:12.122087 7fd7477fe6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
+1 -1
View File
@@ -1 +1 @@
MANIFEST-000236
MANIFEST-000288
+8 -8
View File
@@ -1,8 +1,8 @@
2026/02/06-21:03:10.160494 7f71b6ffd6c0 Recovering log #234
2026/02/06-21:03:10.170771 7f71b6ffd6c0 Delete type=3 #232
2026/02/06-21:03:10.170846 7f71b6ffd6c0 Delete type=0 #234
2026/02/06-21:51:23.435610 7f71b67fc6c0 Level-0 table #239: started
2026/02/06-21:51:23.435649 7f71b67fc6c0 Level-0 table #239: 0 bytes OK
2026/02/06-21:51:23.473038 7f71b67fc6c0 Delete type=0 #237
2026/02/06-21:51:23.473211 7f71b67fc6c0 Manual compaction at level-0 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
2026/02/06-21:51:23.473250 7f71b67fc6c0 Manual compaction at level-1 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
2026/05/17-11:57:50.303535 7f16433fe6c0 Recovering log #286
2026/05/17-11:57:50.318955 7f16433fe6c0 Delete type=3 #284
2026/05/17-11:57:50.319061 7f16433fe6c0 Delete type=0 #286
2026/05/17-13:21:53.481662 7f1641bfb6c0 Level-0 table #291: started
2026/05/17-13:21:53.481693 7f1641bfb6c0 Level-0 table #291: 0 bytes OK
2026/05/17-13:21:53.490187 7f1641bfb6c0 Delete type=0 #289
2026/05/17-13:21:53.502325 7f1641bfb6c0 Manual compaction at level-0 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
2026/05/17-13:21:53.512979 7f1641bfb6c0 Manual compaction at level-1 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
+8 -8
View File
@@ -1,8 +1,8 @@
2026/02/04-08:49:17.043224 7f3bc7fff6c0 Recovering log #230
2026/02/04-08:49:17.105842 7f3bc7fff6c0 Delete type=3 #228
2026/02/04-08:49:17.106088 7f3bc7fff6c0 Delete type=0 #230
2026/02/04-08:52:25.396931 7f3946fff6c0 Level-0 table #235: started
2026/02/04-08:52:25.396997 7f3946fff6c0 Level-0 table #235: 0 bytes OK
2026/02/04-08:52:25.403390 7f3946fff6c0 Delete type=0 #233
2026/02/04-08:52:25.403717 7f3946fff6c0 Manual compaction at level-0 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
2026/02/04-08:52:25.403823 7f3946fff6c0 Manual compaction at level-1 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
2026/05/02-08:40:55.939668 7fd754fed6c0 Recovering log #282
2026/05/02-08:40:55.949715 7fd754fed6c0 Delete type=3 #280
2026/05/02-08:40:55.949784 7fd754fed6c0 Delete type=0 #282
2026/05/02-08:41:12.184448 7fd7477fe6c0 Level-0 table #287: started
2026/05/02-08:41:12.184496 7fd7477fe6c0 Level-0 table #287: 0 bytes OK
2026/05/02-08:41:12.252892 7fd7477fe6c0 Delete type=0 #285
2026/05/02-08:41:12.365481 7fd7477fe6c0 Manual compaction at level-0 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
2026/05/02-08:41:12.365509 7fd7477fe6c0 Manual compaction at level-1 from '!folders!37mu4dxsSuftlnmP' @ 72057594037927935 : 1 .. '!items!zKOpU34oLziGJW6y' @ 0 : 0; will stop at (end)
+1 -1
View File
@@ -1 +1 @@
MANIFEST-000535
MANIFEST-000587
+8 -8
View File
@@ -1,8 +1,8 @@
2026/02/06-21:03:10.146976 7f71b77fe6c0 Recovering log #533
2026/02/06-21:03:10.156549 7f71b77fe6c0 Delete type=3 #531
2026/02/06-21:03:10.156610 7f71b77fe6c0 Delete type=0 #533
2026/02/06-21:51:23.327858 7f71b67fc6c0 Level-0 table #538: started
2026/02/06-21:51:23.327892 7f71b67fc6c0 Level-0 table #538: 0 bytes OK
2026/02/06-21:51:23.359727 7f71b67fc6c0 Delete type=0 #536
2026/02/06-21:51:23.473179 7f71b67fc6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2026/02/06-21:51:23.473221 7f71b67fc6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2026/05/17-11:57:50.282340 7f16423fc6c0 Recovering log #585
2026/05/17-11:57:50.297125 7f16423fc6c0 Delete type=3 #583
2026/05/17-11:57:50.297189 7f16423fc6c0 Delete type=0 #585
2026/05/17-13:21:53.299508 7f1641bfb6c0 Level-0 table #590: started
2026/05/17-13:21:53.299854 7f1641bfb6c0 Level-0 table #590: 0 bytes OK
2026/05/17-13:21:53.306309 7f1641bfb6c0 Delete type=0 #588
2026/05/17-13:21:53.318877 7f1641bfb6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2026/05/17-13:21:53.325564 7f1641bfb6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
+8 -8
View File
@@ -1,8 +1,8 @@
2026/02/04-08:49:16.956252 7f3bdcbfd6c0 Recovering log #529
2026/02/04-08:49:17.018344 7f3bdcbfd6c0 Delete type=3 #527
2026/02/04-08:49:17.018475 7f3bdcbfd6c0 Delete type=0 #529
2026/02/04-08:52:25.390221 7f3946fff6c0 Level-0 table #534: started
2026/02/04-08:52:25.390273 7f3946fff6c0 Level-0 table #534: 0 bytes OK
2026/02/04-08:52:25.396704 7f3946fff6c0 Delete type=0 #532
2026/02/04-08:52:25.403694 7f3946fff6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2026/02/04-08:52:25.403801 7f3946fff6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2026/05/02-08:40:55.925402 7fd755fef6c0 Recovering log #581
2026/05/02-08:40:55.935869 7fd755fef6c0 Delete type=3 #579
2026/05/02-08:40:55.935924 7fd755fef6c0 Delete type=0 #581
2026/05/02-08:41:11.937698 7fd7477fe6c0 Level-0 table #586: started
2026/05/02-08:41:11.937727 7fd7477fe6c0 Level-0 table #586: 0 bytes OK
2026/05/02-08:41:11.998871 7fd7477fe6c0 Delete type=0 #584
2026/05/02-08:41:12.122041 7fd7477fe6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2026/05/02-08:41:12.122099 7fd7477fe6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
+246
View File
@@ -88,3 +88,249 @@
padding-left: 8px;
font-size: 0.9rem;
}
/* -------------------------------------------------- */
/* 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);
}
}
}
+42
View File
@@ -410,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);
+4 -4
View File
@@ -467,7 +467,7 @@
.d30-label {
flex-grow: 1;
font-weight: bold;
color: #e0d5f0;
color: #2a1a3a;
text-transform: uppercase;
letter-spacing: 0.5px;
font-size: calc(var(--font-size-standard) * 0.9);
@@ -477,11 +477,11 @@
font-family: var(--font-primary);
font-size: calc(var(--font-size-standard) * 1.5);
font-weight: bold;
color: #ff69b4;
background: rgba(255, 105, 180, 0.1);
color: #3d006e;
background: rgba(255, 255, 255, 0.35);
padding: 4px 12px;
border-radius: 12px;
border: 1px solid rgba(255, 105, 180, 0.3);
border: 1px solid rgba(138, 43, 226, 0.4);
}
}
+2 -2
View File
@@ -6,7 +6,7 @@
"download": "#{DOWNLOAD}#",
"url": "#{URL}#",
"license": "LICENSE",
"version": "13.0.0",
"version": "14.0.0",
"authors": [
{
"name": "Uberwald",
@@ -15,7 +15,7 @@
],
"compatibility": {
"minimum": "13",
"verified": "13"
"verified": "14"
},
"esmodules": ["lethal-fantasy.mjs"],
"styles": ["css/fvtt-lethal-fantasy.css"],
+5
View File
@@ -21,6 +21,11 @@
<a data-action="armorHitPointsMinus"><i class="fa-solid fa-hexagon-minus"></i></a>
</div>
<div class="flexrow armor-hp">
<span class="name" data-tooltip="{{localize 'LETHALFANTASY.Tooltip.combatProgressionStart'}}">{{localize "LETHALFANTASY.Label.combatProgressionStart"}}</span>
{{formInput systemFields.combat.fields.combatProgressionStart value=system.combat.combatProgressionStart disabled=isPlayMode }}
</div>
<div class="flexrow granted">
<span class="">{{localize
"LETHALFANTASY.Label.grantedAttackDice"}}</a></span>
+2 -2
View File
@@ -127,7 +127,7 @@
{{#if D30message}}
<div class="d30-message">
<i class="fa-solid fa-wand-magic-sparkles"></i>
<span>{{D30message}}</span>
<span>{{D30message.description}}</span>
</div>
{{/if}}
</div>
@@ -239,7 +239,7 @@
<div class="damage-result auto-applied">
<div class="auto-damage-notice">
<i class="fa-solid fa-check-circle"></i>
<span>Damage automatically applied to defender (with Armor DR)</span>
<span>Damage automatically applied to defender (with damage reduction)</span>
</div>
</div>
{{else}}
+9 -1
View File
@@ -3,7 +3,7 @@
{{!-- GM Controls --}}
{{#if user.isGM}}
{{#if combat.round}}
{{#if (or combat.round (eq combat.turn 0))}}
<!-- <button type="button" class="inline-control combat-control icon fa-solid fa-backward-step"
data-action="previousRound" data-tooltip aria-label="{{ localize "COMBAT.RoundPrev" }}"></button>
<button type="button" class="inline-control combat-control icon fa-solid fa-arrow-left" data-action="previousTurn"
@@ -13,6 +13,14 @@
<span>{{ localize "COMBAT.End" }}</span>
</button>
{{#if combat.round}}
<button type="button" class="combat-control combat-control-lg" data-action="rollMonsterProgression"
data-tooltip="{{ localize 'LETHALFANTASY.Combat.RollMonsters' }}">
<i class="fa-solid fa-dragon" inert></i>
<span>{{ localize "LETHALFANTASY.Combat.RollMonsters" }}</span>
</button>
{{/if}}
<!-- <button type="button" class="inline-control combat-control icon fa-solid fa-arrow-right" data-action="nextTurn"
data-tooltip aria-label="{{ localize "COMBAT.TurnNext" }}"></button> -->
<button type="button" class="inline-control combat-control icon fa-solid fa-forward-step" data-action="nextRound"
+1 -1
View File
@@ -70,7 +70,7 @@
{{!-- Combat Status --}}
<strong class="encounter-title">
{{#if combats.length}}
{{#if combat.round}}
{{#if (or combat.round (eq combat.turn 0))}}
{{ localize "COMBAT.Round" round=combat.round }}
{{else}}
{{ localize "COMBAT.NotStarted" }}
+97 -1
View File
@@ -18,7 +18,16 @@
<fieldset>
<legend>{{localize "LETHALFANTASY.Label.attacks"}}</legend>
<div class="attacks">
<div class="attack-mode-selector">
<label>{{localize "LETHALFANTASY.Label.attackMode"}}</label>
<select name="system.attackMode">
<option value="melee" {{#if (eq system.attackMode "melee")}}selected{{/if}}>{{localize "LETHALFANTASY.Label.meleeModeLabel"}}</option>
<option value="ranged" {{#if (eq system.attackMode "ranged")}}selected{{/if}}>{{localize "LETHALFANTASY.Label.rangedModeLabel"}}</option>
</select>
</div>
{{#if (eq system.attackMode "melee")}}
<div class="attacks melee-attacks">
{{#each system.attacks as |item key|}}
<div class="attack" data-attack-key="{{key}}" >
<div class="">
@@ -42,6 +51,9 @@
<div class="numeric">
<input type="number" name="system.attacks.{{item.key}}.damageModifier" value="{{item.damageModifier}}" data-tooltip="Damage modifier"/>
</div>
<div class="">
<input type="checkbox" name="system.attacks.{{item.key}}.noExplode" {{checked item.noExplode}} data-tooltip="No exploding dice on damage" />
</div>
<div class="attack-icons">
@@ -64,6 +76,87 @@
</div>
{{/each}}
</div>
{{else}}
<div class="attacks ranged-attacks">
{{#each system.rangedAttacks as |item key|}}
<div class="attack" data-attack-key="{{key}}" >
<div class="">
<input type="checkbox" name="system.rangedAttacks.{{item.key}}.enabled" {{checked item.enabled}} data-tooltip="Attack enabled/disabled" />
</div>
<div class="name">
<input type="text" name="system.rangedAttacks.{{item.key}}.name" value="{{item.name}}" data-tooltip="Attack name" />
</div>
<div class="numeric">
<input type="number" name="system.rangedAttacks.{{item.key}}.attackScore" value="{{item.attackScore}}" data-tooltip="Progression number" />
</div>
<div class="numeric">
<input type="number" name="system.rangedAttacks.{{item.key}}.attackModifier" value="{{item.attackModifier}}" data-tooltip="Attack modifier" />
</div>
<div class="numeric">
<input type="number" name="system.rangedAttacks.{{item.key}}.defenseModifier" value="{{item.defenseModifier}}" data-tooltip="Defense modifier"/>
</div>
<div class="damage-dice">
<input type="text" name="system.rangedAttacks.{{item.key}}.damageDice" value="{{item.damageDice}}" data-tooltip="Damage dice"/>
</div>
<div class="numeric">
<input type="number" name="system.rangedAttacks.{{item.key}}.damageModifier" value="{{item.damageModifier}}" data-tooltip="Damage modifier"/>
</div>
<div class="">
<input type="checkbox" name="system.rangedAttacks.{{item.key}}.noExplode" {{checked item.noExplode}} data-tooltip="No exploding dice on damage" />
</div>
<div class="attack-icons">
<a class="rollable" data-roll-type="monster-attack" data-roll-key="{{item.key}}" data-tooltip="Roll Attack">
<i class="lf-roll-small fa-solid fa-bow-arrow" data-roll-type="monster-attack" data-roll-key="{{item.key}}"></i>
</a>
<a class="rollable" data-roll-type="monster-defense" data-roll-key="{{item.key}}" data-tooltip="Roll Defense">
<i class="fa-solid fa-shield-halved" data-roll-type="monster-defense" data-roll-key="{{item.key}}"></i>
</a>
<a class="rollable" data-roll-type="monster-damage" data-roll-key="{{item.key}}"
data-tooltip="Roll Damage">
<i class="fa-regular fa-face-head-bandage" data-roll-type="monster-damage"
data-roll-key="{{item.key}}"></i>
</a>
</div>
</div>
{{/each}}
<div class="ranged-weapon-range">
<label>{{localize "LETHALFANTASY.Label.range"}}</label>
<div class="range-fields">
<div class="range-field">
<label>{{localize "LETHALFANTASY.Label.pointBlank"}}</label>
<input type="number" name="system.rangedWeaponRange.pointBlank" value="{{system.rangedWeaponRange.pointBlank}}" />
</div>
<div class="range-field">
<label>{{localize "LETHALFANTASY.Label.short"}}</label>
<input type="number" name="system.rangedWeaponRange.short" value="{{system.rangedWeaponRange.short}}" />
</div>
<div class="range-field">
<label>{{localize "LETHALFANTASY.Label.medium"}}</label>
<input type="number" name="system.rangedWeaponRange.medium" value="{{system.rangedWeaponRange.medium}}" />
</div>
<div class="range-field">
<label>{{localize "LETHALFANTASY.Label.long"}}</label>
<input type="number" name="system.rangedWeaponRange.long" value="{{system.rangedWeaponRange.long}}" />
</div>
<div class="range-field">
<label>{{localize "LETHALFANTASY.Label.extreme"}}</label>
<input type="number" name="system.rangedWeaponRange.extreme" value="{{system.rangedWeaponRange.extreme}}" />
</div>
<div class="range-field">
<label>{{localize "LETHALFANTASY.Label.outOfSkill"}}</label>
<input type="number" name="system.rangedWeaponRange.outOfSkill" value="{{system.rangedWeaponRange.outOfSkill}}" />
</div>
</div>
</div>
</div>
{{/if}}
</fieldset>
<fieldset>
@@ -92,6 +185,9 @@
<div class="numeric">
<input type="number" name="system.combatHTH.{{item.key}}.damageModifier" value="{{item.damageModifier}}" data-tooltip="Damage modifier"/>
</div>
<div class="">
<input type="checkbox" name="system.combatHTH.{{item.key}}.noExplode" {{checked item.noExplode}} data-tooltip="No exploding dice on damage" />
</div>
<div class="attack-icons">
+1
View File
@@ -30,6 +30,7 @@
{{formField systemFields.savingThrow value=system.savingThrow}}
{{formField systemFields.extraAetherPoints value=system.extraAetherPoints}}
{{formField systemFields.criticalType value=system.criticalType}}
{{formField systemFields.damageDice value=system.damageDice}}
<fieldset>