Initial release

This commit is contained in:
2026-05-08 23:05:29 +02:00
parent c0223977d2
commit 2953481a1c
157 changed files with 1940 additions and 392 deletions
+49 -1
View File
@@ -69,6 +69,23 @@ Hooks.once("ready", () => {
console.info(`${SYSTEM_ID} | Ready`)
})
Hooks.on("deleteCombat", (combat) => {
if (!game.user.isGM) return
const pcActors = [...new Set(
combat.combatants
.filter(c => c.actor?.hasPlayerOwner)
.map(c => c.actor)
)]
const cores = pcActors.flatMap(actor =>
actor.items.filter(item => item.type === "resonance-core" && !item.system.burnedOut && item.system.usageDie !== "depleted")
)
if (!cores.length) return
const lines = cores.map(c => `<li><strong>${c.parent.name}</strong> — ${c.name} (${c.system.usageDie})</li>`).join("")
ChatMessage.create({
content: `<article class="mgne-chat-card mode-check"><div class="chat-card-body"><p class="chat-special">⚙️ ${game.i18n.localize("MGNE.Notification.RollUsageDiceReminder")}</p><ul style="margin:.3rem 0 0 1rem;padding:0">${lines}</ul></div></article>`,
})
})
Hooks.on("renderCombatTracker", (_app, element) => {
const root = element instanceof HTMLElement ? element : element?.[0]
if (!root) return
@@ -142,7 +159,38 @@ Hooks.on("renderChatMessageHTML", (message, element) => {
const targetActor = token?.actor
if (!targetActor) return
select.value = ""
await targetActor.applyDamage(damageTotal, { critical: damageCritical, chat: true })
let finalDamage = damageTotal
const targetOmens = targetActor.system?.omens?.current ?? 0
if (targetOmens > 0) {
const spendOmen = await foundry.applications.api.DialogV2.wait({
window: { title: game.i18n.localize("MGNE.RollDialog.OmenReduceTitle") },
classes: ["mgne", "roll-dialog"],
content: `<section class="mgne-roll-dialog"><p>${game.i18n.format("MGNE.RollDialog.OmenReducePrompt", { name: targetActor.name, omens: targetOmens })}</p></section>`,
buttons: [
{ label: game.i18n.localize("MGNE.Common.No"), icon: "fa-solid fa-xmark", callback: () => false },
{ label: game.i18n.localize("MGNE.RollDialog.OmenReduceButton"), icon: "fa-solid fa-star", callback: () => true },
],
rejectClose: false,
})
if (spendOmen) {
const reduceRoll = await (new Roll("1d6")).evaluate()
// Re-read omens after dialog to avoid overwriting concurrent changes
const currentTargetOmens = targetActor.system?.omens?.current ?? 0
await targetActor.update({ "system.omens.current": Math.max(0, currentTargetOmens - 1) })
finalDamage = Math.max(0, damageTotal - reduceRoll.total)
const reduceMsg = game.i18n.format("MGNE.Roll.OmenReducedDamage", {
name: targetActor.name, reduced: reduceRoll.total, final: finalDamage,
})
await ChatMessage.create({
speaker: ChatMessage.getSpeaker({ actor: targetActor }),
rolls: [reduceRoll],
content: `<article class="mgne-chat-card mode-check"><div class="chat-card-body"><p class="chat-special">${reduceMsg}</p></div></article>`,
})
}
}
await targetActor.applyDamage(finalDamage, { critical: damageCritical, chat: true })
})
})
})