1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
import constants from "../../util/constants"
import { addCommas } from "../../util/helperFunctions"
const PREFIX = constants.PREFIX
export function hotmCalc(hotmName, minLevel, maxLevel)
{
if(hotmName == undefined)
{
let hotmData = JSON.parse(FileLib.read("Coleweight", "data/hotm.json")).data
ChatLib.chat(`/cw calc hotm (hotmName listed below) (minLevel) [maxLevel]`)
for(let i = 0; i < hotmData.length; i++)
{
ChatLib.chat(hotmData[i].names[0])
}
return
}
new Thread(() => {
if(maxLevel == undefined)
{
maxLevel = minLevel
minLevel = 2
}
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,
reward = findReward(hotmObjectToFind.rewardFormula, minLevel, maxLevel)
if(hotmObjectToFind.names[0] == "fortunate")
powderSum = findCost(undefined, minLevel, maxLevel, true)
else
powderSum = findCost(hotmObjectToFind.costFormula, 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("")
}).start()
}
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.toLowerCase()))
return hotmData[i]
}
}
export function findCost(costFormula, minLevel, maxLevel, fortunate = false)
{
let powderSum = 0
if(fortunate)
powderSum = Math.pow(maxLevel+1, 3.05)
else
{
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", 2+maxLevel-minLevel))
}
|