From 5f94d56578949d70a016cb6131ef98bd096ef8ca Mon Sep 17 00:00:00 2001 From: Xelio Date: Sun, 3 Mar 2013 22:42:51 +0800 Subject: [PATCH 1/3] Add guid to window.PLAYER and add constant MAX_RESO_PER_PLAYER --- code/boot.js | 1 + code/player_names.js | 11 +++++++++++ main.js | 1 + 3 files changed, 13 insertions(+) diff --git a/code/boot.js b/code/boot.js index 7e5882a2..6c97cb55 100644 --- a/code/boot.js +++ b/code/boot.js @@ -159,6 +159,7 @@ window.setupMap = function() { // included as inline script in the original site, the data is static // and cannot be updated. window.setupPlayerStat = function() { + PLAYER.guid = playerNameToGuid(PLAYER.nickname); var level; var ap = parseInt(PLAYER.ap); for(level = 0; level < MIN_AP_FOR_LEVEL.length; level++) { diff --git a/code/player_names.js b/code/player_names.js index 85362f2c..0d2557d5 100644 --- a/code/player_names.js +++ b/code/player_names.js @@ -17,6 +17,17 @@ window.getPlayerName = function(guid) { return '{'+guid.slice(0, 12)+'}'; } +window.playerNameToGuid = function(playerName){ + var guid = null; + $.each(Object.keys(localStorage), function(ind,key) { + if(playerName === localStorage[key]) { + guid = key; + return false; + } + }); + return guid; +} + // resolves all player GUIDs that have been added to the list. Reruns // renderPortalDetails when finished, so that then-unresolved names // get replaced by their correct versions. diff --git a/main.js b/main.js index 7553fd48..d4328181 100644 --- a/main.js +++ b/main.js @@ -189,6 +189,7 @@ window.CAPTURE_PORTAL = 500; //AP for capturing a portal window.DEPLOY_RESONATOR = 125; //AP for deploying a resonator window.COMPLETION_BONUS = 250; //AP for deploying all resonators on portal window.MAX_PORTAL_LEVEL = 8; +window.MAX_RESO_PER_PLAYER = [0, 8, 4, 4, 4, 2, 2, 1, 1]; // OTHER MORE-OR-LESS CONSTANTS ////////////////////////////////////// window.TEAM_NONE = 0; From 5e8cab6c885dc9d8d6284eb88ff46a7abf2de67e Mon Sep 17 00:00:00 2001 From: Xelio Date: Sun, 3 Mar 2013 23:59:44 +0800 Subject: [PATCH 2/3] Store player level at setupPlayerStat --- code/boot.js | 1 + 1 file changed, 1 insertion(+) diff --git a/code/boot.js b/code/boot.js index 6c97cb55..2204acd1 100644 --- a/code/boot.js +++ b/code/boot.js @@ -165,6 +165,7 @@ window.setupPlayerStat = function() { for(level = 0; level < MIN_AP_FOR_LEVEL.length; level++) { if(ap < MIN_AP_FOR_LEVEL[level]) break; } + PLAYER.level = level; var thisLvlAp = MIN_AP_FOR_LEVEL[level-1]; var nextLvlAp = MIN_AP_FOR_LEVEL[level] || ap; From 3263664e489d8b2cacca8eaef318748d6c67a27a Mon Sep 17 00:00:00 2001 From: Xelio Date: Mon, 4 Mar 2013 00:33:52 +0800 Subject: [PATCH 3/3] Add window.UPGRADE_ANOTHERS_RESONATOR --- main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/main.js b/main.js index d4328181..ff11efb8 100644 --- a/main.js +++ b/main.js @@ -188,6 +188,7 @@ window.DESTROY_FIELD = 750; //AP for destroying field window.CAPTURE_PORTAL = 500; //AP for capturing a portal window.DEPLOY_RESONATOR = 125; //AP for deploying a resonator window.COMPLETION_BONUS = 250; //AP for deploying all resonators on portal +window.UPGRADE_ANOTHERS_RESONATOR = 65; //AP for upgrading another's resonator window.MAX_PORTAL_LEVEL = 8; window.MAX_RESO_PER_PLAYER = [0, 8, 4, 4, 4, 2, 2, 1, 1];