From d7ec66131d702cbd5ec04e928b47e0cd292c1574 Mon Sep 17 00:00:00 2001 From: peshomir <80340328+peshomir@users.noreply.github.com> Date: Mon, 14 Jul 2025 12:26:54 +0300 Subject: [PATCH] Context for known donation history error --- src/donationsTracker.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/donationsTracker.js b/src/donationsTracker.js index aad8c42..5e03d69 100644 --- a/src/donationsTracker.js +++ b/src/donationsTracker.js @@ -1,6 +1,7 @@ import WindowManager from "./windowManager.js"; import { getVar } from "./gameInterface.js"; import { escapeHtml } from "./utils.js"; +import { debugWithContext } from "./debugging.js"; WindowManager.add({ name: "donationHistory", @@ -16,10 +17,16 @@ const donationsTracker = new (function(){ this.donationHistory = Array(512); // fill the array with empty arrays with length of 3 //for (var i = 0; i < 512; i++) this.donationHistory.push([]); // not needed as .reset is called on game start - this.getHistoryOf = function(playerID) { - return this.donationHistory[playerID].toReversed(); + let resetCalled = false; + this.getHistoryOf = function (playerID) { + return debugWithContext(() => this.donationHistory[playerID].toReversed(), { + playerID, + resetCalled, + type: typeof this.donationHistory[playerID], + isArray: Array.isArray(this.donationHistory[playerID]) + }); } - this.reset = function() { for (var i = 0; i < 512; i++) this.donationHistory[i] = []; }; + this.reset = function() { resetCalled = true; for (var i = 0; i < 512; i++) this.donationHistory[i] = []; }; this.logDonation = function(senderID, receiverID, amount) { const donationInfo = [senderID, receiverID, amount]; this.donationHistory[receiverID].push(donationInfo);