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
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"id": "zero-engine",
|
"id": "zero-engine",
|
||||||
"title": "Zero Engine (SLA Industries)",
|
"title": "Zero Engine (SLA Industries)",
|
||||||
"description": "A basic game system for SLA Industries using the Zero Engine rules.",
|
"description": "A basic game system for SLA Industries using the Zero Engine rules.",
|
||||||
"version": "1.4.4",
|
"version": "1.4.5",
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
"minimum": 13,
|
"minimum": 13,
|
||||||
"verified": "14.359"
|
"verified": "14.359"
|
||||||
|
|||||||
@@ -873,7 +873,7 @@
|
|||||||
|
|
||||||
<div class="finances-credits-hero">
|
<div class="finances-credits-hero">
|
||||||
<span class="fin-credit-label">CURRENT BALANCE</span>
|
<span class="fin-credit-label">CURRENT BALANCE</span>
|
||||||
<span class="fin-credit-value"><input type="number" name="system.details.credits" value="{{system.details.credits}}" /> c</span>
|
<span class="fin-credit-value"><input type="number" name="system.details.credits" value="{{system.details.credits}}" placeholder="500" min="0" /> c</span>
|
||||||
{{#if system.finances.debt}}<span class="fin-debt-badge">⚠ DEBT {{system.finances.debt}}c</span>{{/if}}
|
{{#if system.finances.debt}}<span class="fin-debt-badge">⚠ DEBT {{system.finances.debt}}c</span>{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
+7
-3
@@ -304,7 +304,7 @@ class ZeroEngineActorSheet extends foundry.appv1.sheets.ActorSheet {
|
|||||||
const _inc = this.actor.system.finances?.income || {};
|
const _inc = this.actor.system.finances?.income || {};
|
||||||
const _exp = this.actor.system.finances?.expenses || {};
|
const _exp = this.actor.system.finances?.expenses || {};
|
||||||
context.weeklyIncome = (_inc.salary||0) + (_inc.bpnReward||0) + (_inc.other||0);
|
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.weeklyNet = context.weeklyIncome - context.weeklyExpenses;
|
||||||
context.weeklyNetSign = context.weeklyNet >= 0 ? '+' : '';
|
context.weeklyNetSign = context.weeklyNet >= 0 ? '+' : '';
|
||||||
context.weeklyNetColor = context.weeklyNet >= 0 ? '#44cc66' : '#cc1111';
|
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×
|
// Bullet tax is DOUBLED: base cost (ammo) + tax of equal value = 2×
|
||||||
const totalCost = costPerRound * roundsFired * 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);
|
const newCredits = Math.max(0, currentCredits - totalCost);
|
||||||
|
|
||||||
// ── Credit deduction — critical, standalone update ──────────────────────
|
// ── Credit deduction — critical, standalone update ──────────────────────
|
||||||
@@ -6122,7 +6126,7 @@ class ZeroEngineActorSheetMk2 extends ZeroEngineActorSheet {
|
|||||||
const inc = context.system.finances.income || {};
|
const inc = context.system.finances.income || {};
|
||||||
const exp = context.system.finances.expenses || {};
|
const exp = context.system.finances.expenses || {};
|
||||||
context.weeklyIncome = (inc.salary||0) + (inc.bpnReward||0) + (inc.other||0);
|
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.weeklyNet = context.weeklyIncome - context.weeklyExpenses;
|
||||||
context.weeklyNetSign = context.weeklyNet >= 0 ? '+' : '';
|
context.weeklyNetSign = context.weeklyNet >= 0 ? '+' : '';
|
||||||
context.weeklyNetColor = context.weeklyNet >= 0 ? '#44cc66' : '#cc1111';
|
context.weeklyNetColor = context.weeklyNet >= 0 ? '#44cc66' : '#cc1111';
|
||||||
|
|||||||
Reference in New Issue
Block a user