// ==UserScript==
// @name Planets.nu Hover Prediction
// @namespace quapla/Hover Prediction
// @date 2016-05-20
// @author Quapla - Jim Clark - Dtolman - 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 2.11
// ==/UserScript==
//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
2.10 - Added Prediction by Quapla
2.11 - Added Funktion from Stephen Piper
------------------------------------------------------------------------------*/
function wrapper()
{ // wrapper for injection
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;
if (vgap.terseInfo)
var tersecolspan = 8;
else
var tersecolspan = 4;
var txt = "";
if (hit.isPlanet)
{ //planet
// if (hit.id < 0) { hit = vgap.getPlanet(-hit.id); } // For what is that good? Quapla
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 class='CleanTable'>";
if (hit.infoturn == 0)
{ //unknown planet
//txt += this.hitText(hit, hit.isPlanet).replace(" ", ""); // For what is that good? Quapla
}
else
{
if (hit.nativeclans > 0) // Has natives
{
txt += "<tr><td colspan=" + tersecolspan + ">" + addCommas(hit.nativeclans * 100) + " " + hit.nativeracename + " - " + hit.nativegovernmentname + "</td></tr>";
}
var nText = gsv(hit.neutronium) + " / " + gsv(hit.groundneutronium);
var dText = gsv(hit.duranium) + " / " + gsv(hit.groundduranium);
var tText = gsv(hit.tritanium) + " / " + gsv(hit.groundtritanium);
var mText = gsv(hit.molybdenum) + " / " + gsv(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 (settings.terseInfo)
{
txt += "<div class='ItemSelectionBox minCorrection'>";
txt += "<table class='CleanTable'>";
if (hit.ownerid == vgap.player.id && hit.readystatus == 0) // Planet ready?
txt += "<tr><td colspan='2' class='WarnText'>" + hit.id + ":" + hit.name + "</td>";
else
txt += "<tr><td colspan='2'>" + hit.id + ":" + hit.name + "</td>";
if (hit.clans > 0) // Has Clans
{
txt += "<td align='right' colspan='2'> " + hit.clans + "</td>";
txt += "<td align='right'> " + hit.friendlycode + "</td>";
if (hit.temp > 84 || hit.temp < 15)
txt += "<td align='right' class='Warntext'>";
else
txt += "<td align='right'>";
txt += " " + hit.temp + "</td>";
}
txt += "</tr>";
if (hit.nativeclans > 0) // Has Natives
{
txt += "<tr><td colspan='2'>" + hit.nativeracename + "</td>";
txt += "<td align='right' colspan='2'> " + hit.nativeclans + "</td>"
if (hit.ownerid == vgap.player.id)
{
txt += "<td align='right'> " + hit.nativehappypoints + "%</td>";
txt += "<td align='right'> " + 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>"
// }
if (hit.infoturn != 0 && !vgap.godmode)
{
// txt += this.hitText(c, hit.isPlanet).replace(" ", "");
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(c, hit.nativetaxrate);
ns = hitText.prototype.nativesupportedtax(c);
cs = ns - nt;
nt = Math.min(nt, ns);
nt10 = hitText.prototype.nativeTaxAmount(c, 10);
ns10 = hitText.prototype.nativesupportedtax(c);
cs10 = ns10 - nt10;
nt10 = Math.min(nt10, ns10);
}
ct = Math.round(hit.clans * hit.colonisttaxrate / 1000);
mn = hitText.prototype.miningRate(c, hit.groundneutronium, hit.densityneutronium);
md = hitText.prototype.miningRate(c, hit.groundduranium, hit.densityduranium);
mm = hitText.prototype.miningRate(c, hit.groundmolybdenum, hit.densitymolybdenum);
mt = hitText.prototype.miningRate(c, hit.groundtritanium, hit.densitytritanium);
txt += "</table><table class='CleanTable'>";
if (hit.groundneutronium > 0)
{
txt += "<tr><td>Neu:</td><td align='right'>" + hit.neutronium + "/ </td><td align='right'>" + hit.groundneutronium
+ "+ </td><td align='right'>" + mn + "</td>";
txt += "<td> Sup:</td><td align='right'>" + hit.supplies + "+ </td><td align='right'>" + sp + "- ";
if (sps < 0)
txt += "</td><td class='WarnText' align='right'>" + (-sps);
txt += "</td></tr>";
txt += "<tr><td>Dur:</td><td align='right'>" + hit.duranium + "/ </td><td align='right'>" + hit.groundduranium
+ "+ </td><td align='right'>" + md + "</td>";
txt += "<td> $:</td><td align='right'>" + hit.megacredits + "+ </td><td align='right'>" + (nt + ct) + "- ";
if (cs < 0)
txt += "</td><td class='WarnText' align='right'>" + (-cs);
txt += "</td></tr>";
txt += "<tr><td>Tri:</td><td align='right'>" + hit.tritanium + "/ </td><td align='right'>" + hit.groundtritanium
+ "+ </td><td align='right'>" + mt + "</td>";
if (hit.nativeclans > 0)
{
txt += "<td> 10%:</td><td> </td><td align='right'>" + nt10 + "- ";
if (cs10 < 0)
txt += "</td><td class='WarnText' align='right'>" + (-cs10);
}
txt += "</td></tr>";
txt += "<tr><td>Mol:</td><td align='right'>" + hit.molybdenum + "/ </td><td align='right'>" + hit.groundmolybdenum
+ "+ </td><td align='right'>" + mm + "</td>";
txt += "<td> M/F/D:</td><td colspan=2> " + hit.mines + " / " + hit.factories + " / " + hit.defense + "<td>";
txt += "</tr>";
var n = vgap.getStarbase(hit.id);
if (n != null && (hit.ownerid == vgap.player.id || vgap.fullallied(hit.ownerid)))
{
if (n.starbasetype != 2)
{
if (n.isbuilding)
{
txt += "<tr><td colspan='6'>Bld: " + vgap.getHull(n.buildhullid).name + "</td></tr>";
}
else
{
txt += "<tr><td colspan='6' class='WarnText'>SB Not Building</td></tr>";
}
}
}
else
{
if (hit.duranium > 119 && hit.tritanium > 401 && hit.molybdenum > 339 && (hit.megacredits + hit.supplies) > 899)
txt += "<tr><td colspan='6' class='WarnText'>Can build Starbase</td></tr>";
}
}
if (hit.ownerid != vgap.player.id && hit.ownerid != 0)
{
var k = vgap.getPlayer(hit.ownerid);
var l = vgap.getRace(k.raceid);
txt += "<tr><td colspan='4'>" + l.name + " (" + k.username + ")</td></tr>";
}
txt += this.hitText(c, hit.isPlanet).replace(" ", "");
}
txt += "</table>";
}
// old txt +=
// "<tr> <td>Neu: </td><td> " + nText + " </td>" + "<td>Col: </td><td> " + addCommas(gsv(hit.clans * 100)) + "</td></tr>" +
// "<tr> <td>Dur: </td><td> " + dText + " </td>" + "<td>Sup: </td><td> " + gsv(hit.supplies) + "</td></tr>" +
// "<tr> <td>Tri: </td><td> " + tText + " </td>" + "<td>MC: </td><td> " + gsv(hit.megacredits) + "</td></tr>" +
// "<tr> <td>Mol: </td><td> " + mText + " </td>" + "<td>FC: </td><td> " + hit.friendlycode + "</td></tr>";
else
{
txt +=
"<tr> <td>Neutronium: </td><td> " + nText + " </td>" + "<td>Colonists: </td><td> " + addCommas(gsv(hit.clans * 100)) + "</td></tr>" +
"<tr> <td>Duranium: </td><td> " + dText + " </td>" + "<td>Supplies: </td><td> " + gsv(hit.supplies) + "</td></tr>" +
"<tr> <td>Tritanium: </td><td> " + tText + " </td>" + "<td>Megacredits: </td><td> " + gsv(hit.megacredits) + "</td></tr>" +
"<tr> <td>Molybdenum: </td><td> " + mText + " </td>" + "<td>Friendly Code: </td><td> " + hit.friendlycode + "</td></tr>";
}
/// Population in popup text
//////////////////////
var planetOwner = null;
var maxPop = 0;
var minPop = 0;
// Do we have a temp scan?
if (hit.temp >= 0 && hit.temp <= 100)
{
// Use your race if plnet 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;
}
}
// 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;
}
txt += "<tr><td>GrowPop: </td><td> " + (minPop == 0 ? "n/a" : minPop) + "</td><td>Max: </td><td> " + maxPop + "</td></tr>";
}
//////////////////////
var starbase = vgap.getStarbase(hit.id);
if (starbase != null && (hit.ownerid == vgap.player.id || hit.allyupdate))
{
txt += "<tr> <td>" + (false /*settings.terseInfo*/ ? "Ftr: " : "Fighters: ") + "</td><td> " + starbase.fighters + "</td></tr>";
/// Add tech levels for SB
///////////////////////
txt += "<tr><td>Hull: </td><td> " + starbase.hulltechlevel + "</td><td>Engine: </td><td> " + starbase.enginetechlevel + "</td></tr>";
txt += "<tr><td>Beam: </td><td> " + starbase.beamtechlevel + "</td><td>Torp: </td><td> " + starbase.torptechlevel + "</td></tr>";
///////////////////////
if (starbase.isbuilding)
{
txt += "<tr> <td colspan='4'>Build: " + vgap.getHull(starbase.buildhullid).name + "</td></tr>";
}
}
//txt += this.hitText(hit, hit.isPlanet).replace(" ", "");
}
//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='4'>" + race.name + " (" + player.username + ")</td></tr>";
}
txt += this.hitText(hit, hit.isPlanet).replace(" ", "");
txt += "</table></div>";
}
else
{ //ship
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;
}
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;
}
// 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];
};
vgaPlanets.prototype.nativeTaxAmount = function (c, ntr)
{
var nt = 0;
if (c.nativeclans > 0)
{
if (c.race == 6 && ntr > 20)
{ // borg == 6
ntr = 20;
}
var nt = (c.nativeclans / 100) * (ntr / 10) * (c.nativegovernment / 5);
nt = c.nativetype == 5 ? 0 : nt; // amorphous == 5
nt *= c.race == 1 ? 2 : 1; // feds == 1
nt *= c.nativetype == 6 ? 2 : 1; // insect == 6
nt = Math.round(nt);
}
return nt;
};
vgaPlanets.prototype.nativesupportedtax = function (c)
{
ns = c.clans;
ns *= c.race == 1 ? 2 : 1; // feds == 1
ns *= c.nativetype == 6 ? 2 : 1; // insect == 6
return ns;
};
vgaPlanets.prototype.miningRate = function (p, ground, density)
{
m = vgap.miningRate(p, density);
m = m > ground ? ground : Math.round(m);
return m;
};
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);