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
-4
@@ -34,7 +34,7 @@ function draw(min, max, skew) {
|
||||
// a hunter's finds today (Central), prizes excluded
|
||||
// day defaults to today: called without it the comparison was against undefined and silently
|
||||
// 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).length; }
|
||||
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; }
|
||||
function daily(memberId, doneIds, bonus) { const s = settings(); const base = Math.max(1, Number(s.missionsPerDay) || 3);
|
||||
// every live paid mission this hunter has not done yet adds one, because the company is not
|
||||
// funding that completion
|
||||
@@ -54,12 +54,12 @@ function paidToday(day) {
|
||||
// two accounts sharing a wallet get one drip per mission per day between them.
|
||||
function completed(memberId, missionId, wallet) {
|
||||
const w = wallet ? String(wallet).toLowerCase() : null; const day = ctDay();
|
||||
return store.read('payouts', []).some(p => p.missionId === missionId && p.day === day && p.status !== 'failed' && !p.prize && !p.ref && (p.memberId === Number(memberId) || (w && p.wallet && String(p.wallet).toLowerCase() === w)));
|
||||
return store.read('payouts', []).some(p => p.missionId === missionId && p.day === day && p.status !== 'failed' && !p.prize && !p.ref && !p.detective && (p.memberId === Number(memberId) || (w && p.wallet && String(p.wallet).toLowerCase() === w)));
|
||||
}
|
||||
// the mission ids this member (or wallet) has done today
|
||||
function doneToday(memberId, wallet) {
|
||||
const w = wallet ? String(wallet).toLowerCase() : null; const day = ctDay();
|
||||
return new Set(store.read('payouts', []).filter(p => p.day === day && p.status !== 'failed' && !p.prize && !p.ref && (p.memberId === Number(memberId) || (w && p.wallet && String(p.wallet).toLowerCase() === w))).map(p => p.missionId));
|
||||
return new Set(store.read('payouts', []).filter(p => p.day === day && p.status !== 'failed' && !p.prize && !p.ref && !p.detective && (p.memberId === Number(memberId) || (w && p.wallet && String(p.wallet).toLowerCase() === w))).map(p => p.missionId));
|
||||
}
|
||||
|
||||
// record a completion; decide paid-today vs queued
|
||||
@@ -86,6 +86,23 @@ function grant(member, mission) {
|
||||
return { ok: true, rec, queued: overCap };
|
||||
}
|
||||
|
||||
// A fixed, disclosed amount for a non-find task (an Ad Detective case). House money, so it sits inside
|
||||
// the same daily cap as finds and queues past it; it is never a find (the detective flag keeps it out
|
||||
// of the daily limit, the leaderboard, prizes, referral matches and the find badges).
|
||||
function grantFixed(member, t) {
|
||||
const s = settings(); const day = ctDay(); const pol = Math.round(Number(t.pol) * 10000) / 10000;
|
||||
if (!(pol > 0)) return { error: 'no reward set' };
|
||||
const overCap = paidToday(day) + pol > Number(s.dailyCapPol);
|
||||
const rec = {
|
||||
id: Date.now().toString(36) + Math.random().toString(36).slice(2, 8),
|
||||
memberId: Number(member.memberId), email: member.email, wallet: member.wallet, username: member.username || null,
|
||||
missionId: t.missionId, site: t.site, pol, day, at: Date.now(), detective: t.detective || true,
|
||||
status: overCap ? 'queued' : 'due', tx: null, paidAt: null, error: null,
|
||||
};
|
||||
store.update('payouts', [], all => { all.push(rec); return all; });
|
||||
return { ok: true, rec, queued: overCap };
|
||||
}
|
||||
|
||||
// what the faucet should pay now: due entries, then queued ones as long as today's cap allows
|
||||
function payable() {
|
||||
const s = settings(); const day = ctDay();
|
||||
@@ -124,4 +141,4 @@ function totals() {
|
||||
return { paid: paid.length, pol: Math.round(paid.reduce((n, p) => n + p.pol, 0) * 10000) / 10000, queued: all.filter(p => p.status === 'queued').length, today: paidToday(ctDay()), hunters: new Set(paid.map(p => p.memberId)).size };
|
||||
}
|
||||
|
||||
module.exports = { settings, setSettings, draw, grant, completed, doneToday, payable, mark, ledger, mine, totals, paidToday, pool, nextResetAt, daily, findsToday, unposted };
|
||||
module.exports = { settings, setSettings, draw, grant, grantFixed, completed, doneToday, payable, mark, ledger, mine, totals, paidToday, pool, nextResetAt, daily, findsToday, unposted };
|
||||
|
||||
Reference in New Issue
Block a user