Mystery Hunt Box + Ad Detective, badge tiers
Finish the day's Code Hunts to unlock one box a day. It opens to an Ad Detective case on one site with a fixed 0.15 POL reward shown up front: visit (the embed records the visit after the dwell, no code), then answer one question, one attempt. Paid inside the house cap, never counted as a find. 34-question bank seeded from lib/detective-bank.json; a hunter never repeats a question until they have seen every one for that site. Admin panel with per-question stats and retire/restore. New badges (all ledger-derived): Detective, Sleuth, Investigator, Master Detective; Scout, Guide, Trail Boss; Week Sweep; 7-Day Streak. Badges already earned on deploy are marked announced without posting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+21
-3
@@ -20,12 +20,23 @@ const BADGES = [
|
||||
{ id: 'streak', name: 'On a Streak', icon: '\u{1F525}', why: 'finds on three days in a row' },
|
||||
{ id: 'top', name: 'Top Hunter', icon: '\u{1F3C6}', why: 'won a weekly prize as #1' },
|
||||
{ id: 'recruiter', name: 'Recruiter', icon: '\u{1F91D}', why: 'brought a hunter who found their first code' },
|
||||
// 2026-09-26: tiers on top of the originals, all derived from the ledger, so they count work already done
|
||||
{ id: 'weekstreak', name: '7-Day Streak', icon: '⚡', why: 'finds on seven days in a row' },
|
||||
{ id: 'weeksweep', name: 'Week Sweep', icon: '\u{1F5D3}\uFE0F', why: 'a find on every site inside one week' },
|
||||
{ id: 'scout', name: 'Scout', icon: '\u{1F6A9}', why: 'brought three hunters who found their first code' },
|
||||
{ id: 'guide', name: 'Guide', icon: '\u{1F3EE}', why: 'brought ten hunters who found their first code' },
|
||||
{ id: 'trailboss', name: 'Trail Boss', icon: '\u{1F3D4}\uFE0F', why: 'brought twenty-five hunters who found their first code' },
|
||||
// Ad Detective (Mystery Hunt Box): correct answers, never finds
|
||||
{ id: 'detective', name: 'Detective', icon: '\u{1F50E}', why: 'solved your first Ad Detective case' },
|
||||
{ id: 'sleuth', name: 'Sleuth', icon: '\u{1F463}', why: 'solved five Ad Detective cases' },
|
||||
{ id: 'investigator', name: 'Investigator', icon: '\u{1F4CC}', why: 'solved fifteen Ad Detective cases' },
|
||||
{ id: 'masterdetective', name: 'Master Detective', icon: '\u{1F5DD}\uFE0F', why: 'solved thirty Ad Detective cases' },
|
||||
];
|
||||
const PRIZE_DEFAULTS = { weeklyPrizes: [3, 2, 1], weeklyMinFinds: 10 };
|
||||
function prizeRules() { const s = rewards.settings(); return { pol: Array.isArray(s.weeklyPrizes) && s.weeklyPrizes.length ? s.weeklyPrizes.map(Number) : PRIZE_DEFAULTS.weeklyPrizes, minFinds: Number(s.weeklyMinFinds) > 0 ? Number(s.weeklyMinFinds) : PRIZE_DEFAULTS.weeklyMinFinds }; }
|
||||
|
||||
function excluded() { const s = rewards.settings(); const list = Array.isArray(s.leaderboardExclude) ? s.leaderboardExclude : [1]; return new Set(list.map(Number)); }
|
||||
function finds() { return store.read('payouts', []).filter(p => p.status !== 'failed' && !p.prize && !p.ref); } // prize drips are not finds
|
||||
function finds() { return store.read('payouts', []).filter(p => p.status !== 'failed' && !p.prize && !p.ref && !p.detective); } // prize, referral and Ad Detective drips are not finds
|
||||
|
||||
// Central day arithmetic on 'YYYY-MM-DD' keys
|
||||
function dayMinus(dayKey, n) { const [y, m, d] = dayKey.split('-').map(Number); const t = Date.UTC(y, m - 1, d) - n * 86400000; return new Date(t).toISOString().slice(0, 10); }
|
||||
@@ -39,8 +50,12 @@ function inPeriod(p, period, today) {
|
||||
|
||||
function badgesFor(memberId, list) {
|
||||
const mine = (list || finds()).filter(p => p.memberId === Number(memberId));
|
||||
if (!mine.length) return [];
|
||||
const out = new Set();
|
||||
// Ad Detective cases solved: their own family, earned even by someone with no finds counted yet
|
||||
const all = store.read('payouts', []);
|
||||
const solved = all.filter(p => p.memberId === Number(memberId) && p.detective && p.status !== 'failed').length;
|
||||
if (solved >= 1) out.add('detective'); if (solved >= 5) out.add('sleuth'); if (solved >= 15) out.add('investigator'); if (solved >= 30) out.add('masterdetective');
|
||||
if (!mine.length) return BADGES.filter(b => out.has(b.id));
|
||||
out.add('first');
|
||||
if (mine.length >= 5) out.add('hunter');
|
||||
if (mine.length >= 20) out.add('tracker');
|
||||
@@ -49,9 +64,12 @@ function badgesFor(memberId, list) {
|
||||
if (mine.some(p => p.pol >= 0.4)) out.add('lucky');
|
||||
const days = new Set(mine.map(p => p.day));
|
||||
for (const d of days) { if (days.has(dayMinus(d, 1)) && days.has(dayMinus(d, 2))) { out.add('streak'); break; } }
|
||||
for (const d of days) { let run = true; for (let i = 1; i < 7; i++) if (!days.has(dayMinus(d, i))) { run = false; break; } if (run) { out.add('weekstreak'); break; } }
|
||||
if (sites.size) { const wk = new Map(); for (const p of mine) { const w = weekOf(p.day); if (!wk.has(w)) wk.set(w, new Set()); wk.get(w).add(p.site); } for (const s of wk.values()) if ([...sites].every(x => s.has(x))) { out.add('weeksweep'); break; } }
|
||||
if (store.read('payouts', []).some(p => p.memberId === Number(memberId) && p.prize && p.prize.rank === 1 && p.status !== 'failed')) out.add('top');
|
||||
// earned by a bounty, not a match: someone they brought turned up and found their first code
|
||||
if (store.read('payouts', []).some(p => p.memberId === Number(memberId) && p.ref && p.ref.kind === 'bounty' && p.status !== 'failed')) out.add('recruiter');
|
||||
const brought = all.filter(p => p.memberId === Number(memberId) && p.ref && p.ref.kind === 'bounty' && p.status !== 'failed').length;
|
||||
if (brought >= 1) out.add('recruiter'); if (brought >= 3) out.add('scout'); if (brought >= 10) out.add('guide'); if (brought >= 25) out.add('trailboss');
|
||||
return BADGES.filter(b => out.has(b.id));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user