var actionText = ['Please select at least one fleet.', 'Rename', 'Change orders', 'Switch status', 'Split', 'Merge', 'Sell', 'Disband', 'View trajectory', 'Clear selection', 'Cancel sale', 'Sale details']; var statusText = ['Attack', 'Defense', 'Avail.', 'Unavail.', 'On sale', 'Sold', ' (bundled)']; var sectionTitles = ['Own planets', 'Allied planets', 'Other planets', 'Moving fleets', 'Fleets standing by']; var noFleetsFound = 'No fleets were found.'; var foSelHeader = 'OwnerNameHaulShips (G/F/C/B)PowerTrajectory'; var foAvaHeader = 'OwnerNameHaulShips (G/F/C/B)PowerCurrent Orders'; var curOrdersTxt = ['Defending ', 'Attacking ', '', '', 'Moving to ', 'Moving to ', ' for defense', ' for attack', 'Standing by in Hyperspace to defend ', 'Standing by in Hyperspace to attack ', '', '']; var noSelection = 'no destination selected'; var smapCoordTxt = "System at coordinates "; var dirTxt = ['Up', 'Left', 'Right', 'Down']; var unchartedTxt = "(uncharted)"; var orbitTypes = ['Planet', 'Planetary remains', 'Class 1 nebula', 'Class 2 nebula', 'Class 3 nebula', 'Class 4 nebula']; var salesText = ['Target player:', 'Price:', 'Minimum bid:']; function drawMainLayout() { var i, str = '
'; // Locations str += ''; // Modes str += ''; // Current status str += ''; // Allies mode str += '
Locations:Fleet mode:
Fleet status:Fleet owner:
'; // Search engine str += '
'; str += 'Search for '; str += '
'; // Main display str += '
 
'; // Commands str += '
'; str += '
Actions: Help
'; str += '
'; document.getElementById('fpage').innerHTML = str; document.getElementById('sText').value = sText; } function drawMovingHeader(hasSel) { var str; str = ''; if (hasSel) { str += ''; } str += ''; str += ''; str += ''; str += ''; str += ''; str += '
 OwnerNameHaulGA ShipsFightersCruisersBattle CruisersPowerStatus
Current LocationDestinationE.T.A.H.S. Standby
'; return str; } function drawWaitingHeader(hasSel) { var str; str = ''; if (hasSel) { str += ''; } str += ''; str += ''; str += ''; str += ''; str += ''; str += '
 OwnerNameHaulGA ShipsFightersCruisersBattle CruisersPowerStatus
LocationTime SpentTime LeftLoss Prob.
'; return str; } function drawPlanetBox(planet) { var str = ''; var so = (planet.fleetLocation.details && planet.fleetLocation.details.owner != '' && planet.fleetLocation.details.owner != myself.id); var apow = 0, dpow = 0; str += "'; if (so) { str += ''; } str += "
" + planet.fleetLocation.name + ''; str += " (" + planet.fleetLocation.x + ',' + planet.fleetLocation.y + ',' + planet.fleetLocation.orbit + ')'; if (planet.fleetLocation.details && planet.fleetLocation.details.tag != '') { str += ' [' + planet.fleetLocation.details.tag + ']'; } str += ''; str += players.get(planet.fleetLocation.details.owner) + ''; if (turrets != 0) { str += '' + formatNumber(turrets) + ' turret' + (turrets > 1 ? 's' : ''); str += '; power: ' + formatNumber(tPower) + ''; dpow += parseInt(tPower, 10); } else { str += 'No turrets'; } } } else { str += ' colspan="2">' + (planet.fleetLocation.opacity == 1 ? 'Planetary remains' : ('Class ' + (planet.fleetLocation.opacity - 1) + ' nebula')); } str += '
'; str += ''; str += ''; str += ''; planet.fleets.sort(sortPlanetFleets); for (j=0;j= planet.fleetLocation.details.pop) { act.push(a); } else if (og > 0) { var ep = parseInt(planet.fleetLocation.details.pop, 10) - og * a.gaPop; ep = Math.ceil(ep / a.gaPop); ang.push([a,ep.toString()]); } } } if (act.length || ang.length || apow != 0 || planet.fleetLocation.details.vacation || planet.fleetLocation.details.protection) { str += '
 OwnerNameHaulGA ShipsFightersCruisersBattle CruisersPowerStatus
'; if (act.length) { for (j=0;j' + formatNumber(ang[j][1]) + ' more GA Ship' + (ang[j][1] > 1 ? 's' : '') + ' to take this planet.'; if (j != ang.length - 1) { str += '
'; } } if (apow != 0) { str += '
'; } } if (apow != 0) { str += 'Battle status: ' + formatNumber((om == 0 ? dpow : apow).toString()) + ' vs. ' + formatNumber((om == 1 ? dpow : apow).toString()) + ''; if (planet.fleetLocation.details.vacation || planet.fleetLocation.details.protection) { str += '
'; } } if (planet.fleetLocation.details.protection) { str += 'Planet is under protection!'; } else if (planet.fleetLocation.details.vacation) { str += 'Planet is on vacation!'; } } } str += '
'; } else { str += 'noflt">No fleets found'; } str += '
'; return str; } function getNewFleetName(p) { return prompt("Please type the new name for th"+(p?"ese fleets":"is fleet")+".", ""); } function alertFleetName(e) { var str = 'Error: '; switch (e) { case 0: str += 'please specify a name'; break; case 1: str += 'this name is too long'; break; case 2: str += 'this name is too short'; break; case 3: str += 'a fleet was not found'; break; case 200: str += 'you can\'t rename a fleet while in vacation mode'; break; default: str += 'an unknown error has occured'; break; } alert(str + '.'); } function getMergedFleetName() { return prompt("Please type the name of the merged fleet. Leave blank to keep\nits former name.\n", ''); } function alertFleetMerge(e) { var str = 'Error: '; switch (e) { case 0: str += 'this name is too long'; break; case 1: str += 'this name is too short'; break; case 2: str += 'a fleet was not found'; break; case 200: str += 'you can\'t merge fleets while in vacation mode'; break; default: str += 'an unknown error has occured'; break; } alert(str + '.'); } function alertFleetSwitch(e) { var str = 'Error: '; switch (e) { case 0: str += 'you no longer have control over this fleet'; break; case 1: str += 'you can\'t switch to attack mode on a planet you own'; break; case 2: str += 'you (or your alliance) are in the planet owner\'s enemy list'; break; case 3: str += 'the Peacekeepers will not let you get away with that so easily'; break; case 200: str += 'you can\'t switch a fleet\'s status while in vacation mode'; break; default: str += 'an unknown error has occured'; break; } alert(str + '.'); } function alertFleetDisband(e) { var str = 'Error: '; switch (e) { case 0: str += 'you don\'t have control over this fleet'; break; case 1: str += 'the selected fleet(s) no longer exist'; break; case 2: str += 'not enough cash to cancel the fleet\'s sale'; break; case 200: str += 'you can\'t disband fleets while in vacation mode'; break; default: str += 'an unknown error has occured'; break; } alert(str + '.'); } function alertFleetSplit(e) { var str = 'Error: '; switch (e) { case 0: str += 'you no longer have control over this fleet'; break; case 1: str += 'you are trying to cheat, aren\'t you? If not, contact us'; break; case 2: case 5: str += 'the fleet you tried to split is no longer available'; break; case 3: case 4: case 7: str += 'the fleet\'s size has changed in the meantime'; break; case 10: str += 'the new fleets\' name is too short'; break; case 11: str += 'the new fleets\' name is too long'; break; case 200: str += 'you can\'t split a fleet while in vacation mode'; break; default: str += 'an unknown error has occured'; break; } alert(str + '.'); } function alertFleetOrders(e) { var str = 'Error: '; switch (e) { case 0: str += 'you no longer have control over these fleets'; break; case 1: str += 'the destination planet wasn\'t found'; break; case 2: str += 'an internal error occured.\nPlease report this to the staff as "setOrders/2"'; break; case 3: str += 'the fleets you selected are for sale'; break; case 4: str += 'the fleets you selected are no longer available'; break; case 200: str += 'you can\'t change fleet orders while in vacation mode'; break; default: str += 'an unknown error has occured'; break; } alert(str + '.'); } function alertServerError() { alert('Error: an error has occured on the server.\nPlease contact the staff.'); } function alertViewSale() { alert('Error: this sale is no longer available'); } function drawSplitPage() { var i, str = '

'; var f = splitParam[0]; switch (f.orders.oType) { case 0: str += 'Split fleet orbitting ' + f.orders.loc.name + '


'; str += '
'; str += ''; str += ''; str += ''; str += drawFleetLine(f, (f.owner == myself.id ? 'own' : 'ally'), false); str += '
OwnerNameHaulGA ShipsFightersCruisersBattle CruisersPowerStatus
'; break; case 1: str += 'Split moving fleet
'; str += drawMovingFleetLine(f, false); str += '
' + drawMovingHeader(false) + '
'; break; case 2: str += 'Split waiting fleet
'; str += drawWaitingFleetLine(f, false); str += '
' + drawWaitingHeader() + '
'; break; } str += '

New fleet(s)

'; str += ''; str += ''; str += ''; if (f.ships[0] > 0) { var c = 'setSplitShips(0,parseInt(this.value, 10))'; c = "onKeyUp='"+c+"' onClick='"+c+"'"; str += ''; } if (f.ships[1] > 0) { var c = 'setSplitShips(1,parseInt(this.value, 10))'; c = " onKeyUp='"+c+"' onClick='"+c+"'"; str += ''; } if (f.ships[2] > 0) { var c = 'setSplitShips(2,parseInt(this.value, 10))'; c = " onKeyUp='"+c+"' onClick='"+c+"'"; str += ''; } if (f.ships[3] > 0) { var c = 'setSplitShips(3,parseInt(this.value, 10))'; c = " onKeyUp='"+c+"' onClick='"+c+"'"; str += ''; } if (f.ships[2] > 0 || f.ships[3] > 0) str += ''; str += ''; str += '
Split type:
 
Amount of fleets:
New name:
 
GA Ships: / ' + formatNumber(f.ships[0]) + '
Fighters: / ' + formatNumber(f.ships[1]) + '
Cruisers: / ' + formatNumber(f.ships[2]) + '
Battle Cruisers: / ' + formatNumber(f.ships[3]) + '
Haul used:0
Haul available:0
 
'; str += ''; str += '
'; str += '
'; document.getElementById('fpage').innerHTML = str; } function confirmDisband(p) { return confirm('Are you sure you want to disband ' + (p ? 'these fleets' : 'this fleet') + '?'); } function drawOrdersPage() { var str = '
' + '

Change Orders

 
' + '

New orders

 
 
' + ' 

Selected fleets

 
' + '

Available fleets

 
'; document.getElementById('fpage').innerHTML = str; } function getMoveToLine() { if (moveTo == -1) return "No destination selected - Set destination"; return "Move to " + moveToLoc.name + " (" + moveToLoc.x + ',' + moveToLoc.y + ',' + moveToLoc.orbit + ") - Change destination - " + "Remove destination"; } function getStandByLine() { if (!selCanHS) { waitTime = -1; return "Selection is not capable of Hyperspace travel"; } if (waitTime == -1) return "No Hyperspace stand-by orders - Set delay"; return "Selection is scheduled to stand by in Hyperspace for " + waitTime + "h " + " - Change delay" + " - Remove delay"; } function getModeLine() { var fd = false; if (orderFleets.length) { var i; for (i=0;i" + ""; } function getOrderLinks() { var str = ""; if (orderFleets.length > 0) str += 'Confirm - '; str += 'Cancel'; return str; } function getFleetDelay(current) { return prompt("Please enter the duration of the fleet's Hyperspace stand by,\nin hours.", current); } function fleetDelayError(e) { var str = "Error: "; switch (e) { case 0: str += "please type a valid number"; break; case 1: str += "the delay must be at least 1 hour"; break; case 2: str += "the delay must be at most 48 hours"; break; } alert(str); } function drawDestinationSelection() { var str = '
'; str += '

Set Destination

'; str += '

Current selection:  

'; str += 'Please use the map on the right to select a new destination.

'; str += '

'; str += '

'; str += '
 
'; document.getElementById('fpage').innerHTML = str; } function drawMapControls() { var str; // Centre map on coords... str = '

 

'; str += ''; str += ''; str += ''; str += ''; // Centre map on own planet... str += ''; str += ''; str += ''; // Centre map on planet... str += ''; str += ''; str += ''; str += '
'; str += '
 '; str += '(,)
'; str += '
 '; str += '
'; str += '
 '; str += '

'; return str; } function alertMap() { alert('Error: this planet was not found on the map'); } function getTrajectoryText(id, t) { if (!t) return "(loading)"; var f = fleets.get(id); if (t.length == 0 && f.orders.oType != 1) return "N/A"; var r, i, str = ''; return str; } function drawFleetTrajectory() { var str, f = fleetTrajectory.fleet, o = allies.get(f.owner); var used = f.ships[0] * o.gSpace + f.ships[1] * o.fSpace; var haul = f.ships[2] * o.cHaul + f.ships[3] * o.bHaul; var m = parseInt(f.mode, 10); str = '

View Fleet Trajectory ...

' + '' + 'Close

Selected Fleet

' + foAvaHeader + '
' + players.get(f.owner) + '' + f.name + ''; if (haul == 0) str += 'N/A'; else { var hp = Math.round(used * 100 / haul); str += (hp > 200) ? '>200%' : (hp + '%'); } var op = locations.get(fleetTrajectory.from); str += '' + formatNumber(f.ships[0]) + ' / ' + formatNumber(f.ships[1]) + ' / ' + formatNumber(f.ships[2]) + ' / ' + formatNumber(f.ships[3]) + '' + formatNumber(f.power) + '' + curOrdersTxt[m+4] + f.orders.to.name + curOrdersTxt[m+6] + '

Trajectory

Fleet moving in ' + (fleetTrajectory.hyperspace ? 'Hyperspace' : 'normal space') + '; original point of origin: ' + '' + op.name + ' (' + op.x + ',' + op.y + ',' + op.orbit + ')

' + ''; var hc = false; if (fleetTrajectory.changed > 0) { str += ''; hc = true; } var i; for (i=0;i' + wp.name + ' (' + wp.system + ',' + wp.orbit + ')'; } if (fleetTrajectory.wait != 0) { var wp = fleetTrajectory.waypoints[fleetTrajectory.waypoints.length - 1]; str += ''; } str += '
LocationType' + 'Status
' + fleetTrajectory.waypoints[0].name + ' (' + fleetTrajectory.waypoints[0].system + ',' + fleetTrajectory.waypoints[0].orbit + ')'+ orbitTypes[fleetTrajectory.waypoints[0].opacity] + 'Rerouting (' + fleetTrajectory.changed + ' minute' + (fleetTrajectory.changed > 1 ? 's' : '') + ')
' + orbitTypes[wp.opacity] + ''; if (!hc) { var n = wp.eta - fleetTrajectory.left; if (n > 0) str += 'Left orbit ' + n + ' minute' + (n>1?'s':'') + ' ago'; else str += 'Just left orbit'; } else if (i < fleetTrajectory.waypoints.length - 1) { var n = fleetTrajectory.left + fleetTrajectory.changed - wp.eta; str += 'Leaving orbit in ' + n + ' minute' + (n>1?'s':''); } else { var n = fleetTrajectory.left + fleetTrajectory.changed - wp.eta; str += 'Reaching destination in ' + n + ' minute' + (n>1?'s':''); } str += '
' + wp.name + ' (' + wp.system + ',' + wp.orbit + ')' + orbitTypes[wp.opacity] + 'Standing by in Hyperspace for ' + fleetTrajectory.wait + ' hour' + (fleetTrajectory.wait>1?'s':'') + '
'; document.getElementById('fpage').innerHTML = str; } function drawSellLayout() { var str; str = '
' + '

Sell Fleets ...

 
' + '
 
'; document.getElementById('fpage').innerHTML = str; } function FleetSale_drawForm() {with(this){ var str; str = '

 

Orbitting ' + fleetLocation.name + ' (' + fleetLocation.x + ',' + fleetLocation.y + ',' + fleetLocation.orbit + ')

Selected Fleets

' + ''; var tot = [0,0,0,0,0]; for (var i=0;i'; for (var j=0;j<4;j++) { str += ''; tot[j] += parseInt(fleets[i].ships[j], 10); } str += ''; tot[4] += parseInt(fleets[i].power, 10); } str += ''; for (i=0;i<5;i++) str += ''; var smc = ['','','','']; smc[mode] = ' checked="checked"'; str += '
Fleet NameG.A. ShipsFightersCruisers' + 'Battle CruisersPower
' + formatNumber(fleets[i].ships[j]) + '' + formatNumber(fleets[i].power) + '
Total' + formatNumber(tot[i].toString()) + '

