fix: guard against NaN credits in GM Finance Ledger

This commit is contained in:
2026-06-02 23:20:03 +01:00
parent 02d7177122
commit 2945f66d9a
2 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
"id": "zero-engine",
"title": "Zero Engine (SLA Industries)",
"description": "A basic game system for SLA Industries using the Zero Engine rules.",
"version": "1.4.6",
"version": "1.4.7",
"compatibility": {
"minimum": 13,
"verified": "14.359"
+8 -2
View File
@@ -5559,6 +5559,12 @@ class SLAGMFinanceTool extends Application {
return $html;
}
/** Parse a credit value safely — NaN, null, undefined all become 0 */
_safeCredits(val) {
const n = Number(val);
return isNaN(n) ? 0 : n;
}
_getPCData() {
return (game.actors ?? [])
.filter(a => a.type === 'character' && a.system?.details?.isPlayerCharacter)
@@ -5571,7 +5577,7 @@ class SLAGMFinanceTool extends Application {
return {
id: a.id,
name: a.name,
credits: Number(a.system.details?.credits ?? 0),
credits: this._safeCredits(a.system.details?.credits),
weeklyIncome,
weeklyExpenses,
netWeekly
@@ -5588,7 +5594,7 @@ class SLAGMFinanceTool extends Application {
const weeklyIncome = (inc.salary||0) + (inc.bpnReward||0) + (inc.other||0);
const weeklyExpenses = (exp.accommodation||0) + (exp.drugs||0) + (exp.subscriptions||0) + (exp.other||0) + (exp.bulletTax||0);
const net = weeklyIncome - weeklyExpenses;
const current = Number(actor.system?.details?.credits ?? 0);
const current = this._safeCredits(actor.system?.details?.credits);
const newBal = current + net;
await actor.update({ 'system.details.credits': newBal });
ui.notifications.info(