Replaced clang format with prettuier (sadly)
This commit is contained in:
@@ -10,7 +10,7 @@ const hypixel = "https://api.hypixel.net/player"
|
||||
const guild = "https://api.hypixel.net/guild"
|
||||
const minotar = "https://minotar.net/helm/"
|
||||
|
||||
async function getUUID(ign: string): Promise<string|null> {
|
||||
async function getUUID(ign: string): Promise<string | null> {
|
||||
try {
|
||||
const req: Profile = await fetch(mojang + ign)
|
||||
return req.data.id
|
||||
@@ -19,7 +19,7 @@ async function getUUID(ign: string): Promise<string|null> {
|
||||
}
|
||||
}
|
||||
|
||||
async function getIGN(uuid: string): Promise<string|null> {
|
||||
async function getIGN(uuid: string): Promise<string | null> {
|
||||
try {
|
||||
const req: Profile2 = await fetch(mojanguuid + uuid)
|
||||
return req.data.name
|
||||
@@ -28,12 +28,12 @@ async function getIGN(uuid: string): Promise<string|null> {
|
||||
}
|
||||
}
|
||||
|
||||
async function getPlayer(uuid: string): Promise<PlayerData|null> {
|
||||
async function getPlayer(uuid: string): Promise<PlayerData | null> {
|
||||
const playerReq: Player = await fetch(hypixel, {
|
||||
params: {
|
||||
key: apikey,
|
||||
uuid: uuid
|
||||
}
|
||||
uuid: uuid,
|
||||
},
|
||||
})
|
||||
|
||||
if (!playerReq.data.player) {
|
||||
@@ -43,14 +43,17 @@ async function getPlayer(uuid: string): Promise<PlayerData|null> {
|
||||
return playerReq.data.player
|
||||
}
|
||||
|
||||
async function getGuild(query: string, type?: string): Promise<GuildData|null> {
|
||||
async function getGuild(
|
||||
query: string,
|
||||
type?: string,
|
||||
): Promise<GuildData | null> {
|
||||
const reqType = type ? type : "player"
|
||||
|
||||
const guildReq: Guild = await fetch(guild, {
|
||||
params: {
|
||||
key: apikey,
|
||||
[reqType]: query
|
||||
}
|
||||
[reqType]: query,
|
||||
},
|
||||
})
|
||||
|
||||
if (!guildReq.data.guild) {
|
||||
@@ -60,14 +63,8 @@ async function getGuild(query: string, type?: string): Promise<GuildData|null> {
|
||||
return guildReq.data.guild
|
||||
}
|
||||
|
||||
async function getHeadURL(ign: string): Promise<string|null> {
|
||||
async function getHeadURL(ign: string): Promise<string | null> {
|
||||
return minotar + ign
|
||||
}
|
||||
|
||||
export {
|
||||
getUUID,
|
||||
getIGN,
|
||||
getPlayer,
|
||||
getGuild,
|
||||
getHeadURL
|
||||
}
|
||||
export { getUUID, getIGN, getPlayer, getGuild, getHeadURL }
|
||||
|
||||
@@ -10,14 +10,14 @@ function getExpForLevel(level: number): number {
|
||||
}
|
||||
|
||||
switch (respectedLevel) {
|
||||
case 1:
|
||||
return 500
|
||||
case 2:
|
||||
return 1000
|
||||
case 3:
|
||||
return 2000
|
||||
case 4:
|
||||
return 3500
|
||||
case 1:
|
||||
return 500
|
||||
case 2:
|
||||
return 1000
|
||||
case 3:
|
||||
return 2000
|
||||
case 4:
|
||||
return 3500
|
||||
}
|
||||
return 5000
|
||||
}
|
||||
@@ -25,8 +25,7 @@ function getExpForLevel(level: number): number {
|
||||
function getLevelRespectingPrestige(level: number): number {
|
||||
if (level > HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE) {
|
||||
return level - HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return level % LEVELS_PER_PRESTIGE
|
||||
}
|
||||
}
|
||||
@@ -39,7 +38,7 @@ const HIGHEST_PRESTIGE = 50
|
||||
function bedwarsLevel(exp: number): number {
|
||||
const prestiges = Math.floor(exp / XP_PER_PRESTIGE)
|
||||
let level = prestiges * LEVELS_PER_PRESTIGE
|
||||
let expWithoutPrestiges = exp - (prestiges * XP_PER_PRESTIGE)
|
||||
let expWithoutPrestiges = exp - prestiges * XP_PER_PRESTIGE
|
||||
|
||||
for (let i = 1; i <= EASY_LEVELS; ++i) {
|
||||
const expForEasyLevel = getExpForLevel(i)
|
||||
@@ -52,4 +51,4 @@ function bedwarsLevel(exp: number): number {
|
||||
return level + expWithoutPrestiges / 5000
|
||||
}
|
||||
|
||||
export { bedwarsLevel }
|
||||
export { bedwarsLevel }
|
||||
|
||||
@@ -3,21 +3,8 @@
|
||||
*/
|
||||
function guildLevel(exp: number): number {
|
||||
const EXP_NEEDED = [
|
||||
100000,
|
||||
150000,
|
||||
250000,
|
||||
500000,
|
||||
750000,
|
||||
1000000,
|
||||
1250000,
|
||||
1500000,
|
||||
2000000,
|
||||
2500000,
|
||||
2500000,
|
||||
2500000,
|
||||
2500000,
|
||||
2500000,
|
||||
3000000,
|
||||
100000, 150000, 250000, 500000, 750000, 1000000, 1250000, 1500000,
|
||||
2000000, 2500000, 2500000, 2500000, 2500000, 2500000, 3000000,
|
||||
]
|
||||
|
||||
let level = 0
|
||||
@@ -28,13 +15,15 @@ function guildLevel(exp: number): number {
|
||||
let need = 0
|
||||
if (i >= EXP_NEEDED.length) {
|
||||
need = EXP_NEEDED[EXP_NEEDED.length - 1]
|
||||
} else { need = EXP_NEEDED[i] }
|
||||
} else {
|
||||
need = EXP_NEEDED[i]
|
||||
}
|
||||
|
||||
// If the required exp to get to the next level isn't met returns
|
||||
// the current level plus progress towards the next (unused exp/need)
|
||||
// Otherwise increments the level and substracts the used exp from exp var
|
||||
if ((exp - need) < 0) {
|
||||
return Math.round((level + (exp / need)) * 100) / 100
|
||||
if (exp - need < 0) {
|
||||
return Math.round((level + exp / need) * 100) / 100
|
||||
}
|
||||
level += 1
|
||||
exp -= need
|
||||
@@ -49,9 +38,11 @@ function guildLevel(exp: number): number {
|
||||
*/
|
||||
function scaledGEXP(input: number): number {
|
||||
if (input <= 200000) return Number(input)
|
||||
if (input <= 700000) return Number(Math.round(((input - 200000) / 10) + 200000))
|
||||
if (input > 700000) return Number(Math.round(((input - 700000) / 33) + 250000))
|
||||
if (input <= 700000)
|
||||
return Number(Math.round((input - 200000) / 10 + 200000))
|
||||
if (input > 700000)
|
||||
return Number(Math.round((input - 700000) / 33 + 250000))
|
||||
return 0
|
||||
}
|
||||
|
||||
export { guildLevel, scaledGEXP }
|
||||
export { guildLevel, scaledGEXP }
|
||||
|
||||
@@ -9,7 +9,13 @@ const REVERSE_CONST = REVERSE_PQ_PREFIX * REVERSE_PQ_PREFIX
|
||||
const GROWTH_DIVIDES_2 = 2 / GROWTH
|
||||
|
||||
function getLevel(exp: number): number {
|
||||
return exp <= 1 ? 1 : Math.floor(1 + REVERSE_PQ_PREFIX + Math.sqrt(REVERSE_CONST + GROWTH_DIVIDES_2 * exp))
|
||||
return exp <= 1
|
||||
? 1
|
||||
: Math.floor(
|
||||
1 +
|
||||
REVERSE_PQ_PREFIX +
|
||||
Math.sqrt(REVERSE_CONST + GROWTH_DIVIDES_2 * exp),
|
||||
)
|
||||
}
|
||||
|
||||
function hypixelLevel(exp: number): number {
|
||||
@@ -17,8 +23,8 @@ function hypixelLevel(exp: number): number {
|
||||
}
|
||||
|
||||
function getTotalExpToLevel(level: number): number {
|
||||
const lv = Math.floor(level); const
|
||||
x0 = getTotalExpToFullLevel(lv)
|
||||
const lv = Math.floor(level)
|
||||
const x0 = getTotalExpToFullLevel(lv)
|
||||
if (level === lv) return x0
|
||||
return (getTotalExpToFullLevel(lv + 1) - x0) * (level % 1) + x0
|
||||
}
|
||||
@@ -33,5 +39,4 @@ function getPercentageToNextLevel(exp: number): number {
|
||||
return (exp - x0) / (getTotalExpToLevel(lv + 1) - x0)
|
||||
}
|
||||
|
||||
|
||||
export { hypixelLevel }
|
||||
export { hypixelLevel }
|
||||
|
||||
@@ -19,4 +19,4 @@ function skywarsLevel(xp: number): number {
|
||||
return 0
|
||||
}
|
||||
|
||||
export { skywarsLevel }
|
||||
export { skywarsLevel }
|
||||
|
||||
@@ -2,4 +2,4 @@ function formatUuid(uuid: string): string {
|
||||
return uuid.replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5")
|
||||
}
|
||||
|
||||
export { formatUuid }
|
||||
export { formatUuid }
|
||||
|
||||
Reference in New Issue
Block a user