Sale details

' + '' + '
   
  
  
 
'; return str; }} function drawSellLinks(valid) { var str; if (valid) str = 'Confirm - '; else str = ''; str += 'Cancel'; document.getElementById('chordc').innerHTML = str; } function saleAlert(ec, id) { var str; if (ec == -1) str = "Go away, kiddie."; else if (ec == 4) str = 'Error: some fleets were no longer available for sale; they have been\nremoved from the ' + 'list. Please verify the updated fleet sale form.'; else if (ec == 5) { str = 'Error: none of the previously selected fleets are available for sale.'; } else if (ec == 200) { str = 'Error: you are not allowed to sell fleets while in vacation mode.'; } else if (ec == 201) { str = 'Error: you are not allowed to sell fleets while under Peacekeeper protection.'; } else { str = 'An error occured while handling the sale at ' + locations.get(id).name + ':\n'; switch (ec) { case 0: str += 'The target player could not be found.'; break; case 1: str += 'The target player is in a different protection level.'; break; case 2: str += 'The price is invalid.'; break; case 3: str += 'Auction sales require an expiration date.'; break; case 6: str += 'You are trying to sell or give a fleet to yourself.'; break; case 7: str += 'The target player has not been in the game long enough to\naccept the offer.'; break; } } alert(str); } function confirmCancelSale(pl) { return confirm('Are you sure you want to cancel the sale of th' + (pl?'ese fleets':'is fleet') + '?'); } function drawSaleDetails(l, name) { var str, f = fleets.get(l[1]), o = allies.get(f.owner); var used = f.ships[0] * o.gSpace + f.ships[1] * o.fSpace; var haul = f.ships[2] * o.cHaul + f.ships[3] * o.bHaul; var m = parseInt(f.mode, 10); str = '

