var menuText = ['Public Offers','Direct Offers','Sent Offers']; var searchText = ['Search for planet: ', 'Search for location: ']; var prhStatus = ['Cancelled', 'Transfer Cancelled', 'Accepted', 'Expired', 'Rejected']; var soModes = ['Gift', 'Private Sale', 'Public Sale', 'Auction Sale']; // Listing texts, defaults var notFound = 'No items found.'; var listingText = ['Display %1% items / page', 'Page %1% / %2%']; // Planet sales var noPSales = '

There are no planets for sale in this area.

'; var noPSalesFound = 'No matching planets were found.'; var psListingText = ['Display %1% planets / page', 'Page %1% / %2%']; var psHeaders = ['Planet', 'Coords.', 'Pop.', 'Turrets', 'Fact.', 'Fleets', 'Owner', 'Expiration', 'Price', 'Action']; // Fleet sales var noFSales = '

There are no fleets for sale in this area.

'; var noFSalesFound = 'No matching locations were found.'; var fsListingText = ['Display %1% planets / page', 'Page %1% / %2%']; var fsHeaders = ['Location', 'Coords.', 'G.A.S.', 'Fgt.', 'Cru.', 'B.Cru.', 'Owner', 'Expiration', 'Price', 'Action'] // Pending private offers var noPOffers = '

There are no offers pending our approval.

'; var noPOffersFound = 'No offers matching this location.

'; var proHeaders = ['Received', 'Sender', 'Price', 'Expiration', 'Details']; // Private offers history var noPHist = '

The history is empty.

'; var noPHistFound = 'No archived offers matching this location.

'; var prhHeaders = ['Received', 'Sender', 'Price', 'Last Change', 'Status', 'Details']; // Pending sent offers var noSOffers = '

We have not offered to sell or give anything recently.

'; var noSOffersFound = 'No offers matching this location.

'; var sopHeaders = ['Date', 'Offer Type', 'Price', 'Expiration', 'To Player', 'Details']; // Private offers history var noSHist = '

The history is empty.

'; var noSHistFound = 'No archived offers matching this location.

'; var sohHeaders = ['Last Change', 'Status', 'Sent', 'Offer Type', 'Price', 'To Player', 'Details']; function drawPublicLayout() { var str = ''; str += ''; // Map table str += '

Planets For Sale

 
'; str += '

 

Fleets For Sale

 
'; str += ''; str += ''; str += '
 Up 
Left '; str += 'Right
 Down 
'; // Centre map on coords... str += '

 

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

Distance:

