Combat initiativ

This commit is contained in:
LeRatierBretonnien 2025-01-18 19:26:14 +01:00
parent 4e673913a1
commit 4198bf82be
28 changed files with 102 additions and 82 deletions

View File

@ -7,6 +7,7 @@ export class LethalFantasyCombatTracker extends CombatTracker {
for (let u of data.turns) {
let c = game.combat.combatants.get(u.id);
u.progressionCount = c.system.progressionCount
u.isMonster = c.actor.type === "monster"
}
console.log("Combat Data", data);
return data;
@ -107,7 +108,19 @@ export class LethalFantasyCombat extends Combat {
let advanceTime = Math.max(this.turns.length - this.turn, 0) * CONFIG.time.turnTime;
advanceTime += CONFIG.time.roundTime;
let nextRound = this.round + 1;
let initOK = true;
for (let c of this.combatants) {
if (c.initiative === null) {
initOK = false;
break;
}
}
if (!initOK) {
ui.notifications.error("All combatants must have initiative rolled before the round can advance.");
return this;
}
for (let c of this.combatants) {
if ( nextRound >= c.initiative) {
c.update({ 'system.progressionCount': c.system.progressionCount + 1 });

View File

@ -565,8 +565,10 @@ export default class LethalFantasyRoll extends Roll {
},
{
action: "cancel",
label: "Other action, no weapon progression dice",
callback: (event, button, dialog) => { return null; }
label: "Other action, no progression dice",
callback: (event, button, dialog) => {
return null;
}
}
],
rejectClose: false // Click on Close button will not launch an error
@ -574,12 +576,16 @@ export default class LethalFantasyRoll extends Roll {
console.log("RollContext", rollContext)
if (rollContext === null || !rollContext?.progressionDiceId) {
let combat = game.combats.get(options.combatId)
let combatant = combat.combatants.get(options.combatantId)
combatant.update({ 'system.progressionCount': 1 })
return
}
// Get the weapons from the actor items
let actor = game.actors.get(options.actorId)
let weapon = actor.items.find(i => i.type === "weapon" && i.id === rollContext.progressionDiceId)
let isMonster = actor.type === "monster"
// Get the dice and roll it
let formula = weapon.system.combatProgressionDice
let roll = new Roll(formula)
@ -592,7 +598,7 @@ export default class LethalFantasyRoll extends Roll {
if (roll.total <= max ) {
// Notify that the player can act now with a chat message
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionOK", { name: actor.name, weapon: weapon.name, roll: roll.total })
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionOK", { isMonster, name: actor.name, weapon: weapon.name, roll: roll.total })
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: actor }) })
// Update the combatant progression count
let combat = game.combats.get(options.combatId)
@ -600,7 +606,7 @@ export default class LethalFantasyRoll extends Roll {
combatant.update({ 'system.progressionCount': 0 })
} else {
// Notify that the player cannot act now with a chat message
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionKO", { name: actor.name, weapon: weapon.name, roll: roll.total })
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionKO", { isMonster, name: actor.name, weapon: weapon.name, roll: roll.total })
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: actor }) })
}
}

View File

@ -173,7 +173,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
let roll = new Roll("1D8")
await roll.evaluate()
let max = rollProgressionCount
let msg = await roll.toMessage({ flavor: `Progression Roll for ${this.parent.name}, progression count : ${rollProgressionCount}/${max}` } )
let msg = await roll.toMessage({ flavor: `Progression Roll for ${this.parent.name}` } )
await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
let hasAttack = false
@ -181,16 +181,12 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
let attack = this.attacks[key]
if (attack.attackScore > 0 && attack.attackScore === roll.total) {
hasAttack = true
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionOK", { name: this.parent.name, weapon: attack.name, roll: roll.total })
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionOKMonster", { isMonster: true, name: this.parent.name, weapon: attack.name, roll: roll.total })
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: this.parent }) })
// Update the combatant progression count
let combat = game.combats.get(combatId)
let combatant = combat.combatants.get(combatantId)
combatant.update({ 'system.progressionCount': 0 })
}
}
if (!hasAttack) {
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionKO", { name: this.parent.name, roll: roll.total })
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionKOMonster", { isMonster: true, name: this.parent.name, roll: roll.total })
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: this.parent }) })
}

View File

@ -1 +1 @@
MANIFEST-000074
MANIFEST-000082

View File

