Facts you learn as you play (SkyCash): tips priced from the live IAP catalog on the lobby, run-over and chapter-cleared cards; Level up on InstantAdPay button in the lobby
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
// "Facts so you learn as you play" (SkyCash, 2026-09-30). Every number comes from InstantAdPay's live
|
||||
// catalog (price in cents, credits, and the POL the contract quotes right now), never typed in, so the
|
||||
// tips stay true as POL moves. Cached ten minutes; with no catalog only the price-free tips show.
|
||||
'use strict';
|
||||
const IAP = () => String(process.env.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, '');
|
||||
const RATES = { visitCost: 3, featuredPerDay: 40 }; // IAP ads.js rates (visitCostPerVisit, featuredPerDay)
|
||||
let cache = { at: 0, products: [] };
|
||||
const fmt = n => Number(n).toLocaleString('en-US', { maximumFractionDigits: n < 10 ? 2 : 0 });
|
||||
|
||||
async function catalog() {
|
||||
if (Date.now() - cache.at < 10 * 60000) return cache.products;
|
||||
try {
|
||||
const r = await fetch(IAP() + '/api/catalog', { signal: AbortSignal.timeout(6000) }); const j = await r.json();
|
||||
const products = (j.products || []).filter(p => p.active && p.exists).map(p => ({ usd: p.priceCents / 100, credits: Number(p.creditAmount), pol: Number(BigInt(p.costWei) / 10n ** 12n) / 1e6 })).filter(p => p.pol > 0);
|
||||
if (products.length) cache = { at: Date.now(), products };
|
||||
} catch (e) { if (!cache.products.length) cache.at = Date.now() - 9 * 60000; } // retry in a minute
|
||||
return cache.products;
|
||||
}
|
||||
|
||||
async function list(settings) {
|
||||
const ps = await catalog(); const by = usd => ps.find(p => p.usd === usd);
|
||||
const p5 = by(5), p20 = by(20), p100 = by(100); const th = Number(settings.thresholdPol), drip = Number(settings.dripPol);
|
||||
const tips = [
|
||||
'Every refuel is a verified visit an advertiser paid for on InstantAdPay. A share of it funds everyone’s chapter drips.',
|
||||
'Shield Core and Slow Field cost POL from your game balance, and that POL goes straight back into the pool.',
|
||||
'Your game balance pays out at ' + fmt(th) + ' POL, to the wallet on your InstantAdPay account. Link one under Wallet if you have not.',
|
||||
'Only the first clear of a chapter pays a drip (' + fmt(drip) + ' POL). Replays are for practice and for drips to spend in the hangar.',
|
||||
'Your first $20 buyer on InstantAdPay pays you 50 percent. Your second opens level 2: 20 percent of everything their people buy.',
|
||||
'InstantAdPay packages are bought with POL and pay your sponsor on the spot, on chain. Nothing to withdraw, nothing to wait for.',
|
||||
];
|
||||
if (p20) tips.push('A $20 InstantAdPay package is about ' + fmt(p20.pol) + ' POL today. Half of it goes to the sponsor, on chain, the moment it is bought.');
|
||||
if (p5) tips.push('$5 on InstantAdPay is ' + fmt(p5.credits) + ' credits, about ' + fmt(p5.pol) + ' POL today. That runs ' + Math.floor(p5.credits / RATES.visitCost) + ' verified visits to your own page.');
|
||||
if (p5) tips.push('A Featured ad on InstantAdPay is ' + RATES.featuredPerDay + ' credits a day. A $5 pack keeps you featured for ' + Math.floor(p5.credits / RATES.featuredPerDay) + ' days.');
|
||||
if (p100 && p100.credits > p100.usd * 100) tips.push('The $100 InstantAdPay pack is ' + fmt(p100.credits) + ' credits for about ' + fmt(p100.pol) + ' POL today: ' + fmt(p100.credits - p100.usd * 100) + ' bonus credits on top of the ' + fmt(p100.usd * 100) + ' you paid for.');
|
||||
return tips;
|
||||
}
|
||||
module.exports = { list, catalog };
|
||||
@@ -76,6 +76,7 @@ canvas#game{position:absolute;inset:0;width:100%;height:100%;display:block;touch
|
||||
.buy.no{opacity:.4;pointer-events:none}
|
||||
.led{display:flex;justify-content:space-between;gap:8px;font-size:12px;color:var(--ink2);padding:7px 2px;border-top:1px solid var(--line)}.led:first-child{border-top:0}.led .m{font:700 12px var(--mono);color:var(--gold);white-space:nowrap}.led .m.ok{color:var(--ok)}.led .m.neg{color:var(--sig)}.led a{color:var(--cyan2)}
|
||||
.prog{height:8px;background:rgba(255,255,255,.08);border-radius:4px;overflow:hidden;margin-top:8px}.prog i{display:block;height:100%;background:linear-gradient(90deg,var(--cyan),var(--gold));box-shadow:0 0 10px rgba(255,194,75,.5)}
|
||||
.tip{margin:12px 0 0;padding:10px 12px;border-radius:10px;background:rgba(34,211,238,.07);border:1px solid rgba(34,211,238,.25);font-size:12px;line-height:1.45;color:var(--ink2);text-align:left}.tip b{display:block;font:700 9px var(--body);letter-spacing:.16em;text-transform:uppercase;color:var(--cyan);margin-bottom:3px}
|
||||
.toast{position:absolute;left:50%;bottom:calc(70px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);z-index:20;background:var(--panel2);border:1px solid var(--line);color:var(--ink);font-size:12px;padding:8px 12px;border-radius:10px;opacity:0;transition:opacity .2s;pointer-events:none;max-width:92%;text-align:center}
|
||||
.toast.on{opacity:1}
|
||||
.tapdesk{position:absolute;bottom:calc(14px + env(safe-area-inset-bottom,0px));left:14px;z-index:5;font:600 10px var(--body);letter-spacing:.14em;text-transform:uppercase;color:var(--muted);pointer-events:none}
|
||||
@@ -105,8 +106,10 @@ canvas#game{position:absolute;inset:0;width:100%;height:100%;display:block;touch
|
||||
<div class="stat"><small>Balance</small><b class="ok" id="lPol">0.000</b></div>
|
||||
</div>
|
||||
<div class="pool" id="lPool"></div>
|
||||
<div class="tip" id="lTip" hidden></div>
|
||||
<button class="btn" id="bPlay" type="button">Play</button>
|
||||
<div class="row2"><button class="btn ghost" id="bHangar" type="button">Hangar</button><button class="btn ghost" id="bBalance" type="button">Balance</button></div>
|
||||
<a class="btn gold" id="bLevel" href="https://instantadpay.com/my#buy" style="text-decoration:none;text-align:center;font-size:13px;padding:11px">Level up on InstantAdPay</a>
|
||||
<div class="member" id="lMember"><i></i>connecting…</div>
|
||||
<div class="member" style="margin-top:6px"><a id="lIap" href="https://instantadpay.com/my" style="color:var(--muted)">InstantAdPay dashboard</a> · <a href="/" style="color:var(--muted)">tester briefing</a></div>
|
||||
</div>
|
||||
@@ -117,12 +120,14 @@ canvas#game{position:absolute;inset:0;width:100%;height:100%;display:block;touch
|
||||
<div class="ov" id="ovClear" hidden><div class="card">
|
||||
<div class="eyebrow" id="cEyebrow">Chapter cleared</div><h2 id="cTitle">Banked 20 drips</h2>
|
||||
<div class="big" id="cBig">+0.010<small>POL</small></div><p id="cText"></p><span class="chip ok" id="cChip"></span>
|
||||
<div class="tip" id="cTip" hidden></div>
|
||||
<button class="btn gold" id="bNext" type="button">Next chapter</button><button class="btn ghost" id="bLobby1" type="button">Back to lobby</button>
|
||||
</div></div>
|
||||
|
||||
<div class="ov" id="ovOver" hidden><div class="card">
|
||||
<div class="eyebrow" id="oEyebrow">Out of fuel</div><h2 id="oTitle">Run over</h2><p id="oText"></p>
|
||||
<button class="btn sig" id="bRefuel" type="button">Refuel · sponsor page</button><span class="chip sig" id="oChip">verified visit on InstantAdPay · pays your fuel</span>
|
||||
<div class="tip" id="oTip" hidden></div>
|
||||
<div class="row2"><button class="btn ghost" id="bRestart" type="button">Restart</button><button class="btn ghost" id="bLobby2" type="button">Lobby</button></div>
|
||||
</div></div>
|
||||
|
||||
|
||||
+6
-5
@@ -6,7 +6,8 @@ var $ = function (id) { return document.getElementById(id); };
|
||||
var canvas = $('game'), ctx = canvas.getContext('2d');
|
||||
var W = 390, H = 760, DPR = 1, floorY = H - DRSpawn.FLOOR;
|
||||
var player = { x: 100, y: 300, vy: 0, r: 13, tilt: 0 };
|
||||
var ME = null, P = null, BAL = null, POOL = null, IAP = 'https://instantadpay.com';
|
||||
var ME = null, P = null, BAL = null, POOL = null, IAP = 'https://instantadpay.com', TIPS = [], tipAt = Math.floor(Math.random() * 97);
|
||||
function tip(id) { var el = $(id); if (!TIPS.length) { el.hidden = true; return; } var t = TIPS[tipAt++ % TIPS.length]; el.innerHTML = '<b>Did you know</b>' + esc(t); el.hidden = false; } // rotates through the facts
|
||||
var R = null; // the live run
|
||||
var muted = false; try { muted = localStorage.getItem('dr.muted') === '1'; } catch (e) {}
|
||||
|
||||
@@ -43,12 +44,12 @@ var hudCache = {}; function setHud() { if (!R) return; var v = { d: R.drips, c:
|
||||
function f3(n) { return Number(n || 0).toFixed(3); }
|
||||
|
||||
/* ---------- lobby / me ---------- */
|
||||
function loadMe() { return api('/api/me').then(function (r) { if (r._status !== 200) throw r; ME = r.me; P = r.player; BAL = r.balance; POOL = r.pool; IAP = r.iap || IAP; return r; }); }
|
||||
function loadMe() { return api('/api/me').then(function (r) { if (r._status !== 200) throw r; ME = r.me; P = r.player; BAL = r.balance; POOL = r.pool; IAP = r.iap || IAP; TIPS = r.tips || []; return r; }); }
|
||||
function lobby() {
|
||||
R = null; $('hud').classList.remove('on'); $('tapdesk').hidden = true;
|
||||
$('lChap').textContent = P.chapter; $('lDrips').textContent = P.bank.toLocaleString(); $('lPol').textContent = f3(BAL.unpaid);
|
||||
$('lPool').innerHTML = 'POL pool <b>' + f3(POOL.available) + '</b> · today’s cap left <b>' + f3(POOL.capLeft) + '</b> · a chapter drip is <b>' + f3(POOL.dripPol) + '</b>';
|
||||
$('lIap').href = IAP + '/my';
|
||||
$('lIap').href = IAP + '/my'; $('bLevel').href = IAP + '/my#buy'; tip('lTip');
|
||||
$('lMember').innerHTML = '<i class="' + (ME.wallet ? '' : 'no') + '"></i>InstantAdPay · ' + (ME.username ? '@' + ME.username : '#' + ME.memberId) + ' · ' + (ME.wallet ? ME.wallet.slice(0, 6) + '…' + ME.wallet.slice(-4) : 'no wallet on file');
|
||||
show('ovLobby');
|
||||
}
|
||||
@@ -110,7 +111,7 @@ function update(dt) {
|
||||
function crash(x, y) { sfx.crash(); burst(x, y, 36, '255,59,122', 260); burst(x, y, 14, '255,255,255', 160); R.shake = .5; over('Courier hit', 'A bot got you.'); }
|
||||
function over(title, why) {
|
||||
R.paused = true; flush(false);
|
||||
setTimeout(function () { if (!R) return; $('oEyebrow').textContent = title; $('oTitle').textContent = 'Run over at ' + R.drips; $('oText').textContent = why + ' Refuel with a sponsor visit and keep this run, drips and chapter progress intact.'; $('bRefuel').hidden = false; $('oChip').hidden = false; show('ovOver'); }, 450);
|
||||
setTimeout(function () { if (!R) return; $('oEyebrow').textContent = title; $('oTitle').textContent = 'Run over at ' + R.drips; $('oText').textContent = why + ' Refuel with a sponsor visit and keep this run, drips and chapter progress intact.'; $('bRefuel').hidden = false; $('oChip').hidden = false; tip('oTip'); show('ovOver'); }, 450);
|
||||
}
|
||||
function cleared() {
|
||||
R.paused = true; pill('Verifying…');
|
||||
@@ -124,7 +125,7 @@ function cleared() {
|
||||
var why = { paid: 'First clear, verified. Added to your game balance.', replay: c.first ? 'Verified.' : 'You cleared this one before. Only the first clear pays.', pool: 'The POL pool is empty right now. Refuel visits fill it, so this clear counts but pays nothing.', cap: 'Today’s pool cap is spent. Chapter counts, no POL today.', flagged: 'This run was flagged by the server check, so it pays nothing.' };
|
||||
$('cText').textContent = why[c.reason] || ''; $('cChip').className = 'chip ' + (c.pol ? 'ok' : 'sig'); $('cChip').textContent = (c.pol ? 'verified' : c.reason) + ' · ' + tm + ' play time';
|
||||
R.chapter = c.next; R.goal = c.nextGoal; R.chapDrips = 0; if (r.pool != null) POOL.available = r.pool;
|
||||
setTimeout(function () { show('ovClear'); }, 500);
|
||||
tip('cTip'); setTimeout(function () { show('ovClear'); }, 500);
|
||||
});
|
||||
}
|
||||
$('bNext').addEventListener('click', function () { if (!R) return; R.paused = false; R.inv = 1.5; hideAll(); });
|
||||
|
||||
@@ -23,6 +23,7 @@ const ledger = require('./lib/ledger');
|
||||
const faucet = require('./lib/faucet');
|
||||
const spawn = require('./lib/spawn');
|
||||
const badge = require('./lib/badge');
|
||||
const tips = require('./lib/tips'); // facts you learn as you play, priced from the live IAP catalog
|
||||
|
||||
const PORT = Number(process.env.PORT || 3000);
|
||||
const DATA_DIR = process.env.DATA_DIR || path.join(__dirname, 'data');
|
||||
@@ -234,7 +235,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (!me) return json(res, 401, { error: 'Sign in through InstantAdPay first.', iap: IAP + '/api/my/driprunner' });
|
||||
if (p === '/api/me' && req.method === 'GET') {
|
||||
const pl = ledger.pool();
|
||||
return json(res, 200, { me: { memberId: me.memberId, username: me.username, wallet: me.wallet }, player: game.view(me), balance: ledger.balance(me.memberId), pool: { available: pl.available, capLeft: pl.capLeft, dripPol: Number(ledger.settings().dripPol) }, iap: IAP, site: SITE });
|
||||
return json(res, 200, { me: { memberId: me.memberId, username: me.username, wallet: me.wallet }, player: game.view(me), balance: ledger.balance(me.memberId), pool: { available: pl.available, capLeft: pl.capLeft, dripPol: Number(ledger.settings().dripPol) }, iap: IAP, site: SITE, tips: await tips.list(ledger.settings()) });
|
||||
}
|
||||
if (p === '/api/balance' && req.method === 'GET') return json(res, 200, ledger.balance(me.memberId));
|
||||
if (p === '/api/run/start' && req.method === 'POST') { const { body } = await readBody(req); const r = game.start(me, body.W, body.H); return json(res, 200, { runId: r.id, seed: r.seed, W: r.W, H: r.H, speed: r.speed, chapter: r.chapter, goal: r.goal, armed: r.armed, ship: r.ship }); }
|
||||
|
||||
Reference in New Issue
Block a user