update code to support extra level-related parameters supplied in the PLAYER object, negating the need for lists of XM and AP values per level

This commit is contained in:
Jon Atkins 2014-04-29 01:09:30 +01:00
parent f0134d45f1
commit 395502dcef
2 changed files with 12 additions and 14 deletions

View File

@ -373,20 +373,20 @@ window.setMapBaseLayer = function() {
// included as inline script in the original site, the data is static // included as inline script in the original site, the data is static
// and cannot be updated. // and cannot be updated.
window.setupPlayerStat = function() { window.setupPlayerStat = function() {
var level; // stock site updated to supply the actual player level, AP requirements and XM capacity values
var ap = parseInt(PLAYER.ap); var level = PLAYER.verified_level;
for(level = 0; level < MIN_AP_FOR_LEVEL.length; level++) { PLAYER.level = level; //for historical reasons IITC expects PLAYER.level to contain the current player level
if(ap < MIN_AP_FOR_LEVEL[level]) break;
}
PLAYER.level = level;
var thisLvlAp = MIN_AP_FOR_LEVEL[level-1]; var ap = parseInt(PLAYER.ap);
var nextLvlAp = MIN_AP_FOR_LEVEL[level] || ap; var thisLvlAp = parseInt(PLAYER.min_ap_for_current_level);
var nextLvlAp = parseInt(PLAYER.min_ap_for_next_level);
if (nextLvlAp) {
var lvlUpAp = digits(nextLvlAp-ap); var lvlUpAp = digits(nextLvlAp-ap);
var lvlApProg = Math.round((ap-thisLvlAp)/(nextLvlAp-thisLvlAp)*100); var lvlApProg = Math.round((ap-thisLvlAp)/(nextLvlAp-thisLvlAp)*100);
} // else zero nextLvlAp - so at maximum level(?)
var xmMax = parseInt(PLAYER.xm_capacity);
var xmMax = MAX_XM_PER_LEVEL[level];
var xmRatio = Math.round(PLAYER.energy/xmMax*100); var xmRatio = Math.round(PLAYER.energy/xmMax*100);
var cls = PLAYER.team === 'RESISTANCE' ? 'res' : 'enl'; var cls = PLAYER.team === 'RESISTANCE' ? 'res' : 'enl';
@ -395,7 +395,7 @@ window.setupPlayerStat = function() {
var t = 'Level:\t' + level + '\n' var t = 'Level:\t' + level + '\n'
+ 'XM:\t' + PLAYER.energy + ' / ' + xmMax + '\n' + 'XM:\t' + PLAYER.energy + ' / ' + xmMax + '\n'
+ 'AP:\t' + digits(ap) + '\n' + 'AP:\t' + digits(ap) + '\n'
+ (level < 8 ? 'level up in:\t' + lvlUpAp + ' AP' : 'Congrats! (neeeeerd)') + (nextLvlAp > 0 ? 'level up in:\t' + lvlUpAp + ' AP' : 'Maximul level reached(!)')
+ '\n\Invites:\t'+PLAYER.available_invites + '\n\Invites:\t'+PLAYER.available_invites
+ '\n\nNote: your player stats can only be updated by a full reload (F5)'; + '\n\nNote: your player stats can only be updated by a full reload (F5)';

View File

@ -180,8 +180,6 @@ window.NOMINATIM = 'http://nominatim.openstreetmap.org/search?format=json&limit=
// INGRESS CONSTANTS ///////////////////////////////////////////////// // INGRESS CONSTANTS /////////////////////////////////////////////////
// http://decodeingress.me/2012/11/18/ingress-portal-levels-and-link-range/ // http://decodeingress.me/2012/11/18/ingress-portal-levels-and-link-range/
window.RESO_NRG = [0, 1000, 1500, 2000, 2500, 3000, 4000, 5000, 6000]; window.RESO_NRG = [0, 1000, 1500, 2000, 2500, 3000, 4000, 5000, 6000];
window.MAX_XM_PER_LEVEL = [0, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000];
window.MIN_AP_FOR_LEVEL = [0, 2500, 20000, 70000, 150000, 300000, 600000, 1200000];
window.HACK_RANGE = 40; // in meters, max. distance from portal to be able to access it window.HACK_RANGE = 40; // in meters, max. distance from portal to be able to access it
window.OCTANTS = ['E', 'NE', 'N', 'NW', 'W', 'SW', 'S', 'SE']; window.OCTANTS = ['E', 'NE', 'N', 'NW', 'W', 'SW', 'S', 'SE'];
window.OCTANTS_ARROW = ['→', '↗', '↑', '↖', '←', '↙', '↓', '↘']; window.OCTANTS_ARROW = ['→', '↗', '↑', '↖', '←', '↙', '↓', '↘'];