Fix lethargy/cast again
All checks were successful
Release Creation / build (release) Successful in 43s

This commit is contained in:
LeRatierBretonnien 2025-04-16 08:33:18 +02:00
parent fdd72e9375
commit cb60bb6027
24 changed files with 136 additions and 94 deletions

View File

@ -93,6 +93,21 @@ export class LethalFantasyCombat extends Combat {
c.update({ 'system.progressionCount': 0 });
}
setCasting(cId) {
let c = this.combatants.get(cId);
c.setFlag(SYSTEM.id, "casting", true);
}
resetCasting(cId) {
let c = this.combatants.get(cId);
c.setFlag(SYSTEM.id, "casting", false);
}
isCasting(cId) {
let c = this.combatants.get(cId);
return c.getFlag(SYSTEM.id, "casting");
}
async nextTurn() {
console.log("NEXT TURN");

View File

@ -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
}

View File

@ -1 +1 @@
MANIFEST-000203
MANIFEST-000207

View File

@ -1,8 +1,8 @@
2025/04/15-20:28:27.909693 7f5c827fc6c0 Recovering log #201
2025/04/15-20:28:27.920405 7f5c827fc6c0 Delete type=3 #199
2025/04/15-20:28:27.920498 7f5c827fc6c0 Delete type=0 #201
2025/04/15-20:29:29.823399 7f5c81bff6c0 Level-0 table #206: started
2025/04/15-20:29:29.823453 7f5c81bff6c0 Level-0 table #206: 0 bytes OK
2025/04/15-20:29:29.855733 7f5c81bff6c0 Delete type=0 #204
2025/04/15-20:29:29.869881 7f5c81bff6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!znm6T1ef4qQI8BX7' @ 0 : 0; will stop at (end)
2025/04/15-20:29:29.899952 7f5c81bff6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!znm6T1ef4qQI8BX7' @ 0 : 0; will stop at (end)
2025/04/16-08:18:09.103824 7f5c83fff6c0 Recovering log #205
2025/04/16-08:18:09.114815 7f5c83fff6c0 Delete type=3 #203
2025/04/16-08:18:09.114932 7f5c83fff6c0 Delete type=0 #205
2025/04/16-08:32:26.394277 7f5c81bff6c0 Level-0 table #210: started
2025/04/16-08:32:26.394334 7f5c81bff6c0 Level-0 table #210: 0 bytes OK
2025/04/16-08:32:26.400532 7f5c81bff6c0 Delete type=0 #208
2025/04/16-08:32:26.400730 7f5c81bff6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!znm6T1ef4qQI8BX7' @ 0 : 0; will stop at (end)
2025/04/16-08:32:26.400790 7f5c81bff6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!znm6T1ef4qQI8BX7' @ 0 : 0; will stop at (end)

View File

@ -1,8 +1,8 @@
2025/04/15-20:12:44.848433 7f5c83fff6c0 Recovering log #197
2025/04/15-20:12:44.863682 7f5c83fff6c0 Delete type=3 #195
2025/04/15-20:12:44.863747 7f5c83fff6c0 Delete type=0 #197
2025/04/15-20:17:42.198359 7f5c81bff6c0 Level-0 table #202: started
2025/04/15-20:17:42.198471 7f5c81bff6c0 Level-0 table #202: 0 bytes OK
2025/04/15-20:17:42.205479 7f5c81bff6c0 Delete type=0 #200
2025/04/15-20:17:42.225325 7f5c81bff6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!znm6T1ef4qQI8BX7' @ 0 : 0; will stop at (end)
2025/04/15-20:17:42.225430 7f5c81bff6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!znm6T1ef4qQI8BX7' @ 0 : 0; will stop at (end)
2025/04/15-20:28:27.909693 7f5c827fc6c0 Recovering log #201
2025/04/15-20:28:27.920405 7f5c827fc6c0 Delete type=3 #199
2025/04/15-20:28:27.920498 7f5c827fc6c0 Delete type=0 #201
2025/04/15-20:29:29.823399 7f5c81bff6c0 Level-0 table #206: started
2025/04/15-20:29:29.823453 7f5c81bff6c0 Level-0 table #206: 0 bytes OK
2025/04/15-20:29:29.855733 7f5c81bff6c0 Delete type=0 #204
2025/04/15-20:29:29.869881 7f5c81bff6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!znm6T1ef4qQI8BX7' @ 0 : 0; will stop at (end)
2025/04/15-20:29:29.899952 7f5c81bff6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!znm6T1ef4qQI8BX7' @ 0 : 0; will stop at (end)

