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:
martbost
2026-11-02 13:23:21 -06:00
parent 4c0aa35e6c
commit ab57b4089e
6 changed files with 41 additions and 23 deletions
+5 -3
View File
@@ -56,19 +56,21 @@ const ok = (name, cond, info) => { if (cond) { pass++; console.log(' ok ', nam
rewards.setSettings({ minPol: 0.05, maxPol: 1, dailyCapPol: 20, missionsPerDay: 3 });
const me = { memberId: 7, email: 'hugh@example.com', username: 'hugh', wallet: '0x' + 'a'.repeat(40) }, day = missions.ctDay();
const m1 = { id: 'm1', site: 'example.com' }, m2 = { id: 'm2', site: 'two.com' }, mpaid = { id: 'adv', site: 'adv.com', paid: true, hunterPol: 0.2 };
const q1 = rewards.quote(m1); ok('the quote is the draw inside the range', q1 >= 0.05 && q1 <= 1);
const q1 = rewards.quote(m1, true); ok('the quote is the draw inside the range', q1 >= 0.05 && q1 <= 1);
const q0 = rewards.quote(m1, false); ok('the free tier draws on the small range (2026-11-02)', q0 >= 0.02 && q0 <= 0.1);
let g = rewards.grant(me, m1, { pol: 0.03, nominal: q1, gp: { ref: 'find:m1:' + day, kind: 'daily' } });
ok('a find pays what IAP allowed, due for the faucet', g.ok && g.rec.pol === 0.03 && g.rec.status === 'due' && g.rec.nominal === q1 && g.rec.gp.ref === 'find:m1:' + day);
g = rewards.grant(me, m2, { pol: 0, nominal: 0.2, gp: { ref: 'find:m2:' + day, kind: 'daily', capHit: 'daily' } });
ok('a find at the cap: recorded as capped, pays nothing, never reaches the faucet', g.capped && g.rec.status === 'capped' && g.rec.pol === 0 && !rewards.payable().some(p => p.id === g.rec.id));
ok('a capped find still counts as today\'s find and completes the mission', rewards.findsToday(7) === 2 && rewards.completed(7, 'm2', me.wallet) && rewards.daily(7, new Set(), 0, 0).left === 1);
ok('a capped find still counts as today\'s find and completes the mission', rewards.findsToday(7) === 2 && rewards.completed(7, 'm2', me.wallet) && rewards.daily(7, new Set(), 0, 0, true).left === 1);
const gw = rewards.grant(me, { id: 'm3', site: 'three.com' }, { pol: 0.4, status: 'gp-wait', nominal: 0.4, gp: { ref: 'find:m3:' + day, kind: 'daily', pending: true } });
ok('IAP unreachable: the find is recorded as gp-wait, not payable yet', gw.waiting && gw.rec.status === 'gp-wait' && !rewards.payable().some(p => p.id === gw.rec.id));
rewards.settleQueued(gw.rec.id, 0.25, { pass: false }); const settled = store.read('payouts', []).find(p => p.id === gw.rec.id);
ok('the queue answer settles it: pays the allowed part, due', settled.pol === 0.25 && settled.status === 'due' && settled.gp.pending === false);
rewards.settleQueued(gw.rec.id, 0.9, {}); ok('a settled row is not settled twice', store.read('payouts', []).find(p => p.id === gw.rec.id).pol === 0.25);
const gpaid = rewards.grant(me, mpaid); ok('an advertiser-funded mission pays the advertiser\'s amount, ungated (no gp on the row)', gpaid.rec.pol === 0.2 && !gpaid.rec.gp && gpaid.rec.paid === true);
ok('the perk: +2 missions a day with the pass', rewards.daily(7, new Set(), 0, 2).limit === 5 && rewards.daily(7, new Set(), 0, 0).limit === 3);
ok('the perk: +2 missions a day with the pass', rewards.daily(7, new Set(), 0, 2, true).limit === 5 && rewards.daily(7, new Set(), 0, 0, true).limit === 3);
ok('the free tier: one hunt a day without the pass (2026-11-02)', rewards.daily(7, new Set(), 0, 0, false).limit === 1 && rewards.daily(7, new Set(), 0, 0).limit === 1);
// ---- Ad Detective: the case is scored first, then IAP decides; a second case a day with the pass
rewards.setSettings({ detectiveOn: 1, detectivePol: 0.15 });