From 091db4ddc845432c2d655c74c5b42cf22af564f1 Mon Sep 17 00:00:00 2001 From: peshomir <80340328+peshomir@users.noreply.github.com> Date: Thu, 15 Feb 2024 22:01:01 +0200 Subject: [PATCH] Fix for game update 1.91.3 Made changes to the build script --- build.js | 30 ++++++++++++++++-------------- static/fx_core.js | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/build.js b/build.js index 7d97440..78c7ca1 100644 --- a/build.js +++ b/build.js @@ -17,17 +17,19 @@ const replaceOne = (expression, replaceValue) => { //const dictionary = { __dictionaryVersion: '1.90.0 4 Feb 2024', playerId: 'bB', playerNames: 'hA', playerBalances: 'bC', playerTerritories: 'bj', gIsSingleplayer: 'fc', gIsTeamGame: 'cH' }; //if (!script.includes(`"${dictionary.__dictionaryVersion}"`)) throw new Error("Dictionary is outdated."); let dictionary = {}; -[/,\w+="Player: "\+(?\w+)\[\w+\],\w+=\(\w\+=" Balance: "\+\w+\.\w+\((?\w+)\[\w+\]\)\)\+\(" Territory: "\+\w+\.\w+\((?\w+)\[\w+\]\)\)\+\(" Coords: "/g, -/{\w+===(?\w+)\?\w+\(175," Message to "/g, -/=(?\w+)\?"Players":"Bots"/g, -/,(?\w+)=\(\w+=\w+\)<7\|\|9===\w+,/g, -] - .forEach(expression => { - result = expression.exec(script); - if (result === null) throw new Error("no match for ") + expression; - if (expression.exec(script) !== null) throw new Error("more than one match for: ") + expression; - for (let [key, value] of Object.entries(result.groups)) dictionary[key] = value; - }); +[ + /=(?\w+)\?"Players":"Bots"/g, + /,(?\w+)=\(\w+=\w+\)<7\|\|9===\w+,/g, + /=function\((\w+),(\w+),\w+\){\1===(?\w+)\?\w+\(175,\w+\.\w+\(18,\[(?\w+)\[\2\]\]\),1001,\2,\w+\(/g, + // this one broke in 1.91.3 /{\w+===(?\w+)\?\w+\(175," Message to "/g, + /\w+\.\w+\((\w+)\)\?\w+\.\w+\(\1\)\?(\w+)=(\w+\.\w+)\(13,\[\2\]\):\(\w+=\w+\.\w+\(\1\),\2=\3\(14,\[(?\w+)\[(\w+)\],(\w+\.\w+\.\w+\()(?\w+)\[\5\]\),\6(?\w+)\[\5\]\),\2\]\),\w+=!0\):\2=/g, + // this one also broke in 1.91.3 /,\w+="Player: "\+(?\w+)\[\w+\],\w+=\(\w\+=" Balance: "\+\w+\.\w+\((?\w+)\[\w+\]\)\)\+\(" Territory: "\+\w+\.\w+\((?\w+)\[\w+\]\)\)\+\(" Coords: "/g, +].forEach(expression => { + result = expression.exec(script); + if (result === null) throw new Error("no match for ") + expression; + if (expression.exec(script) !== null) throw new Error("more than one match for: ") + expression; + for (let [key, value] of Object.entries(result.groups)) dictionary[key] = value; +}); // Replace assets const assets = require('./assets.js'); @@ -48,7 +50,7 @@ replaceOne(/(0===(\w+)\?(\w+)\[\2\]\.length)-1:(\3\[\2\]\.length:1,)/g, "$1 - 2 { // Add Troop Density and Maximum Troops in side panel -- todo const { groups: { valuesArray } } = replaceOne(/(,(?\w+)\[\d\]="Interest",\2\[\d\]="Income",\2\[\d\]="Time"),(\w+=\w+-\w+\(\w+,100\),\((?\w+)=new Array\(\2\.length\)\)\[0\]=\w+)/g, '$1, $.push("Max Troops", "Density"), $3'); // add labels - replaceOne(new RegExp(/(:(?\w+)<7\?\w+\.\w+\(valuesArray\[\2\]\)):(\w+\.\w+\(valuesArray\[7\]\))}/ + replaceOne(new RegExp(/(:(?\w+)<7\?\w+\.\w+\.\w+\(valuesArray\[\2\]\)):(\w+\.\w+\(valuesArray\[7\]\))}/ .source.replace(/valuesArray/g, valuesArray), "g"), '$1 : $ === 7 ? $3 ' + `: $ === 8 ? utils.getMaxTroops(${dictionary.playerTerritories}, ${dictionary.playerId}) ` @@ -59,9 +61,9 @@ replaceOne(/(0===(\w+)\?(\w+)\[\2\]\.length)-1:(\3\[\2\]\.length:1,)/g, "$1 - 2 } // Increment win counter on wins -replaceOne(/(=function\((\w+)\){)([^}]+),((\w+\(0),\w+<100\?\w+\[\w+\]\+" won the game."[^,]+,([^()]+?\))),(?[^}]+},)/g, +replaceOne(/(=function\((\w+)\){)([^}]+),((\w+\(0),\w+<100\?(\w+\.\w+)\(11,(\[\w+\[\w+\]\])\):\6\(12,\7\),(3,\2,[^()]+?\))),(?[^}]+},)/g, `$1 if (${dictionary.playerId} === $2) wins_counter++, window.localStorage.setItem("fx_winCount", wins_counter); ` + -`$3, $4, $5, "Your Current Win Count is Now " + wins_counter, $6, $`); +`$3, $4, $5, "Your Current Win Count is Now " + wins_counter, $8, $`); { // Add settings button and win count diff --git a/static/fx_core.js b/static/fx_core.js index bcc5a32..0e488cf 100644 --- a/static/fx_core.js +++ b/static/fx_core.js @@ -1,5 +1,5 @@ const fx_version = '0.6.0.3'; // FX Client Version -const fx_update = 'Feb 6'; // FX Client Last Updated +const fx_update = 'Feb 15'; // FX Client Last Updated if (localStorage.getItem("fx_winCount") == undefined || localStorage.getItem("fx_winCount") == null) {