Fleet Sale Details

' + '' + 'Close

Fleet

' + foAvaHeader + '
' + o.getName() + '' + f.name + '' if (haul == 0) str += 'N/A'; else { var hp = Math.round(used * 100 / haul); str += (hp > 200) ? '>200%' : (hp + '%'); } str += '' + formatNumber(f.ships[0]) + ' / ' + formatNumber(f.ships[1]) + ' / ' + formatNumber(f.ships[2]) + ' / ' + formatNumber(f.ships[3]) + '' + formatNumber(f.power) + '' + (f.orders.oType == 3 ? 'On sale at ' : 'Waiting for transfer at ') + f.orders.loc.name + '

Sale details

'; if (st == 1) str += ''; str += ''; break; case '1': str += 'Public offer' + ''; st = 2; break; case '2': str += 'Auction sale' + ''; if (l[8] != '') { str += ''; if (l[3] == "") str += ''; } st = 3; break; } if (l[3] != "") { var tx = parseInt(l[5],10) + 1; str += ''; if (st > 1) str += ''; str += ''; } str += '
Sale type:'; var st; switch (l[6]) { case '0': if (l[7] == '0') { str += 'Gift'; st = 0; } else { str += 'Direct offer'; st = 1; } str += '
To player:' + name + '
Price:€' + formatNumber(l[7]) + '
Expires:' + (l[2] == "" ? 'Never' : formatDate(l[2])) + '
Price:' + formatNumber(l[7]) + '
Expires:' + (l[2] == "" ? 'Never' : formatDate(l[2])) + '
Minimum bid:' + formatNumber(l[7]) + '
Expires:' + formatDate(l[2]) + '
Latest bid at:' + formatDate(l[10]) + '
' + 'Bid:€' + formatNumber(l[8]) + '
Bid by:' + name + '
Finalized:' + formatDate(l[3]) + '
Sold to:' + name + '
Transfer time:' + tx + ' hour' + (tx > 1 ? 's' : '') + '
'; document.getElementById('fpage').innerHTML = str; }