FIx for spells/miracles

This commit is contained in:
2026-04-30 23:08:23 +02:00
parent b4211c121d
commit 1641be6516
6 changed files with 50 additions and 15 deletions
+2 -2
View File
@@ -250,7 +250,7 @@
"Oaths": "Oaths", "Oaths": "Oaths",
"Weapons": "Weapons", "Weapons": "Weapons",
"Attacks": "Attacks", "Attacks": "Attacks",
"Armor": "Armor & Shields", "Armor": "Armor",
"Ammunition": "Ammunition", "Ammunition": "Ammunition",
"ItemSlots": "Item Slots", "ItemSlots": "Item Slots",
"Spells": "Spells", "Spells": "Spells",
@@ -444,7 +444,7 @@
"ExplodeOn5": "Explode on 5+", "ExplodeOn5": "Explode on 5+",
"ExplodeOn5Hint": "trait bonus — 5s & 6s explode", "ExplodeOn5Hint": "trait bonus — 5s & 6s explode",
"DiceColor": "Dice Color", "DiceColor": "Dice Color",
"DiceColorHint": "equipment traits can upgrade dice", "DiceColorHint": "White (4+), Red (3+), or Black (2+) thresholds",
"AttackTitle": "Attack: {weapon}", "AttackTitle": "Attack: {weapon}",
"DamageTitle": "Damage: {weapon}", "DamageTitle": "Damage: {weapon}",
"Attack": "Attack", "Attack": "Attack",
+12 -3
View File
@@ -6,9 +6,10 @@ export default class OathHammerMiracleDialog {
const sys = miracle.system const sys = miracle.system
const actorSys = actor.system const actorSys = actor.system
const wpRank = actorSys.attributes.willpower.rank const wpRank = actorSys.attributes.willpower.rank
const magicRank = actorSys.skills.magic.rank const magicRank = actorSys.skills.magic.rank
const basePool = wpRank + magicRank const magicColor = actorSys.skills.magic.colorDiceType ?? "white"
const basePool = wpRank + magicRank
const isRitual = sys.isRitual const isRitual = sys.isRitual
const dv = isRitual ? (sys.difficultyValue || 1) : null const dv = isRitual ? (sys.difficultyValue || 1) : null
@@ -18,6 +19,12 @@ export default class OathHammerMiracleDialog {
return key ? game.i18n.localize(key) : sys.divineTradition return key ? game.i18n.localize(key) : sys.divineTradition
})() })()
const colorOptions = [
{ value: "white", label: game.i18n.localize("OATHHAMMER.ColorDice.White"), selected: magicColor === "white" },
{ value: "red", label: game.i18n.localize("OATHHAMMER.ColorDice.Red"), selected: magicColor === "red" },
{ value: "black", label: game.i18n.localize("OATHHAMMER.ColorDice.Black"), selected: magicColor === "black" },
]
// Miracle count options — DV = miracle number today // Miracle count options — DV = miracle number today
const miracleCountOptions = Array.from({ length: 10 }, (_, i) => ({ const miracleCountOptions = Array.from({ length: 10 }, (_, i) => ({
value: i + 1, value: i + 1,
@@ -55,6 +62,7 @@ export default class OathHammerMiracleDialog {
magicRank, magicRank,
basePool, basePool,
miracleCountOptions, miracleCountOptions,
colorOptions,
bonusOptions, bonusOptions,
availableLuck, availableLuck,
isHuman, isHuman,
@@ -93,6 +101,7 @@ export default class OathHammerMiracleDialog {
return { return {
dv: computedDV, dv: computedDV,
isRitual, isRitual,
colorOverride: result.colorOverride ?? magicColor,
bonus: parseInt(result.bonus) || 0, bonus: parseInt(result.bonus) || 0,
visibility: result.visibility ?? game.settings.get("core", "rollMode"), visibility: result.visibility ?? game.settings.get("core", "rollMode"),
explodeOn5: result.explodeOn5 === "true", explodeOn5: result.explodeOn5 === "true",
+12 -3
View File
@@ -25,9 +25,10 @@ export default class OathHammerSpellDialog {
const sys = spell.system const sys = spell.system
const actorSys = actor.system const actorSys = actor.system
const intRank = actorSys.attributes.intelligence.rank const intRank = actorSys.attributes.intelligence.rank
const magicRank = actorSys.skills.magic.rank const magicRank = actorSys.skills.magic.rank
const basePool = intRank + magicRank const magicColor = actorSys.skills.magic.colorDiceType ?? "white"
const basePool = intRank + magicRank
const currentStress = actorSys.arcaneStress.value const currentStress = actorSys.arcaneStress.value
const stressThreshold = actorSys.arcaneStress.threshold const stressThreshold = actorSys.arcaneStress.threshold
@@ -41,6 +42,12 @@ export default class OathHammerSpellDialog {
return entry ? game.i18n.localize(entry.label) : (sys.tradition ?? "") return entry ? game.i18n.localize(entry.label) : (sys.tradition ?? "")
})() })()
const colorOptions = [
{ value: "white", label: game.i18n.localize("OATHHAMMER.ColorDice.White"), selected: magicColor === "white" },
{ value: "red", label: game.i18n.localize("OATHHAMMER.ColorDice.Red"), selected: magicColor === "red" },
{ value: "black", label: game.i18n.localize("OATHHAMMER.ColorDice.Black"), selected: magicColor === "black" },
]
const enhancementOptions = Object.entries(SPELL_ENHANCEMENTS).map(([key, def]) => ({ const enhancementOptions = Object.entries(SPELL_ENHANCEMENTS).map(([key, def]) => ({
value: key, value: key,
label: game.i18n.localize(def.label), label: game.i18n.localize(def.label),
@@ -87,6 +94,7 @@ export default class OathHammerSpellDialog {
magicRank, magicRank,
basePool, basePool,
poolSizeOptions, poolSizeOptions,
colorOptions,
currentStress, currentStress,
stressThreshold, stressThreshold,
isOverThreshold, isOverThreshold,
@@ -134,6 +142,7 @@ export default class OathHammerSpellDialog {
poolPenalty: enh.penalty, poolPenalty: enh.penalty,
redDice: enh.redDice, redDice: enh.redDice,
noStress: enh.noStress, noStress: enh.noStress,
colorOverride: result.colorOverride ?? magicColor,
elementalBonus: parseInt(result.elementalBonus) || 0, elementalBonus: parseInt(result.elementalBonus) || 0,
bonus: parseInt(result.bonus) || 0, bonus: parseInt(result.bonus) || 0,
poolSize: Math.min(Math.max(1, parseInt(result.poolSize) || basePool), basePool), poolSize: Math.min(Math.max(1, parseInt(result.poolSize) || basePool), basePool),
+8 -7
View File
@@ -468,6 +468,7 @@ export async function rollSpellCast(actor, spell, options = {}) {
poolPenalty = 0, poolPenalty = 0,
redDice = false, redDice = false,
noStress = false, noStress = false,
colorOverride = "white",
elementalBonus = 0, elementalBonus = 0,
bonus = 0, bonus = 0,
poolSize = null, poolSize = null,
@@ -489,8 +490,8 @@ export async function rollSpellCast(actor, spell, options = {}) {
const totalDice = poolSize !== null const totalDice = poolSize !== null
? Math.max(1, Math.min(poolSize + bonus + poolPenalty + elementalBonus + grimPenalty + (luckSpend * luckDicePerPoint), baseDice)) ? Math.max(1, Math.min(poolSize + bonus + poolPenalty + elementalBonus + grimPenalty + (luckSpend * luckDicePerPoint), baseDice))
: Math.max(baseDice, 1) : Math.max(baseDice, 1)
const threshold = redDice ? 3 : 4 const threshold = colorOverride === "black" ? 2 : colorOverride === "red" ? 3 : 4
const colorEmoji = redDice ? "🔴" : "⬜" const colorEmoji = colorOverride === "black" ? "⬛" : colorOverride === "red" ? "🔴" : "⬜"
const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, explodeOn5) const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, explodeOn5)
const diceHtml = _diceHtml(diceResults, threshold) const diceHtml = _diceHtml(diceResults, threshold)
@@ -560,13 +561,12 @@ export async function rollSpellCast(actor, spell, options = {}) {
` `
const rollMode = visibility ?? game.settings.get("core", "rollMode") const rollMode = visibility ?? game.settings.get("core", "rollMode")
const spellColorType = redDice ? "red" : "white"
const msgData = { const msgData = {
speaker: ChatMessage.getSpeaker({ actor }), speaker: ChatMessage.getSpeaker({ actor }),
content, content,
rolls: rolls, rolls: rolls,
sound: CONFIG.sounds.dice, sound: CONFIG.sounds.dice,
flags: { "fvtt-oath-hammer": { luckRoll: _luckFlagData(actor, threshold, spellColorType, dv, false, explodeOn5) } }, flags: { "fvtt-oath-hammer": { luckRoll: _luckFlagData(actor, threshold, colorOverride, dv, false, explodeOn5) } },
} }
ChatMessage.applyRollMode(msgData, rollMode) ChatMessage.applyRollMode(msgData, rollMode)
await ChatMessage.create(msgData) await ChatMessage.create(msgData)
@@ -590,6 +590,7 @@ export async function rollMiracleCast(actor, miracle, options = {}) {
const { const {
dv = 1, dv = 1,
isRitual = false, isRitual = false,
colorOverride = "white",
bonus = 0, bonus = 0,
visibility, visibility,
explodeOn5 = false, explodeOn5 = false,
@@ -604,8 +605,8 @@ export async function rollMiracleCast(actor, miracle, options = {}) {
const magicRank = actorSys.skills.magic.rank const magicRank = actorSys.skills.magic.rank
const luckDicePerPoint = luckIsHuman ? 3 : 2 const luckDicePerPoint = luckIsHuman ? 3 : 2
const totalDice = Math.max(wpRank + magicRank + bonus + (luckSpend * luckDicePerPoint), 1) const totalDice = Math.max(wpRank + magicRank + bonus + (luckSpend * luckDicePerPoint), 1)
const threshold = 4 const threshold = colorOverride === "black" ? 2 : colorOverride === "red" ? 3 : 4
const colorEmoji = "⬜" const colorEmoji = colorOverride === "black" ? "⬛" : colorOverride === "red" ? "🔴" : "⬜"
const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, explodeOn5) const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, explodeOn5)
const diceHtml = _diceHtml(diceResults, threshold) const diceHtml = _diceHtml(diceResults, threshold)
@@ -664,7 +665,7 @@ export async function rollMiracleCast(actor, miracle, options = {}) {
content, content,
rolls: rolls, rolls: rolls,
sound: CONFIG.sounds.dice, sound: CONFIG.sounds.dice,
flags: { "fvtt-oath-hammer": { luckRoll: _luckFlagData(actor, threshold, "white", dv, false, explodeOn5) } }, flags: { "fvtt-oath-hammer": { luckRoll: _luckFlagData(actor, threshold, colorOverride, dv, false, explodeOn5) } },
} }
ChatMessage.applyRollMode(msgData, rollMode) ChatMessage.applyRollMode(msgData, rollMode)
await ChatMessage.create(msgData) await ChatMessage.create(msgData)
+8
View File
@@ -45,6 +45,14 @@
</div> </div>
{{/unless}} {{/unless}}
<div class="roll-option-row">
<label>{{localize "OATHHAMMER.Dialog.DiceColor"}}</label>
<select name="colorOverride">
{{#each colorOptions}}<option value="{{value}}"{{#if selected}} selected{{/if}}>{{label}}</option>{{/each}}
</select>
<span class="roll-option-hint">{{localize "OATHHAMMER.Dialog.DiceColorHint"}}</span>
</div>
<div class="roll-option-row"> <div class="roll-option-row">
<label>{{localize "OATHHAMMER.Dialog.Modifier"}}</label> <label>{{localize "OATHHAMMER.Dialog.Modifier"}}</label>
<select name="bonus"> <select name="bonus">
+8
View File
@@ -44,6 +44,14 @@
</div> </div>
{{/if}} {{/if}}
<div class="roll-option-row">
<label>{{localize "OATHHAMMER.Dialog.DiceColor"}}</label>
<select name="colorOverride">
{{#each colorOptions}}<option value="{{value}}"{{#if selected}} selected{{/if}}>{{label}}</option>{{/each}}
</select>
<span class="roll-option-hint">{{localize "OATHHAMMER.Dialog.DiceColorHint"}}</span>
</div>
<div class="roll-option-row"> <div class="roll-option-row">
<label>{{localize "OATHHAMMER.Dialog.Enhancement"}}</label> <label>{{localize "OATHHAMMER.Dialog.Enhancement"}}</label>
<select name="enhancement" class="enhancement-select"> <select name="enhancement" class="enhancement-select">