I'm trying to create a bot that interprets an array (exp table) and returns the exp difference between two levels.
I'm new to JavaScript still, so I'm sure it's something within my code, I have tried various combinations of array.find, array[x] and moving formula into variables. I just cannot seem to figure it out.
var xparray = [1, 0, 2, 300, 3, 900, 4, 2000, 5, 3700, 6, 6000, 7, 10200, 8, 16200, 9, 23550, 10, 33480, 11, 45280, 12, 60880, 13, 80480, 14, 104180, 15, 130580, 16, 161080, 17, 196480, 18, 236980, 19, 282680, 20, 333680, 21, 390280, 22, 454180, 23, 525580, 24, 604680, 25, 691780, 26, 786980, 27, 896780, 28, 1021580, 29, 1161780, 30, 1317680, 31, 1480180, 32, 1656080, 33, 1845680, 34, 2049180, 35, 2267080, 36, 2499400, 37, 2749300, 38, 3017100, 39, 3303300, 40, 3608200, 41, 3932200, 42, 4272400, 43, 4629200, 44, 5002900, 45, 5393700, 46, 5801900, 47, 6239500, 48, 6707000, 49, 7205000, 50, 7734000, 51, 8598000, 52, 9656400, 53, 10923600, 54, 12478800, 55, 14350800, 56, 16568400, 57, 19160400, 58, 22155600, 59, 25582800, 60, 29470800, 61, 33940800, 62, 38813800, 63, 44129800, 64, 49938800, 65, 56302800, 66, 63297800, 67, 71019800, 68, 79594800, 69, 89187800, 70, 100013800, 71, 112462800, 72, 126343800, 73, 141899800, 74, 159398400, 75, 179148400, 76, 201478400, 77, 226818400, 78, 255468400, 79, 288218400, 80, 325868400];
var tn = (String(message).length);
// !xp 40 60
var a = (String(message).length)-3;
var b = (String(message).length)-3;
var c = (String(message).length)-5;
var d = (String(message).length)-2;
var t0 = message.substring(b, a); //(-3,-3)
var t1 = message.substring(c, b); //(-5,-3)
var t2 = message.substring(d, tn); //(-2,0)
var na = function(t0){return (t0*2)-1};
var nb = function(t1){return (t1*2)-1};
var nc = function(t2){return (t2*2)-1};
var T1 = xparray.find(function(element) {
return element > t2});
var T2 = xparray.find(function(element) {
return element > t0;
});
var T3 = xparray.find(function(element) {
return element > t1;
});
var t3 = function(T1, T2, T3) {
if (message.length = 7) {
return T1 - T2;
} else {
return T1 - T3;
}
};`
I expect this to pull values 40 and 60 from the end of the string '!xp 40 60', interpret the array and pull the next value after 40 (3608200) and the value after 60 (29470800), then preform a calculation to take the 40 value away from the 60 value (29470800-3608200). So far I think the issue lies around the T1, T2 and T3 values as they are always returning 1, or the value in the array after 1 (300).
[[lvl, xp], [lvl, xp], ...]would be easier to read and handlemessage? please add the wanted result as well.