- Percentile roll cards: outcome banners (crit/success/failure) with icons and margin-of-success text instead of color-only inline styles. - Damage and lethality cards: Apply Damage / Apply Lethality buttons that hit targeted or selected tokens, auto-subtracting equipped armor protection reduced by the weapon's armor-piercing value. - Sanity damage cards: apply buttons for success/failure loss with GM whispers for temporary insanity (5+), breaking point crossings, and 0 SAN. - Ammo: weapon ammo is now numeric with a magazine capacity; attack rolls expend a round (ammoTracking setting, default on), gear tab shows an ammo column with a reload control, compendium weapons carry capacities. - CSS: drop live Google Fonts imports (offline reliability); DG2 styles with dark-theme support. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
/* eslint-disable import/prefer-default-export */
|
|
import { handleDG2ChatAction } from "./apply-effects.js";
|
|
|
|
export async function handleInlineActions(btnWithAction, messageId) {
|
|
const action = btnWithAction.dataset?.action;
|
|
const message = game.messages.get(messageId);
|
|
|
|
// DG2 apply actions work off targets, not the message speaker.
|
|
if (action?.startsWith("dg2-")) {
|
|
await handleDG2ChatAction(btnWithAction, message);
|
|
return;
|
|
}
|
|
|
|
const actor = message?.speakerActor;
|
|
if (!actor) return;
|
|
|
|
if (action === "rollback-skill-failure-state") {
|
|
const rollbackFlag = message.getFlag("deltagreen2", "rollbacks");
|
|
await actor.update(foundry.utils.deepClone(rollbackFlag));
|
|
|
|
// eslint-disable-next-line no-use-before-define
|
|
toggleAllSkillFailures(rollbackFlag);
|
|
|
|
const label = btnWithAction
|
|
.closest(".rollback-section")
|
|
?.querySelector("label");
|
|
const oldHtml = label.outerHTML;
|
|
label.classList.toggle("strike");
|
|
|
|
message.update({
|
|
[`flags.deltagreen2.rollbacks`]: rollbackFlag,
|
|
content: message.content.replace(oldHtml, label.outerHTML),
|
|
});
|
|
}
|
|
}
|
|
|
|
function toggleAllSkillFailures(data) {
|
|
for (const skill of Object.values(data.system?.skills || {})) {
|
|
skill.failure = !skill.failure;
|
|
}
|
|
for (const skill of Object.values(data.system?.typedSkills || {})) {
|
|
skill.failure = !skill.failure;
|
|
}
|
|
}
|