diff --git a/build.js b/build.js
index 285fd54..0b3ccc5 100644
--- a/build.js
+++ b/build.js
@@ -15,6 +15,7 @@ const replaceOne = (expression, replaceValue) => {
script = script.replace(expression, replaceValue);
return result;
}
+const replace = (...args) => script = script.replace(...args);
const matchOne = (expression) => {
const result = expression.exec(script);
if (result === null) throw new Error("no match for: ") + expression;
@@ -97,266 +98,8 @@ rawCodeSegments.forEach(code => {
fs.writeFileSync("./build/fx_core.js", `const dictionary = ${JSON.stringify(dictionary)};\n` + fs.readFileSync("./build/fx_core.js").toString());
-// Constants for easy usage of otherwise long variable access expressions
-const dict = dictionary;
-const playerId = `${dict.game}.${dict.playerId}`;
-const rawPlayerNames = `${dict.playerData}.${dict.rawPlayerNames}`;
-const gIsSingleplayer = `${dict.game}.${dict.gIsSingleplayer}`;
-
-// Replace assets
-import assets from './assets.js';
-replaceOne(/(\(4,"crown",4,")[^"]+"\),/g, "$1" + assets.crownIcon + "\"),");
-replaceOne(/(\(6,"territorial\.io",6,")[^"]+"\),/g, "$1" + assets.fxClientLogo + "\"),");
-
-// Add FX Client version info to the game version window
-replaceRawCode(`ar.oa(4,1,new s8("ℹ️ "+Translations.txt[84],gameVersion+"
"+ah.aC5+"",`,
-`ar.oa(4,1,new s8("ℹ️ "+Translations.txt[84],gameVersion+"
"+ah.aC5+""
-+ "
" + "FX Client v" + fx_version + " " + fx_update + "
FX Client Discord server"
-+ "
Github repository",`);
-
-// Max size for custom maps: from 4096x4096 to 8192x8192
-// TODO: test this; it might cause issues with new boat mechanics?
-
-{ // Add Troop Density and Maximum Troops in side panel
- const { valuesArray } = replaceRawCode(`,labels[5]=aV.nU[76],labels[6]=aV.nU[77],labels[7]=aV.nU[78],a0Z=game.tn-eT(game.tn,100),(valuesArray=new Array(labels.length))[0]=game.io?`,
- `,labels[5]=aV.nU[76],labels[6]=aV.nU[77],labels[7]=aV.nU[78],
- labels.push("Max Troops", "Density"), // add labels
- a0Z=game.tn-eT(game.tn,100),(valuesArray=new Array(labels.length))[0]=game.io?`);
- 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(${dict.playerData}.${dict.playerTerritories}, ${playerId}) `
- + `: utils.getDensity(${playerId}) }`);
- // increase the size of the side panel by 25% to make the text easier to read
- replaceOne(/(this\.\w+=Math\.floor\(\(\w+\.\w+\.\w+\(\)\?\.1646:\.126\))\*(\w+\.\w+\),)/g, "$1 * 1.25 * $2");
-}
-
-// Increment win counter on wins
-replaceRawCode(`=function(sE){o.ha(sE,2),b.h9<100?xD(0,aZ.tG(4,[a8.jx[sE]]),3,sE,ad.gN,ad.kl,-1,!0):xD(0,aZ.tG(12,[a8.jx[sE]]),3,sE,ad.gN,ad.kl,-1,!0),`,
- `=function(sE){
- if (${playerId} === sE && !${gIsSingleplayer})
- wins_counter++, window.localStorage.setItem("fx_winCount", wins_counter),
- xD(0,"Your Win Count is now " + wins_counter,3,sE,ad.gN,ad.kl,-1,!0);
- o.ha(sE,2),b.h9<100?xD(0,aZ.tG(4,[a8.jx[sE]]),3,sE,ad.gN,ad.kl,-1,!0):xD(0,aZ.tG(12,[a8.jx[sE]]),3,sE,ad.gN,ad.kl,-1,!0),`);
-
-
-{ // Add settings button and win count
-// render gear icon and win count
-replaceRawCode(`,fy=aV.nU[80],fontSize=.65*height,canvas.font=aY.g0.g1(1,fontSize),canvas.fillStyle="rgba("+gR+","+tD+","+hj+",0.6)",canvas.fillRect(x,y,width,height),`,
-`,fy=aV.nU[80],fontSize=.65*height,
-canvas.imageSmoothingEnabled = true,
-canvas.drawImage(settingsGearIcon, x - width / 2, y, height, height),
-canvas.imageSmoothingEnabled = false,
-(settings.displayWinCounter && (
- canvas.font = aY.g0.g1(1, Math.floor(height * 0.4)),
- canvas.fillStyle = "#ffffff",
- canvas.fillText("Win count: " + wins_counter, Math.floor(x + width / 2), Math.floor((y + height / 2) * 2))
-)),
-canvas.font=aY.g0.g1(1,fontSize),canvas.fillStyle="rgba("+gR+","+tD+","+hj+",0.6)",canvas.fillRect(x,y,width,height),`);
-
-// handle settings button click
-replaceRawCode(`(q6=Math.floor((b7.cv.fv()?.145:.09)*aK.fw),gap=Math.floor(.065*(b7.cv.fv()?.53:.36)*aK.fw),gap=aK.g5-q6-gap,jd=b0.gap,q6=Math.floor(.35*q6),gap<=mouseX&&mouseY= gap - q6 / 0.7 && mouseY < jd + q6 && WindowManager.openWindow("settings"))
-)`);
-}
-
-{ // Keybinds
- // match required variables
- const { 0: match, groups: { attackBarObject, setRelative } } = matchOne(/:"."===(\w+\.key)\?(?\w+)\.(?\w+)\(31\/32\):"."===\1\?\2\.\3\(32\/31\):/g,);
- // create a setAbsolutePercentage function on the attack percentage bar object,
- // and also register the keybind handler functions
- replaceOne(/}(function \w+\((\w+)\){return!\(1<\2&&1===(?\w+)\|\|\(1<\2&&\2\*\3-\3<1\/1024\?\2=\(\3\+1\/1024\)\/\3:\2<1)/g,
- "} this.setAbsolutePercentage = function(newPercentage) { $ = newPercentage; }; "
- + "keybindFunctions.setAbsolute = this.setAbsolutePercentage; "
- + `keybindFunctions.setRelative = (arg1) => ${attackBarObject}.${setRelative}(arg1); $1`);
- // insert keybind handling code into the keyDown handler function
- replaceOne(new RegExp(/(function \w+\((?\w+)\){)([^}]+matched)/g.source.replace(/matched/g, escapeRegExp(match)), "g"),
- "$1 if (keybindHandler($.key)) return; $3");
-}
-
-// Set the default font to Trebuchet MS
-script = script.replace(/sans-serif"/g, 'Trebuchet MS"');
-
-// Realistic bot names setting
-// matches c4[i] = c4[i].replace(a6U[dx], a6V[dx])
-replaceOne(/(((\w+)\[\w+\])=\2\.replace\(\w+(\[\w+\]),\w+\4\))/g, "$1; if (settings.realisticNames) $3 = realisticNames;")
-
-// Hide all links in main menu depending on settings
-//replaceOne(/(this\.\w+=function\(\){)((\w+\.\w+)\[2\]=\3\[3\]=\3\[4\]=(?!this\.\w+\.\w+),)/g,
-//"$1 if (settings.hideAllLinks) $3[0] = $3[1] = $; else $3[0] = $3[1] = true; $2")
-
-// Make the main canvas context have an alpha channel if a custom background is being used
-replaceOne(/(document\.getElementById\("canvasA"\),\(\w+=\w+\.getContext\("2d",){alpha:!1}/g, "$1 {alpha: makeMainMenuTransparent}")
-// Clear canvas background if a custom background is being used
-replaceOne(/(this\.\w+=function\(\){var (\w+),(\w+);)(\w+\.\w+\?\([^()]+setTransform\(\3=\2<\3\?\3:\2,0,0,\3,(?:Math\.floor\(\([^)]+\)\/2\)[,)]){2},(?:[^)]+\),){2}[^)]+\):(?