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==
|
||||
// @id iitc-plugin-ap-list@xelio
|
||||
// @name IITC plugin: AP List
|
||||
// @version 0.4.3.@@DATETIMEVERSION@@
|
||||
// @version 0.4.4.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
@ -44,13 +44,15 @@ window.plugin.apList.destroyPortalsGuid = new Array();
|
||||
window.plugin.apList.portalLocationIndicator;
|
||||
window.plugin.apList.animTimeout;
|
||||
|
||||
|
||||
// ENTRY POINT ///////////////////////////////////////////////////////////////////
|
||||
window.plugin.apList.handleUpdate = function() {
|
||||
if(!requests.isLastRequest('getThinnedEntitiesV2')) return;
|
||||
plugin.apList.updateSortedPortals();
|
||||
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
||||
}
|
||||
|
||||
// CONTENT GENERATION ////////////////////////////////////////////////////////////
|
||||
|
||||
// Generate html table from top portals
|
||||
window.plugin.apList.updatePortalTable = function(side) {
|
||||
var table = '<table id="ap-list-table">'
|
||||
@ -116,25 +118,7 @@ window.plugin.apList.getPortalDestroyCheckbox = function(portal) {
|
||||
return div;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// Combine title and test
|
||||
// Combine ap title and test
|
||||
window.plugin.apList.getPortalApText = function(portal) {
|
||||
var title = plugin.apList.getPortalApTitle(portal);
|
||||
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;
|
||||
if(plugin.apList.portalSide(portal) === plugin.apList.SIDE_FRIENDLY) {
|
||||
t = 'Deploy & Upgrade\n';
|
||||
|
||||
for(var i = 0; i < playerApGain.upgradedReso.length; i++) {
|
||||
var reso = playerApGain.upgradedReso[i];
|
||||
var apGain = (reso.level === 0) ? DEPLOY_RESONATOR : UPGRADE_ANOTHERS_RESONATOR;
|
||||
t += 'Resonator on ' + OCTANTS[reso.slot] + '\t' + reso.level + '->'
|
||||
+ 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';
|
||||
} else {
|
||||
t = 'Destroy & Capture:\n'
|
||||
@ -203,6 +194,8 @@ window.plugin.apList.getPortalLink = function(portal) {
|
||||
return div;
|
||||
}
|
||||
|
||||
// MAIN LOGIC FUNCTIONS //////////////////////////////////////////////////////////
|
||||
|
||||
// Loop through portals and get playerApGain, then put in sortedPortals by side and sort them by AP.
|
||||
window.plugin.apList.updateSortedPortals = function() {
|
||||
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) {
|
||||
if(!a || !b) 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) {
|
||||
return (portal.controllingTeam.team === PLAYER.team)
|
||||
return (portal.controllingTeam.team === PLAYER.team
|
||||
|| portal.controllingTeam.team === 'NEUTRAL')
|
||||
? plugin.apList.SIDE_FRIENDLY
|
||||
: plugin.apList.SIDE_ENEMY;
|
||||
}
|
||||
@ -361,6 +342,12 @@ window.plugin.apList.getDeployOrUpgradeApGain = function(d) {
|
||||
var totalAp = 0;
|
||||
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
|
||||
// by others(only level lower than player level) or by player.
|
||||
for(var i = 0; i < 8; i++) {
|
||||
@ -402,7 +389,8 @@ window.plugin.apList.getDeployOrUpgradeApGain = function(d) {
|
||||
// Add upgraded reso to result
|
||||
targetReso.newLevel = i;
|
||||
upgradedReso.push(targetReso);
|
||||
// Add ap
|
||||
// Counting upgrade or deploy
|
||||
(targetReso.level === 0) ? deployCount++ : upgradedCount++;
|
||||
totalAp += (targetReso.level === 0)
|
||||
? DEPLOY_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 {
|
||||
captureBonus: captureBonus,
|
||||
completionBonus: completionBonus,
|
||||
totalAp: totalAp,
|
||||
upgradedReso: upgradedReso
|
||||
};
|
||||
@ -523,6 +521,21 @@ window.plugin.apList.getShieldsMitigation = function(portal) {
|
||||
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) {
|
||||
renderPortalDetails(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
|
||||
window.plugin.apList.displayFriendly = function() {
|
||||
plugin.apList.changeDisplaySide(plugin.apList.SIDE_FRIENDLY);
|
||||
@ -606,6 +637,8 @@ window.plugin.apList.showReloadLabel = function() {
|
||||
$('#ap-list-reload').show();
|
||||
}
|
||||
|
||||
// SETUP /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
window.plugin.apList.setupVar = function() {
|
||||
plugin.apList.sides[plugin.apList.SIDE_FRIENDLY] = plugin.apList.SIDE_FRIENDLY;
|
||||
plugin.apList.sides[plugin.apList.SIDE_ENEMY] = plugin.apList.SIDE_ENEMY;
|
||||
|
Loading…
x
Reference in New Issue
Block a user