@ -1,8 +1,8 @@
2025/01/17-19:47:11.164832 7f3b911f96c0 Recovering log #72
2025/01/17-19:47:11.212359 7f3b911f96c0 Delete type=3 #70
2025/01/17-19:47:11.212431 7f3b911f96c0 Delete type=0 #72
2025/01/17-23:59:30.263234 7f3b8b3ff6c0 Level-0 table #77: started
2025/01/17-23:59:30.263263 7f3b8b3ff6c0 Level-0 table #77: 0 bytes OK
2025/01/17-23:59:30.269621 7f3b8b3ff6c0 Delete type=0 #75
2025/01/17-23:59:30.282079 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zFrygJ2TnrxchBai' @ 0 : 0; will stop at (end)
2025/01/17-23:59:30.282123 7f3b8b3ff6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zFrygJ2TnrxchBai' @ 0 : 0; will stop at (end)
2025/01/18-18:45:51.397204 7f3b8bfff6c0 Recovering log #80
2025/01/18-18:45:51.459450 7f3b8bfff6c0 Delete type=3 #78
2025/01/18-18:45:51.459524 7f3b8bfff6c0 Delete type=0 #80
2025/01/18-19:25:39.662101 7f3b8b3ff6c0 Level-0 table #85: started
2025/01/18-19:25:39.662133 7f3b8b3ff6c0 Level-0 table #85: 0 bytes OK
2025/01/18-19:25:39.686749 7f3b8b3ff6c0 Delete type=0 #83
2025/01/18-19:25:39.734023 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zFrygJ2TnrxchBai' @ 0 : 0; will stop at (end)
2025/01/18-19:25:39.734056 7f3b8b3ff6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zFrygJ2TnrxchBai' @ 0 : 0; will stop at (end)

View File

@ -1,8 +1,8 @@
2025/01/16-23:12:53.401299 7ffb067fc6c0 Recovering log #68
2025/01/16-23:12:53.411672 7ffb067fc6c0 Delete type=3 #66
2025/01/16-23:12:53.411749 7ffb067fc6c0 Delete type=0 #68
2025/01/17-07:54:26.962616 7ff867fff6c0 Level-0 table #73: started
2025/01/17-07:54:26.962692 7ff867fff6c0 Level-0 table #73: 0 bytes OK
2025/01/17-07:54:26.994859 7ff867fff6c0 Delete type=0 #71
2025/01/17-07:54:27.074108 7ff867fff6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zFrygJ2TnrxchBai' @ 0 : 0; will stop at (end)
2025/01/17-07:54:27.074173 7ff867fff6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zFrygJ2TnrxchBai' @ 0 : 0; will stop at (end)
2025/01/18-09:15:00.143272 7f3b909f86c0 Recovering log #76
2025/01/18-09:15:00.153506 7f3b909f86c0 Delete type=3 #74
2025/01/18-09:15:00.153575 7f3b909f86c0 Delete type=0 #76
2025/01/18-15:51:00.716946 7f3b8b3ff6c0 Level-0 table #81: started
2025/01/18-15:51:00.716985 7f3b8b3ff6c0 Level-0 table #81: 0 bytes OK
2025/01/18-15:51:00.727010 7f3b8b3ff6c0 Delete type=0 #79
2025/01/18-15:51:00.756449 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zFrygJ2TnrxchBai' @ 0 : 0; will stop at (end)
2025/01/18-15:51:00.756506 7f3b8b3ff6c0 Manual compaction at level-1 from '!folders!ATr9wZhg5uTVTksM' @ 72057594037927935 : 1 .. '!items!zFrygJ2TnrxchBai' @ 0 : 0; will stop at (end)

Binary file not shown.

View File

@ -1 +1 @@
MANIFEST-000074
MANIFEST-000082

View File

