Skip to content

Instantly share code, notes, and snippets.

@phoenixlzx phoenixlzx/exp.js
Last active Aug 29, 2015

Embed
What would you like to do?
exp.js for NyanWorld
// exp.js table designed by phoenixlzx <i@phoenixlzx.com>
// level 1 - 10 | exp 0 - 324
// for (i = 1; i <= 10; i++) { exp[i] = i == 1 ? 0 : (i * 6 + exp[i-1]) }
// level 11 - 20 | exp 434 - 1874
// for (i = 11; i <= 20; i++) { exp[i]= i * 10 + exp[i-1] }
// level 21 - 40 | exp 2189 - 11024
// for (i = 21; i <= 40; i++) { exp[i] = i * 15 + exp[i-1] }
// level 41 - 50 | exp 12008 - 21944
// for (i = 41; i <= 50; i++) { exp[i] = i * 24 + exp[i-1] }
var expTable = {
'1': 0,
'2': 12,
'3': 30,
'4': 54,
'5': 84,
'6': 120,
'7': 162,
'8': 210,
'9': 264,
'10': 324,
'11': 434,
'12': 554,
'13': 684,
'14': 824,
'15': 974,
'16': 1134,
'17': 1304,
'18': 1484,
'19': 1674,
'20': 1874,
'21': 2189,
'22': 2519,
'23': 2864,
'24': 3224,
'25': 3599,
'26': 3989,
'27': 4394,
'28': 4814,
'29': 5249,
'30': 5699,
'31': 6164,
'32': 6644,
'33': 7139,
'34': 7649,
'35': 8174,
'36': 8714,
'37': 9269,
'38': 9839,
'39': 10424,
'40': 11024,
'41': 12008,
'42': 13016,
'43': 14048,
'44': 15104,
'45': 16184,
'46': 17288,
'47': 18416,
'48': 19568,
'49': 20744,
'50': 21944 }
function getLevel(exp, mypet) {
for (i = 1; i <= 50; i++) {
if (expTable[i] <= exp && expTable[i+1] > exp) {
return i;
} else if (i === 50) {
return 50;
}
}
}
function getRequiredExp(exp, mypet) {
var level = getLevel(exp, mypet);
if (level === 50) {
return 10240;
} else {
return getExpByLevel(level + 1, mypet) - getExpByLevel(level, mypet);
}
}
function getCurrentExp(exp, mypet) {
if (exp >= 21944) {
return 21944;
} else {
return exp - getExpByLevel(getLevel(exp, mypet), mypet);
}
}
function getExpByLevel(level, mypet) {
return expTable[level];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.