Swarm Simulator Cheat
/**
* No need, LZString is already loaded on swarmsim page
**
var script = document.createElement('script');
script.src = 'https://cdn.rawgit.com/pieroxy/lz-string/master/libs/lz-string.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
*/
var JDCSSC_DELIMITATOR = '|';
var JDCSSC_PREFIX_CHEATER = btoa("Cheater :(\n\n");
var JDCSSC_WATCHED_CONFIG = {
"centipedeprod": 2,
"centipedetwin": 0,
"droneprod": 2,
"dronetwin": 0,
"empressprod": 2,
"empresstwin": 0,
"goddessprod": 2,
"goddesstwin": 0,
"greaterqueenprod": 2,
"greaterqueentwin": 0,
"hiveprod": 2,
"hivetwin": 0,
"hivequeenprod": 2,
"hivequeentwin": 0,
"hiveprod": 2,
"hivetwin": 0,
"nestprod": 2,
"nesttwin": 0,
"overmind2prod": 2,
"overmind2twin": 0,
"overmind3prod": 2,
"overmind3twin": 0,
"overmind4prod": 2,
"overmind4twin": 0,
"overmind5prod": 2,
"overmind5twin": 0,
"overmindprod": 2,
"overmindtwin": 0,
"pantheon2prod": 2,
"pantheon2twin": 0,
"pantheon3prod": 2,
"pantheon3twin": 0,
"pantheon4prod": 2,
"pantheon4twin": 0,
"pantheon5prod": 2,
"pantheon5twin": 0,
"pantheonprod": 2,
"pantheontwin": 0,
"prophetprod": 2,
"prophettwin": 0,
"queenprod": 2,
"queentwin": 0,
"centipedeempower": 0,
"devourerempower": 0,
"giantspiderempower": 0,
"goonempower": 0,
"locustempower": 0,
"mosquitoempower": 0,
"roachempower": 0,
"spiderempower": 0,
"stingerempower": 0,
"swarmlingempower": 0,
"waspempower": 0
};
var swarmSimCheat = {
version: '',
data: {},
importSave: function () {
var saveInput;
var currentHash = window.location.hash;
// Go on "Options" page
window.location.hash = '/options';
saveInput = document.getElementById('export');
// One retry
if (typeof saveInput === 'undefined' || saveInput === null || !saveInput) {
setTimeout(function () {
saveInput = document.getElementById('export');
}, 500);
}
this.data = this.decodeSave(saveInput.value, true);
// Return on current tab
window.location.hash = currentHash;
},
sendSave: function () {
var saveInput;
var currentHash = window.location.hash;
// Go on "Options" page
//document.querySelector('ul.nav.nav-tabs li.dropdown a').click();
window.location.hash = '/options';
saveInput = document.getElementById('export');
// One retry
if (typeof saveInput === 'undefined' || saveInput === null || !saveInput) {
setTimeout(function () {
saveInput = document.getElementById('export');
}, 500);
}
saveInput.value = this.encodeSave(true);
// Fire onchange event
if ("createEvent" in document) {
var evt = document.createEvent("HTMLEvents");
evt.initEvent("change", false, true);
saveInput.dispatchEvent(evt);
}
else {
saveInput.fireEvent("onchange");
}
// Return on current tab
window.location.hash = currentHash;
},
viewAllData: function (stringify) {
if (stringify) {
return JSON.stringify(this.data, null, 2);
} else {
return this.data;
}
},
viewUnits: function (stringify) {
if (stringify) {
return JSON.stringify(this.data.unittypes, null, 2);
} else {
return this.data.unittypes;
}
},
viewStatistics: function (stringify) {
if (stringify) {
return JSON.stringify(this.data.statistics, null, 2);
} else {
return this.data.statistics;
}
},
viewAchievements: function (stringify) {
if (stringify) {
return JSON.stringify(this.data.achievements, null, 2);
} else {
return this.data.achievements;
}
},
viewOptions: function (stringify) {
if (stringify) {
return JSON.stringify(this.data.options, null, 2);
} else {
return this.data.options;
}
},
viewWatched: function (stringify) {
if (stringify) {
return JSON.stringify(this.data.watched, null, 2);
} else {
return this.data.watched;
}
},
addUnitsInteger: function (type, amount) {
var quantity = parseInt(this.data.unittypes[type]);
this.data.unittypes[type] = quantity + amount;
},
addUnitsFloat: function (type, amount) {
var quantity = parseFloat(this.data.unittypes[type]);
this.data.unittypes[type] = quantity + amount;
},
setCustomWatched: function () {
this.data.watched = JDCSSC_WATCHED_CONFIG;
},
decodeSave: function (originalSavedGame, json) {
var split, encoded, decoded;
split = originalSavedGame.split(JDCSSC_DELIMITATOR);
this.version = atob(split[0]);
encoded = split[1].substring(JDCSSC_PREFIX_CHEATER.length);
decoded = LZString.decompressFromBase64(encoded.trim());
if (json) {
return JSON.parse(decoded);
} else {
return decoded;
}
},
encodeSave: function (json) {
var newSavedGame = '',
decoded;
if (json) {
decoded = JSON.stringify(this.data);
} else {
decoded = this.data;
}
newSavedGame += btoa(this.version);
newSavedGame += JDCSSC_DELIMITATOR;
newSavedGame += JDCSSC_PREFIX_CHEATER;
newSavedGame += LZString.compressToBase64(decoded);
return newSavedGame;
}
};