gh-pages
peshomir 2024-03-10 18:59:15 +00:00
parent 2f373c413d
commit ee2f347363
4 changed files with 76 additions and 37 deletions

View File

@ -1,6 +1,6 @@
const dictionary = {"gIsSingleplayer":"j1","gIsTeamGame":"ha","playerId":"eu","playerNames":"k5","playerBalances":"ev","playerTerritories":"fP","uiOffset":"nf"}; 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'; // FX Client Version const fx_version = '0.6.2.1'; // FX Client Version
const fx_update = 'Mar 8'; // FX Client Last Updated const fx_update = 'Mar 10'; // FX Client Last Updated
if (localStorage.getItem("fx_winCount") == undefined || localStorage.getItem("fx_winCount") == null) { if (localStorage.getItem("fx_winCount") == undefined || localStorage.getItem("fx_winCount") == null) {
var wins_counter = 0; var wins_counter = 0;
@ -201,6 +201,7 @@ var WindowManager = new (function() {
if (windows[windowName].isOpen === false) return; if (windows[windowName].isOpen === false) return;
windows[windowName].isOpen = false; windows[windowName].isOpen = false;
windows[windowName].element.style.display = "none"; windows[windowName].element.style.display = "none";
if (windows[windowName].onClose !== undefined) windows[windowName].onClose();
}; };
this.closeAll = function() { this.closeAll = function() {
Object.values(windows).forEach(function(windowObj) { Object.values(windows).forEach(function(windowObj) {
@ -218,7 +219,8 @@ WindowManager.add({
element: document.querySelector("#donationhistory"), element: document.querySelector("#donationhistory"),
beforeOpen: function(isSingleplayer) { beforeOpen: function(isSingleplayer) {
document.getElementById("donationhistory_note").style.display = ((true || settings.showBotDonations || /*getVarByName("dt")*/ isSingleplayer) ? "none" : "block"); document.getElementById("donationhistory_note").style.display = ((true || settings.showBotDonations || /*getVarByName("dt")*/ isSingleplayer) ? "none" : "block");
} },
onClose: function() { donationsTracker.openedWindowPlayerID = null; }
}); });
WindowManager.add({ WindowManager.add({
name: "playerList", name: "playerList",
@ -237,11 +239,14 @@ const playerList = new (function () {
document.getElementById("playerlist_content").addEventListener("click", event => { document.getElementById("playerlist_content").addEventListener("click", event => {
const playerId = event.target.closest("tr[data-player-id]")?.getAttribute("data-player-id"); const playerId = event.target.closest("tr[data-player-id]")?.getAttribute("data-player-id");
if (!playerId) return; 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) { this.display = function displayPlayerList(playerNames) {
let listContent = ""; const gHumans = getVar("gHumans");
for (let i = 0; i < playerNames.length; i++) { const gLobbyMaxJoin = getVar("gLobbyMaxJoin");
let listContent = `<h3>Players (${gHumans})</h3>`;
for (let i = 0; i < gLobbyMaxJoin; i++) {
if (i === gHumans) listContent += `<h3>Bots (${gLobbyMaxJoin - gHumans})</h3>`;
listContent += `<tr data-player-id="${i}"><td><span class="color-light-gray">${i}.</span> ${escapeHtml(playerNames[i])}</td></tr>` listContent += `<tr data-player-id="${i}"><td><span class="color-light-gray">${i}.</span> ${escapeHtml(playerNames[i])}</td></tr>`
} }
document.getElementById("playerlist_content").innerHTML = listContent; document.getElementById("playerlist_content").innerHTML = listContent;
@ -261,38 +266,50 @@ const playerList = new (function () {
} }
}); });
var donationsTracker = new (function(){ var donationsTracker = new (function(){
this.openedWindowPlayerID = null;
this.contentElement = document.querySelector("#donationhistory_content");
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
// from inside of game: this.getHistoryOf = function(playerID) {
// ((!gE[g].startsWith("[Bot] ") || settings.showBotDonations) && donationsTracker.logDonation(g,k,x)) return this.donationHistory[playerID].toReversed();
}
this.reset = function() { 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);
this.donationHistory[senderID].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) { function generateTableRowItem(historyItem, index, playerID, isNew) {
return this.donationHistory[playerID]; const playerNames = getVar("playerNames");
}; const row = document.createElement("tr");
this.reset = function() { for (var i = 0; i < 512; i++) this.donationHistory[i] = []; }; if (isNew) row.setAttribute("class", "new");
}); let content = `<td><span class="color-light-gray">${index}.</span> `;
function displayDonationsHistory(playerID, playerNames = getVar("playerNames"), isSingleplayer = getVar("gIsSingleplayer")) { if (playerID === historyItem[1])
var history = donationsTracker.getRecipientHistoryOf(playerID); content += `Received <span class="color-green">${historyItem[2]}</span> resources from ${escapeHtml(playerNames[historyItem[0]])}`;
else content += `Sent <span class="color-red">${historyItem[2]}</span> resources to ${escapeHtml(playerNames[historyItem[1]])}`;
content += "</td>";
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 for " + playerNames[playerID] + ":");
console.log(history); console.log(history);
document.querySelector("#donationhistory h1").innerHTML = "Donation history for " + escapeHtml(playerNames[playerID]); document.querySelector("#donationhistory h1").innerHTML = "Donation history for " + escapeHtml(playerNames[playerID]);
var historyText = ""; this.contentElement.innerHTML = "";
history.reverse(); if (history.length > 0) history.forEach((historyItem, index) => {
if (history.length > 0) history.forEach(function(historyItem, index) { this.contentElement.appendChild(generateTableRowItem(historyItem, history.length - index, playerID));
historyText += `<span class="color-light-gray">${(history.length - index)}.</span> `;
if (playerID === historyItem[1])
historyText += `Received <span class="color-green">${historyItem[2]}</span> resources from ${escapeHtml(playerNames[historyItem[0]])}<br>`;
else historyText += `Sent <span class="color-red">${historyItem[2]}</span> resources to ${escapeHtml(playerNames[historyItem[1]])}<br>`;
}); });
else historyText = "Nothing to display"; else this.contentElement.innerText = "Nothing to display";
document.querySelector("#donationhistory p#donationhistory_text").innerHTML = historyText; this.openedWindowPlayerID = playerID;
WindowManager.openWindow("donationHistory", isSingleplayer); WindowManager.openWindow("donationHistory", isSingleplayer);
} }
});
var utils = new (function() { var utils = new (function() {
this.getMaxTroops = function(playerTerritories, playerID) { return (playerTerritories[playerID]*150).toString(); }; this.getMaxTroops = function(playerTerritories, playerID) { return (playerTerritories[playerID]*150).toString(); };

View File

@ -3249,7 +3249,7 @@ function bb() {
a0e = !1; a0e = !1;
var a12 = a13(jo); 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] >= 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) { }, this.s4 = function(jn, jo, deltaY) {
var a14; 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, 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,

View File

@ -34,7 +34,7 @@
<meta itemprop="image" content="https://mohsenemx.github.io/FXclient/assets/logo.png"> <meta itemprop="image" content="https://mohsenemx.github.io/FXclient/assets/logo.png">
<!-- FX Client CSS --> <!-- FX Client CSS -->
<link rel="stylesheet" href="main.css?1709913010311"> <link rel="stylesheet" href="main.css?1710097154884">
<!-- Game CSS --> <!-- Game CSS -->
<style> <style>
html, html,
@ -117,10 +117,10 @@
<div class="window scrollable selectable" id="donationhistory" style="display:none"> <div class="window scrollable selectable" id="donationhistory" style="display:none">
<h1>Donation history for </h1> <h1>Donation history for </h1>
<p id="donationhistory_note">Note: donations from bots are not shown here</p> <p id="donationhistory_note">Note: donations from bots are not shown here</p>
<p id="donationhistory_text"></p> <table><tbody id="donationhistory_content"></tbody></table>
</div> </div>
<script src="variables.js?1709913010311"></script> <script src="variables.js?1710097154884"></script>
<script src="fx_core.js?1709913010311"></script> <script src="fx_core.js?1710097154884"></script>
<script src="game.js?1709913010311"></script> <script src="game.js?1710097154884"></script>
</body> </body>
</html> </html>

View File

@ -16,7 +16,7 @@
width : 90%; width : 90%;
top : 0; top : 0;
color : white; color : white;
font-family : 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; font-family : 'Franklin Gothic Medium', 'Trebuchet MS', Arial, sans-serif;
margin : auto; margin : auto;
margin-top : 20px; margin-top : 20px;
right : 0; right : 0;
@ -62,6 +62,15 @@ h1 {
margin-block-end : 0.5em; margin-block-end : 0.5em;
transition : 0.2s; transition : 0.2s;
} }
#playerlist h1 {
margin-block-start: 0.3em;
margin-block-end : 0.3em;
}
h3 {
font-weight : normal;
margin-block-start: 0.6em;
margin-block-end : 0.6em;
}
canvas, canvas,
input, input,
@ -86,6 +95,19 @@ td {
#playerlist_content.clickable td { cursor: pointer; } #playerlist_content.clickable td { cursor: pointer; }
#playerlist_content.clickable td:hover { background-color: #00ff0040; } #playerlist_content.clickable td:hover { background-color: #00ff0040; }
tr.new {
animation: flashAnimation 0.4s ease-out;
}
@keyframes flashAnimation {
0% {
background-color: #ffffffaa;
}
100% {
background-color: transparent;
}
}
table { table {
border-spacing: 0px; border-spacing: 0px;
} }