Skip to content

Instantly share code, notes, and snippets.

@llyyr
Created May 14, 2019 22:22
Show Gist options
  • Save llyyr/5426a6bd9e916e010143d41e19714c10 to your computer and use it in GitHub Desktop.
Save llyyr/5426a6bd9e916e010143d41e19714c10 to your computer and use it in GitHub Desktop.
Script for Chiaki Fan Club Discord server
def __truncate(n, decimals=7):
multiplier = 10 ** decimals
return int(n * multiplier) / multiplier
def get_xp_from_lvl(lvl):
return int((5/3) * lvl**3 + (45/2) * lvl**2 + (455/6) * lvl)
def get_lvl_from_xp(xp):
a = 5/3
b = 45/2
c = 455/6
d = xp * -1
f = ((3*(c/a)) - ((b**2)/(a**2)))/3
g = ((2*((b**3)/(a**3))) - ((9*b*c)/(a**2)) + (27*(d/a)))/27
h = (g**2)/4 + (f**3)/27
if h < 0 or h == 0:
#all roots are real aka the the xp input was negative
return
elif f == 0 and g == 0 and h == 0:
#all roots are real and equal, this is impossible with mee6's level equation
return
elif h > 0:
#only one root is real, only result we care about
r = -(g/2) + h**(1/2)
s = r**(1/3)
t = -(g/2) - h**(1/2)
u = t**(1/3)
x1 = (s + u) - (b/(3*a))
#print("Your level is", __truncate(x1))
#print("Your floored level is", __truncate(x1,0))
return int(round(__truncate(x1,0)))
def xp_beautifier(total_xp):
truncate_xp = get_xp_from_lvl(__truncate(get_lvl_from_xp(total_xp),0))
floorlvl_xp = total_xp - truncate_xp
level, xp = get_lvl_from_xp(total_xp), floorlvl_xp
return level, xp
if __name__ == "__main__":
previous = input("What was your last known level?\n")
previous_xp = input("What was your last known XP?\n")
current = input("What is your current level?\n")
current_xp = input("What is your current XP?\n")
current_total_xp = get_xp_from_lvl(int(current)) + int(current_xp)
previous_total_xp = get_xp_from_lvl(int(previous)) + int(previous_xp)
total_xp = previous_total_xp+current_total_xp
level, xp = xp_beautifier(total_xp)
print("Your current level is " + str(level) + " and leftover XP is " + str(xp) + ".")
if level < 40:
role_name = "First Year"
rawxp = get_xp_from_lvl(40) - total_xp
req_lvl, req_xp = xp_beautifier(rawxp+current_total_xp)
elif level >= 40 and level < 50:
role_name = "Second Year"
rawxp = get_xp_from_lvl(50) - total_xp
req_lvl, req_xp = xp_beautifier(rawxp+current_total_xp)
elif level >= 50 and level < 60:
role_name = "Third Year"
rawxp = get_xp_from_lvl(60) - total_xp
req_lvl, req_xp = xp_beautifier(rawxp+current_total_xp)
elif level >= 60 and level < 70:
role_name = "Graduate"
rawxp = get_xp_from_lvl(70) - total_xp
req_lvl, req_xp = xp_beautifier(rawxp+current_total_xp)
elif level >= 70 and level < 80:
role_name = "Alumini"
rawxp = get_xp_from_lvl(80) - total_xp
req_lvl, req_xp = xp_beautifier(rawxp+current_total_xp)
elif level >= 80:
role_name = "Africa"
req_lvl = 69
req_xp = "ur mom"
print("Your next promotion to " + role_name + " is at level " + str(req_lvl) + " and " + str(req_xp) + " XP.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment