From 049273fbc66ec47085e612c5b39fe6f55c8a9c85 Mon Sep 17 00:00:00 2001 From: Tim Evans Date: Tue, 2 Jun 2026 22:53:00 +0100 Subject: [PATCH] fix: bullet tax balance + expenses total (v1.4.5) Three bugs: 1. weeklyExpenses total omitted bulletTax from the sum (both getData paths) Fix: add (_exp.bulletTax||0) to the calculation 2. _applyBulletTax read undefined credits as 0 (actors created before the credits field existed have null/undefined, not zero) Fix: fallback to 500 (template default) only when value is null/undefined 3. Finances tab CURRENT BALANCE showed just C because input had no placeholder Fix: add placeholder=500 min=0 to the credits input in character-sheet.hbs --- system.json | 2 +- templates/actor/character-sheet.hbs | 2 +- zero-engine.mjs | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/system.json b/system.json index ef5c40d..0dada84 100644 --- a/system.json +++ b/system.json @@ -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.4", + "version": "1.4.5", "compatibility": { "minimum": 13, "verified": "14.359" diff --git a/templates/actor/character-sheet.hbs b/templates/actor/character-sheet.hbs index 222a930..26dfb8e 100644 --- a/templates/actor/character-sheet.hbs +++ b/templates/actor/character-sheet.hbs @@ -873,7 +873,7 @@
CURRENT BALANCE - c + c {{#if system.finances.debt}}⚠ DEBT {{system.finances.debt}}c{{/if}}
diff --git a/zero-engine.mjs b/zero-engine.mjs index c3d670b..24b645a 100644 --- a/zero-engine.mjs +++ b/zero-engine.mjs @@ -304,7 +304,7 @@ class ZeroEngineActorSheet extends foundry.appv1.sheets.ActorSheet { const _inc = this.actor.system.finances?.income || {}; const _exp = this.actor.system.finances?.expenses || {}; context.weeklyIncome = (_inc.salary||0) + (_inc.bpnReward||0) + (_inc.other||0); - context.weeklyExpenses = (_exp.accommodation||0) + (_exp.drugs||0) + (_exp.subscriptions||0) + (_exp.other||0); + context.weeklyExpenses = (_exp.accommodation||0) + (_exp.drugs||0) + (_exp.subscriptions||0) + (_exp.other||0) + (_exp.bulletTax||0); context.weeklyNet = context.weeklyIncome - context.weeklyExpenses; context.weeklyNetSign = context.weeklyNet >= 0 ? '+' : ''; context.weeklyNetColor = context.weeklyNet >= 0 ? '#44cc66' : '#cc1111'; @@ -6008,7 +6008,11 @@ async function _applyBulletTax(actor, weaponData, roundsFired) { // Bullet tax is DOUBLED: base cost (ammo) + tax of equal value = 2× const totalCost = costPerRound * roundsFired * 2; - const currentCredits = Number(actor.system?.details?.credits ?? 0); + // Fall back to 500 (template default) not 0 — actors created before the + // credits field existed have undefined here, not zero. + const storedCredits = actor.system?.details?.credits; + const currentCredits = (storedCredits !== undefined && storedCredits !== null) + ? Number(storedCredits) : 500; const newCredits = Math.max(0, currentCredits - totalCost); // ── Credit deduction — critical, standalone update ────────────────────── @@ -6122,7 +6126,7 @@ class ZeroEngineActorSheetMk2 extends ZeroEngineActorSheet { const inc = context.system.finances.income || {}; const exp = context.system.finances.expenses || {}; context.weeklyIncome = (inc.salary||0) + (inc.bpnReward||0) + (inc.other||0); - context.weeklyExpenses = (exp.accommodation||0) + (exp.drugs||0) + (exp.subscriptions||0) + (exp.other||0); + context.weeklyExpenses = (exp.accommodation||0) + (exp.drugs||0) + (exp.subscriptions||0) + (exp.other||0) + (exp.bulletTax||0); context.weeklyNet = context.weeklyIncome - context.weeklyExpenses; context.weeklyNetSign = context.weeklyNet >= 0 ? '+' : ''; context.weeklyNetColor = context.weeklyNet >= 0 ? '#44cc66' : '#cc1111';