From 5d148a5b3b5ed0e9057686685a4f73adee7084a2 Mon Sep 17 00:00:00 2001 From: martbost Date: Fri, 13 Nov 2026 14:57:25 -0600 Subject: [PATCH] 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 --- board.js | 11 ++++++++++- server.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/board.js b/board.js index 7721ce9..5a2aca5 100644 --- a/board.js +++ b/board.js @@ -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 || '' }); } diff --git a/server.js b/server.js index b1611e6..7c3214e 100644 --- a/server.js +++ b/server.js @@ -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); };