'; str += '
'; document.getElementById('mkppage').innerHTML = str; // Draw listings pfsListing.draw(); ffsListing.draw(); } function drawPSFleets(v) { if (!v.fleet) return "No fleet"; return "G: " + v.fleet[1] + "; F: " + v.fleet[2] + "; C: " + v.fleet[3] + "; B: " + v.fleet[4] + ""; } function drawPSAction(v) { var s = sellers.get(v.seller); if (s.isMe) return 'Cancel Sale'; else if (v.auction) return 'Place Bid'; return 'Buy'; } function drawFSAction(v) { var s = sellers.get(v.seller); if (s.isMe) return 'Cancel Sale'; else if (v.auction) return 'Place Bid'; return 'Buy'; } function drawExpire(v) { if (v.expires == '') return 'Never'; return formatDate(v.expires); } // Messages for planet sales function confirmPCancel(p) { return confirm('You are about to cancel the public sale of planet ' + p.name + '.\nPlease confirm.'); } function confirmBuyPlanet(p) { return confirm('Are you sure you want to buy planet ' + p.name + ' for\n' + formatNumber(p.price) + ' euros?'); } function planetBought() { alert('Planet has been bought. Control will be transfered to you in 4h, unless\nthe transfer is canceled by the current owner or he loses the planet.'); } function postPBuyError(err) { if (err == '0') { alert('Unable to buy the planet: the offer has expired.'); } else if (err == '1') { alert('Unable to buy the planet: not enough cash.'); } else if (err == '200') { alert('You can\'t use the marketplace while on vacation.'); } else if (err == '201') { alert('You can\'t use the marketplace while under Peacekeeper protection.'); } else{ alert('Unable to buy the planet: unknown error.'); } } function confirmBidPlanet(p) { return prompt('Please place your bid for planet ' + p.name + '.\nMinimum bid: ' + formatNumber(p.price) + ' euros.', (parseInt(p.price)+1).toString()); } function pBidError(p) { alert('Minimum bid for planet ' + p.name + ' is ' + formatNumber(p.price) + ' euros.\nYour bid must be higher than this.'); } function postPBidError(d) { if (d=='0') { alert('Unable to place the bid: the offer has expired.'); startUpdate(); } else if (d=='1') { alert('Unable to place the bid: not enough cash.'); startUpdate(); } else if (d == '200') { alert('You can\'t use the marketplace while on vacation.'); startUpdate(); } else if (err == '201') { alert('You can\'t use the marketplace while under Peacekeeper protection.'); startUpdate(); } else { var a = d.split('#'); var p = getPlanetOffer(a[1]); if (!p) { alert('An unknown error has occured.'); startUpdate(); return; } alert('Unable to place the bid on planet ' + p.name + '\nSomeone has placed a new bid in the meantime.\nThe minimum price is now ' + formatNumber(a[2])); p.price = a[2]; pfsListing.updateDisplay(); doPlacePBid(p.offer); } } // Messages for fleet sales function getFleetComposition(f) { var a = new Array(); if (f.fleet[0] > 0) a.push(f.fleet[0] + ' GA Ship' + (f.fleet[0] > 1 ? 's' : '')); if (f.fleet[1] > 0) a.push(f.fleet[1] + ' Fighter' + (f.fleet[1] > 1 ? 's' : '')); if (f.fleet[2] > 0) a.push(f.fleet[2] + ' Cruiser' + (f.fleet[2] > 1 ? 's' : '')); if (f.fleet[3] > 0) a.push(f.fleet[3] + ' Battle Cruiser' + (f.fleet[3] > 1 ? 's' : '')); return a.join(', '); } function confirmFCancel(f) { return confirm( 'You are about to cancel the public sale of the fleet located at ' + f.plName + '.\n' + 'Fleet composition: ' + getFleetComposition(f) + '.\nPlease confirm.' ); } function confirmBuyFleet(f) { return confirm( 'Are you sure you want to buy the fleet located at ' + f.plName + ' for\n' + formatNumber(f.price) + ' euros?\n' + 'Fleet composition: ' + getFleetComposition(f) + '.\n'); } function fleetBought() { alert('The fleet has been bought. Control will be transfered to you in 4h, unless\nthe transfer is canceled by the current owner or the fleet is destroyed.'); } function postFBuyError(err) { if (err == '0') { alert('Unable to buy the fleet: the offer has expired.'); } else if (err == '1') { alert('Unable to buy the fleet: not enough cash.'); } else if (err == '200') { alert('You can\'t use the marketplace while on vacation.'); } else if (err == '201') { alert('You can\'t use the marketplace while under Peacekeeper protection.'); } else { alert('Unable to buy the fleet: unknown error.'); } } function confirmBidFleet(f) { return prompt( 'Please place your bid for the fleet located at ' + f.plName + '.\n' + 'Fleet composition: ' + getFleetComposition(f) + '.\n' + 'Minimum bid: ' + formatNumber(f.price) + ' euros.', (parseInt(f.price,10) + 1).toString()); } function fBidError(f) { alert('Minimum bid for fleet at ' + f.plName + ' is ' + formatNumber(f.price) + ' euros.\nYour bid must be higher than this.'); } function postFBidError(d) { if (d=='0') { alert('Unable to place the bid: the offer has expired.'); startUpdate(); } else if (d=='1') { alert('Unable to place the bid: not enough cash.'); startUpdate(); } else if (d == '200') { alert('You can\'t use the marketplace while on vacation.'); startUpdate(); } else if (err == '201') { alert('You can\'t use the marketplace while under Peacekeeper protection.'); startUpdate(); } else { var a = d.split('#'); var p = getFleetOffer(a[1]); if (!p) { alert('An unknown error has occured.'); startUpdate(); return; } alert('Unable to place the bid on fleet at ' + f.plName + '\nSomeone has placed a new bid in the meantime.\nThe minimum price is now ' + formatNumber(a[2])); p.price = a[2]; ffsListing.updateDisplay(); doPlaceFBid(p.offer); } } // Private offers function drawPrivateLayout() { var str = '

