From 1ffc0a89be42fcde95a04a87cc00dbc347b27ece Mon Sep 17 00:00:00 2001 From: Ninjune Date: Wed, 7 Dec 2022 21:36:53 -0600 Subject: v1.7.0 --- commands/calculate/calcSpeed.js | 47 +++++++++++++++++++++++++++++ commands/calculate/calculate.js | 36 ++++++++++++++++++++++ commands/calculate/hotmCalc.js | 55 ++++++++++++++++++++++++++++++++++ commands/calculate/tick.js | 66 +++++++++++++++++++++++++++++++++++++++++ commands/credits.js | 7 +++++ commands/help.js | 10 +++---- commands/spiral.js | 2 +- commands/throne.js | 2 +- commands/tick.js | 64 --------------------------------------- 9 files changed, 218 insertions(+), 71 deletions(-) create mode 100644 commands/calculate/calcSpeed.js create mode 100644 commands/calculate/calculate.js create mode 100644 commands/calculate/hotmCalc.js create mode 100644 commands/calculate/tick.js create mode 100644 commands/credits.js delete mode 100644 commands/tick.js (limited to 'commands') diff --git a/commands/calculate/calcSpeed.js b/commands/calculate/calcSpeed.js new file mode 100644 index 0000000..1b2eae6 --- /dev/null +++ b/commands/calculate/calcSpeed.js @@ -0,0 +1,47 @@ +import constants from "../../util/constants" +import { parseNotatedInput } from "../../util/helperFunctions" +const PREFIX = constants.PREFIX + + +export function calcSpeed(powder) +{ + let speedLevels = 1, + professionalLevels = 1 + + if(powder == undefined || parseNotatedInput(powder) == "NI") return ChatLib.chat(constants.CALCULATEERRORMESSAGE) + powder = parseNotatedInput(powder) + + while(powder > msPowder(speedLevels) + profPowder(professionalLevels)) + { + if(ms2SpeedPerPowder(speedLevels + 1) > professionalSpeedPerPowder(professionalLevels + 1) && speedLevels < 50) + { + powder -= msPowder(speedLevels++) + } + else if (professionalLevels < 140) + { + powder -= profPowder(professionalLevels++) + } + else break + } + return ChatLib.chat(`&bGet &6&l${speedLevels} &bmining speed levels and &6&l${professionalLevels} &bprofessional levels.`) +} + +function ms2SpeedPerPowder(miningSpeedLevel) // 40 speed per level +{ + return 40/msPowder(miningSpeedLevel) +} + +function professionalSpeedPerPowder(professionalLevel) // 5 speed per level +{ + return 5/profPowder(professionalLevel) +} + +function msPowder(miningSpeedLevel) +{ + return Math.floor(Math.pow(miningSpeedLevel+1, 3.2)) +} + +function profPowder(professionalLevel) +{ + return Math.floor(Math.pow(professionalLevel+1, 2.3)) +} \ No newline at end of file diff --git a/commands/calculate/calculate.js b/commands/calculate/calculate.js new file mode 100644 index 0000000..cc4a006 --- /dev/null +++ b/commands/calculate/calculate.js @@ -0,0 +1,36 @@ +import constants from "../../util/constants" +import { hotmCalc } from "./hotmCalc" +import { calcSpeed } from "./calcSpeed" +import { tick } from "./tick" +import { helpCommand } from "../help" +const PREFIX = constants.PREFIX + + +export function calculate(args) +{ + switch(args[0].toLowerCase()) + { + case "hotm": + case "hotmcalc": + case "calchotm": + hotmCalc(args[1], args[2], args[3]) + break + case "tick": + tick(args[1], args[2]) + break + case "calcspeed": + case "speed": + calcSpeed(args[1]) + break + case "help": + ChatLib.chat("&b--------------[ &a&l/cw calculate &b]--------------") + helpCommand("calculate tick", "Calculates tick data.", "(mining speed) (('r','jade', etc) || breaking power of block))") + helpCommand("calculate speed", "Calculates the ratio of mining speed 2 to professional with a certain amount of powder.", "(powder)") + helpCommand("calculate hotm", "Calculates powder between two levels of a certain perk.", "(perk) (minlevel) [maxlevel]") + ChatLib.chat("&b------------------------------------------") + return + default: + return ChatLib.chat(constants.CALCULATEERRORMESSAGE) + } +} + diff --git a/commands/calculate/hotmCalc.js b/commands/calculate/hotmCalc.js new file mode 100644 index 0000000..415e7f4 --- /dev/null +++ b/commands/calculate/hotmCalc.js @@ -0,0 +1,55 @@ +import constants from "../../util/constants" +import { addCommas } from "../../util/helperFunctions" +const PREFIX = constants.PREFIX + + +export function hotmCalc(hotmName, minLevel, maxLevel) +{ + if(maxLevel == undefined) + { + maxLevel = minLevel + minLevel = 1 + } + + if(minLevel != parseInt(minLevel) || maxLevel != parseInt(maxLevel)) return ChatLib.chat(constants.CALCULATEERRORMESSAGE) + + minLevel = parseInt(minLevel) + maxLevel = parseInt(maxLevel) + let hotmObjectToFind = findHotmObject(hotmName) + if(hotmObjectToFind == undefined) return ChatLib.chat(`${PREFIX}&cDid not find HOTM perk with name '${hotmName}'!`) + + maxLevel = (maxLevel < hotmObjectToFind.maxLevel ? maxLevel : hotmObjectToFind.maxLevel) + + let powderSum = findCost(hotmObjectToFind.costFormula, minLevel, maxLevel), + reward = findReward(hotmObjectToFind.rewardFormula, minLevel, maxLevel) + + ChatLib.chat("") + ChatLib.chat(`&6${hotmObjectToFind.nameStringed} ${minLevel} - ${maxLevel} &bwill cost &6&l${addCommas(Math.round(powderSum))} &6${hotmObjectToFind.powderType[0].toUpperCase() + hotmObjectToFind.powderType.slice(1)} &bpowder.`) + ChatLib.chat(`&6${hotmObjectToFind.nameStringed} ${minLevel} - ${maxLevel} &bwill give &6&l${addCommas(Math.round(reward * 100) / 100)} &bof whatever reward is listed.`) + ChatLib.chat("") +} + +export function findHotmObject(hotmName) +{ + let hotmData = JSON.parse(FileLib.read("Coleweight", "data/hotm.json")).data + + for(let i = 0; i < hotmData.length; i++) + { + if(hotmData[i].names.includes(hotmName)) + return hotmData[i] + } +} + +export function findCost(costFormula, minLevel, maxLevel) +{ + let powderSum = 0 + + for(let currentLevel = minLevel; currentLevel < maxLevel; currentLevel++) // finds cost + powderSum += eval(costFormula.replace("currentLevel", currentLevel)) + return powderSum +} + +export function findReward(rewardFormula, minLevel, maxLevel) +{ + return eval(rewardFormula.replace("Level", 1+maxLevel-minLevel)) +} \ No newline at end of file diff --git a/commands/calculate/tick.js b/commands/calculate/tick.js new file mode 100644 index 0000000..5969710 --- /dev/null +++ b/commands/calculate/tick.js @@ -0,0 +1,66 @@ +import constants from "../../util/constants" +const PREFIX = constants.PREFIX + +export function tick(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) + let strength = findStrength(block) + if(strength < 1) return ChatLib.chat(`${PREFIX}&cBlock must be a gemstone or positive breaking power! (or starting letter of gemstone)`) + let currentBlockTick = strength*30/speed, + currentShardTick = (strength-200)*30/speed, + nextBlockSpeed, nextShardSpeed + + if(currentBlockTick < Math.floor(currentBlockTick) + 0.5) + nextBlockSpeed = strength*30/(Math.floor(currentBlockTick)-0.5) + else + nextBlockSpeed = strength*30/(Math.floor(currentBlockTick)+0.5) + + if(currentShardTick < Math.floor(currentShardTick) + 0.5) + nextShardSpeed = strength*30/(Math.floor(currentShardTick)-0.5) + else + nextShardSpeed = strength*30/(Math.floor(currentShardTick)+0.5) + + ChatLib.chat(`\n&bCurrently mining blocks in &6&l${Math.round(currentBlockTick)} ticks` + + `\n&bCurrently mining shards in &6&l${Math.round(currentShardTick)} ticks` + + `\n&bNext block tick will be at: &6&l${Math.round(nextBlockSpeed)} mining speed` + + `\n&bNext shard tick will be at: &6&l${Math.round(nextShardSpeed)} mining speed` + + `\n&bYou need &6&l${Math.round(nextBlockSpeed - speed)} mining speed&b to get the next block tick.` + + `\n&bYou need &6&l${Math.round(nextShardSpeed - speed)} mining speed&b to get the next shard tick.\n`) +} + +function findStrength(block) +{ + let strength = -1 + + if(block == parseInt(block)) + strength = block + else + { + switch(block.toLowerCase()) + { + case "ruby": + case "r": + strength = 2500 + break + case "j": + case "jade": + case "a": + case "amber": + case "amethyst": + case "s": + case "sapphire": + strength = 3200 + break + case "t": + case "topaz": + case "o": + case "opal": + strength = 4000 + } + } + + return strength +} diff --git a/commands/credits.js b/commands/credits.js new file mode 100644 index 0000000..af4aa28 --- /dev/null +++ b/commands/credits.js @@ -0,0 +1,7 @@ +import constants from "../util/constants" +const PREFIX = constants.PREFIX + +export function credits() +{ + ChatLib.chat(`${PREFIX}&bCW was made by Ninjune#0670 (NinOnCubed).`) +} \ No newline at end of file diff --git a/commands/help.js b/commands/help.js index 05c5a04..8e06b51 100644 --- a/commands/help.js +++ b/commands/help.js @@ -7,14 +7,15 @@ export function help() helpCommand("", "Gets Coleweight of specified user", "(username)") helpCommand("help", "This menu.", "") helpCommand("time", "Prints time on timer (timer gui doesn't have to be visible).", "") - helpCommand("tick", "Shows tick data.", "(mining speed) (('r','jade', etc) || breaking power of block))") + helpCommand("calculate", "Calculates things. '/cw calculate help' for more info.", "") helpCommand("leaderboard", "Shows leaderboard.", "(min) [max]") helpCommand("info", "Prints coleweight info.", "") ChatLib.chat(ChatLib.getCenteredText("&a&lSettings")) helpCommand("settings", "Opens settings.", "") helpCommand("claim", "Claims a chollows sapphire structure in a lobby.", "(throne || spiral)") - helpCommand("setkey", "Sets API key (can also use /api new)-", "(key)") + helpCommand("setkey", "Sets API key (can also use /api new)", "(key)") helpCommand("reload", "Reloads the gui.", "") + helpCommand("track", "Sets tracked collection for collection tracker.", "(collection)") ChatLib.chat(ChatLib.getCenteredText("&a&lWaypoints")) helpCommand("coords", "Opens coords gui.", "") helpCommand("throne", "Guide for setting up waypoints for throne.", "[toggle]") @@ -27,8 +28,7 @@ export function help() } // Made by Almighty Stylla <3 -function helpCommand(command, desc, usage) +export function helpCommand(command, desc, usage) { ChatLib.chat(new TextComponent(`&a${PREFIX} /cw ${command} => &b${desc}`).setHoverValue(`${"/cw " + command + " " + usage}`)) -} - +} \ No newline at end of file diff --git a/commands/spiral.js b/commands/spiral.js index 6574f18..f9f00aa 100644 --- a/commands/spiral.js +++ b/commands/spiral.js @@ -45,7 +45,7 @@ export function spiral(arg2) } register("renderWorld", () => { - waypointRender(spiralWaypoints, true) + waypointRender(spiralWaypoints, true, true) }) register("worldLoad", () => { diff --git a/commands/throne.js b/commands/throne.js index 517c93d..c3a2e1c 100644 --- a/commands/throne.js +++ b/commands/throne.js @@ -41,7 +41,7 @@ export function throne(arg2) register("renderWorld", () => { - waypointRender(throneWaypoints, true) + waypointRender(throneWaypoints, true, true) }) diff --git a/commands/tick.js b/commands/tick.js deleted file mode 100644 index 7af81e2..0000000 --- a/commands/tick.js +++ /dev/null @@ -1,64 +0,0 @@ -import constants from "../util/constants" -const PREFIX = constants.PREFIX - -export function tick(speed, block) -{ - if(speed == undefined || parseInt(speed) != speed) - return `${PREFIX}&cMining speed must be an integer!` - let strength = findStrength(block) - if(strength < 1) return `${PREFIX}&cBlock must be a gemstone or positive breaking power! (or starting letter of gemstone)` - let currentBlockTick = strength*30/speed, - currentShardTick = (strength-200)*30/speed, - nextBlockSpeed, nextShardSpeed - - if(currentBlockTick < Math.floor(currentBlockTick) + 0.5) - nextBlockSpeed = strength*30/(Math.floor(currentBlockTick)-0.5) - else - nextBlockSpeed = strength*30/(Math.floor(currentBlockTick)+0.5) - - if(currentShardTick < Math.floor(currentShardTick) + 0.5) - nextShardSpeed = strength*30/(Math.floor(currentShardTick)-0.5) - else - nextShardSpeed = strength*30/(Math.floor(currentShardTick)+0.5) - - ChatLib.chat(`\n&bCurrently mining blocks in &6&l${Math.round(currentBlockTick)} ticks` + - `\n&bCurrently mining shards in &6&l${Math.round(currentShardTick)} ticks` + - `\n&bNext block tick will be at: &6&l${Math.round(nextBlockSpeed)} mining speed` + - `\n&bNext shard tick will be at: &6&l${Math.round(nextShardSpeed)} mining speed` + - `\n&bYou need &6&l${Math.round(nextBlockSpeed - speed)} mining speed&b to get the next block tick.` + - `\n&bYou need &6&l${Math.round(nextShardSpeed - speed)} mining speed&b to get the next shard tick.\n`) -} - -function findStrength(block) -{ - let strength = -1 - - if(block == parseInt(block)) - strength = block - else - { - switch(block.toLowerCase()) - { - case "ruby": - case "r": - strength = 2500 - break - case "j": - case "jade": - case "a": - case "amber": - case "amethyst": - case "s": - case "sapphire": - strength = 3200 - break - case "t": - case "topaz": - case "o": - case "opal": - strength = 4000 - } - } - - return strength -} -- cgit