Number 1: Object to String converter:
Python:
def strObj (obj):
str = "{"
for t in obj: str = str + t + ": " + obj[t] + ", "
return str.substring(0, str.length - 2) + "}"
Javascript:
function strObj (obj) {
let str = "{";
for (let t in obj) str = str + t + ": " + obj[t] + ", ";
return str.substring(0, str.length - 2) + "}";
}
Number 2: hero type detector (useful in dueling grounds or stuff like that)
Python:
I’m too lazy to type it, just use a converter, lol.
Javascript:
hero.findOpponent = function () {
for (let enemy of hero.findEnemies()) if (enemy.id.includes("Hero Placeholder")) return enemy;
return undefined;
};
hero.findData = function (u) {
let unit = u;
var unitData = {hero: null, type: null};
switch (unit.type) {
case "assassin":
unitData.hero = "Ritic";
break;
case "intellect":
unitData.hero = "Armando";
break;
case "librarian":
unitData.hero = "Hushbaum";
break;
case "trapper":
unitData.hero = "Senick";
break;
case "knight":
unitData.hero = "Tharin";
break;
case "sorcerer":
unitData.hero = "Pender";
break;
case "goliath":
unitData.hero = "Okar";
break;
case "duelist":
unitData.hero = "Alejandro";
break;
case "champion":
unitData.hero = "Ida";
break;
case "necromancer":
unitData.hero = "Nalfar";
break;
case "captain":
unitData.hero = "Anya";
break;
case "samurai":
unitData.hero = "Hattori";
break;
case "guardian":
unitData.hero = "Illia";
break;
case "pixie":
unitData.hero = "Zana";
break;
case "forest-archer":
unitData.hero = "Naria";
break;
case "potion-master":
unitData.hero = "Omarn";
break;
case "master-wizard":
unitData.hero = "Usara";
break;
}
unit = unitData.hero;
if (unit === "Illia" || unit === "Anya" || unit === "Tharin" || unit === "Okar" || unit === "Alejandro" || unit === "Ida" || unit === "Hattori" || unit === "Armando" || unit === "Arryn" || unit === "Gordon") unitData.type = "warrior";
if (unit === "Zana" || unit === "Senick" || unit === "Ritic" || unit === "Naria" || unit === "Amara") unitData.type = "ranger";
if (unit === "Usara" || unit === "Hushbaum" || unit === "Nalfar" || unit === "Pender" || unit === "Omarn") unitData.type = "wizard";
return unitData;
// IKR, I had to write all of that. xD
};
If these simple code clips that don’t solve any levels aren’t allowed, please let me know.
Also, just a side note: don’t ask how I formatted Javascript code properly