Context for known donation history error

main
peshomir 2025-07-14 12:26:54 +03:00
parent bb36014f55
commit d7ec66131d
1 changed files with 10 additions and 3 deletions

View File

@ -1,6 +1,7 @@
import WindowManager from "./windowManager.js"; import WindowManager from "./windowManager.js";
import { getVar } from "./gameInterface.js"; import { getVar } from "./gameInterface.js";
import { escapeHtml } from "./utils.js"; import { escapeHtml } from "./utils.js";
import { debugWithContext } from "./debugging.js";
WindowManager.add({ WindowManager.add({
name: "donationHistory", name: "donationHistory",
@ -16,10 +17,16 @@ const donationsTracker = new (function(){
this.donationHistory = Array(512); this.donationHistory = Array(512);
// fill the array with empty arrays with length of 3 // 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 //for (var i = 0; i < 512; i++) this.donationHistory.push([]); // not needed as .reset is called on game start
this.getHistoryOf = function(playerID) { let resetCalled = false;
return this.donationHistory[playerID].toReversed(); 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) { this.logDonation = function(senderID, receiverID, amount) {
const donationInfo = [senderID, receiverID, amount]; const donationInfo = [senderID, receiverID, amount];
this.donationHistory[receiverID].push(donationInfo); this.donationHistory[receiverID].push(donationInfo);