From fdc885cd4d9c64900891634f84b939c04f61e154 Mon Sep 17 00:00:00 2001 From: Nikolay Kharitonov Date: Mon, 1 Jan 2024 01:24:55 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20fix=20JSON=20prototype=20polluti?= =?UTF-8?q?on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DEV-389 --- src/game/game.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/game/game.js b/src/game/game.js index 619ff0b6..856168f7 100644 --- a/src/game/game.js +++ b/src/game/game.js @@ -8,7 +8,9 @@ market = require('./market'), customPrototypes = require('./custom-prototypes'), bindFunction = Function.call.bind(Function.bind), - objectCreate = Object.create; + objectCreate = Object.create, + jsonStringify = JSON.stringify, + jsonParse = JSON.parse; var findCacheFn = { [C.FIND_CREEPS]: (i) => !i.spawning, @@ -165,7 +167,7 @@ progressTotal: Math.pow(gplLevel+1, 2) * 1000 - gplBaseProgress }, market: {}, - resources: JSON.parse(JSON.stringify(runtimeData.user.resources||{})), + resources: jsonParse(jsonStringify(runtimeData.user.resources||{})), getObjectById(id) { return register._objects[id] || null; }, @@ -430,7 +432,7 @@ game.market = register.market = market.make(runtimeData, intents, register); - _.extend(globals, JSON.parse(JSON.stringify(C))); + _.extend(globals, jsonParse(jsonStringify(C))); return game; };