This commit is contained in:
@@ -119,18 +119,12 @@ export class LethalFantasyCombat extends Combat {
|
||||
}
|
||||
|
||||
async rollInitiative(ids, options) {
|
||||
console.log("%%%%%%%%% Roll Initiative", ids, options);
|
||||
|
||||
ids = typeof ids === "string" ? [ids] : ids;
|
||||
let messages = [];
|
||||
let rollMode = game.settings.get("core", "rollMode");
|
||||
|
||||
let updates = [];
|
||||
for (let cId of ids) {
|
||||
const c = this.combatants.get(cId);
|
||||
const playerOwner = game.users.find(u => u.active && !u.isGM && u.character?.id === c.actor.id);
|
||||
if (game.user.isGM && playerOwner) {
|
||||
console.log("Rolling initiative for", c.actor.name);
|
||||
game.socket.emit(`system.${SYSTEM.id}`, { type: "rollInitiative", userId: playerOwner.id, actorId: c.actor.id, combatId: this.id, combatantId: c.id });
|
||||
} else {
|
||||
await c.actor.system.rollInitiative(this.id, c.id);
|
||||
@@ -165,6 +159,8 @@ export class LethalFantasyCombat extends Combat {
|
||||
} else {
|
||||
ui.notifications.info(`No monsters act yet — earliest monster initiative is ${earliest} (current round: ${currentRound}).`);
|
||||
}
|
||||
} else {
|
||||
this._monsterProgressionRolledRound = currentRound;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,15 +185,12 @@ export class LethalFantasyCombat extends Combat {
|
||||
}
|
||||
|
||||
async nextTurn() {
|
||||
console.log("NEXT TURN");
|
||||
|
||||
let turn = this.turn ?? -1;
|
||||
let skipDefeated = this.settings.skipDefeated;
|
||||
|
||||
// Determine the next turn number
|
||||
let next = null;
|
||||
for (let [i, t] of this.turns.entries()) {
|
||||
console.log("Turn", t);
|
||||
if (i <= turn) continue;
|
||||
if (skipDefeated && t.isDefeated) continue;
|
||||
next = i;
|
||||
@@ -221,7 +214,6 @@ export class LethalFantasyCombat extends Combat {
|
||||
this.turnsDone = false
|
||||
|
||||
let turn = this.turn === null ? null : 0; // Preserve the fact that it's no-one's turn currently.
|
||||
console.log("ROUND", this);
|
||||
|
||||
let advanceTime = Math.max(this.turns.length - this.turn, 0) * CONFIG.time.turnTime;
|
||||
advanceTime += CONFIG.time.roundTime;
|
||||
@@ -239,6 +231,21 @@ export class LethalFantasyCombat extends Combat {
|
||||
return this;
|
||||
}
|
||||
|
||||
// Warn if eligible monsters have not rolled progression dice this round
|
||||
const eligibleMonsters = this.combatants.filter(
|
||||
c => c.actor?.type === "monster" && !c.isDefeated && c.initiative !== null && this.round >= c.initiative
|
||||
);
|
||||
if (eligibleMonsters.length > 0 && this._monsterProgressionRolledRound !== this.round) {
|
||||
const proceed = await foundry.applications.api.DialogV2.confirm({
|
||||
window: { title: game.i18n.localize("LETHALFANTASY.Combat.monstersNotRolledTitle") },
|
||||
content: `<p>${game.i18n.localize("LETHALFANTASY.Combat.monstersNotRolledMsg")}</p>`,
|
||||
yes: { label: game.i18n.localize("LETHALFANTASY.Combat.proceedYes") },
|
||||
no: { label: game.i18n.localize("LETHALFANTASY.Combat.proceedNo") },
|
||||
rejectClose: false,
|
||||
});
|
||||
if (!proceed) return this;
|
||||
}
|
||||
|
||||
for (let c of this.combatants) {
|
||||
if (nextRound >= c.initiative) {
|
||||
if (c.actor.type === "monster") continue; // Monsters roll manually via the "Roll Monsters" button
|
||||
|
||||
@@ -142,11 +142,14 @@ export async function rollFreeDie(dieType, count = 1, explode = false) {
|
||||
`
|
||||
|
||||
const rollMode = game.settings.get("core", "rollMode")
|
||||
// Normalize old-style rollMode keys (v12/v13) to new-style (v14), fallback to "public"
|
||||
const modeMap = { publicroll: "public", gmroll: "gm", blindroll: "blind", selfroll: "self" }
|
||||
const mode = modeMap[rollMode] ?? rollMode ?? "public"
|
||||
const msgData = {
|
||||
speaker: ChatMessage.getSpeaker(),
|
||||
content,
|
||||
sound: CONFIG.sounds.dice,
|
||||
mode,
|
||||
}
|
||||
ChatMessage.applyMode(msgData, rollMode)
|
||||
await ChatMessage.create(msgData)
|
||||
}
|
||||
|
||||
@@ -370,7 +370,9 @@ export default class LethalFantasyRoll extends Roll {
|
||||
beyondSkill = !!rollContext.beyondSkill
|
||||
letItFly = !!rollContext.letItFly
|
||||
saveSpell = !!rollContext.saveSpell
|
||||
rollContext.visibility ||= rollContext.rollMode || game.settings.get("core", "rollMode")
|
||||
const _rawMode = rollContext.rollMode || game.settings.get("core", "rollMode")
|
||||
const _modeMap = { publicroll: "public", gmroll: "gm", blindroll: "blind", selfroll: "self" }
|
||||
rollContext.visibility ||= _modeMap[_rawMode] ?? _rawMode ?? "public"
|
||||
rollContext.modifier ||= modifier
|
||||
rollContext.favor ||= "none"
|
||||
rollContext.changeDice ||= `${dice}`
|
||||
|
||||
@@ -35,6 +35,9 @@ export default class LethalFantasyMiracle extends foundry.abstract.TypeDataModel
|
||||
|
||||
schema.attackRoll = new fields.StringField({ required: true, initial: "" })
|
||||
schema.powerRoll = new fields.StringField({ required: true, initial: "" })
|
||||
schema.damageDice = new fields.StringField({ required: false, initial: "" })
|
||||
schema.damageDiceOverpowered = new fields.StringField({ required: false, initial: "" })
|
||||
schema.damageDiceOverpowered2 = new fields.StringField({ required: false, initial: "" })
|
||||
|
||||
return schema
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
|
||||
await roll.toMessage({
|
||||
flavor,
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.parent })
|
||||
})
|
||||
}, { messageMode: roll.options.rollMode ?? game.settings.get("core", "rollMode") })
|
||||
return
|
||||
}
|
||||
case "weapon-damage-small":
|
||||
|
||||
@@ -40,6 +40,8 @@ export default class LethalFantasySpell extends foundry.abstract.TypeDataModel {
|
||||
schema.attackRoll = new fields.StringField({ required: true, initial: "" })
|
||||
schema.powerRoll = new fields.StringField({ required: true, initial: "" })
|
||||
schema.damageDice = new fields.StringField({ required: false, initial: "" })
|
||||
schema.damageDiceOverpowered = new fields.StringField({ required: false, initial: "" })
|
||||
schema.damageDiceOverpowered2 = new fields.StringField({ required: false, initial: "" })
|
||||
|
||||
return schema
|
||||
}
|
||||
|
||||
+22
-17
@@ -862,20 +862,25 @@ export default class LethalFantasyUtils {
|
||||
} else if (data.attackRollType === "spell-attack" || data.attackRollType === "miracle-attack") {
|
||||
const attacker = game.actors.get(data.attackerId)
|
||||
const spell = attacker?.items.get(data.attackWeaponId)
|
||||
const damageDice = spell?.system?.damageDice
|
||||
if (damageDice) {
|
||||
damageButton = `
|
||||
<div class="attack-result-damage">
|
||||
<button class="roll-damage-btn"
|
||||
data-attacker-id="${data.attackerId}"
|
||||
data-defender-id="${data.defenderId}"
|
||||
data-defender-token-id="${data.defenderTokenId || ""}"
|
||||
data-damage-type="spell"
|
||||
data-damage-formula="${damageDice}">
|
||||
<i class="fa-solid fa-wand-magic-sparkles"></i> Spell Damage (${damageDice})
|
||||
</button>
|
||||
</div>
|
||||
`
|
||||
const tiers = [
|
||||
{ formula: spell?.system?.damageDice, label: "Standard" },
|
||||
{ formula: spell?.system?.damageDiceOverpowered, label: "Overpowered" },
|
||||
{ formula: spell?.system?.damageDiceOverpowered2, label: "Overpowered 2" },
|
||||
].filter(t => t.formula)
|
||||
if (tiers.length) {
|
||||
const buttons = tiers.map(t => {
|
||||
const escapedFormula = Handlebars.escapeExpression(t.formula)
|
||||
return `
|
||||
<button class="roll-damage-btn"
|
||||
data-attacker-id="${data.attackerId}"
|
||||
data-defender-id="${data.defenderId}"
|
||||
data-defender-token-id="${data.defenderTokenId || ""}"
|
||||
data-damage-type="spell"
|
||||
data-damage-formula="${escapedFormula}">
|
||||
<i class="fa-solid fa-wand-magic-sparkles"></i> ${t.label} (${escapedFormula})
|
||||
</button>`
|
||||
}).join("")
|
||||
damageButton = `<div class="attack-result-damage">${buttons}</div>`
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -902,10 +907,10 @@ export default class LethalFantasyUtils {
|
||||
</div>
|
||||
<div class="combat-result-text">
|
||||
${outcome === "shielded-hit"
|
||||
? `<i class="fa-solid fa-shield"></i> <strong>${data.attackerName}</strong> hits <strong>${data.defenderName}</strong>, but the shield blocked — apply armor DR + shield DR <strong>${data.shieldDamageReduction || 0}</strong>.`
|
||||
? `<i class="fa-solid fa-shield"></i> <strong>${data.defenderName}</strong> has blocked with shield — apply armor DR + shield DR <strong>${data.shieldDamageReduction || 0}</strong>.`
|
||||
: isAttackWin
|
||||
? `<i class="fa-solid fa-circle-check"></i> <strong>${data.attackerName}</strong> hits <strong>${data.defenderName}</strong>!`
|
||||
: `<i class="fa-solid fa-shield-halved"></i> <strong>${data.defenderName}</strong> parries the attack!`
|
||||
: `<i class="fa-solid fa-shield-halved"></i> <strong>${data.defenderName}</strong> avoided the attack!`
|
||||
}
|
||||
</div>
|
||||
${damageButton}
|
||||
@@ -1195,7 +1200,7 @@ export default class LethalFantasyUtils {
|
||||
ChatMessage.create({
|
||||
user: game.user.id,
|
||||
speaker: { alias: targetActor.name },
|
||||
mode: "gmroll",
|
||||
mode: "gm",
|
||||
content: messageContent
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user