Fix actions again
All checks were successful
Release Creation / build (release) Successful in 58s

This commit is contained in:
2025-04-21 17:40:43 +02:00
parent 87a90b73ce
commit 4b087fc9d8
25 changed files with 105 additions and 90 deletions

View File

@ -221,8 +221,8 @@ export default class LethalFantasyRoll extends Roll {
hasChangeDice = false
options.rollTarget.value = options.rollTarget.actorModifiers.levelSpellModifier + options.rollTarget.actorModifiers.intSpellModifier
options.rollTarget.charModifier = options.rollTarget.actorModifiers.intSpellModifier
hasStaticModifier = options.rollType === "spell-power"
hasModifier = options.rollType !== "spell-attack"
hasStaticModifier = true // options.rollType === "spell-power"
hasModifier = true //options.rollType !== "spell-attack"
options.rollTarget.staticModifier = options.rollTarget.actorLevel
} else if (options.rollType === "miracle" || options.rollType === "miracle-attack" || options.rollType === "miracle-power") {
@ -234,8 +234,8 @@ export default class LethalFantasyRoll extends Roll {
hasChangeDice = false
options.rollTarget.value = options.rollTarget.actorModifiers.levelMiracleModifier + options.rollTarget.actorModifiers.chaMiracleModifier
options.rollTarget.charModifier = options.rollTarget.actorModifiers.chaMiracleModifier
hasStaticModifier = options.rollType === "spell-power"
hasModifier = options.rollType !== "miracle-attack"
hasStaticModifier = true // options.rollType === "spell-power"
hasModifier = true // options.rollType !== "miracle-attack"
options.rollTarget.staticModifier = options.rollTarget.actorLevel
} else if (options.rollType === "shield-roll") {
@ -373,6 +373,7 @@ export default class LethalFantasyRoll extends Roll {
if (hasStaticModifier) {
modifierFormula += ` + ${options.rollTarget.staticModifier}`
}
modifierFormula += ` + ${options.rollTarget.charModifier}`
let sign = fullModifier < 0 ? "-" : "+"
if (hasExplode) {
titleFormula = `${dice}E ${sign} ${modifierFormula}`
@ -640,11 +641,15 @@ export default class LethalFantasyRoll extends Roll {
})
} else if (currentAction.type === "spell" || currentAction.type === "miracle") {
let label = ""
if ( currentAction.castingDone) {
label = "Roll lethargy dice"
} else {
if ( currentAction.spellStatus === "castingTime") {
label = "Wait casting time"
}
if ( currentAction.spellStatus === "toBeCasted") {
label = "Cast spell/miracle"
}
if ( currentAction.spellStatus === "lethargy") {
label = "Roll lethargy dice"
}
buttons.push({
action: "roll",
label: label,
@ -675,7 +680,7 @@ export default class LethalFantasyRoll extends Roll {
}
})
const rollContext = await foundry.applications.api.DialogV2.wait({
let rollContext = await foundry.applications.api.DialogV2.wait({
window: { title: "Combat Action Dialog" },
classes: ["lethalfantasy"],
content,
@ -715,34 +720,45 @@ export default class LethalFantasyRoll extends Roll {
actionItem.progressionCount = 1
actionItem.rangedMode = rangedMode
actionItem.castingTime = 1
actionItem.castingDone = false
actionItem.spellStatus = "castingTime"
// Set the flag on the combatant
await combatant.setFlag(SYSTEM.id, "currentAction", actionItem)
let message = `${combatant.name} action : ${selectedItem.name}`
let message = `${combatant.name} action : ${selectedItem.name}, start rolling progression dice`
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
combatant.actor.prepareRoll(actionItem.type === "weapon" ? "weapon-attack" : "spell-attack", selectedChoice)
return
rollContext = (actionItem.type == "weapon") ? "rollProgressionDice" : "rollLethargyDice" // Set the roll context to rollProgressionDice
currentAction = actionItem
}
if (currentAction) {
if (rollContext === "rollLethargyDice") {
if ( !currentAction.castingDone) {
if ( currentAction.castingTime <= currentAction.system.castingTime) {
if ( currentAction.spellStatus === "castingTime") {
if ( currentAction.castingTime < currentAction.system.castingTime) {
let message = `Casting time : ${currentAction.name}, count : ${currentAction.castingTime}/${currentAction.system.castingTime}`
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
currentAction.castingTime += 1
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
return
} else {
let message = `Spell ${currentAction.name} has ben casted !`
let message = `Spell ${currentAction.name} ready to be cast on next second !`
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
currentAction.castingTime = 1
currentAction.castingDone = true
currentAction.spellStatus = "toBeCasted"
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
return
}
} else {
}
if ( currentAction.spellStatus === "toBeCasted") {
combatant.actor.prepareRoll( (currentAction.type === "spell") ? "spell-attack" : "miracle-attack" , currentAction._id)
if (currentAction.type === "spell") {
currentAction.spellStatus = "lethargy"
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
} else {
// No lethargy for miracle
await combatant.setFlag(SYSTEM.id, "currentAction", "")
}
return
}
if ( currentAction.spellStatus === "lethargy") {
// Roll lethargy dice
let dice = LethalFantasyUtils.getLethargyDice(currentAction.system.level)
let roll = new Roll(dice)
@ -810,10 +826,8 @@ export default class LethalFantasyRoll extends Roll {
// Notify that the player can act now with a chat message
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionOK", { isMonster, name: combatant.actor.name, weapon: currentAction.name, roll: roll.total })
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
// Update the combatant progression count
await combatant.setFlag(SYSTEM.id, "currentAction", "")
// Display the action selection window again
combatant.actor.system.rollProgressionDice(options.combatId, options.combatantId )
combatant.actor.prepareRoll(currentAction.type === "weapon" ? "weapon-attack" : "spell-attack", currentAction._id)
} else {
// Notify that the player cannot act now with a chat message
currentAction.progressionCount += 1