aboutsummaryrefslogtreecommitdiff
path: root/commands/calculate/tick.js
diff options
context:
space:
mode:
authorNinjune x <enderknight537@gmail.com>2022-12-13 20:47:42 -0600
committerNinjune x <enderknight537@gmail.com>2022-12-13 20:47:42 -0600
commit1891ada92ab1911cfaaa7ad0e72c85573f4fcbb6 (patch)
tree2b6a36efccdade45d14a79a608b8dc6026fa3805 /commands/calculate/tick.js
parentad055ba90a3055db32f04ff5163ff4e1c85dfdfa (diff)
downloadcoleweight-1891ada92ab1911cfaaa7ad0e72c85573f4fcbb6.tar.gz
coleweight-1891ada92ab1911cfaaa7ad0e72c85573f4fcbb6.tar.bz2
coleweight-1891ada92ab1911cfaaa7ad0e72c85573f4fcbb6.zip
v1.8.0
Diffstat (limited to 'commands/calculate/tick.js')
-rw-r--r--commands/calculate/tick.js93
1 files changed, 93 insertions, 0 deletions
diff --git a/commands/calculate/tick.js b/commands/calculate/tick.js
new file mode 100644
index 0000000..f8b2433
--- /dev/null
+++ b/commands/calculate/tick.js
@@ -0,0 +1,93 @@
+import constants from "../../util/constants"
+const PREFIX = constants.PREFIX
+
+export function tickCommand(speed, block)
+{
+ if(speed == undefined || parseInt(speed) != speed)
+ return ChatLib.chat(`${PREFIX}&cMining speed must be an integer!`)
+ if(block == undefined)
+ return ChatLib.chat(constants.CALCULATEERRORMESSAGE)
+ const ticks = findTick(speed, block)
+ if(ticks.err) return ChatLib.chat(`${PREFIX}&cBlock must be a gemstone or positive breaking power! (or starting letter of gemstone)`)
+
+
+ ChatLib.chat(`\n&bCurrently mining blocks in &6&l${Math.round(ticks.currentBlockTick)} ticks` +
+ `\n&bCurrently mining shards in &6&l${Math.round(ticks.currentShardTick)} ticks` +
+ `\n&bNext block tick will be at: &6&l${Math.round(ticks.nextBlockSpeed)} mining speed` +
+ `\n&bNext shard tick will be at: &6&l${Math.round(ticks.nextShardSpeed)} mining speed` +
+ `\n&bYou need &6&l${Math.round(ticks.nextBlockSpeed - speed)} mining speed&b to get the next block tick.` +
+ `\n&bYou need &6&l${Math.round(ticks.nextShardSpeed - speed)} mining speed&b to get the next shard tick.\n`)
+}
+
+
+export function findTick(speed, block)
+{
+ let ticks = {err: false},
+ strength = findStrength(block)
+
+ ticks.currentBlockTick = strength*30/speed
+ ticks.currentShardTick = (strength-200)*30/speed
+
+ if(strength < 1) return ticks.err = true
+
+
+ if(ticks.currentBlockTick < Math.floor(ticks.currentBlockTick) + 0.5)
+ ticks.nextBlockSpeed = strength*30/(Math.floor(ticks.currentBlockTick)-0.5)
+ else
+ ticks.nextBlockSpeed = strength*30/(Math.floor(ticks.currentBlockTick)+0.5)
+
+ if(ticks.currentShardTick < Math.floor(ticks.currentShardTick) + 0.5)
+ ticks.nextShardSpeed = strength*30/(Math.floor(ticks.currentShardTick)-0.5)
+ else
+ ticks.nextShardSpeed = strength*30/(Math.floor(ticks.currentShardTick)+0.5)
+
+ return ticks
+}
+
+function findStrength(block)
+{
+ let strength = -1
+
+ if(block == parseInt(block) && block > 5) // change if add block to tick speed blocks in settings
+ strength = block
+ else
+ {
+ switch(block.toString().toLowerCase())
+ {
+ case "0":
+ case "green_mithril":
+ strength = 800
+ break
+ case "1":
+ case "blue_mithril":
+ strength = 1500
+ break
+ case "2":
+ case "ruby":
+ case "r":
+ strength = 2500
+ break
+ case "3":
+ case "j":
+ case "jade":
+ case "a":
+ case "amber":
+ case "amethyst":
+ case "s":
+ case "sapphire":
+ strength = 3200
+ break
+ case "4":
+ case "t":
+ case "topaz":
+ case "o":
+ case "opal":
+ strength = 4000
+ case "5":
+ case "jasper":
+ strength = 5000
+ }
+ }
+
+ return strength
+}