Merge pull request #51 from Xelio/plugin-ap-list-patch-6
Plugin AP List: Fixes
This commit is contained in:
commit
b7bbc75c77
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @id iitc-plugin-ap-list@xelio
|
// @id iitc-plugin-ap-list@xelio
|
||||||
// @name IITC plugin: AP List
|
// @name IITC plugin: AP List
|
||||||
// @version 0.4.3.@@DATETIMEVERSION@@
|
// @version 0.4.4.@@DATETIMEVERSION@@
|
||||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||||
// @updateURL @@UPDATEURL@@
|
// @updateURL @@UPDATEURL@@
|
||||||
// @downloadURL @@DOWNLOADURL@@
|
// @downloadURL @@DOWNLOADURL@@
|
||||||
@ -44,13 +44,15 @@ window.plugin.apList.destroyPortalsGuid = new Array();
|
|||||||
window.plugin.apList.portalLocationIndicator;
|
window.plugin.apList.portalLocationIndicator;
|
||||||
window.plugin.apList.animTimeout;
|
window.plugin.apList.animTimeout;
|
||||||
|
|
||||||
|
// ENTRY POINT ///////////////////////////////////////////////////////////////////
|
||||||
window.plugin.apList.handleUpdate = function() {
|
window.plugin.apList.handleUpdate = function() {
|
||||||
if(!requests.isLastRequest('getThinnedEntitiesV2')) return;
|
if(!requests.isLastRequest('getThinnedEntitiesV2')) return;
|
||||||
plugin.apList.updateSortedPortals();
|
plugin.apList.updateSortedPortals();
|
||||||
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CONTENT GENERATION ////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Generate html table from top portals
|
// Generate html table from top portals
|
||||||
window.plugin.apList.updatePortalTable = function(side) {
|
window.plugin.apList.updatePortalTable = function(side) {
|
||||||
var table = '<table id="ap-list-table">'
|
var table = '<table id="ap-list-table">'
|
||||||
@ -116,25 +118,7 @@ window.plugin.apList.getPortalDestroyCheckbox = function(portal) {
|
|||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.apList.destroyPortal = function(guid) {
|
// Combine ap title and test
|
||||||
// Add to destroyPortalsGuid if not yet added, remove if already added
|
|
||||||
var portalIndex = plugin.apList.destroyPortalIndex(guid);
|
|
||||||
if(portalIndex >= 0) {
|
|
||||||
plugin.apList.destroyPortalsGuid.splice(portalIndex, 1);
|
|
||||||
} else {
|
|
||||||
plugin.apList.destroyPortalsGuid.push(guid);
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.apList.updateSortedPortals();
|
|
||||||
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the index of portal in destroyPortalsGuid
|
|
||||||
window.plugin.apList.destroyPortalIndex = function(guid) {
|
|
||||||
return $.inArray(guid, plugin.apList.destroyPortalsGuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Combine title and test
|
|
||||||
window.plugin.apList.getPortalApText = function(portal) {
|
window.plugin.apList.getPortalApText = function(portal) {
|
||||||
var title = plugin.apList.getPortalApTitle(portal);
|
var title = plugin.apList.getPortalApTitle(portal);
|
||||||
return '<div class="help" title="' + title + '">' + digits(portal.playerApGain.totalAp) + '</div>';
|
return '<div class="help" title="' + title + '">' + digits(portal.playerApGain.totalAp) + '</div>';
|
||||||
@ -147,12 +131,19 @@ window.plugin.apList.getPortalApTitle = function(portal) {
|
|||||||
var playerApGain = portal.playerApGain;
|
var playerApGain = portal.playerApGain;
|
||||||
if(plugin.apList.portalSide(portal) === plugin.apList.SIDE_FRIENDLY) {
|
if(plugin.apList.portalSide(portal) === plugin.apList.SIDE_FRIENDLY) {
|
||||||
t = 'Deploy & Upgrade\n';
|
t = 'Deploy & Upgrade\n';
|
||||||
|
|
||||||
for(var i = 0; i < playerApGain.upgradedReso.length; i++) {
|
for(var i = 0; i < playerApGain.upgradedReso.length; i++) {
|
||||||
var reso = playerApGain.upgradedReso[i];
|
var reso = playerApGain.upgradedReso[i];
|
||||||
var apGain = (reso.level === 0) ? DEPLOY_RESONATOR : UPGRADE_ANOTHERS_RESONATOR;
|
var apGain = (reso.level === 0) ? DEPLOY_RESONATOR : UPGRADE_ANOTHERS_RESONATOR;
|
||||||
t += 'Resonator on ' + OCTANTS[reso.slot] + '\t' + reso.level + '->'
|
t += 'Resonator on ' + OCTANTS[reso.slot] + '\t' + reso.level + '->'
|
||||||
+ reso.newLevel + '\t= ' + apGain + '\n';
|
+ reso.newLevel + '\t= ' + apGain + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(playerApGain.captureBonus > 0)
|
||||||
|
t += 'Capture\t\t= ' + playerApGain.captureBonus + '\n';
|
||||||
|
if(playerApGain.completionBonus > 0)
|
||||||
|
t += 'Bonus\t\t= ' + playerApGain.completionBonus + '\n';
|
||||||
|
|
||||||
t += 'Sum: ' + digits(playerApGain.totalAp) + ' AP';
|
t += 'Sum: ' + digits(playerApGain.totalAp) + ' AP';
|
||||||
} else {
|
} else {
|
||||||
t = 'Destroy & Capture:\n'
|
t = 'Destroy & Capture:\n'
|
||||||
@ -203,6 +194,8 @@ window.plugin.apList.getPortalLink = function(portal) {
|
|||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MAIN LOGIC FUNCTIONS //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Loop through portals and get playerApGain, then put in sortedPortals by side and sort them by AP.
|
// Loop through portals and get playerApGain, then put in sortedPortals by side and sort them by AP.
|
||||||
window.plugin.apList.updateSortedPortals = function() {
|
window.plugin.apList.updateSortedPortals = function() {
|
||||||
plugin.apList.sortedPortals[plugin.apList.SIDE_FRIENDLY] = new Array();
|
plugin.apList.sortedPortals[plugin.apList.SIDE_FRIENDLY] = new Array();
|
||||||
@ -324,19 +317,6 @@ window.plugin.apList.handleDestroyPortal = function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.apList.enableCache = function() {
|
|
||||||
plugin.apList.useCachedPortals = true;
|
|
||||||
plugin.apList.updateSortedPortals();
|
|
||||||
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.plugin.apList.disableCache = function() {
|
|
||||||
plugin.apList.useCachedPortals = false;
|
|
||||||
plugin.apList.cachedPortals = {};
|
|
||||||
plugin.apList.updateSortedPortals();
|
|
||||||
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.plugin.apList.isSamePortal = function(a,b) {
|
window.plugin.apList.isSamePortal = function(a,b) {
|
||||||
if(!a || !b) return false;
|
if(!a || !b) return false;
|
||||||
if(a.team !== b.team) return false;
|
if(a.team !== b.team) return false;
|
||||||
@ -349,7 +329,8 @@ window.plugin.apList.isSamePortal = function(a,b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.apList.portalSide = function(portal) {
|
window.plugin.apList.portalSide = function(portal) {
|
||||||
return (portal.controllingTeam.team === PLAYER.team)
|
return (portal.controllingTeam.team === PLAYER.team
|
||||||
|
|| portal.controllingTeam.team === 'NEUTRAL')
|
||||||
? plugin.apList.SIDE_FRIENDLY
|
? plugin.apList.SIDE_FRIENDLY
|
||||||
: plugin.apList.SIDE_ENEMY;
|
: plugin.apList.SIDE_ENEMY;
|
||||||
}
|
}
|
||||||
@ -361,6 +342,12 @@ window.plugin.apList.getDeployOrUpgradeApGain = function(d) {
|
|||||||
var totalAp = 0;
|
var totalAp = 0;
|
||||||
var upgradedReso = new Array();
|
var upgradedReso = new Array();
|
||||||
|
|
||||||
|
var deployCount = 0;
|
||||||
|
var upgradedCount = 0;
|
||||||
|
|
||||||
|
var captureBonus = 0;
|
||||||
|
var completionBonus = 0;
|
||||||
|
|
||||||
// loop through reso slot and find empty reso, deployed
|
// loop through reso slot and find empty reso, deployed
|
||||||
// by others(only level lower than player level) or by player.
|
// by others(only level lower than player level) or by player.
|
||||||
for(var i = 0; i < 8; i++) {
|
for(var i = 0; i < 8; i++) {
|
||||||
@ -402,7 +389,8 @@ window.plugin.apList.getDeployOrUpgradeApGain = function(d) {
|
|||||||
// Add upgraded reso to result
|
// Add upgraded reso to result
|
||||||
targetReso.newLevel = i;
|
targetReso.newLevel = i;
|
||||||
upgradedReso.push(targetReso);
|
upgradedReso.push(targetReso);
|
||||||
// Add ap
|
// Counting upgrade or deploy
|
||||||
|
(targetReso.level === 0) ? deployCount++ : upgradedCount++;
|
||||||
totalAp += (targetReso.level === 0)
|
totalAp += (targetReso.level === 0)
|
||||||
? DEPLOY_RESONATOR
|
? DEPLOY_RESONATOR
|
||||||
: UPGRADE_ANOTHERS_RESONATOR;
|
: UPGRADE_ANOTHERS_RESONATOR;
|
||||||
@ -411,7 +399,17 @@ window.plugin.apList.getDeployOrUpgradeApGain = function(d) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(deployCount > 0) completionBonus = COMPLETION_BONUS;
|
||||||
|
if(deployCount === 8) captureBonus = CAPTURE_PORTAL;
|
||||||
|
|
||||||
|
totalAp = deployCount * DEPLOY_RESONATOR
|
||||||
|
+ upgradedCount * UPGRADE_ANOTHERS_RESONATOR
|
||||||
|
+ captureBonus
|
||||||
|
+ completionBonus;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
captureBonus: captureBonus,
|
||||||
|
completionBonus: completionBonus,
|
||||||
totalAp: totalAp,
|
totalAp: totalAp,
|
||||||
upgradedReso: upgradedReso
|
upgradedReso: upgradedReso
|
||||||
};
|
};
|
||||||
@ -523,6 +521,21 @@ window.plugin.apList.getShieldsMitigation = function(portal) {
|
|||||||
return shieldsMitigation;
|
return shieldsMitigation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FEATURE TOGGLES AND INTERACTION HANDLER ///////////////////////////////////////
|
||||||
|
|
||||||
|
window.plugin.apList.enableCache = function() {
|
||||||
|
plugin.apList.useCachedPortals = true;
|
||||||
|
plugin.apList.updateSortedPortals();
|
||||||
|
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.plugin.apList.disableCache = function() {
|
||||||
|
plugin.apList.useCachedPortals = false;
|
||||||
|
plugin.apList.cachedPortals = {};
|
||||||
|
plugin.apList.updateSortedPortals();
|
||||||
|
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
||||||
|
}
|
||||||
|
|
||||||
window.plugin.apList.selectPortal = function(guid) {
|
window.plugin.apList.selectPortal = function(guid) {
|
||||||
renderPortalDetails(guid);
|
renderPortalDetails(guid);
|
||||||
plugin.apList.setPortalLocationIndicator(guid);
|
plugin.apList.setPortalLocationIndicator(guid);
|
||||||
@ -567,6 +580,24 @@ window.plugin.apList.animPortalLocationIndicator = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.plugin.apList.destroyPortal = function(guid) {
|
||||||
|
// Add to destroyPortalsGuid if not yet added, remove if already added
|
||||||
|
var portalIndex = plugin.apList.destroyPortalIndex(guid);
|
||||||
|
if(portalIndex >= 0) {
|
||||||
|
plugin.apList.destroyPortalsGuid.splice(portalIndex, 1);
|
||||||
|
} else {
|
||||||
|
plugin.apList.destroyPortalsGuid.push(guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.apList.updateSortedPortals();
|
||||||
|
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the index of portal in destroyPortalsGuid
|
||||||
|
window.plugin.apList.destroyPortalIndex = function(guid) {
|
||||||
|
return $.inArray(guid, plugin.apList.destroyPortalsGuid);
|
||||||
|
}
|
||||||
|
|
||||||
// Change display table to friendly portals
|
// Change display table to friendly portals
|
||||||
window.plugin.apList.displayFriendly = function() {
|
window.plugin.apList.displayFriendly = function() {
|
||||||
plugin.apList.changeDisplaySide(plugin.apList.SIDE_FRIENDLY);
|
plugin.apList.changeDisplaySide(plugin.apList.SIDE_FRIENDLY);
|
||||||
@ -606,6 +637,8 @@ window.plugin.apList.showReloadLabel = function() {
|
|||||||
$('#ap-list-reload').show();
|
$('#ap-list-reload').show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SETUP /////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
window.plugin.apList.setupVar = function() {
|
window.plugin.apList.setupVar = function() {
|
||||||
plugin.apList.sides[plugin.apList.SIDE_FRIENDLY] = plugin.apList.SIDE_FRIENDLY;
|
plugin.apList.sides[plugin.apList.SIDE_FRIENDLY] = plugin.apList.SIDE_FRIENDLY;
|
||||||
plugin.apList.sides[plugin.apList.SIDE_ENEMY] = plugin.apList.SIDE_ENEMY;
|
plugin.apList.sides[plugin.apList.SIDE_ENEMY] = plugin.apList.SIDE_ENEMY;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user