Fix lethargy/cast again
All checks were successful
Release Creation / build (release) Successful in 43s
All checks were successful
Release Creation / build (release) Successful in 43s
This commit is contained in:
@ -636,6 +636,13 @@ export default class LethalFantasyRoll extends Roll {
|
||||
return output
|
||||
},
|
||||
},
|
||||
{
|
||||
action: "cast",
|
||||
label: "Cast a spell",
|
||||
callback: (event, button, dialog) => {
|
||||
return "casting"
|
||||
},
|
||||
},
|
||||
{
|
||||
action: "cancel",
|
||||
label: "Other action, no progression dice",
|
||||
@ -648,15 +655,26 @@ export default class LethalFantasyRoll extends Roll {
|
||||
})
|
||||
|
||||
console.log("RollContext", dialogContext,rollContext)
|
||||
if (rollContext === null || !rollContext?.progressionDiceId) {
|
||||
let combat = game.combats.get(options.combatId)
|
||||
let combatant = combat.combatants.get(options.combatantId)
|
||||
combatant.update({ 'system.progressionCount': 0 })
|
||||
let combat = game.combats.get(options.combatId)
|
||||
let actor = game.actors.get(options.actorId)
|
||||
|
||||
if ( rollContext === "casting") {
|
||||
combat.setCasting(options.combatantId)
|
||||
let message = `Starting casting a spell !`
|
||||
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: actor }) })
|
||||
return
|
||||
}
|
||||
|
||||
if (rollContext === null || !rollContext?.progressionDiceId) {
|
||||
c.resetCasting(options.combatantId)
|
||||
combat.resetProgression(options.combatantId)
|
||||
let message = `${actor.name} : Other action, progression reset`
|
||||
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: actor }) })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Get the weapons from the actor items
|
||||
let actor = game.actors.get(options.actorId)
|
||||
let rangedMode
|
||||
let searchId = rollContext.progressionDiceId
|
||||
if ( searchId.match("simpleAim")) {
|
||||
@ -676,27 +694,36 @@ export default class LethalFantasyRoll extends Roll {
|
||||
searchId = searchId.replace("spell", "")
|
||||
let spell = actor.items.find(i => i.type === "spell" && i.id === searchId)
|
||||
let dice = LethalFantasyUtils.getLethargyDice(spell.system.level)
|
||||
if (options.rollProgressionCount <= spell.system.castingTime ) {
|
||||
let message = `Spell casting time : ${spell.name}, count : ${options.rollProgressionCount}/${spell.system.castingTime}`
|
||||
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: actor }) })
|
||||
return
|
||||
}
|
||||
let formula = dice
|
||||
let roll = new Roll(formula)
|
||||
await roll.evaluate()
|
||||
let max = roll.dice[0].faces - 1
|
||||
let toCompare = Math.min(options.rollProgressionCount-spell.system.castingTime, max)
|
||||
let message
|
||||
if (roll.total > toCompare) {
|
||||
message = `Spell Lethargy ongoing ... (${roll.total}/${toCompare}, spell level ${spell.system.level})`
|
||||
} else {
|
||||
let combat = game.combats.get(options.combatId)
|
||||
combat.resetProgression(options.combatantId)
|
||||
message = `Spell Lethargy ended ! (${roll.total}/${toCompare}, spell level ${spell.system.level})`
|
||||
}
|
||||
let msg = await roll.toMessage({ flavor: message }, { rollMode: rollContext.visibility })
|
||||
if (game?.dice3d) {
|
||||
await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
|
||||
if (combat.isCasting(options.combatantId)) {
|
||||
if (options.rollProgressionCount <= spell.system.castingTime ) {
|
||||
let message = `Spell casting time : ${spell.name}, count : ${options.rollProgressionCount}/${spell.system.castingTime}`
|
||||
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: actor }) })
|
||||
return
|
||||
}
|
||||
if (options.rollProgressionCount > spell.system.castingTime) {
|
||||
let message = `Spell ${spell.name} has been cast !`
|
||||
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: actor }) })
|
||||
combat.resetCasting(options.combatantId)
|
||||
combat.resetProgression(options.combatantId)
|
||||
return
|
||||
}
|
||||
} else{
|
||||
let formula = dice
|
||||
let roll = new Roll(formula)
|
||||
await roll.evaluate()
|
||||
let max = roll.dice[0].faces - 1
|
||||
let toCompare = Math.min(options.rollProgressionCount, max)
|
||||
let message
|
||||
if (roll.total > toCompare) {
|
||||
message = `Spell Lethargy ongoing ... (${roll.total}/${toCompare}, spell level ${spell.system.level})`
|
||||
} else {
|
||||
combat.resetProgression(options.combatantId)
|
||||
message = `Spell Lethargy ended ! (${roll.total}/${toCompare}, spell level ${spell.system.level})<br>${actor.name} can return to normal actions.`
|
||||
}
|
||||
let msg = await roll.toMessage({ flavor: message }, { rollMode: rollContext.visibility })
|
||||
if (game?.dice3d) {
|
||||
await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user