Board: no repeated banners (Marty 2026-11-13): a member whose spot is on the board gets no Banner Spin fill tile, and no image or Banner Spin code appears twice on one board

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-13 14:57:25 -06:00
parent 62985840f7
commit 5d148a5b3b
2 changed files with 11 additions and 2 deletions
+10 -1
View File
@@ -43,7 +43,16 @@ function pick(n) {
return { s, u: (c.viewsOwed - store.views(s.id).total) / left + Math.random() * 1e-6 };
}).sort((a, b) => b.u - a.u).slice(0, n - chosen.length).map(x => x.s);
const tiles = chosen.concat(rest).sort((a, b) => b.id - a.id).map(spotTile);
for (const sp of memberSpins()) { if (tiles.length >= n) break; tiles.push({ t: 'spin', img: sp.img, href: sp.link, title: sp.title }); }
// no repeats on one board (Marty 2026-11-13: the same banner showed twice): a member whose spot is already here gets no fill
// tile, and no image or Banner Spin appears twice
const code = u => (String(u || '').match(/\/[ic]\/([a-z0-9]+)/i) || [])[1] || String(u || '');
const owners = new Set(tiles.map(t => t.owner).filter(Boolean)); const used = new Set(tiles.map(t => code(t.img)));
for (const sp of memberSpins()) {
if (tiles.length >= n) break;
if ((sp.owner && owners.has(sp.owner)) || used.has(code(sp.img))) continue;
used.add(code(sp.img)); if (sp.owner) owners.add(sp.owner);
tiles.push({ t: 'spin', img: sp.img, href: sp.link, title: sp.title });
}
const house = cfgMod.house(); let i = Math.floor(Math.random() * house.length);
const stop = Math.min(n, tiles.length + house.length); // each house entry at most once per board
while (tiles.length < stop) { const h = house[i++ % house.length]; tiles.push({ t: 'house', key: h.key, img: h.img, href: '/go/h-' + h.key, title: h.title, note: h.note || '' }); }
+1 -1
View File
@@ -478,7 +478,7 @@ const server = http.createServer(async (req, res) => {
for (const m of chain.allMembers()) {
const r = await lsSpins({ wallet: m.address }).catch(() => null);
const sp = r && r.account && (r.spins || []).find(x => !x.paused && x.banners > 0);
if (sp) out.push({ img: 'https://rubav.com/i/' + sp.code + '.gif', link: 'https://rubav.com/c/' + sp.code + '?placement=board&s1=fill', title: (r.username ? '@' + r.username + ': ' : '') + sp.name });
if (sp) out.push({ owner: m.address, img: 'https://rubav.com/i/' + sp.code + '.gif', link: 'https://rubav.com/c/' + sp.code + '?placement=board&s1=fill', title: (r.username ? '@' + r.username + ': ' : '') + sp.name });
}
board.setMemberSpins(out);
};