diff --git a/commands/bonus.js b/commands/bonus.js index 6ad439a..a3f789f 100644 --- a/commands/bonus.js +++ b/commands/bonus.js @@ -1,13 +1,19 @@ exports.name = "bonus"; exports.description = ":star: Sums and calculates bonus for player stat numbers."; -exports.usage = "< [inf optional extra numbers]"; -exports.example = "< [inf optional extra numbers]"; +exports.example = "CLIENT_PREFIX:bonus 100 100"; exports.hidden = false; exports.run = (client, message, args) => { let is1nan = false; if (!args[0]) - return message.channel.send("Not enough arguments, consult < { if (isNaN(parseInt(arg))) { is1nan = true; @@ -16,7 +22,10 @@ exports.run = (client, message, args) => { }); if (is1nan) return message.channel.send( - "You have provided invalid arguments to this command, please consult < { diff --git a/commands/cat.js b/commands/cat.js index f8153cb..a9547ae 100644 --- a/commands/cat.js +++ b/commands/cat.js @@ -1,16 +1,24 @@ exports.name = "cat"; exports.description = ":cat: Calculates boost for cat."; -exports.usage = "< "; -exports.example = "< { if (!args[0] || !args[1]) - return message.channel.send("Not enough arguments, consult < { if (!args[0] || !args[1]) - return message.channel.send("Not enough arguments, consult < { if (!args[0]) { @@ -139,7 +140,7 @@ exports.run = async (client, message, args) => { tbl += p.returnKeyWord + "\n"; }); return message.channel - .send(`Available items in pricing table:\n\`\`\`\n${tbl}\`\`\`\nFor usage, consult \`< { }); if (!gameValue) { return message.channel.send( - "You didn't include any numbers in your query. Try again or consult `< { @@ -200,6 +204,9 @@ exports.run = async (client, message, args) => { } } else message.channel.send( - "Your query couldn't be matched with anything, please refine your query or reffer to `< 1e-3) { + const f1 = getBeamDamage(x1, totalStats - x1); + const f2 = getBeamDamage(x2, totalStats - x2); + + if (f1 < f2) { + left = x1; + x1 = x2; + x2 = left + phi * (right - left); + } else { + right = x2; + x2 = x1; + x1 = right - phi * (right - left); + } + } + + const hdmg = (left + right) / 2; + const ab2 = totalStats - hdmg; + return { + hdmg: hdmg, + ab2: ab2, + }; +} + +exports.name = "ev"; +exports.description = + ":robot: Calculate how much hero damage/ab2 you should aim for."; +exports.usage = + "CLIENT_PREFIX:ev OR CLIENT_PREFIX:ev "; +exports.example = "CLIENT_PREFIX:ev 6000 5000\nCLIENT_PREFIX:ev 10000"; +exports.hidden = false; +exports.run = (client, message, args) => { + if (!args[0]) + return message.channel.send( + "Not enough arguments, consult CLIENT_PREFIX:help.".replaceAll( + "CLIENT_PREFIX:", + client.prefix + ) + ); + let total = parseInt(args[0]); + if (isNaN(total)) + return message.channel.send( + "One of the arguments is not a number. Consult CLIENT_PREFIX:help.".replaceAll( + "CLIENT_PREFIX:", + client.prefix + ) + ); + if (args[1]) { + if (isNaN(parseInt(args[1]))) { + return message.channel.send( + "One of the arguments is not a number. Consult CLIENT_PREFIX:help.".replaceAll( + "CLIENT_PREFIX:", + client.prefix + ) + ); + } else total += parseInt(args[1]); + } + + const distribution = findOptimalDistribution(total); + + message.channel.send( + `You should aim for **${ + Math.round(distribution.hdmg) - 3 + }** hero damage and **${ + Math.round(distribution.ab2) + 3 + }** ab2. *(approximately)*` + ); +}; diff --git a/commands/hb.js b/commands/hb.js index f83de3f..b3f0e12 100644 --- a/commands/hb.js +++ b/commands/hb.js @@ -27,16 +27,24 @@ function get_damage_multiplier(stat_val) { exports.name = "hb"; exports.description = ":muscle: Calculate hero boost's damage multiplier."; -exports.usage = "<"; -exports.example = "< { if (!args[0]) - return message.channel.send("Not enough arguments, consult < { let embed = new EmbedBuilder(); @@ -12,7 +12,10 @@ exports.run = (client, message, args) => { const cmd = client.commands.get(args[0]); if (!cmd) return message.channel.send( - "Command not found, try `< { embed.addFields( { name: "Usage", - value: cmd.usage, + value: cmd.usage.replaceAll("CLIENT_PREFIX:", client.prefix), }, { name: "Example", - value: cmd.example, + value: cmd.example.replaceAll("CLIENT_PREFIX:", client.prefix), } ); } else { @@ -34,7 +37,10 @@ exports.run = (client, message, args) => { if (cmd.hidden && message.author.id != client.ownerID) return; embed.addFields({ name: cmd.name, - value: cmd.description, + value: cmd.description.replaceAll( + "CLIENT_PREFIX:", + client.prefix + ), }); }); } diff --git a/commands/ms.js b/commands/ms.js index 20e0a09..451b492 100644 --- a/commands/ms.js +++ b/commands/ms.js @@ -1,12 +1,17 @@ exports.name = "ms"; exports.description = ":tada: Calculate moon staff damage taking in to account projectile speed."; -exports.usage = "< [projectile speed]"; -exports.example = "< { if (!args[0] || !args[1]) - return message.channel.send("Not enough arguments, consult < { message.channel.send("Fetching data...").then((m) => { diff --git a/commands/refetch.js b/commands/refetch.js index 1d81e3e..fb47061 100644 --- a/commands/refetch.js +++ b/commands/refetch.js @@ -1,7 +1,7 @@ exports.name = "refetch"; exports.description = ":ninja: Refetch user react data."; -exports.usage = "< { if (message.author.id != client.ownerID) return; diff --git a/commands/res.js b/commands/res.js index 105aa0a..7c0a29f 100644 --- a/commands/res.js +++ b/commands/res.js @@ -2,8 +2,8 @@ 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 = - "< [res] | [second hero stat]"; -exports.example = "< [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++) { diff --git a/commands/tb.js b/commands/tb.js index 521b9ab..0d4883d 100644 --- a/commands/tb.js +++ b/commands/tb.js @@ -28,16 +28,24 @@ function get_damage_multiplier(stat_val) { exports.name = "tb"; exports.description = ":fire: Calculate tower boost's damage multiplier."; -exports.usage = "<"; -exports.example = "< { if (!args[0]) - return message.channel.send("Not enough arguments, consult < { if (err) return console.error(err); @@ -73,8 +74,13 @@ client.on(Events.MessageCreate, async (message) => { const cmd = client.commands.get(command); if (!cmd) return; - - await cmd.run(client, message, args); + try { + await cmd.run(client, message, args); + } catch (e) { + message.channel.send( + "Command " + cmd.name + " exited with an exception: " + e + ); + } }); // Log in to Discord with your client's token diff --git a/old.js b/old.js index 46d783a..6972401 100644 --- a/old.js +++ b/old.js @@ -28,7 +28,7 @@ client.on(Events.MessageCreate, (message) => { return message.channel.send("not implemented."); if (!args[0] || !args[1]) return message.channel.send( - "Not enough arguments, consult < { return message.channel.send("not implemented."); if (!args[0] || !args[1]) return message.channel.send( - "Not enough arguments, consult < { if (command == "ms") { if (!args[0] || !args[1]) return message.channel.send( - "Not enough arguments, consult < { if (command == "cat") { if (!args[0] || !args[1]) return message.channel.send( - "Not enough arguments, consult < { if (command == "bident") { if (!args[0] || !args[1]) return message.channel.send( - "Not enough arguments, consult < { if (command == "cdrag") { if (!args[0] || !args[1] || !args[2]) return message.channel.send( - "Not enough arguments, consult < { embed.addFields( { name: "cat", - value: ":cat: Calculates boost for cat. (< )", + value: ":cat: Calculates boost for cat. (CLIENT_PREFIX:cat )", }, { name: "cdrag", - value: ":dragon: Calculate damage for crystaline dragon taking into account upgrades and additional projectiles. (< )", + value: ":dragon: Calculate damage for crystaline dragon taking into account upgrades and additional projectiles. (CLIENT_PREFIX:cdrag )", }, { name: "cb", - value: ":crossed_swords: Calculate calamity blade damage taking in to account speed. (< [proj speed])", + value: ":crossed_swords: Calculate calamity blade damage taking in to account speed. (CLIENT_PREFIX:cb [proj speed])", }, { name: "bident", - value: ":trident: Calculate bident damage taking in to account speed and charge speed. (< [proj speed] [charge speed])", + value: ":trident: Calculate bident damage taking in to account speed and charge speed. (CLIENT_PREFIX:bident [proj speed] [charge speed])", }, { name: "ms",