// ==UserScript==
// @name Planets.nu Hover Prediction
// @namespace quapla/Hover Prediction
// @date 2016-05-20
// @author Quapla - Jim Clark - Big Beefer - Stephen Piper
// @grant none
// @description NU Starmap-Plugin, that shows more info for Planets, Ships and Minerals next turn
// @include http://planets.nu/home
// @include http://planets.nu/games/*
// @include http://play.planets.nu/*
// @include http://*.planets.nu/*
// @include http://planets.nu/*
// @homepage
// @version 3.085
// ==/UserScript==
// Reference Big Beefer: https://greasyfork.org/en/scripts/2618-planets-nu-improved-hover-text
// Reference Stephen Piper: https://greasyfork.org/en/scripts/17959-hovertextbox
//1 Humanoid - Any starbase that is built around a humanoid planet will have tech 10 hull technology automatically.
//7 Amphibian - Any starbase that is built around a amphibian planet will have tech 10 beam technology automatically.
//8 Ghipsoldal - Any starbase that is built around a ghipsoldal planet will have tech 10 engine technology automatically.
//9 Siliconoid - Any starbase that is built around a siliconoid planet will have tech 10 torpedo technology automatically.
//2 Bovinoid - Bovinoids are very valuable. Every 10000 Bovinoids will produce 1 supply unit per turn.
//3 Reptilian - If there Reptilians living on a planet then your mining rate will be doubled.
//4 Avian - Are quick to forgive you for overtaxing them. They will allow you to slightly overtax them without growing unhappy.
//5 Amorphous - The only bad natives. The Amorphous lifeforms eat 500 colonists (5 clans) per turn.
//6 Insectoid - Insectoids produce twice the normal amount of credits per turn per percentage as other native races.
/*------------------------------------------------------------------------------
1. Shows total mineral info if available from darksene or superspy
2. Adds FC to planet info (could make to only show if not "???" but currently
always shows
3. If there's a base, shows fighters as well.
4. Moved the code to show planet owner outside of infoturn==0 test. When player
knew ownership from a "share intel", infoturn was still 0,
so the owner was not shown in the hover text
5. (ver 0.4) Added FC to ships too
6. (ver 0.5) Shorten form to 3 lines for owned ships (controlled by
vgap.terseInfo). Add damage and cloak state if applicable.
7. (ver 0.6) Add Warp for owned ships. Also, add ship hull being built to
starbase.
8. (ver 0.7) Add Map Tools Control "Switch Info View" to switch views.
9. (ver 0.7) Add ship owner in short form for allies
10.(ver 0.9) Add persistent settings, remove switch view map tool
11.(ver 0.10) Add setting to display ship mission for player's ships
12.(ver 0.11) More information for allies displayed if ally update script is
in use.
13.(ver 0.11) Replaces showHover and shipTransferView to show more info when
available
14.(ver 0.13) Fixes show race for allied ships
15.(ver 0.14) Update for new site
2.0 - Added more info to text
3.00 - Added Prediction by Quapla with added funktion from Stephen Piper
------------------------------------------------------------------------------*/
function wrapper() { // wrapper for injection
function hitText() {}
hitText.prototype = {
nativeTaxAmount : function (c, ntr) // How much do natives pay at 'c' with 'ntr'-taxrate - limited by natives/taxrate
{
var nt = 0;
if (c.nativeclans > 0) {
if (c.race == 6 && ntr > 20) { // borg == 6 can be taxed with 20% max
ntr = 20;
}
nt = (c.nativeclans / 100) * (ntr / 10) * (c.nativegovernment / 5);
nt = c.nativetype == 5 ? 0 : nt; // amorphous == 5 wont pay
nt *= c.race == 1 ? 2 : 1; // feds == 1 pay twice
nt *= c.nativetype == 6 ? 2 : 1; // insect == 6 pay twice
nt = Math.round(nt);
}
return nt;
},
nativesupportedtax : function (c) // How taxes can we receive at 'c' - limited by clans
{
var ns = c.clans;
ns *= c.race == 1 ? 2 : 1; // feds == 1
ns *= c.nativetype == 6 ? 2 : 1; // insect == 6
return ns;
},
showMin : function (txt, surface, change, ground) // Shows Minerals AAAA | 00000000 | + 0000 | (00000)
{
var showtxt = "<td>" + txt + " </td>"; // class='val' is green - style='color:#fff;' sets white
showtxt += "<td style='text-align:right;'>" + addCommas(surface) + " </td>";
showtxt += "<td style='text-align:right;'> +" + addCommas(change) + " </td>";
showtxt += "<td style='text-align:right;'";
if (ground < 100)
showtxt += " style='color:#ff0000;'"; // Red
else if (ground < 1000)
showtxt += " style='color:#ffa500;'"; // Orange
else if (ground > 10000)
showtxt += " style='color:#008000;'"; // Green
showtxt += "> (" + addCommas(ground) + ") </td>";
return showtxt;
},
GetMaxPop : function (hit) // Gets max. Population on Planet hit
{
/// Population in popup text
//////////////////////
var planetOwner = null;
var maxPop = 0;
// Do we have a temp scan?
if (hit.temp >= 0 && hit.temp <= 100) {
// Use your race if planet unowned
if (hit.ownerid == 0)
planetOwner = vgap.getPlayer(vgap.player.id);
else
planetOwner = vgap.getPlayer(hit.ownerid);
// Find max pop
// xtal
if (planetOwner.raceid == 7) {
maxPop = 1000 * hit.temp;
} else {
maxPop = Math.round(Math.sin(3.14 * (100 - hit.temp) / 100) * 100000);
if (hit.temp > 84)
maxPop = Math.floor((20099.9 - (200 * hit.temp)) / 10);
if (hit.temp < 15)
maxPop = Math.floor((299.9 + (200 * hit.temp)) / 10);
// Cols, Rebles, Fascists, Bots
if (hit.temp > 80 && (planetOwner.raceid == 4 || planetOwner.raceid == 9 || planetOwner.raceid == 10 || planetOwner.raceid == 11))
maxPop = 60;
// Rebels
if (hit.temp <= 19 && planetOwner.raceid == 10)
maxPop = 90000;
}
if (hit.debrisdisk > 0) {
maxPop = 0;
if (vgap.getStarbase(maxPop.id) != null) {
maxPop = 500;
}
}
}
return maxPop;
},
GetMinPop : function (hit) // Gets minimal Population on Hit
{
/// Population in popup text
//////////////////////
var planetOwner = null;
var minPop = 0;
// Do we have a temp scan?
if (hit.temp >= 0 && hit.temp <= 100) {
// Use your race if planet unowned
if (hit.ownerid == 0)
planetOwner = vgap.getPlayer(vgap.player.id);
else
planetOwner = vgap.getPlayer(hit.ownerid);
// Find min growth pop
var targetGrowth = 1;
// Worms!
if (hit.nativetype == 5)
targetGrowth = 6;
// xtal
if (planetOwner.raceid == 7) {
minPop = Math.floor(targetGrowth * 11 / (hit.temp / 100));
if (vgap.advActive(47)) {
minPop = Math.floor(targetGrowth * 11 / hit.temp * hit.temp / 4000);
}
if (hit.temp < 15)
minPop = 0;
} else {
// This should just be a formula like: minPop = Math.floor(targetGrowth * 11 / Math.sin(3.14*(100-hit.temp)/100)));
// But that is off but a bit. This seems more acurate, but is still slightly off the chart I was going off. Which may be wrong too!
// ...
for (minPop = 10; minPop < 300; minPop++) {
var growth = Math.round(Math.sin(3.14 * ((100 - hit.temp) / 100)) * minPop / 20);
if (growth >= targetGrowth)
break;
}
if (hit.temp < 15 || hit.temp > 84)
minPop = 0;
if (minPop >= 299)
minPop = 0;
}
if (hit.debrisdisk > 0) {
minPop = 0;
}
}
//////////////////////
return minPop;
},
miningRate(p, ground, density) {
m = vgap.miningRate(p, density);
m = m > ground ? ground : Math.round(m);
return m;
},
};
vgaPlanets.prototype.setupAddOn = function (addOnName) {
if (vgaPlanets.prototype.addOns == null)
vgaPlanets.prototype.addOns = {};
vgaPlanets.prototype.addOns[addOnName] = {};
var settings = localStorage.getItem(addOnName + ".settings");
if (settings != null)
vgaPlanets.prototype.addOns[addOnName].settings = JSON.parse(settings);
else
vgaPlanets.prototype.addOns[addOnName].settings = {};
vgaPlanets.prototype.addOns[addOnName].saveSettings = function () {
localStorage.setItem(addOnName + ".settings", JSON.stringify(vgaPlanets.prototype.addOns[addOnName].settings));
}
};
vgaPlanets.prototype.setupAddOn("vgapHoverPrediction");
/*
if (vgaPlanets.prototype.addOns == null) vgaPlanets.prototype.addOns = {};
vgaPlanets.prototype.addOns.vgapHoverPrediction = {};
var settings = localStorage.getItem("vgapHoverPrediction.settings");
if (settings != null)
vgaPlanets.prototype.addOns.vgapHoverPrediction.settings = JSON.parse(settings);
else
vgaPlanets.prototype.addOns.vgapHoverPrediction.settings = {}; //{terseInfo: false};
vgaPlanets.prototype.addOns.vgapHoverPrediction.saveSettings = function () {
localStorage.setItem("vgapHoverPrediction.settings", JSON.stringify(vgaPlanets.prototype.addOns.vgapHoverPrediction.settings));
};
*/
vgapMap.prototype.hitTextBox = function (hit) {
var settings = vgap.addOns.vgapHoverPrediction.settings;
var txt = "";
var wtx = "";
if (hit.isPlanet) { //planet
// if (hit.id < 0) { hit = vgap.getPlanet(-hit.id); } // For what is that good? Quapla
// 8 Colomns
// AAAA | 00000000 | + 0000 | (00000') || BBBB | 00000000 | + 0000 | (00000')
// Cln: | 23450 | + 21 | (451') || Avi: | 23450 | + 21 | (451')
txt += "<div class='ItemSelectionBox minCorrection'>";
// txt += "<span>" + hit.id + ": " + hit.name;
// if (hit.temp != -1)
// txt += "<span style='float:right;'>Temp: " + hit.temp + "</span>";
// txt += "</span>";
txt += "<table border='1' style='table-layout:fixed' class='CleanTable'><colgroup span='8'></colgroup>";
if (hit.infoturn == 0) { //unknown planet
// txt += this.hitText(hit, hit.isPlanet).replace(" ", ""); // Later for all Planets
} else {
// if (hit.nativeclans > 0) // Has natives
// {
// txt += "<tr><td colspan=8>" + addCommas(hit.nativeclans * 100) + " " + hit.nativeracename + " - " + hit.nativegovernmentname + "</td></tr>";
// }
//txt += "<div class='ItemSelectionBox minCorrection'>";
//txt += "<table class='CleanTable'>";
if (hit.ownerid == vgap.player.id && hit.readystatus == 0)
wtx = " class='WarnText'";
else
wtx = ""; // Planet not ready?
txt += "<tr><td" + wtx + ">" + hit.id + ": </td>";
txt += "<td colspan = '3' " + wtx + ">" + hit.name + "</td>";
txt += "<td>FC: </td><td>" + hit.friendlycode + "</td>";
if (hit.temp != -1) // Temperature known
{
if (hit.temp > 84 || hit.temp < 15)
wtx = " class='WarnText'";
else
wtx = ""; // Planet Hot/Cold?
txt += "<td style='text-align:right;' colspan='2'" + wtx + "> " + hit.temp + "°</td>";
}
txt += "</tr>";
if (hit.clans > 0) // Has Clans
{
// txt += "<td>Cln: </td><td>" + hit.clans + " </td><td style='float:right;'>+ " + (minPop == 0 ? "n/a" : minPop) + "+ </td><td style='float:right;'>(" + maxPop + ")</td>";
txt += "<tr>" + hitText.prototype.showMin("Cln:", hit.clans, (hitText.prototype.GetMinPop(hit) == 0 ? "n/a" : hitText.prototype.GetMinPop(hit)), hitText.prototype.GetMaxPop(hit));
} else {
txt += "<tr><td colspan='4'>Unowned</td>";
}
if (hit.nativeclans > 0) // Has Natives
{
txt += "<td>" + hit.nativeracename.substr(0, 5) + ": </td>";
txt += "<td>" + addCommas(hit.nativeclans) + "</td>";
if (hit.ownerid == vgap.player.id)
if (hit.nativehappypoints < 40) {
wtx = "ff0000"; // Red
} else if (hit.nativehappypoints < 70) {
wtx = "ffa500"; // Orange
} else {
wtx = "008000"; // Green
}
txt += "<td style='color:#" + wtx + ";'> " + hit.nativehappypoints + "%</td>";
txt += "<td> " + hit.nativetaxrate + "%</td>";
}
}
txt += "</tr>";
// if (vgap.player.status == 7 && !hit) {
// var e = ["None", "Colonization", "Build Starbase", "Supply
// Starbase", "Exploration", "Build Special", "Attack", "Defend",
// "Move Fuel"];
// return "<tr><td colspan='" + a + "' class='WarnText'>" +
// e[b.goal] + "-" + b.goaltarget + "</td></tr>"
// }
var sp = hit.factories;
var cs = 0;
var nt = 0;
var cs10 = 0;
var nt10 = 0;
var sps = 0;
if (hit.nativeclans > 0) {
if (hit.nativetype == 2) { // bovinoid
spn = Math.floor(hit.nativeclans / 100);
sps = hit.clans - spn;
sp += sps > 0 ? spn : hit.clans;
}
nt = hitText.prototype.nativeTaxAmount(hit, hit.nativetaxrate); // Can pay max
ns = hitText.prototype.nativesupportedtax(hit); // Can get may
cs = ns - nt; // Won't get because lack of Clans
nt = Math.min(nt, ns);
nt10 = hitText.prototype.nativeTaxAmount(hit, 10);
ns10 = hitText.prototype.nativesupportedtax(hit);
cs10 = ns10 - nt10;
nt10 = Math.min(nt10, ns10);
}
ct = Math.round(hit.clans * hit.colonisttaxrate / 1000);
mn = hitText.prototype.miningRate(hit, hit.groundneutronium, hit.densityneutronium);
md = hitText.prototype.miningRate(hit, hit.groundduranium, hit.densityduranium);
mm = hitText.prototype.miningRate(hit, hit.groundmolybdenum, hit.densitymolybdenum);
mt = hitText.prototype.miningRate(hit, hit.groundtritanium, hit.densitytritanium);
var nText = hit.groundneutronium;
var dText = hit.groundduranium;
var tText = hit.groundtritanium;
var mText = hit.groundmolybdenum;
if (hit.totalneutronium > 0 && hit.groundneutronium < 0) { //"total" info available, surface/ground is not, enables display of dark sense and superspy info in hover text
nText = hit.totalneutronium;
dText = hit.totalduranium;
tText = hit.totaltritanium;
mText = hit.totalmolybdenum;
}
if (hit.groundneutronium > 0) {
txt += "<tr>" + hitText.prototype.showMin("Neu:", hit.neutronium, mn, nText);
txt += "<td>Sup:</td><td style='text-align:right;'>" + addCommas(hit.supplies) + "</td>";
txt += "<td style='text-align:right;'>+ " + sp;
if (sps < 0)
txt += "</td><td class='val' style='color:#f00;'>-" + (-sps);
txt += "</td></tr>";
txt += "<tr>" + hitText.prototype.showMin("Dur:", hit.duranium, md, dText);
txt += "<td>MC:</td><td style='text-align:right;'>" + addCommas(hit.megacredits) + "</td><td style='text-align:right;'>+ " + (nt + ct);
if (cs < 0)
txt += "</td><td class='val' style='color:#f00;'>-" + (-cs);
txt += "</td></tr>";
txt += "<tr>" + hitText.prototype.showMin("Tri:", hit.tritanium, mt, tText);
txt += "<td>  $ :</td><td style='text-align:right;'>" + addCommas(hit.megacredits + hit.supplies) + "</td>";
txt += "<td style='text-align:right;'>+ " + (nt + ct + sp);
txt += "</td></tr>";
/* Not used if (hit.nativeclans > 0){
txt += "<td> 10%:</td><td> </td><td>" + nt10 + "- ";
if (cs10 < 0)
txt += "</td><td class='WarnText'>" + (-cs10);
} */
txt += "<tr>" + hitText.prototype.showMin("Mol:", hit.molybdenum, mm, mText);
txt += "<td>M|F|D:</td><td style='text-align:right;'> " + hit.mines + " </td><td style='text-align:right;'> " + hit.factories + " </td><td style='text-align:right;'> " + hit.defense + "</td></tr>";
var sb = vgap.getStarbase(hit.id);
if (sb != null && (hit.ownerid == vgap.player.id || vgap.fullallied(hit.ownerid))) {
if (sb.starbasetype != 2) {
if (sb.isbuilding) {
txt += "<tr><td colspan='8'>Build: " + vgap.getHull(sb.buildhullid).name + "</td></tr>";
} else {
txt += "<tr><td colspan='8' class='WarnText'>Starbase is not building</td></tr>";
}
}
/// Add tech levels for SB
txt += "<tr><td colspan='2'>Defense: " + sb.defense + "</td><td colspan='2'>Fighters: " + sb.fighters + "</td>";
txt += "<td colspan='4'>Tech: H-" + sb.hulltechlevel + " E-" + sb.enginetechlevel + " B-" + sb.beamtechlevel;
txt += " T-" + sb.torptechlevel + "</td></tr>";
} else {
if (hit.duranium > 119 && hit.tritanium > 401 && hit.molybdenum > 339 && (hit.megacredits + hit.supplies) > 899)
txt += "<tr><td colspan='8' style='color:#0f0;'>Can build Starbase</td></tr>";
}
}
//known planet
if (hit.ownerid != vgap.player.id && hit.ownerid != 0) {
var player = vgap.getPlayer(hit.ownerid);
var race = vgap.getRace(player.raceid);
txt += "<tr><td colspan='8' class='WarnText'>" + race.name + " (" + player.username + ")</td></tr>";
}
// txt += this.hitText(hit, hit.isPlanet).replace(" ", "");
} // End of known Planets
wtx = this.hitText(hit, hit.isPlanet).replace("'4'", "'8'");
txt += wtx.replace(" ", "");
txt += "</table></div>";
if (settings.showPrediction) { // Quapla
var html = "<div class='ItemSelectionBox minCorrection'>";
html += "<table class='CleanTable' style='width: 100%'>"; // New Table
html += "<tr><td colspan='8'>Prediction:</td></tr>";
html += "</table></div>";
txt += html;
}
} // End of Planets
else { //ships
var ship = hit;
var hull = vgap.getHull(ship.hullid);
var totalCargo = ship.ammo + ship.duranium + ship.tritanium + ship.molybdenum + ship.supplies + ship.clans;
var html = "<div class='ItemSelectionBox minCorrection'>";
if (ship.ownerid == vgap.player.id || vgap.fullallied(ship.ownerid)) {
var player = vgap.getPlayer(ship.ownerid);
var race = vgap.getRace(player.raceid);
html += "<table class='CleanTable' style='width: 100%'>"; // New Table
if (settings.terseInfo) {
html += "<tr><td colspan='8'>" + ship.id + ": " + ship.name + "</td></tr>";
if ((settings.showHullForAllies && vgap.fullallied(ship.ownerid)) || (settings.showHullForMine && ship.ownerid == vgap.player.id))
html += "<tr><td colspan='8'>" + hull.name + "</td></tr>";
html += "<tr><td>Neu:</td><td> " + gsv(ship.neutronium) + " / " + hull.fueltank + " </td><td> Dur:</td><td> " + gsv(ship.duranium) + "</td><td> Tri:</td><td> " + gsv(ship.tritanium) + "</td><td> Mol:</td><td> " + gsv(ship.molybdenum) + "</td></tr>";
html += "<tr><td>MC:</td><td> " + gsv(ship.megacredits) + "</td><td>  Cln:</td><td> " + gsv(ship.clans) + "</td><td>  Sup:</td><td> " + gsv(ship.supplies) + "</td>";
if (ship.torps > 0 || ship.bays > 0) {
var ammoText = "   Ftr";
if (ship.torps > 0)
ammoText = "   Tor";
html += "<td>" + ammoText + ":</td><td> " + gsv(ship.ammo) + "</td></tr>";
}
if (ship.ownerid == vgap.player.id || ship.allyupdate) {
html += "<tr>";
if (settings.showShipMission)
html += "<td colspan='2'>" + vgap.getShipMission(ship) + ((ship.mission == 6 || ship.mission == 7) && ship.mission1target > 0 ? " " + ship.mission1target : "") + "</td>";
else
html += "<td/><td/>";
if (ship.damage > 0)
html += "<td> Dmg:</td><td class='BadText'> " + ship.damage + "</td>";
else if (ship.iscloaked)
html += "<td colspan='2' class='GoodText'> Cloaked</td>";
else
html += "<td/><td/>";
html += "<td colspan='2'> Warp " + ship.warp + "</td>"
html += "<td> FC:</td><td> " + ship.friendlycode + "</td></tr>";
}
if (settings.showPlayerForAllies && vgap.fullallied(ship.ownerid)) {
html += "<tr><td colspan='8'>" + race.name + " (" + player.username + ")" + "</td></tr>";
}
} else {
html += "<tr><td colspan='4'>" + ship.id + ": " + ship.name + "</td></tr>";
if ((settings.showHullForAllies && vgap.fullallied(ship.ownerid)) || (settings.showHullForMine && ship.ownerid == vgap.player.id))
html += "<tr><td colspan='4'>" + hull.name + "</td></tr>";
html += "<tr><td>Neutronium:</td><td> " + gsv(ship.neutronium) + "/" + hull.fueltank + " </td><td> Clans:</td><td> " + gsv(ship.clans) + "</td></tr>";
html += "<tr><td>Duranium:</td><td> " + gsv(ship.duranium) + "</td><td> Supplies:</td><td> " + gsv(ship.supplies) + "</td></tr>";
html += "<tr><td>Tritanium:</td><td> " + gsv(ship.tritanium) + "</td><td> Megacredits:</td><td> " + gsv(ship.megacredits) + "</td></tr>";
html += "<tr><td>Molybdenum:</td><td> " + gsv(ship.molybdenum) + "</td>";
if (ship.torps > 0 || ship.bays > 0) {
var ammoText = " Fighters";
if (ship.torps > 0)
ammoText = " Torpedos";
html += "<td>" + ammoText + ":</td><td> " + gsv(ship.ammo) + "</td></tr>";
}
if (ship.ownerid == vgap.player.id || ship.allyupdate) {
html += "<tr><td>Friendly Code:</td><td> " + ship.friendlycode + "</td></tr>";
/*
if (settings.showShipMission)
html += "<tr><td colspan='8'>" + vgap.getShipMission(ship) + ( (ship.mission == 6 || ship.mission == 7) && ship.mission1target > 0 ? " " + ship.mission1target : "") + "</td></tr>";
*/
}
if (settings.showPlayerForAllies && vgap.fullallied(ship.ownerid)) {
html += "<tr><td colspan='4'>" + race.name + " (" + player.username + ")" + "</td></tr>";
}
}
html += this.hitText(hit, hit.isPlanet).replace(" ", "");
html += "</table>";
} else { //enemy
var player = vgap.getPlayer(ship.ownerid);
var hull = vgap.getHull(ship.hullid);
var race = vgap.getRace(player.raceid);
html += "<div class='enemyShipStyle'>";
html += "<table class='CleanTable'>";
html += "<tr><td colspan='2'>" + ship.id + ": " + ship.name + "</td></tr>";
html += "<tr><td colspan='2'>" + hull.name + "</td></tr>";
html += "<tr><td>Heading:</td><td> " + gsv(ship.heading) + " at Warp: " + gsv(ship.warp) + "</td></tr>";
html += "<tr><td>Mass: </td><td> " + gsv(ship.mass) + "</td></tr>";
html += "<tr><td colspan='2'>" + race.name + " (" + player.username + ")" + "</td></tr>";
//html += "<tr><td>Neutronium:</td><td>?/" + hull.fueltank + " </td><td> Total Cargo:</td><td>?/" + hull.cargo + "</td></tr>";
html += this.hitText(hit, hit.isPlanet).replace(" ", "");
html += "</table>";
html += "</div>";
}
html += "</div>";
txt = html;
}
// vgap.action added for the assistant (Alex):
//vgap.action();
return txt;
};
vgaPlanets.prototype.shipTransferView = function (ship, onclick) {
var hull = vgap.getHull(ship.hullid);
var totalCargo = ship.ammo + ship.duranium + ship.tritanium + ship.molybdenum + ship.supplies + ship.clans;
var html = "<div class='ItemSelection' onclick='" + onclick + "'>";
html += "<img src='" + hullImg(ship.hullid) + "'/>";
if (ship.ownerid == vgap.player.id || vgap.fullallied(ship.ownerid)) {
html += "<div " + (vgap.fullallied(ship.ownerid) ? "class='AllyText'" : "") + ">";
if (ship.ownerid != vgap.player.id)
html += vgap.raceName(ship.ownerid);
html += "<span>" + ship.id + ": " + ship.name + "</span>";
html += "<table class='CleanTable'>";
html += "<tr><td>Neutronium:</td><td>" + gsv(ship.neutronium) + "/" + hull.fueltank + " </td><td>Total Cargo:</td><td>" + gsv(totalCargo) + "/" + hull.cargo + "</td></tr>";
html += "<tr><td>Duranium:</td><td>" + gsv(ship.duranium) + "</td><td>Supplies:</td><td>" + gsv(ship.supplies) + "</td></tr>";
html += "<tr><td>Tritanium:</td><td>" + gsv(ship.tritanium) + "</td><td>Megacredits:</td><td>" + gsv(ship.megacredits) + "</td></tr>";
html += "<tr><td>Molybdenum:</td><td>" + gsv(ship.molybdenum) + "</td><td>Clans:</td><td>" + gsv(ship.clans) + "</td></tr>";
if (ship.torps > 0 || ship.bays > 0) {
var ammoText = "Fighters";
if (ship.torps > 0)
ammoText = "Torpedos";
html += "<tr><td>" + ammoText + ":</td><td>" + gsv(ship.ammo) + "</td></tr>";
} else
html += "<tr><td/><td/></tr>";
html += "</table></div>";
} else {
html += "<span class='BadText'>" + ship.id + ": " + ship.name + "</span>";
html += "<div class='BadText'>" + vgap.raceName(ship.ownerid);
html += "<table class='CleanTable'>";
html += "<tr><td>Neutronium:</td><td>?/" + hull.fueltank + " </td><td>Total Cargo:</td><td>?/" + hull.cargo + "</td></tr>";
html += "</table></div>";
}
html += "</div>";
// vgap.action added for the assistant (Alex):
// vgap.action();
return html;
};
vgaPlanets.prototype.shipFullInfoView = function (ship, onclick) {
var view = this.shipTransferView(ship, onclick);
console.log(view);
var html = ""; //"<table class='CleanTable'>";
//html += "<tr>";
html += "<td>Friendly Code:</td><td>" + ship.friendlycode + "</td></tr>";
html += "<tr><td colspan='2'>Warp " + ship.warp + "</td>"
html += "<td colspan='2'>" + vgap.getShipMission(ship) + ((ship.mission == 6 || ship.mission == 7) && ship.mission1target > 0 ? " " + ship.mission1target : "") + "</td></tr>";
html += "<tr>";
if (ship.damage > 0)
html += "<td>Damage:</td><td class='BadText'>" + ship.damage + "</td>";
else if (ship.iscloaked)
html += "<td colspan='2' class='GoodText'>Cloaked</td>";
else
html += "<td/><td/>";
html += "</tr></table>";
//html += "</table>"
// vgap.action added for the assistant (Alex):
// vgap.action();
view = view.split("</tr></table>").join(html);
return view;
};
vgaPlanets.prototype.showHover = function (shipId) {
var ship = vgap.getShip(shipId);
var newheight = 100;
if (ship.ownerid == vgap.player.id || ship.allyupdate) {
this.hc.html(this.shipFullInfoView(ship, ""));
newheight = 120;
if (ship.allyupdate)
newheight += 10;
} else if (vgap.fullallied(ship.ownerid)) {
this.hc.html(this.shipTransferView(ship, ""));
newheight = 110
} else
this.hc.html(this.shipScan(ship, ""));
this.hc.show();
this.hc.height(newheight);
// vgap.action added for the assistant (Alex):
// vgap.action();
};
//*/
vgaPlanets.prototype.getShipMission = function (ship) {
var missions = new Array();
var mdesc = new Array();
var raceid = vgap.getPlayer(ship.ownerid).raceid;
missions.push("Exploration");
mdesc.push("Return information about planets you visit.");
missions.push("Mine Sweep");
mdesc.push("Sweep or detect enemy minefields.");
if (ship.torps > 0) {
missions.push("Lay Mines");
mdesc.push("Convert your torpedos to deep space mines.");
} else {
missions.push("");
mdesc.push("");
}
missions.push("Kill!!");
mdesc.push("Attack any enemy ship or planet you encounter.");
if (ship.hullid == 84 || ship.hullid == 96 || ship.hullid == 9) {
missions.push("Bio Scan");
mdesc.push("Search for native life on nearby planets.");
} else {
missions.push("Sensor Sweep");
mdesc.push("Search for enemy colonies on nearby planets.");
}
missions.push("Land and Disassemble");
mdesc.push("Dismantle this ship on an owned or unowned planet.");
//if (ships.length > 1 && this.hull.engines > 1) {
missions.push("Try to Tow");
mdesc.push("Try to tow another ship at this location.");
/*
}
else {
missions.push("");
mdesc.push("");
}
*/
missions.push("Try to Intercept");
mdesc.push("Try to intercept the ship you have selected.");
if (raceid == 1) {
missions.push("Super Refit");
mdesc.push("Upgrade this ship to the best available parts. Must be at a starbase to work.");
} else if (raceid == 2) {
if (ship.beams > 0) {
missions.push("Hisssss!");
mdesc.push("Increase the happiness on the planet you orbit.");
} else {
missions.push("");
mdesc.push("");
}
} else if (raceid == 3) {
missions.push("Super Spy");
mdesc.push("Spy on an enemy planet for info or to change its friendly code.");
} else if (raceid == 4) {
if (ship.beams > 0) {
missions.push("Pillage Planet");
mdesc.push("Pillage a planet for supplies and money.");
} else {
missions.push("");
mdesc.push("");
}
} else if (raceid == 5) {
missions.push("Rob Ship");
mdesc.push("Rob an enemy ship of its fuel or cargo.");
} else if (raceid == 6) {
missions.push("Self Repair");
mdesc.push("Repair this ship by 10% / turn.");
} else if (raceid == 7) {
if (ship.torps > 0) {
missions.push("Lay Web Mines");
mdesc.push("Convert your torpedos to special fuel sucking mines.");
} else {
missions.push("");
mdesc.push("");
}
} else if (raceid == 8) {
missions.push("Dark Sense");
mdesc.push("Sense enemy colonies and starbases on nearby planets.");
} else if (raceid == 9 || raceid == 11) {
if (ship.bays > 0) {
missions.push("Build Fighters");
mdesc.push("Build fighters on your ship for 3 tritanium, 2 molybdenum and 5 supplies each.");
} else {
missions.push("");
mdesc.push("");
}
} else if (raceid == 10) {
missions.push("Rebel Ground Attack");
mdesc.push("Sabotage the planet to destroy buildings and kill colonists.");
}
if (vgap.getHull(ship.hullid).cancloak) {
missions.push("Cloak");
mdesc.push("Make this ship invisible to enemies.");
} else {
missions.push("");
mdesc.push("");
}
/*
if (this.planet != null) {
missions.push("Beam up Neutronium Fuel from " + this.planet.name);
mdesc.push("");
missions.push("Beam up Duranium from " + this.planet.name);
mdesc.push("");
missions.push("Beam up Tritanium from " + this.planet.name);
mdesc.push("");
missions.push("Beam up Molybdenum from " + this.planet.name);
mdesc.push("");
missions.push("Beam up Supplies from " + this.planet.name);
mdesc.push("");
} else {
*/
missions.push("Beam up Fuel");
mdesc.push("");
missions.push("Beam up Duranium");
mdesc.push("");
missions.push("Beam up Tritanium");
mdesc.push("");
missions.push("Beam up Molybdenum");
mdesc.push("");
missions.push("Beam up Supplies");
mdesc.push("");
//}
return missions[ship.mission];
};
var old_showSettings = vgapDashboard.prototype.showSettings;
vgapDashboard.prototype.showSettings = function () {
old_showSettings.apply(this, arguments);
var settings = vgaPlanets.prototype.addOns.vgapHoverPrediction.settings;
var html = "";
html += "<div id='vgapHoverPredictionSettings'><table>";
html += "<tr><th colspan='4'>Add-On Settings: Planets.nu Hover Prediction</th></tr>";
html += "<tr>";
html += "<td>Use short format</td><td><input type='checkbox'" + (settings.terseInfo ? "checked='true'" : "") + "onChange='vgaPlanets.prototype.addOns.vgapHoverPrediction.settings.terseInfo = !vgaPlanets.prototype.addOns.vgapHoverPrediction.settings.terseInfo; vgap.addOns.vgapHoverPrediction.saveSettings();'/></td>";
html += "<td>Show player for allied ships</td><td><input type='checkbox'" + (settings.showPlayerForAllies ? "checked='true'" : "") + "onChange='vgaPlanets.prototype.addOns.vgapHoverPrediction.settings.showPlayerForAllies = !vgaPlanets.prototype.addOns.vgapHoverPrediction.settings.showPlayerForAllies; vgap.addOns.vgapHoverPrediction.saveSettings();'/></td>";
html += "</tr><tr>";
html += "<td>Show hull type for allied ships</td><td><input type='checkbox'" + (settings.showHullForAllies ? "checked='true'" : "") + "onChange='vgaPlanets.prototype.addOns.vgapHoverPrediction.settings.showHullForAllies = !vgaPlanets.prototype.addOns.vgapHoverPrediction.settings.showHullForAllies; vgap.addOns.vgapHoverPrediction.saveSettings();'/></td>";
html += "<td>Show hull type for my ships</td><td><input type='checkbox'" + (settings.showHullForMine ? "checked='true'" : "") + "onChange='vgaPlanets.prototype.addOns.vgapHoverPrediction.settings.showHullForMine = !vgaPlanets.prototype.addOns.vgapHoverPrediction.settings.showHullForMine; vgap.addOns.vgapHoverPrediction.saveSettings();'/></td>";
html += "</tr><tr>";
html += "<td>Show mission for ships</td><td><input type='checkbox'" + (settings.showShipMission ? "checked='true'" : "") + "onChange='vgaPlanets.prototype.addOns.vgapHoverPrediction.settings.showShipMission = !vgaPlanets.prototype.addOns.vgapHoverPrediction.settings.showShipMission; vgap.addOns.vgapHoverPrediction.saveSettings();'/></td>";
html += "<td>Show Prediction</td><td><input type='checkbox'" + (settings.showPrediction ? "checked='true'" : "") + "onChange='vgaPlanets.prototype.addOns.vgapHoverPrediction.settings.showPrediction = !vgaPlanets.prototype.addOns.vgapHoverPrediction.settings.showPrediction; vgap.addOns.vgapHoverPrediction.saveSettings();'/></td>";
html += "</tr>";
html += "</table></div>";
$("#SoundSettings").after(html);
this.pane.jScrollPane();
};
/* //REPLACED MAP TOOL WITH PERSISTENT SETTING
var old_loadControls = vgapMap.prototype.loadControls;
vgapMap.prototype.loadControls = function () {
old_loadControls.apply(this, arguments);
var additem = "<li onclick='vgap.addOns.vgapHoverPrediction.settings.terseInfo = !vgap.addOns.vgapHoverPrediction.settings.terseInfo;'>Switch Info View</li>";
//$("#MapTools").append(additem);
$("#MapTools > li:contains('Connections (q)')").after(additem);
var height = this.controls.height() - this.toolsMenu.height();
this.controls.css("marginTop", "-" + this.controls.height() + "px");
};
*/
}
var script = document.createElement("script");
script.type = "application/javascript";
script.textContent = "(" + wrapper + ")();";
document.body.appendChild(script);