View File

@ -1 +1 @@
MANIFEST-000202
MANIFEST-000206

View File

@ -1,8 +1,8 @@
2025/04/15-20:28:27.924832 7f5c83fff6c0 Recovering log #200
2025/04/15-20:28:27.935942 7f5c83fff6c0 Delete type=3 #198
2025/04/15-20:28:27.936056 7f5c83fff6c0 Delete type=0 #200
2025/04/15-20:29:29.646786 7f5c81bff6c0 Level-0 table #205: started
2025/04/15-20:29:29.646851 7f5c81bff6c0 Level-0 table #205: 0 bytes OK
2025/04/15-20:29:29.673575 7f5c81bff6c0 Delete type=0 #203
2025/04/15-20:29:29.759542 7f5c81bff6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
2025/04/15-20:29:29.759654 7f5c81bff6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
2025/04/16-08:18:09.118755 7f5c82ffd6c0 Recovering log #204
2025/04/16-08:18:09.129516 7f5c82ffd6c0 Delete type=3 #202
2025/04/16-08:18:09.129610 7f5c82ffd6c0 Delete type=0 #204
2025/04/16-08:32:26.380608 7f5c81bff6c0 Level-0 table #209: started
2025/04/16-08:32:26.380651 7f5c81bff6c0 Level-0 table #209: 0 bytes OK
2025/04/16-08:32:26.386680 7f5c81bff6c0 Delete type=0 #207
2025/04/16-08:32:26.400698 7f5c81bff6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
2025/04/16-08:32:26.400776 7f5c81bff6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)

View File

@ -1,8 +1,8 @@
2025/04/15-20:12:44.869154 7f5c82ffd6c0 Recovering log #196
2025/04/15-20:12:44.884227 7f5c82ffd6c0 Delete type=3 #194
2025/04/15-20:12:44.884371 7f5c82ffd6c0 Delete type=0 #196
2025/04/15-20:17:42.205662 7f5c81bff6c0 Level-0 table #201: started
2025/04/15-20:17:42.205704 7f5c81bff6c0 Level-0 table #201: 0 bytes OK
2025/04/15-20:17:42.212053 7f5c81bff6c0 Delete type=0 #199
2025/04/15-20:17:42.225357 7f5c81bff6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
2025/04/15-20:17:42.225453 7f5c81bff6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
2025/04/15-20:28:27.924832 7f5c83fff6c0 Recovering log #200
2025/04/15-20:28:27.935942 7f5c83fff6c0 Delete type=3 #198
2025/04/15-20:28:27.936056 7f5c83fff6c0 Delete type=0 #200
2025/04/15-20:29:29.646786 7f5c81bff6c0 Level-0 table #205: started
2025/04/15-20:29:29.646851 7f5c81bff6c0 Level-0 table #205: 0 bytes OK
2025/04/15-20:29:29.673575 7f5c81bff6c0 Delete type=0 #203
2025/04/15-20:29:29.759542 7f5c81bff6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
2025/04/15-20:29:29.759654 7f5c81bff6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)

Binary file not shown.

View File

@ -1 +1 @@
MANIFEST-000202
MANIFEST-000206

View File

@ -1,8 +1,8 @@
2025/04/15-20:28:27.891776 7f5c82ffd6c0 Recovering log #200
2025/04/15-20:28:27.903632 7f5c82ffd6c0 Delete type=3 #198
2025/04/15-20:28:27.903749 7f5c82ffd6c0 Delete type=0 #200
2025/04/15-20:29:29.673732 7f5c81bff6c0 Level-0 table #205: started
2025/04/15-20:29:29.673787 7f5c81bff6c0 Level-0 table #205: 0 bytes OK
2025/04/15-20:29:29.697981 7f5c81bff6c0 Delete type=0 #203
2025/04/15-20:29:29.759583 7f5c81bff6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2025/04/15-20:29:29.759670 7f5c81bff6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2025/04/16-08:18:09.087776 7f5c837fe6c0 Recovering log #204
2025/04/16-08:18:09.098866 7f5c837fe6c0 Delete type=3 #202
2025/04/16-08:18:09.098959 7f5c837fe6c0 Delete type=0 #204
2025/04/16-08:32:26.386837 7f5c81bff6c0 Level-0 table #209: started
2025/04/16-08:32:26.386877 7f5c81bff6c0 Level-0 table #209: 0 bytes OK
2025/04/16-08:32:26.394093 7f5c81bff6c0 Delete type=0 #207
2025/04/16-08:32:26.400713 7f5c81bff6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2025/04/16-08:32:26.400808 7f5c81bff6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)

