Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const INI_COEF = 0.05;
- const attackWeight = 3;
- const coefs = {
- "двойной удар. ": 1.8,
- "колун. ": 1.8,
- "тройной удар. ": 2.7,
- "штурм. ": 1.4,
- "двойной выстрел. ": 2,
- "стрельба без штрафов. ": 1.6
- }
- let creatures = [];
- [...Object.values(obj)].forEach(creature => {
- let coef = 1;
- for (const skill of creature.skills) {
- if (Object.keys(coefs).includes(skill.toLowerCase())) {
- coef *= coefs[skill.toLowerCase()];
- }
- }
- let new_cre = creature
- const [min_dmg, max_dmg] = new_cre.damage.split("-");
- [new_cre.min_dmg, new_cre.max_dmg] = [parseInt(min_dmg), parseInt(max_dmg)];
- ["attack", "defence", "maxinit"].forEach(attr => {
- if (typeof creature[attr] === "string") creature[attr] = creature[attr].match(/\d+/)[0]
- })
- new_cre.practical_hp = 80000 / new_cre.cost * new_cre.maxhealth * (1 + (0.05 * new_cre.defence));
- // new_cre.practical_hp = 80000 / new_cre.cost * new_cre.maxhealth;
- new_cre.practical_dmg = 80000 / new_cre.cost * ((new_cre.min_dmg + new_cre.max_dmg) / 2 * (1 + 0.05 * new_cre.attack) * coef);
- new_cre.hp_plus_dmg = new_cre.practical_hp + new_cre.practical_dmg * attackWeight;
- new_cre.hp_dmg_plus_ini = new_cre.hp_plus_dmg * (1 + (new_cre.maxinit - 10) * INI_COEF);
- new_cre.cost = creature.cost;
- new_cre.index = Object.values(obj).indexOf(creature);
- // if (new_cre.index === 98) console.log(coef);
- creatures.push(new_cre);
- })
- let attribute = "hp_dmg_plus_ini"
- creatures = creatures.filter(cre => cre.shots !== "-");
- // creatures = creatures.filter(cre => cre.speed > 7);
- creatures.sort((a, b) => b[attribute] - a[attribute])
- let list = creatures;
- let string = "";
- for (const cre of list) {
- // if (list.indexOf(cre) > 100) break;
- const row =
- list.indexOf(cre) + " " +
- cre.name + " " +
- "❤️" + " " +
- Math.round(cre.practical_hp) + " " + "||" +
- "⚔️" + " " + Math.round(cre.practical_dmg) + "\n"
- string += row;
- }
- console.log(string);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement