Merge pull request #6 from Hollow011/gh-pages

Removed duplicate code based on recent rebase, fixed nits
This commit is contained in:
Hollow011 2013-02-20 23:02:28 -08:00
commit cefb1c5025
6 changed files with 57 additions and 47 deletions

View File

@ -34,7 +34,7 @@ window.renderPortalDetails = function(guid) {
// collect and html-ify random data // collect and html-ify random data
var randDetails = [ var randDetails = [
playerText, sinceText, getRangeText(d), getEnergyText(d), playerText, sinceText, getRangeText(d), getEnergyText(d),
linksText, getAvgResoDistText(d), linkedFields, getDestroyAP(d) linksText, getAvgResoDistText(d), linkedFields, getAttackApGainText(d)
]; ];
randDetails = '<table id="randdetails">' + genFourColumnTable(randDetails) + '</table>'; randDetails = '<table id="randdetails">' + genFourColumnTable(randDetails) + '</table>';

View File

@ -135,35 +135,21 @@ window.renderResonatorDetails = function(slot, level, nrg, dist, nick) {
return [meter, nick || '']; return [meter, nick || ''];
} }
// calculate AP gain from destroying portal // calculate AP gain from destroying portal and then capturing it by deploying resonators
// so far it counts only resonators + links window.getAttackApGainText = function(d) {
window.getDestroyAP = function(d) { var breakdown = getAttackApGain(d);
var resoCount = 0;
$.each(d.resonatorArray.resonators, function(ind, reso) {
if(!reso) return true;
resoCount += 1;
});
var linkCount = d.portalV2.linkedEdges ? d.portalV2.linkedEdges.length : 0;
var fieldCount = d.portalV2.linkedFields ? d.portalV2.linkedFields.length : 0;
var resoAp = resoCount * DESTROY_RESONATOR;
var linkAp = linkCount * DESTROY_LINK;
var fieldAp = fieldCount * DESTROY_FIELD;
var sum = resoAp + linkAp + fieldAp + CAPTURE_PORTAL + 8*DEPLOY_RESONATOR + COMPLETION_BONUS;
function tt(text) { function tt(text) {
var t = 'Destroy &amp; Capture:\n'; var t = 'Destroy &amp; Capture:\n';
t += resoCount + '×\tResonators\t= ' + digits(resoAp) + '\n'; t += breakdown.resoCount + '×\tResonators\t= ' + digits(breakdown.resoAp) + '\n';
t += linkCount + '×\tLinks\t= ' + digits(linkAp) + '\n'; t += breakdown.linkCount + '×\tLinks\t= ' + digits(breakdown.linkAp) + '\n';
t += fieldCount + '×\tFields\t= ' + digits(fieldAp) + '\n'; t += breakdown.fieldCount + '×\tFields\t= ' + digits(breakdown.fieldAp) + '\n';
t += '1×\tCapture\t= ' + CAPTURE_PORTAL + '\n'; t += '1×\tCapture\t= ' + CAPTURE_PORTAL + '\n';
t += '8×\tDeploy\t= ' + (8*DEPLOY_RESONATOR) + '\n'; t += '8×\tDeploy\t= ' + (8 * DEPLOY_RESONATOR) + '\n';
t += '1×\tBonus\t= ' + COMPLETION_BONUS + '\n'; t += '1×\tBonus\t= ' + COMPLETION_BONUS + '\n';
t += 'Sum: ' + digits(sum) + ' AP'; t += 'Sum: ' + digits(breakdown.totalAp) + ' AP';
return '<tt title="'+t+'">' + digits(text) + '</tt>'; return '<tt title="' + t + '">' + digits(text) + '</tt>';
} }
return [tt('AP Gain'), tt(sum)]; return [tt('AP Gain'), tt(breakdown.totalAp)];
} }

View File

@ -66,3 +66,35 @@ window.getAvgResoDist = function(d) {
}); });
return sum/resos; return sum/resos;
} }
window.getAttackApGain = function(d) {
var resoCount = 0;
$.each(d.resonatorArray.resonators, function(ind, reso) {
if (!reso)
return true;
resoCount += 1;
});
var linkCount = d.portalV2.linkedEdges ? d.portalV2.linkedEdges.length : 0;
var fieldCount = d.portalV2.linkedFields ? d.portalV2.linkedFields.length : 0;
var resoAp = resoCount * DESTROY_RESONATOR;
var linkAp = linkCount * DESTROY_LINK;
var fieldAp = fieldCount * DESTROY_FIELD;
var destroyAp = resoAp + linkAp + fieldAp;
var captureAp = CAPTURE_PORTAL + 8 * DEPLOY_RESONATOR + COMPLETION_BONUS;
var totalAp = destroyAp + captureAp;
return {
totalAp: totalAp,
destroyAp: destroyAp,
captureAp: captureAp,
resoCount: resoCount,
resoAp: resoAp,
linkCount: linkCount,
linkAp: linkAp,
fieldCount: fieldCount,
fieldAp: fieldAp
};
}

View File

@ -100,7 +100,7 @@ document.getElementsByTagName('body')[0].innerHTML = ''
+ ' <div id="gamestat">&nbsp;loading global control stats</div>' + ' <div id="gamestat">&nbsp;loading global control stats</div>'
+ ' <input id="geosearch" placeholder="Search location…" type="text"/>' + ' <input id="geosearch" placeholder="Search location…" type="text"/>'
+ ' <div id="portaldetails"></div>' + ' <div id="portaldetails"></div>'
+ ' <input id="redeem" placeholder="Redeem code…" type="text"/>' + ' <input id="redeem" placeholder="Redeem code… (currently down from web)" type="text"/>'
+ ' <div id="toolbox">' + ' <div id="toolbox">'
+ ' <a onmouseover="setPermaLink(this)">permalink</a>' + ' <a onmouseover="setPermaLink(this)">permalink</a>'
+ ' <a href="https://github.com/breunigs/ingress-intel-total-conversion#readme" title="IITC = Ingress Intel Total Conversion.\n\nOn the scripts homepage you can:\n find updates\n get plugins\n report bugs\n and contribute." style="cursor: help">IITCs page</a></div>' + ' <a href="https://github.com/breunigs/ingress-intel-total-conversion#readme" title="IITC = Ingress Intel Total Conversion.\n\nOn the scripts homepage you can:\n find updates\n get plugins\n report bugs\n and contribute." style="cursor: help">IITCs page</a></div>'

View File

@ -3,8 +3,8 @@
// @name iitc: Compute AP statistics // @name iitc: Compute AP statistics
// @version 0.1 // @version 0.1
// @namespace https://github.com/breunigs/ingress-intel-total-conversion // @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-AP-stats.user.js // @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-ap-stats.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-AP-stats.user.js // @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-ap-stats.user.js
// @description Tries to determine overal AP stats for the current zoom // @description Tries to determine overal AP stats for the current zoom
// @include http://www.ingress.com/intel* // @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel* // @match http://www.ingress.com/intel*
@ -35,20 +35,12 @@ window.plugin.compAPStats.compAPStats = function() {
var allEnlFields = []; var allEnlFields = [];
// Grab every portal in the viewable area and compute individual AP stats (ignoring links and fields for now) // Grab every portal in the viewable area and compute individual AP stats
$.each(window.portals, function(ind, portal) { $.each(window.portals, function(ind, portal) {
var d = portal.options.details; var d = portal.options.details;
var resoCount = 0;
// see how many resonators the portal has var portalStats = getAttackApGain(d);
$.each(d.resonatorArray.resonators, function(ind, reso) { var portalSum = portalStats.resoAp + portalStats.captureAp;
if(!reso) return true;
resoCount += 1;
});
// sum up the AP for the resonators, and any bonus
var resoAp = resoCount * DESTROY_RESONATOR;
var portalSum = resoAp + CAPTURE_PORTAL + 8*DEPLOY_RESONATOR + COMPLETION_BONUS;
if (getTeam(d) === TEAM_ENL) { if (getTeam(d) === TEAM_ENL) {
totalAP_RES += portalSum; totalAP_RES += portalSum;
@ -83,15 +75,15 @@ window.plugin.compAPStats.compAPStats = function() {
}); });
// Compute team field AP // Compute team field AP
allResFields = $.unique(allResFields); allResFields = uniqueArray(allResFields);
totalAP_ENL += (allResFields.length * DESTROY_FIELD); totalAP_ENL += (allResFields.length * DESTROY_FIELD);
allEnlFields = $.unique(allEnlFields); allEnlFields = uniqueArray(allEnlFields);
totalAP_RES += (allEnlFields.length * DESTROY_FIELD); totalAP_RES += (allEnlFields.length * DESTROY_FIELD);
// Compute team Link AP // Compute team Link AP
allResEdges = $.unique(allResEdges); allResEdges = uniqueArray(allResEdges);
totalAP_ENL += (allResEdges.length * DESTROY_LINK); totalAP_ENL += (allResEdges.length * DESTROY_LINK);
allEnlEdges = $.unique(allEnlEdges); allEnlEdges = uniqueArray(allEnlEdges);
totalAP_RES += (allEnlEdges.length * DESTROY_LINK); totalAP_RES += (allEnlEdges.length * DESTROY_LINK);
return [totalAP_RES, totalAP_ENL]; return [totalAP_RES, totalAP_ENL];
@ -103,8 +95,8 @@ window.plugin.compAPStats.guess = function() {
var totalAP_ENL = res[1]; var totalAP_ENL = res[1];
var s = 'Calculated AP gain potential:\n\n'; var s = 'Calculated AP gain potential:\n\n';
s += 'Available Resistance AP: \t' + digits(totalAP_RES) + '\n'; s += 'Available Resistance AP:\t' + digits(totalAP_RES) + '\n';
s += 'Available Enlightened AP: \t' + digits(totalAP_ENL) + '\n'; s += 'Available Enlightened AP:\t' + digits(totalAP_ENL) + '\n';
alert(s); alert(s);
} }

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @id iitc-plugin-player-tracker@breunigs // @id iitc-plugin-player-tracker@breunigs
// @name iitc: player tracker // @name iitc: player tracker
// @version 0.2 // @version 0.3
// @namespace https://github.com/breunigs/ingress-intel-total-conversion // @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js // @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js // @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js
@ -79,7 +79,7 @@ window.plugin.playerTracker.processNewData = function(data) {
// Destroy link messages depend on how the link was originally // Destroy link messages depend on how the link was originally
// created. Therefore its not clear which portal the player is // created. Therefore its not clear which portal the player is
// at, so ignore it. // at, so ignore it.
if(markup[1].plain.indexOf('destroyed') !== -1) { if(markup[1].plain.indexOf('destroyed the Link') !== -1) {
skipThisMessage = true; skipThisMessage = true;
return false; return false;
} }