Useful code clips

Is this better?


hero.findOpponent = function () {
    for (let enemy of hero.findEnemies()) if (enemy.id.includes("Hero Placeholder")) return enemy;
    return undefined;
};
hero.findData = function (u) {
    let types = {assassin: "Ritic", intellectual: "Armando/Ned", knight: "Tharin", librarian: "Hushbaum", trapper: "Senick", sorcerer: "Pender", goliath: "Okar", duelist: "Alejandro", champion: "Ida", necromancer: "Nalfar", captain: "Anya", samurai: "Hattori", guardian: "Illia", pixie: "Zana"};
    let uData = {hero: types[u.type], type: null};
    if (!(uData.hero)) {
        switch (u.type) {
            case "forest-archer": return {hero: "Naria", type: "Ranger"};
            case "potion-master": return {hero: "Omarn", type: "Wizard"};
            case "master-wizard": return {hero: "Usara", type: "Wizard"};
        }
    }
    u = uData.hero;
    if (u === "Illia" || u === "Anya" || u === "Tharin" || u === "Okar" || u === "Alejandro" || u === "Ida" || u === "Hattori" || u === "Arryn" || u === "Gordon" || u === "Armando/Ned") uData.type = "Warrior";
    if (u === "Zana" || u === "Senick" || u === "Ritic" || u === "Amara") uData.type = "Ranger";
    if (u === "Hushbaum" || u === "Nalfar" || u === "Pender") uData.type = "Wizard";
    return uData;
};

Sorry about the delay :sweat_smile: I had to go to school…