Fixed lethality display. Improved combat tab styling. Improved edit stats modal.

This commit is contained in:
Aaron Lutomski
2026-06-17 19:03:17 -07:00
parent 219ad971d9
commit cb5cfcfcd0
16 changed files with 330 additions and 104 deletions
+15 -3
View File
@@ -1,4 +1,5 @@
import DG, { BASE_TEMPLATE_PATH } from "../config/index.js";
import { applyDialogTheme } from "./dg-dialog.js";
export default class ActorEditStatForm extends foundry.applications.api.HandlebarsApplicationMixin(
foundry.applications.api.ApplicationV2,
@@ -11,9 +12,13 @@ export default class ActorEditStatForm extends foundry.applications.api.Handleba
/** @override */
static DEFAULT_OPTIONS = {
tag: "form",
classes: [DG.ID, "edit-stat-form"],
window: { title: "Edit statistics form", resizable: true },
position: { width: 400, height: 200 },
classes: [DG.ID, "edit-stat-form", "dg-dialog-app"],
window: {
title: "DG.EditStats.Title",
resizable: true,
contentClasses: ["standard-form"],
},
position: { width: 600, height: "auto" },
actions: {},
form: {
handler: this.formHandler,
@@ -28,11 +33,18 @@ export default class ActorEditStatForm extends foundry.applications.api.Handleba
},
});
/** @override */
async _onRender(context, options) {
await super._onRender(context, options);
applyDialogTheme(this);
}
/** @override */
async _prepareContext(options) {
return {
...(await super._prepareContext(options)),
actor: this.actor,
statKeys: DG.statistics,
sourceStatistics:
this.actor._source?.system?.statistics ?? this.actor.system.statistics,
};
+40
View File
@@ -7,6 +7,8 @@ const PERCENTILE_ROLL_DIALOG_TEMPLATE =
"systems/deltagreen/templates/dialog/modify-percentile-roll.html";
const DAMAGE_ROLL_DIALOG_TEMPLATE =
"systems/deltagreen/templates/dialog/modify-damage-roll.html";
const DAMAGE_OR_LETHALITY_ROLL_DIALOG_TEMPLATE =
"systems/deltagreen/templates/dialog/damage-or-lethality-roll.html";
const QUICK_MODIFIER_PRESETS = [
{
@@ -215,3 +217,41 @@ export async function showDamageRollModifyDialog({ itemName, formula }) {
],
});
}
/**
* @param {object} options
* @param {string} options.itemName
* @returns {Promise<"damage"|"lethality"|void>}
*/
export async function showDamageOrLethalityChoiceDialog({ itemName }) {
const content = await renderTemplate(
DAMAGE_OR_LETHALITY_ROLL_DIALOG_TEMPLATE,
{
itemName,
},
);
return showDgDialog({
modifier: "damage-or-lethality",
content,
window: {
title: game.i18n.localize("DG.DamageOrLethalityRoll.Title"),
},
close: () => null,
buttons: [
{
default: true,
label: game.i18n.localize("DG.DamageOrLethalityRoll.RollDamage"),
action: "damage",
icon: "fas fa-dice",
callback: () => "damage",
},
{
label: game.i18n.localize("DG.DamageOrLethalityRoll.RollLethality"),
action: "lethality",
icon: "fas fa-skull-crossbones",
callback: () => "lethality",
},
],
});
}
+12 -1
View File
@@ -1,4 +1,5 @@
import { getDGRollToken } from "../../chat/dg-chat-card.js";
import { showDamageOrLethalityChoiceDialog } from "../../roll/roll-dialogs.js";
import { createDGRollFromDataset, processDGRoll } from "../../roll/roll.js";
/** @param {typeof foundry.applications.api.ApplicationV2} Base */
@@ -46,7 +47,17 @@ export default function RollSheetMixin(Base) {
}
const item = this.actor.items.get(target.dataset.iid);
const roll = createDGRollFromDataset(target.dataset, {
const rollDataset = { ...target.dataset };
if (rollDataset.rolltype === "damage-or-lethality") {
const choice = await showDamageOrLethalityChoiceDialog({
itemName: item?.name ?? "",
});
if (!choice) return;
rollDataset.rolltype = choice;
}
const roll = createDGRollFromDataset(rollDataset, {
actor: this.actor,
item,
element: target,
+20
View File
@@ -122,4 +122,24 @@ export default function registerHandlebarsHelpers() {
return result;
});
Handlebars.registerHelper("hasWeaponDamage", (damage) => {
const trimmed = String(damage ?? "").trim();
return trimmed !== "" && trimmed !== "0";
});
Handlebars.registerHelper("hasWeaponLethality", (lethality) => {
const value = Number(lethality);
return Number.isFinite(value) && value > 0;
});
Handlebars.registerHelper("hasWeaponDamageAndLethality", (item) => {
const damage = item?.system?.damage;
const lethality = item?.system?.lethality;
const trimmed = String(damage ?? "").trim();
const hasDamage = trimmed !== "" && trimmed !== "0";
const hasLethality =
Number.isFinite(Number(lethality)) && Number(lethality) > 0;
return hasDamage && hasLethality;
});
}
+21 -1
View File
@@ -177,6 +177,22 @@ export function appendRollTargetTooltipSection(
return `${existingTooltip}<br><br>${appendix}`;
}
/**
* @param {string} existingTooltip
* @param {string} [feature]
* @returns {string}
*/
export function appendDistinguishingFeatureSection(existingTooltip, feature) {
const trimmed = String(feature ?? "").trim();
if (!trimmed) return existingTooltip;
const label = game.i18n.localize("DG.EditStats.DistinguishingFeature");
const escaped = foundry.utils.escapeHTML(trimmed);
const section = `<br><br>${foundry.utils.escapeHTML(label)}: ${escaped}`;
if (!existingTooltip) return section;
return `${existingTooltip}${section}`;
}
/**
* Stat and sanity roll-target tooltips for the agent sheet left bar (not skills).
*
@@ -191,8 +207,12 @@ export function prepareAgentStatSanityTooltips(actor) {
for (const [key, stat] of Object.entries(system.statistics ?? {})) {
const base = Number(stat.x5) || 0;
const existing = game.i18n.localize(`DG.Attributes.Tooltip.${key}`);
stat.tooltip = appendRollTargetTooltipSection(
const withFeature = appendDistinguishingFeatureSection(
existing,
stat.distinguishing_feature,
);
stat.tooltip = appendRollTargetTooltipSection(
withFeature,
actor,
"system.rollTarget.statistics",
base,