Free tier and full tier (Marty 2026-11-02, every game must fund itself): a free InstantAdPay account hunts one code a day drawn on 0.02 to 0.10 POL; Game Pass holders keep five a day at the full draw, the weekly prizes and the Mystery Hunt Box (a box already open stays reachable); advertiser-funded finds pay what the advertiser set on every tier; with GAMEPASS off everyone stays on the full tier. New settings freeMissionsPerDay / freeMinPol / freeMaxPol (admin), tests updated
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+10
-5
@@ -89,13 +89,16 @@ const closed = b => !!b && (b.status === 'won' || b.status === 'missed');
|
||||
function putBox(b) { store.update('boxes', {}, all => { all[b.id] = b; return all; }); return b; }
|
||||
function patchBox(id, patch) { let out = null; store.update('boxes', {}, all => { if (all[id]) { Object.assign(all[id], patch); out = all[id]; } return all; }); return out; }
|
||||
|
||||
function earned(me) { const s = settings(); return s.on && rewards.findsToday(me.memberId, ctDay()) >= s.base; }
|
||||
// The box is a Game Pass perk since 2026-11-02 (Marty: the Pass is the purchase that funds the game): a free account hunts
|
||||
// once a day and never reaches the box; pass = false answers 'pass' on the board and refuses to open.
|
||||
function earned(me, pass) { const s = settings(); return s.on && pass !== false && rewards.findsToday(me.memberId, ctDay()) >= s.base; }
|
||||
|
||||
// what the board shows
|
||||
function view(me) {
|
||||
function view(me, pass) {
|
||||
const s = settings(); if (!s.on) return { on: false };
|
||||
const day = ctDay(); const b = getBox(me.memberId, day);
|
||||
const done = rewards.findsToday(me.memberId, day);
|
||||
if (!b && pass === false) return { on: true, status: 'pass', need: s.base, done: Math.min(done, s.base), pol: s.pol };
|
||||
if (!b) return { on: true, status: done >= s.base ? 'ready' : 'locked', need: s.base, done: Math.min(done, s.base), pol: s.pol };
|
||||
const m = missions.get(b.missionId) || {}; const q = bank().find(x => x.id === b.qid);
|
||||
const out = { on: true, status: b.status, pol: b.pol, site: m.site || b.missionId, name: m.name || '', dwell: m.dwell || 30, url: b.url || null, expires: b.exp || null };
|
||||
@@ -108,11 +111,13 @@ function view(me) {
|
||||
}
|
||||
|
||||
// pass = the Game Pass perk (GAME-PASS.md 4): a second case a day once the first is closed; the first case stays the rule for everyone else
|
||||
function open(me, pass) {
|
||||
if (!earned(me)) return { error: 'Finish today’s Code Hunts first. The box unlocks when your last one is found.' };
|
||||
// pass = the second-case perk; allowed = may a box open at all (the full tier: Game Pass holders, or everyone while GAMEPASS is off)
|
||||
function open(me, pass, allowed) {
|
||||
const day = ctDay(); const cur = getBox(me.memberId, day);
|
||||
const second = !!(pass && cur && closed(cur) && !/:2$/.test(cur.id));
|
||||
if (cur && !second) return { ok: true, box: cur };
|
||||
if (cur && !second) return { ok: true, box: cur }; // a box already open today stays reachable (a pass that lapsed mid-day)
|
||||
if (allowed === false) return { error: 'The Mystery Hunt Box opens for Game Pass holders.' };
|
||||
if (!earned(me, true)) return { error: 'Finish today’s Code Hunts first. The box unlocks when your last one is found.' };
|
||||
const c = pickCase(me.memberId, day); if (!c) return { error: 'No cases are open right now. Check back tomorrow.' };
|
||||
let made = null;
|
||||
// idempotent per member per day: a double tap or two tabs can never mint a second box
|
||||
|
||||
+8
-4
@@ -18,7 +18,10 @@ const { ctDay } = require('./missions');
|
||||
// drawSkew k: log-uniform on u^(1/k), so k=1 is the plain log-uniform and k=3 leans hard to the floor
|
||||
// (mean ~0.13 POL on 0.05..1, one drip in eighty above 0.5). missionsPerDay: finds per hunter per
|
||||
// Central day (Marty, 2026-09-20: cap 40, k=3, 3 a day, so a launch morning does not empty the pool)
|
||||
const DEFAULTS = { minPol: 0.05, maxPol: 1, dailyCapPol: 20, lowBalancePol: 40, drawSkew: 3, missionsPerDay: 3 };
|
||||
const DEFAULTS = { minPol: 0.05, maxPol: 1, dailyCapPol: 20, lowBalancePol: 40, drawSkew: 3, missionsPerDay: 3,
|
||||
// the free tier (Marty 2026-11-02, every game must fund itself): a free account gets freeMissionsPerDay hunts drawn on
|
||||
// freeMinPol..freeMaxPol; the full allotment and the full draw are for Game Pass holders (the Pass is the purchase)
|
||||
freeMissionsPerDay: 1, freeMinPol: 0.02, freeMaxPol: 0.1 };
|
||||
function settings() { return Object.assign({}, DEFAULTS, store.read('settings', {})); }
|
||||
function setSettings(patch) { return store.update('settings', {}, s => Object.assign(s, patch)); }
|
||||
|
||||
@@ -36,7 +39,7 @@ function draw(min, max, skew) {
|
||||
// returned 0 for everyone, which would read as "no finds yet" to any new caller
|
||||
function findsToday(memberId, day) { const d = day || ctDay(); return store.read('payouts', []).filter(p => p.memberId === Number(memberId) && p.day === d && p.status !== 'failed' && !p.prize && !p.ref && !p.detective).length; }
|
||||
// passExtra: the Game Pass perk, +2 missions a day while the member's pass is active (GAME-PASS.md 4: 3 -> 5); 0 otherwise
|
||||
function daily(memberId, doneIds, bonus, passExtra) { const s = settings(); const base = Math.max(1, Number(s.missionsPerDay) || 3);
|
||||
function daily(memberId, doneIds, bonus, passExtra, pass) { const s = settings(); const base = pass ? Math.max(1, Number(s.missionsPerDay) || 3) : Math.max(1, Number(s.freeMissionsPerDay) || 1); // free tier since 2026-11-02
|
||||
// every live paid mission this hunter has not done yet adds one, because the company is not
|
||||
// funding that completion
|
||||
let extra = 0; try { extra = require('./paid').extraAllowance(doneIds); } catch (e) {}
|
||||
@@ -44,7 +47,8 @@ function daily(memberId, doneIds, bonus, passExtra) { const s = settings(); cons
|
||||
const fb = Math.max(0, Number(bonus) || 0), pe = Math.max(0, Number(passExtra) || 0);
|
||||
const limit = base + extra + fb + pe; const done = findsToday(memberId, ctDay()); return { limit, done, left: Math.max(0, limit - done), base, friday: fb, pass: pe }; }
|
||||
// the nominal amount a completion of `mission` would pay (the Game Pass asks InstantAdPay about it before grant() records it)
|
||||
function quote(mission) { const s = settings(); return mission.paid ? Math.round(Number(mission.hunterPol || 0) * 10000) / 10000 : draw(Number(s.minPol), Number(s.maxPol)); }
|
||||
function quote(mission, pass) { const s = settings(); if (mission.paid) return Math.round(Number(mission.hunterPol || 0) * 10000) / 10000; // an advertiser-funded find pays what the advertiser set, every tier
|
||||
return pass ? draw(Number(s.minPol), Number(s.maxPol)) : draw(Number(s.freeMinPol), Number(s.freeMaxPol)); } // the free draw since 2026-11-02
|
||||
// What the COMPANY has spent today. Advertiser-funded completions are excluded on purpose: the
|
||||
// hunter is paid out of what the advertiser already put in the faucet, so counting it here would
|
||||
// let a paid mission use up the house budget (Marty, 2026-09-24).
|
||||
@@ -74,7 +78,7 @@ function grant(member, mission, opts) {
|
||||
// An advertiser-funded mission pays exactly what the advertiser set, every time. No draw, so
|
||||
// the reserve taken at purchase is exact and can never come up short.
|
||||
const isPaid = !!mission.paid;
|
||||
const pol = opts.pol != null ? Math.round(Number(opts.pol) * 10000) / 10000 : quote(mission);
|
||||
const pol = opts.pol != null ? Math.round(Number(opts.pol) * 10000) / 10000 : quote(mission, !!opts.pass);
|
||||
const day = ctDay();
|
||||
const budgetLeft = mission.budget ? mission.budget - store.read('payouts', []).filter(p => p.missionId === mission.id && p.status !== 'failed').length : Infinity;
|
||||
if (budgetLeft <= 0) return { error: 'This mission has paid out all it was funded for.' };
|
||||
|
||||
+3
-1
@@ -101,7 +101,9 @@ function awardWeek(monday) {
|
||||
const done = store.read('prizes', []);
|
||||
if (done.some(x => x.week === monday)) return { skipped: 'already awarded', week: monday };
|
||||
const rules = prizeRules();
|
||||
const winners = weekRows(monday).filter(r => r.finds >= rules.minFinds).slice(0, rules.pol.length).map((r, i) => Object.assign({ rank: i + 1, prizePol: rules.pol[i] }, r));
|
||||
// weekly prizes are for Game Pass holders (Marty 2026-11-02: the Pass is the purchase that funds the game); with GAMEPASS off, everyone qualifies as before
|
||||
let passOk = () => true; try { const gp = require('./polgrant'); if (gp.on && gp.on()) passOk = r => { try { return !!gp.passOf(r.memberId, r.email).active; } catch (e) { return false; } }; } catch (e) {}
|
||||
const winners = weekRows(monday).filter(r => r.finds >= rules.minFinds && passOk(r)).slice(0, rules.pol.length).map((r, i) => Object.assign({ rank: i + 1, prizePol: rules.pol[i] }, r));
|
||||
const day = ctDay(), at = Date.now();
|
||||
const recs = winners.map(w => ({ id: 'prize' + monday.replace(/-/g, '') + '-' + w.rank, memberId: w.memberId, email: w.email, wallet: w.wallet, username: w.username, missionId: 'prize:' + monday, site: 'Weekly prize #' + w.rank, pol: w.prizePol, day, at, status: 'due', tx: null, paidAt: null, error: null, prize: { week: monday, rank: w.rank } }));
|
||||
if (recs.length) store.update('payouts', [], all => { all.push(...recs); return all; });
|
||||
|
||||
Reference in New Issue
Block a user