diff --git a/fx_core.js b/fx_core.js
index b453fb1..8659cb8 100644
--- a/fx_core.js
+++ b/fx_core.js
@@ -1,6 +1,6 @@
-const dictionary = {"gIsSingleplayer":"j1","gIsTeamGame":"ha","playerId":"eu","playerNames":"k5","playerBalances":"ev","playerTerritories":"fP","uiOffset":"nf"};
-const fx_version = '0.6.2'; // FX Client Version
-const fx_update = 'Mar 8'; // FX Client Last Updated
+const dictionary = {"gIsSingleplayer":"j1","gIsTeamGame":"ha","playerId":"eu","playerNames":"k5","playerBalances":"ev","playerTerritories":"fP","uiOffset":"nf","gHumans":"h9","playerStates":"hB","gLobbyMaxJoin":"pu"};
+const fx_version = '0.6.2.1'; // FX Client Version
+const fx_update = 'Mar 10'; // FX Client Last Updated
if (localStorage.getItem("fx_winCount") == undefined || localStorage.getItem("fx_winCount") == null) {
var wins_counter = 0;
@@ -201,6 +201,7 @@ var WindowManager = new (function() {
if (windows[windowName].isOpen === false) return;
windows[windowName].isOpen = false;
windows[windowName].element.style.display = "none";
+ if (windows[windowName].onClose !== undefined) windows[windowName].onClose();
};
this.closeAll = function() {
Object.values(windows).forEach(function(windowObj) {
@@ -218,7 +219,8 @@ WindowManager.add({
element: document.querySelector("#donationhistory"),
beforeOpen: function(isSingleplayer) {
document.getElementById("donationhistory_note").style.display = ((true || settings.showBotDonations || /*getVarByName("dt")*/ isSingleplayer) ? "none" : "block");
- }
+ },
+ onClose: function() { donationsTracker.openedWindowPlayerID = null; }
});
WindowManager.add({
name: "playerList",
@@ -237,11 +239,14 @@ const playerList = new (function () {
document.getElementById("playerlist_content").addEventListener("click", event => {
const playerId = event.target.closest("tr[data-player-id]")?.getAttribute("data-player-id");
if (!playerId) return;
- if (getVar("gIsTeamGame")) WindowManager.closeWindow("playerList"), displayDonationsHistory(playerId);
+ if (getVar("gIsTeamGame")) WindowManager.closeWindow("playerList"), donationsTracker.displayHistory(playerId);
});
this.display = function displayPlayerList(playerNames) {
- let listContent = "";
- for (let i = 0; i < playerNames.length; i++) {
+ const gHumans = getVar("gHumans");
+ const gLobbyMaxJoin = getVar("gLobbyMaxJoin");
+ let listContent = `
Players (${gHumans})
`;
+ for (let i = 0; i < gLobbyMaxJoin; i++) {
+ if (i === gHumans) listContent += `Bots (${gLobbyMaxJoin - gHumans})
`;
listContent += `${i}. ${escapeHtml(playerNames[i])} |
`
}
document.getElementById("playerlist_content").innerHTML = listContent;
@@ -261,38 +266,50 @@ const playerList = new (function () {
}
});
var donationsTracker = new (function(){
+ this.openedWindowPlayerID = null;
+ this.contentElement = document.querySelector("#donationhistory_content");
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
- // from inside of game:
- // ((!gE[g].startsWith("[Bot] ") || settings.showBotDonations) && donationsTracker.logDonation(g,k,x))
+ this.getHistoryOf = function(playerID) {
+ return this.donationHistory[playerID].toReversed();
+ }
+ this.reset = function() { 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);
this.donationHistory[senderID].push(donationInfo);
+ if (this.openedWindowPlayerID === senderID || this.openedWindowPlayerID === receiverID) {
+ const indexOfNewItem = this.donationHistory[this.openedWindowPlayerID === senderID ? senderID : receiverID].length;
+ this.contentElement.prepend(generateTableRowItem(donationInfo, indexOfNewItem, this.openedWindowPlayerID, true));
+ }
};
- this.getRecipientHistoryOf = function(playerID) {
- return this.donationHistory[playerID];
- };
- this.reset = function() { for (var i = 0; i < 512; i++) this.donationHistory[i] = []; };
-});
-function displayDonationsHistory(playerID, playerNames = getVar("playerNames"), isSingleplayer = getVar("gIsSingleplayer")) {
- var history = donationsTracker.getRecipientHistoryOf(playerID);
- console.log("History for " + playerNames[playerID] + ":");
- console.log(history);
- document.querySelector("#donationhistory h1").innerHTML = "Donation history for " + escapeHtml(playerNames[playerID]);
- var historyText = "";
- history.reverse();
- if (history.length > 0) history.forEach(function(historyItem, index) {
- historyText += `${(history.length - index)}. `;
+ function generateTableRowItem(historyItem, index, playerID, isNew) {
+ const playerNames = getVar("playerNames");
+ const row = document.createElement("tr");
+ if (isNew) row.setAttribute("class", "new");
+ let content = `${index}. `;
if (playerID === historyItem[1])
- historyText += `Received ${historyItem[2]} resources from ${escapeHtml(playerNames[historyItem[0]])} `;
- else historyText += `Sent ${historyItem[2]} resources to ${escapeHtml(playerNames[historyItem[1]])} `;
- });
- else historyText = "Nothing to display";
- document.querySelector("#donationhistory p#donationhistory_text").innerHTML = historyText;
- WindowManager.openWindow("donationHistory", isSingleplayer);
-}
+ content += `Received ${historyItem[2]} resources from ${escapeHtml(playerNames[historyItem[0]])}`;
+ else content += `Sent ${historyItem[2]} resources to ${escapeHtml(playerNames[historyItem[1]])}`;
+ content += " | ";
+ row.innerHTML = content;
+ return row;
+ }
+ this.displayHistory = function displayDonationsHistory(playerID, playerNames = getVar("playerNames"), isSingleplayer = getVar("gIsSingleplayer")) {
+ var history = donationsTracker.getHistoryOf(playerID);
+ console.log("History for " + playerNames[playerID] + ":");
+ console.log(history);
+ document.querySelector("#donationhistory h1").innerHTML = "Donation history for " + escapeHtml(playerNames[playerID]);
+ this.contentElement.innerHTML = "";
+ if (history.length > 0) history.forEach((historyItem, index) => {
+ this.contentElement.appendChild(generateTableRowItem(historyItem, history.length - index, playerID));
+ });
+ else this.contentElement.innerText = "Nothing to display";
+ this.openedWindowPlayerID = playerID;
+ WindowManager.openWindow("donationHistory", isSingleplayer);
+ }
+});
var utils = new (function() {
this.getMaxTroops = function(playerTerritories, playerID) { return (playerTerritories[playerID]*150).toString(); };
diff --git a/game.js b/game.js
index 84c0798..17fcd7c 100644
--- a/game.js
+++ b/game.js
@@ -3249,7 +3249,7 @@ function bb() {
a0e = !1;
var a12 = a13(jo);
return al.sk() && -1 !== a0c && (a0c = -1, a0j(), b7.d6 = !0), b7.dX - a0d < 350 && a0g === a12 && -1 !== (a12 = (a12 = yn(-1, a12, a0J)) !== a0J && uu(jn, jo) ? a12 : -1) && (jn = jU[a12 + position], a12 === a0J - 1 && a0E[eu] >=
- position + a0J - 1 && (jn = eu), ha && displayDonationsHistory(jn, k5, j1), 0 !== hA[jn]) && f.kR(jn, 800, !1, 0), !0
+ position + a0J - 1 && (jn = eu), ha && donationsTracker.displayHistory(jn, k5, j1), 0 !== hA[jn]) && f.kR(jn, 800, !1, 0), !0
}, this.s4 = function(jn, jo, deltaY) {
var a14;
return !(a0e || kT || (a14 = Math.max(Math.floor(Math.abs(deltaY) / 40), 1), !uu(jn, jo)) || (jn = (jn = yn(-1, a13(jo), a0J)) === a0J || al.sk() ? -1 : jn, 0 < deltaY ? position < f3 - a0J && (position += Math.min(f3 - a0J - position,
diff --git a/index.html b/index.html
index 7459513..ebd7d24 100644
--- a/index.html
+++ b/index.html
@@ -34,7 +34,7 @@
-
+