Pending Offers

 

 

'; str += '

History

 
'; document.getElementById('mkppage').innerHTML = str; // Draw listings proListing.draw(); prhListing.draw(); } function drawPRPrice(i) { return i.price != 0 ? ('€' + formatNumber(i.price)) : 'Free'; } function drawPRDetails(i) { var str = ''; var s, j, ts = ['G.A. Ship', 'Fighter', 'Cruiser', 'Battle Cruiser'], r = new Array(); if (i.planet[0] != '') { str = 'The planet '+i.pName+' at coordinates (' + i.x + ',' + i.y + ',' + i.orbit + '): '; str += '' + formatNumber(i.planet[1]) + 'M inhabitants, ' + formatNumber(i.planet[2]) + ' turrets and '; str += formatNumber(i.planet[3]) + ' factories'; if (i.fleet[0] != '') { str += ' along with a fleet of '; for (j=0;j<4;j++) { if (i.fleet[1+j] == 0) continue; s = '' + formatNumber(i.fleet[1+j]) + ' ' + ts[j]; if (i.fleet[1+j] > 1) s += 's'; r.push(s); } s = r.pop(); str += r.join(', ') + (r.length > 0 ? ' and ' : '') + s; } str += '.'; } else { str += 'A fleet of '; for (j=0;j<4;j++) { if (i.fleet[1+j] == 0) continue; s = '' + formatNumber(i.fleet[1+j]) + ' ' + ts[j]; if (i.fleet[1+j] > 1) s += 's'; r.push(s); } s = r.pop(); str += r.join(', ') + (r.length > 0 ? ' and ' : '') + s; str += ' located in orbit around ' + i.pName + ' (' + i.x + ',' + i.y + ',' + i.orbit + ').'; } if (!i.aDate && i.buyer == null) { str += '
[ Accept offer - '; str += 'Decline offer ]'; } else if (!i.aDate && i.buyer != null) str += '
[ Cancel ]'; return str; } function confirmBuyPrivate(p) { var str = 'Are you sure you want to accept this private offer?'; if (p.price > 0) str += '\nIt will cost you ' + formatNumber(p.price) + ' euros.'; return confirm(str); } function confirmDeclinePrivate() { return confirm('Please confirm that you want to decline this offer.'); } function privateError(err) { if (err == '0') { alert('Unable to accept the offer: it has expired.'); } else if (err == '1') { alert('Unable to accept the offer: not enough cash.'); } else if (err == '200') { alert('You can\'t use the marketplace while on vacation.'); } else if (err == '201') { alert('You can\'t use the marketplace while under Peacekeeper protection.'); } else { alert('Unable to accept the offer: unknown error.'); } } // Sent offers function drawSentLayout() { var str = '

Pending Offers

 

 

'; str += '

History

 
'; document.getElementById('mkppage').innerHTML = str; // Draw listings sopListing.draw(); sohListing.draw(); } function drawSentBuyer(v) { if (v.buyer == '') return "None"; var s = sellers.get(v.buyer); return (s.isMe||s.quit ? '' : ('')) + s.name + (s.isMe||s.quit ? '' : ''); } function confirmCancelSale() { return confirm('You are about to cancel an offer. Please confirm.'); }