From c9e27018909466ddc505471dd7b55d711e15f66d Mon Sep 17 00:00:00 2001 From: Jakub Ludwig Date: Sat, 9 Feb 2013 11:10:53 +0100 Subject: [PATCH] AP for destroying portal Calculate AP gained from destroyed resonators + link TODO: fields :) --- code/portal_detail_display.js | 1 + code/portal_detail_display_tools.js | 22 ++++++++++++++++++++++ main.js | 2 ++ 3 files changed, 25 insertions(+) diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js index 2187b34b..d9d308d9 100644 --- a/code/portal_detail_display.js +++ b/code/portal_detail_display.js @@ -66,6 +66,7 @@ window.renderPortalDetails = function(guid) { + '
'+getModDetails(d)+'
' + '
'+randDetails+'
' + '
'+getResonatorDetails(d)+'
' + + '
'+getDestroyAP(d)+'
' + '
' + '' + '' diff --git a/code/portal_detail_display_tools.js b/code/portal_detail_display_tools.js index b02d40be..42cf0c95 100644 --- a/code/portal_detail_display_tools.js +++ b/code/portal_detail_display_tools.js @@ -131,3 +131,25 @@ window.renderResonatorDetails = function(slot, level, nrg, dist, nick) { var text = ''+(nick||'')+''; return (slot <= 3 ? text+meter : meter+text) + '
'; } + +// calculate AP gain from destroying portal +// so far it counts only resonators + links +window.getDestroyAP = function(d) { + console.log('rendering destroy AP'); + var res_count = 0; + var links = 0; + + $.each(d.resonatorArray.resonators, function(ind, reso) + { + res_count += 1; + }); + + if(d.portalV2.linkedEdges) $.each(d.portalV2.linkedEdges, function(ind, link) + { + links++; + }); + + var ap_count = (res_count * DESTROY_RESONATOR) + (links * DESTROY_LINK); + + return 'Destroy ' + res_count + 'x res + ' + links + 'x link -> ' + ap_count + 'AP'; +} diff --git a/main.js b/main.js index f34165eb..b99017df 100644 --- a/main.js +++ b/main.js @@ -128,6 +128,8 @@ var MIN_AP_FOR_LEVEL = [0, 10000, 30000, 70000, 150000, 300000, 600000, 1200000] var HACK_RANGE = 35; // in meters, max. distance from portal to be able to access it var OCTANTS = ['E', 'NE', 'N', 'NW', 'W', 'SW', 'S', 'SE']; var DEFAULT_PORTAL_IMG = 'http://commondatastorage.googleapis.com/ingress/img/default-portal-image.png'; +var DESTROY_RESONATOR = 75; //AP for destroying portal +var DESTROY_LINK = 187; //AP fro destroying link // OTHER MORE-OR-LESS CONSTANTS ////////////////////////////////////// var NOMINATIM = 'http://nominatim.openstreetmap.org/search?format=json&limit=1&q=';