@ -1,8 +1,8 @@
2025/01/17-19:47:11.219943 7f3b919fa6c0 Recovering log #72
2025/01/17-19:47:11.271701 7f3b919fa6c0 Delete type=3 #70
2025/01/17-19:47:11.271773 7f3b919fa6c0 Delete type=0 #72
2025/01/17-23:59:30.276140 7f3b8b3ff6c0 Level-0 table #77: started
2025/01/17-23:59:30.276162 7f3b8b3ff6c0 Level-0 table #77: 0 bytes OK
2025/01/17-23:59:30.281988 7f3b8b3ff6c0 Delete type=0 #75
2025/01/17-23:59:30.282094 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
2025/01/17-23:59:30.282117 7f3b8b3ff6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
2025/01/18-18:45:51.461997 7f3b919fa6c0 Recovering log #80
2025/01/18-18:45:51.515007 7f3b919fa6c0 Delete type=3 #78
2025/01/18-18:45:51.515089 7f3b919fa6c0 Delete type=0 #80
2025/01/18-19:25:39.714194 7f3b8b3ff6c0 Level-0 table #85: started
2025/01/18-19:25:39.714225 7f3b8b3ff6c0 Level-0 table #85: 0 bytes OK
2025/01/18-19:25:39.733891 7f3b8b3ff6c0 Delete type=0 #83
2025/01/18-19:25:39.734043 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
2025/01/18-19:25:39.734069 7f3b8b3ff6c0 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/01/16-23:12:53.414138 7ffb04ff96c0 Recovering log #68
2025/01/16-23:12:53.424560 7ffb04ff96c0 Delete type=3 #66
2025/01/16-23:12:53.424630 7ffb04ff96c0 Delete type=0 #68
2025/01/17-07:54:27.053199 7ff867fff6c0 Level-0 table #73: started
2025/01/17-07:54:27.053227 7ff867fff6c0 Level-0 table #73: 0 bytes OK
2025/01/17-07:54:27.073980 7ff867fff6c0 Delete type=0 #71
2025/01/17-07:54:27.074166 7ff867fff6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
2025/01/17-07:54:27.074188 7ff867fff6c0 Manual compaction at level-1 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
2025/01/18-09:15:00.156518 7f3b911f96c0 Recovering log #76
2025/01/18-09:15:00.166540 7f3b911f96c0 Delete type=3 #74
2025/01/18-09:15:00.166606 7f3b911f96c0 Delete type=0 #76
2025/01/18-15:51:00.736393 7f3b8b3ff6c0 Level-0 table #81: started
2025/01/18-15:51:00.736420 7f3b8b3ff6c0 Level-0 table #81: 0 bytes OK
2025/01/18-15:51:00.746678 7f3b8b3ff6c0 Delete type=0 #79
2025/01/18-15:51:00.756477 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!yPWGvxHJbDNHVSnY' @ 72057594037927935 : 1 .. '!items!zjvGljrLk5SshC9D' @ 0 : 0; will stop at (end)
2025/01/18-15:51:00.756525 7f3b8b3ff6c0 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-000074
MANIFEST-000082

View File

@ -1,8 +1,8 @@
2025/01/17-19:47:11.076852 7f3b909f86c0 Recovering log #72
2025/01/17-19:47:11.156242 7f3b909f86c0 Delete type=3 #70
2025/01/17-19:47:11.156312 7f3b909f86c0 Delete type=0 #72
2025/01/17-23:59:30.269721 7f3b8b3ff6c0 Level-0 table #77: started
2025/01/17-23:59:30.269744 7f3b8b3ff6c0 Level-0 table #77: 0 bytes OK
2025/01/17-23:59:30.276051 7f3b8b3ff6c0 Delete type=0 #75
2025/01/17-23:59:30.282087 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2025/01/17-23:59:30.282129 7f3b8b3ff6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2025/01/18-18:45:51.345613 7f3b911f96c0 Recovering log #80
2025/01/18-18:45:51.394393 7f3b911f96c0 Delete type=3 #78
2025/01/18-18:45:51.394460 7f3b911f96c0 Delete type=0 #80
2025/01/18-19:25:39.686886 7f3b8b3ff6c0 Level-0 table #85: started
2025/01/18-19:25:39.686918 7f3b8b3ff6c0 Level-0 table #85: 0 bytes OK
2025/01/18-19:25:39.714065 7f3b8b3ff6c0 Delete type=0 #83
2025/01/18-19:25:39.734034 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2025/01/18-19:25:39.734062 7f3b8b3ff6c0 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/01/16-23:12:53.388461 7ffb05ffb6c0 Recovering log #68
2025/01/16-23:12:53.398277 7ffb05ffb6c0 Delete type=3 #66
2025/01/16-23:12:53.398338 7ffb05ffb6c0 Delete type=0 #68
2025/01/17-07:54:27.022206 7ff867fff6c0 Level-0 table #73: started
2025/01/17-07:54:27.022245 7ff867fff6c0 Level-0 table #73: 0 bytes OK
2025/01/17-07:54:27.053062 7ff867fff6c0 Delete type=0 #71
2025/01/17-07:54:27.074144 7ff867fff6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2025/01/17-07:54:27.074195 7ff867fff6c0 Manual compaction at level-1 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2025/01/18-09:15:00.130226 7f3b919fa6c0 Recovering log #76
2025/01/18-09:15:00.139788 7f3b919fa6c0 Delete type=3 #74
2025/01/18-09:15:00.139841 7f3b919fa6c0 Delete type=0 #76
2025/01/18-15:51:00.746782 7f3b8b3ff6c0 Level-0 table #81: started
2025/01/18-15:51:00.746804 7f3b8b3ff6c0 Level-0 table #81: 0 bytes OK
2025/01/18-15:51:00.756314 7f3b8b3ff6c0 Delete type=0 #79
2025/01/18-15:51:00.756497 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!7j8H7DbmBb9Uza2X' @ 72057594037927935 : 1 .. '!items!zt8s7564ep1La4XQ' @ 0 : 0; will stop at (end)
2025/01/18-15:51:00.756534 7f3b8b3ff6c0 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-000074
MANIFEST-000082

