exports.name = "res"; exports.description = ":shield: Calculates how much upgrades you need to max your resistances. For Ult pieces and better. (slightly inaccurate but this is hard to calculate)"; exports.usage = "CLIENT_PREFIX:res [res] | [second hero stat]"; exports.example = "CLIENT_PREFIX:res -3 1 -16 14 | 406 440"; exports.hidden = false; exports.run = (client, message, args) => { for (let i = 0; i < args.length; i++) { if (args[i] == "|") continue; args[i] = parseInt(args[i]); if (isNaN(args[i])) message.channel.send( "Unable to parse argument `" + i + 1 + "` as number, try again or report this issue." ); } let type; if (args[4] == "|") type = 4; else if (args[3] == "|") type = 3; else return message.channel.send("Please provide 3 or 4 resistances."); let resistances = [args[0], args[1], args[2], type == 4 ? args[3] : null]; let mainStat = type == 4 ? args[5] : args[4]; let upgrades = type == 4 ? args[6] : args[5]; let substat = type == 4 ? args[7] : args[6]; upgrades = upgrades - 1; if (!mainStat || !upgrades) return message.channel.send("Please provide atleast 2 stats."); if (!substat) substat = 0; let resUpgrades = 0; resistances.forEach((res) => { if (res == null) return; if (res > 29) return message.channel.send( "Please provide a number less than 29 for resistances." ); if (res < 29) { if (res < 0) { let underzero = Math.abs(res); if (underzero < 13) { resUpgrades += 23 + Math.abs(res); } else { if (underzero == 13 || underzero == 14) { resUpgrades += 23 + 13; } if (underzero == 15 || underzero == 16) { resUpgrades += 23 + 13 + 1; } if (underzero == 17 || underzero == 18) { resUpgrades += 23 + 13 + 2; } if (underzero == 19 || underzero == 20 || underzero == 22) { resUpgrades += 23 + 13 + 3; } if (underzero == 21 || underzero == 23) { resUpgrades += 23 + 13 + 4; } if (underzero > 23) { resUpgrades += 29 - underzero; } } // from 1% to 23% takes 17-18 ups // from 23% to 29% takes 6 ups // from 1% to 29% takes 23 ups // 23 + Math.abs(res) } else { //14 skips 15 to 16 //15 skips 16 to 17 //17 skips 18 to 19 //19 skips 20 to 21 //21 skips to 24 // list: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,18,20,23 // possible if 15,17,19,21,24 //amount of numbers: 18 // skipped 5 upgrades //example 4 // 5,6,7,8,9,10,11,12,13,14,16,18,20,23 // count: 14 // to 29% + 6, result 20 if (res < 14) { let am = 14 - res; resUpgrades += am + 4 + 6; } else { if (res == 14) { resUpgrades += 4 + 6; } if (res == 15 || res == 16) { resUpgrades += 3 + 6; } if (res == 17 || res == 18) { resUpgrades += 2 + 6; } if (res == 19 || res == 20 || res == 22) { resUpgrades += 1 + 6; } if (res == 21 || res == 23) { resUpgrades += 6; } if (res > 23) { resUpgrades += 29 - res; } } } } }); upgrades -= resUpgrades; mainStat += upgrades; let over = 0; if (mainStat > 999) { let over = mainStat - 999; mainStat -= over; substat += over; } message.channel.send( `With ${resUpgrades} upgrades spent in resistances, your piece will reach ${ mainStat + substat }, or ${Math.ceil(mainStat * 1.4 + substat * 1.4)} with set bonus!` ); };