View File

@ -1,8 +1,8 @@
2025/04/15-20:12:44.823825 7f5c827fc6c0 Recovering log #196
2025/04/15-20:12:44.842141 7f5c827fc6c0 Delete type=3 #194
2025/04/15-20:12:44.842235 7f5c827fc6c0 Delete type=0 #196
2025/04/15-20:17:42.218838 7f5c81bff6c0 Level-0 table #201: started
2025/04/15-20:17:42.218876 7f5c81bff6c0 Level-0 table #201: 0 bytes OK
2025/04/15-20:17:42.225069 7f5c81bff6c0 Delete type=0 #199
2025/04/15-20:17:42.225407 7f5c81bff6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2025/04/15-20:17:42.225476 7f5c81bff6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2025/04/15-20:28:27.891776 7f5c82ffd6c0 Recovering log #200
2025/04/15-20:28:27.903632 7f5c82ffd6c0 Delete type=3 #198
2025/04/15-20:28:27.903749 7f5c82ffd6c0 Delete type=0 #200
2025/04/15-20:29:29.673732 7f5c81bff6c0 Level-0 table #205: started
2025/04/15-20:29:29.673787 7f5c81bff6c0 Level-0 table #205: 0 bytes OK
2025/04/15-20:29:29.697981 7f5c81bff6c0 Delete type=0 #203
2025/04/15-20:29:29.759583 7f5c81bff6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2025/04/15-20:29:29.759670 7f5c81bff6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)

Binary file not shown.

View File

@ -1 +1 @@
MANIFEST-000202
MANIFEST-000206

View File

@ -1,8 +1,8 @@
2025/04/15-20:28:27.940175 7f5c837fe6c0 Recovering log #200
2025/04/15-20:28:27.952060 7f5c837fe6c0 Delete type=3 #198
2025/04/15-20:28:27.952156 7f5c837fe6c0 Delete type=0 #200
2025/04/15-20:29:29.698145 7f5c81bff6c0 Level-0 table #205: started
2025/04/15-20:29:29.698204 7f5c81bff6c0 Level-0 table #205: 0 bytes OK
2025/04/15-20:29:29.733235 7f5c81bff6c0 Delete type=0 #203
2025/04/15-20:29:29.759616 7f5c81bff6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2025/04/15-20:29:29.759685 7f5c81bff6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2025/04/16-08:18:09.132463 7f5c827fc6c0 Recovering log #204
2025/04/16-08:18:09.143030 7f5c827fc6c0 Delete type=3 #202
2025/04/16-08:18:09.143156 7f5c827fc6c0 Delete type=0 #204
2025/04/16-08:32:26.374134 7f5c81bff6c0 Level-0 table #209: started
2025/04/16-08:32:26.374198 7f5c81bff6c0 Level-0 table #209: 0 bytes OK
2025/04/16-08:32:26.380413 7f5c81bff6c0 Delete type=0 #207
2025/04/16-08:32:26.400678 7f5c81bff6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2025/04/16-08:32:26.400747 7f5c81bff6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)

View File

@ -1,8 +1,8 @@
2025/04/15-20:12:44.888845 7f5c837fe6c0 Recovering log #196
2025/04/15-20:12:44.908246 7f5c837fe6c0 Delete type=3 #194
2025/04/15-20:12:44.908316 7f5c837fe6c0 Delete type=0 #196
2025/04/15-20:17:42.212289 7f5c81bff6c0 Level-0 table #201: started
2025/04/15-20:17:42.212400 7f5c81bff6c0 Level-0 table #201: 0 bytes OK
2025/04/15-20:17:42.218709 7f5c81bff6c0 Delete type=0 #199
2025/04/15-20:17:42.225383 7f5c81bff6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2025/04/15-20:17:42.225497 7f5c81bff6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2025/04/15-20:28:27.940175 7f5c837fe6c0 Recovering log #200
2025/04/15-20:28:27.952060 7f5c837fe6c0 Delete type=3 #198
2025/04/15-20:28:27.952156 7f5c837fe6c0 Delete type=0 #200
2025/04/15-20:29:29.698145 7f5c81bff6c0 Level-0 table #205: started
2025/04/15-20:29:29.698204 7f5c81bff6c0 Level-0 table #205: 0 bytes OK
2025/04/15-20:29:29.733235 7f5c81bff6c0 Delete type=0 #203
2025/04/15-20:29:29.759616 7f5c81bff6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2025/04/15-20:29:29.759685 7f5c81bff6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)