View File

@ -1,8 +1,8 @@
2025/01/17-19:47:11.275966 7f3b8bfff6c0 Recovering log #72
2025/01/17-19:47:11.332695 7f3b8bfff6c0 Delete type=3 #70
2025/01/17-19:47:11.332765 7f3b8bfff6c0 Delete type=0 #72
2025/01/17-23:59:30.257100 7f3b8b3ff6c0 Level-0 table #77: started
2025/01/17-23:59:30.257148 7f3b8b3ff6c0 Level-0 table #77: 0 bytes OK
2025/01/17-23:59:30.263106 7f3b8b3ff6c0 Delete type=0 #75
2025/01/17-23:59:30.282069 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2025/01/17-23:59:30.282110 7f3b8b3ff6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2025/01/18-18:45:51.517293 7f3b909f86c0 Recovering log #80
2025/01/18-18:45:51.568529 7f3b909f86c0 Delete type=3 #78
2025/01/18-18:45:51.568609 7f3b909f86c0 Delete type=0 #80
2025/01/18-19:25:39.636193 7f3b8b3ff6c0 Level-0 table #85: started
2025/01/18-19:25:39.636238 7f3b8b3ff6c0 Level-0 table #85: 0 bytes OK
2025/01/18-19:25:39.661963 7f3b8b3ff6c0 Delete type=0 #83
2025/01/18-19:25:39.734012 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2025/01/18-19:25:39.734050 7f3b8b3ff6c0 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/01/16-23:12:53.426846 7ffb057fa6c0 Recovering log #68
2025/01/16-23:12:53.436800 7ffb057fa6c0 Delete type=3 #66
2025/01/16-23:12:53.436869 7ffb057fa6c0 Delete type=0 #68
2025/01/17-07:54:26.995011 7ff867fff6c0 Level-0 table #73: started
2025/01/17-07:54:26.995042 7ff867fff6c0 Level-0 table #73: 0 bytes OK
2025/01/17-07:54:27.021986 7ff867fff6c0 Delete type=0 #71
2025/01/17-07:54:27.074123 7ff867fff6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2025/01/17-07:54:27.074180 7ff867fff6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2025/01/18-09:15:00.168890 7f3b8bfff6c0 Recovering log #76
2025/01/18-09:15:00.178560 7f3b8bfff6c0 Delete type=3 #74
2025/01/18-09:15:00.178618 7f3b8bfff6c0 Delete type=0 #76
2025/01/18-15:51:00.727117 7f3b8b3ff6c0 Level-0 table #81: started
2025/01/18-15:51:00.727139 7f3b8b3ff6c0 Level-0 table #81: 0 bytes OK
2025/01/18-15:51:00.736271 7f3b8b3ff6c0 Delete type=0 #79
2025/01/18-15:51:00.756464 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)
2025/01/18-15:51:00.756516 7f3b8b3ff6c0 Manual compaction at level-1 from '!folders!mnO9OzE7BEE2KDfh' @ 72057594037927935 : 1 .. '!items!zkK6ixtCsCw3RH9X' @ 0 : 0; will stop at (end)

View File

@ -6,7 +6,7 @@
"download": "#{DOWNLOAD}#",
"url": "#{URL}#",
"license": "LICENSE",
"version": "12.0.19",
"version": "12.0.20",
"authors": [
{
"name": "Uberwald",

View File

@ -110,7 +110,12 @@
<a class="combatant-control roll score" aria-label="{{localize 'COMBAT.InitiativeRoll'}}" role="button"
data-tooltip="COMBAT.InitiativeRoll" data-control="rollInitiative"></a>
{{/if}}
<span class="initiative">{{this.progressionCount}}</span>
{{#if this.isMonster}}
<span class="initiative">-</span>
{{else}}
<span class="initiative" data-tooltip="Current max. progression counter">{{this.progressionCount}}</span>
{{/if}}
</div>
</li>
{{/each}}