// Public games page (2026-10-10): every game in the network, live ones first, then the ones with an opening date. // Data: /api/public/games/all. Play links go to each game's own site (the game signs the visitor in with InstantAdPay). // A ?ref= on this page is kept by the site's viral-link handling and carried onto the Join button. (function () { var esc = function (s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]; }); }; var ref = ''; try { ref = new URLSearchParams(location.search).get('ref') || ''; } catch (e) {} if (ref) { var j = document.getElementById('gJoin'); if (j) j.href = '/join?ref=' + encodeURIComponent(ref); } function card(g) { var soon = !g.live && g.opens; var ribbon = g.season ? 'Limited time · ends ' + esc(g.season.ends) + '' : soon ? '' + esc(g.opens) + '' : ''; var play = g.live && g.open ? 'Play' : '' + esc(g.opens || 'Opens soon') + ''; var site = g.host ? '' + esc(g.host) + '' : ''; return '
' + (g.art ? '' : '') + ribbon + '
' + '
' + esc(g.tag || '') + '

' + esc(g.name) + '

' + esc(g.blurb || '') + '

' + (g.pays ? '
Pays: ' + esc(g.pays) + '
' : '') + '
' + play + site + '
'; } fetch('/api/public/games/all').then(function (r) { return r.json(); }).then(function (d) { var games = (d && d.games) || []; var live = games.filter(function (g) { return g.live; }), soon = games.filter(function (g) { return !g.live; }); var L = document.getElementById('gLive'), S = document.getElementById('gSoon'); if (!games.length) { document.getElementById('gEmpty').hidden = false; return; } if (live.length) L.innerHTML = '

Open now · ' + live.length + ' game' + (live.length === 1 ? '' : 's') + '

' + live.map(card).join('') + '
'; if (soon.length) S.innerHTML = '

Opening next

' + soon.map(card).join('') + '
'; }).catch(function () { document.getElementById('gEmpty').hidden = false; }); // featured warriors from the PolyWarriors market (2026-10-10): the rarest listings, with the forged art fetch('/api/public/pw-featured').then(function (r) { return r.json(); }).then(function (d) { var f = (d && d.featured) || []; if (!f.length) return; var S = document.getElementById('gSoon'); var host = document.createElement('div'); host.id = 'gFeatured'; host.innerHTML = '

From the PolyWarriors market open the market

' + f.map(function (x) { return '
' + esc(x.rarity) + '' + (x.forSale ? 'For sale' : '') + '
' + esc(x.name) + ' #' + String(x.serial).padStart(4, '0') + '' + (x.forge ? 'Forged ' + esc(x.forge.grade) + ' ' + esc(x.forge.score) + '' : '') + (x.forSale ? '' + esc(x.price) + ' POL' : '') + '
'; }).join('') + '
'; S.parentNode.insertBefore(host, S.nextSibling); }).catch(function () {}); })();