Fix reset progression roll
All checks were successful
Release Creation / build (release) Successful in 1m12s

This commit is contained in:
2025-04-15 20:29:56 +02:00
parent 9035ad4bfb
commit fdd72e9375
24 changed files with 90 additions and 90 deletions

View File

@ -12,7 +12,7 @@ export class LethalFantasyCombatTracker extends CombatTracker {
console.log("Combat Data", data);
return data;
}
activateListeners(html) {
super.activateListeners(html);
// Display Combat settings
@ -23,6 +23,7 @@ export class LethalFantasyCombatTracker extends CombatTracker {
c.update({ 'initiative': c.initiative + 1 });
console.log("Initiative Plus");
});
html.find(".initiative-minus").click(ev => {
ev.preventDefault();
let cId = ev.currentTarget.closest(".combatant").dataset.combatantId;
@ -131,7 +132,7 @@ 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) {
@ -140,10 +141,10 @@ export class LethalFantasyCombat extends Combat {
}
}
if (!initOK) {
ui.notifications.error("All combatants must have initiative rolled before the round can advance.");
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 });
@ -153,7 +154,7 @@ export class LethalFantasyCombat extends Combat {
} else {
user = game.users.find(u => u.active && u.isGM);
c.actor.system.rollProgressionDice(this.id, c.id, c.system.progressionCount+1);
}
}
}
}
@ -169,4 +170,3 @@ export class LethalFantasyCombat extends Combat {
return a.initiative - b.initiative;
}
}

View File

@ -237,25 +237,25 @@ export default class LethalFantasyRoll extends Roll {
hasStaticModifier = options.rollType === "spell-power"
hasModifier = options.rollType !== "miracle-attack"
options.rollTarget.staticModifier = options.rollTarget.actorLevel
} else if (options.rollType === "shield-roll") {
hasD30 = false
hasD30 = false
options.rollName = "Shield Defense"
dice = options.rollTarget.system.defense.toUpperCase()
baseFormula = dice
baseFormula = dice
hasModifier = true
hasChangeDice = false
hasMaxValue = false
hasExplode = false
options.rollTarget.value = 0
} else if (options.rollType.includes("weapon-damage")) {
options.rollName = options.rollTarget.name
hasModifier = true
hasChangeDice = false
let damageBonus = (options.rollTarget.weapon.system.applyStrengthDamageBonus) ? options.rollTarget.combat.damageModifier : 0
options.rollTarget.value = damageBonus + options.rollTarget.weaponSkillModifier + options.rollTarget.weapon.system.bonuses.damageBonus
options.rollTarget.charModifier = damageBonus
options.rollTarget.charModifier = damageBonus
if (options.rollType.includes("small")) {
dice = options.rollTarget.weapon.system.damage.damageS
} else {
@ -423,7 +423,7 @@ export default class LethalFantasyRoll extends Roll {
/**
* A hook event that fires before the roll is made.
* @function
* @function
* @memberof hookEvents
* @param {Object} options Options for the roll.
* @param {Object} rollData All data related to the roll.
@ -530,7 +530,7 @@ export default class LethalFantasyRoll extends Roll {
/**
* A hook event that fires after the roll has been made.
* @function
* @function
* @memberof hookEvents
* @param {Object} options Options for the roll.
* @param {Object} rollData All data related to the roll.
@ -651,7 +651,7 @@ export default class LethalFantasyRoll extends Roll {
if (rollContext === null || !rollContext?.progressionDiceId) {
let combat = game.combats.get(options.combatId)
let combatant = combat.combatants.get(options.combatantId)
combatant.update({ 'system.progressionCount': 1 })
combatant.update({ 'system.progressionCount': 0 })
return
}
@ -680,15 +680,15 @@ export default class LethalFantasyRoll extends Roll {
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
let message
if (roll.total > toCompare) {
message = `Spell Lethargy ongoing ... (${roll.total}/${toCompare}, spell level ${spell.system.level})`
message = `Spell Lethargy ongoing ... (${roll.total}/${toCompare}, spell level ${spell.system.level})`
} else {
let combat = game.combats.get(options.combatId)
combat.resetProgression(options.combatantId)
@ -697,7 +697,7 @@ export default class LethalFantasyRoll extends Roll {
let msg = await roll.toMessage({ flavor: message }, { rollMode: rollContext.visibility })
if (game?.dice3d) {
await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
}
}
return
}
@ -709,8 +709,8 @@ export default class LethalFantasyRoll extends Roll {
let toSplit = weapon.system.speed[rangedMode]
let split = toSplit.split("+")
rangedLoad = Number(split[0]) || 0
formula = split[1]
console.log("Ranged Mode", rangedMode, rangedLoad, formula, options.rollProgressionCount)
formula = split[1]
console.log("Ranged Mode", rangedMode, rangedLoad, formula, options.rollProgressionCount)
}
if (rangedLoad && options.rollProgressionCount <= rangedLoad ) {
@ -859,7 +859,7 @@ export default class LethalFantasyRoll extends Roll {
/**
* A hook event that fires after the roll has been made.
* @function
* @function
* @memberof hookEvents
* @param {Object} options Options for the roll.
* @param {Object} rollData All data related to the roll.
@ -910,7 +910,7 @@ export default class LethalFantasyRoll extends Roll {
/** @override */
async render(chatOptions = {}) {
let chatData = await this._getChatCardData(chatOptions.isPrivate)
console.log("ChatData", chatData)
console.log("ChatData", chatData)
return await renderTemplate(this.constructor.CHAT_TEMPLATE, chatData)
}