Weekly prizes are open to every hunter with the minimum finds, Game Pass or not (Marty 2026-11-23, reversing the 11-02 Pass-only rule: the leaderboard promised the top three and only one Pass holder was winning); admin /api/admin/prizes/fill pays the unpaid places of a week already awarded under the old rule, never anyone twice; guides and terms say the same
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
+22
-4
@@ -102,9 +102,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();
|
||||
// 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));
|
||||
// weekly prizes are for EVERY hunter with the minimum finds, Game Pass or not (Marty 2026-11-23: the leaderboard promised the top
|
||||
// three and only one Pass holder was winning; this reverses the 2026-11-02 Pass-only rule)
|
||||
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));
|
||||
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; });
|
||||
@@ -112,6 +112,24 @@ function awardWeek(monday) {
|
||||
store.update('prizes', [], all => { all.push(entry); return all; });
|
||||
return entry;
|
||||
}
|
||||
// fill a week that was ALREADY awarded under an older rule (Marty 2026-11-23, the week of 11-16 paid only the one Pass holder): today's
|
||||
// rule picks the top hunters again, and anyone in that list who was not paid for the week gets the prize of their place. Nobody already
|
||||
// paid is touched, nothing is paid twice (a payout row for that member and week blocks it), and a second call adds nothing.
|
||||
function awardFill(monday) {
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(monday || '') || weekOf(monday) !== monday) return { error: 'not a Monday key' };
|
||||
const done = store.read('prizes', []), cur = done.find(x => x.week === monday);
|
||||
if (!cur) return { error: 'that week has not been awarded yet' };
|
||||
const rules = prizeRules(), paidTo = new Set(store.read('payouts', []).filter(p => p.prize && p.prize.week === monday).map(p => p.memberId));
|
||||
const top = 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));
|
||||
const add = top.filter(w => !paidTo.has(w.memberId));
|
||||
if (!add.length) return { week: monday, winners: [], filled: 0 };
|
||||
const day = ctDay(), at = Date.now();
|
||||
const recs = add.map(w => ({ id: 'prize' + monday.replace(/-/g, '') + '-f' + 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, fill: true } }));
|
||||
store.update('payouts', [], all => { all.push(...recs); return all; });
|
||||
const added = add.map(w => ({ rank: w.rank, memberId: w.memberId, who: w.who, finds: w.finds, pol: w.pol, prizePol: w.prizePol }));
|
||||
store.update('prizes', [], all => { const e = all.find(x => x.week === monday); if (e) { e.winners = e.winners.concat(added).sort((a, b) => a.rank - b.rank); e.filledAt = at; } return all; });
|
||||
return { week: monday, winners: added, filled: added.length };
|
||||
}
|
||||
// on every tick: the most recent completed week gets awarded on the first tick after it ends
|
||||
function awardDue(notify) {
|
||||
const last = dayMinus(weekOf(ctDay()), 7);
|
||||
@@ -139,4 +157,4 @@ function memberByName(who) {
|
||||
}
|
||||
function shareLink(site, me) { const ref = me.username || me.memberId; return site + '/?r=' + encodeURIComponent(String(ref)); }
|
||||
|
||||
module.exports = { BADGES, badgesFor, leaderboard, rankOf, shareLink, weekOf, weekRows, awardWeek, awardDue, prizes, prizeRules, nameOf, memberByName };
|
||||
module.exports = { BADGES, badgesFor, leaderboard, rankOf, shareLink, weekOf, weekRows, awardWeek, awardFill, awardDue, prizes, prizeRules, nameOf, memberByName };
|
||||
|
||||
Reference in New Issue
Block a user