Phase 4: close loot/refund leaks, landing-site garrisons, speed-scaled shipping, update/offsite tooling, broad e2e
Built: - Economy: raid loot capped to the room the raiders have at home (rest stays with the victim, "lootLeft" in the report); trade escrow reserves its room so refunds always fit; trade accept refuses with no_room_for_goods when the goods would not fit. Loot destroyed per 30-day run 31-61k -> ~1k, refunds clipped ~27k -> 0 (docs/BALANCE.md, 3 seeds). - End game: members of the holding alliance garrison landing sites (migration 005_site_garrison.sql), garrison counts in site defence, 72 h capture shield, withdraw route, POP view lists garrisoned units. Shipping capacity scales with world speed (3x world: winner 76-98 -> ~30-36 days after sites open). Bot runs show real contests (84-194 attacks on held sites at 1x). - Ops: deploy/update.sh (backup, stop, ff-merge, npm ci --ignore-scripts, health check, rollback), deploy/upstream-offsite (rsync only), admin end-world snapshots results, EPIPE fix, docs/workflows/ filled in. - e2e 62 -> 163 checks: units, raids/reports, alliance+messages, trade, end game, nb, PWA, reconnect, slow polling fallback (opt-in). Two app bugs found: message push ignored, "New" button stayed English. Tested: npm test 274/274, openapi check, npm run e2e 163/163 (137 s), bot runs 50x30d seeds 1-3 and 140-day/60-day speed-3 end-game runs INVARIANTS OK, adversarial review pass (findings fixed or documented). NOT tested: update.sh on a real box (systemd, real npm, runuser; stubs only, shellcheck not installed), garrison card/loot text on a phone, Node 22.13, humans. Known leaks left open and documented (BALANCE S6): loot/shipments can still overflow when stock arrives in flight, bounced backbone shipments lose overflow (reported to the sender). Garrison numbers (heldDefenceMult 2, shield 72 h) are first guesses from 2 seeds. Not claimed: balanced. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
parent
9104480463
commit
3c23c51902
92 changed files with 4887 additions and 300 deletions
|
|
@ -25,16 +25,25 @@
|
|||
const urls = { inbox: '/messages/inbox', sent: '/messages/outbox', alliance: '/messages/alliance' };
|
||||
|
||||
// ------------------------------------------------------------------ unread badge (works without the screen being open)
|
||||
const badge = { n: 0, polling: false };
|
||||
const badge = { n: 0, polling: false, again: false };
|
||||
async function pollUnread() {
|
||||
if (!App.state.user || badge.polling || document.hidden) return;
|
||||
if (!App.state.user || document.hidden) return;
|
||||
if (badge.polling) { badge.again = true; return; } // a message that lands while a poll is in flight: ask once more
|
||||
badge.polling = true;
|
||||
try { const r = await App.api.get('/messages/inbox', { limit: 1 }); setUnread(r.unread || 0); } catch (e) { /* a badge is a convenience */ } finally { badge.polling = false; }
|
||||
try { const r = await App.api.get('/messages/inbox', { limit: 1 }); setUnread(r.unread || 0); } catch (e) { /* a badge is a convenience */ } finally { badge.polling = false; if (badge.again) { badge.again = false; pollUnread(); } }
|
||||
}
|
||||
// App.setBadge (main.js) shows it on this screen's nav button, or summed on the "More" button when the screen lives there.
|
||||
function setUnread(n) { badge.n = n; App.state.unreadMsgs = n; App.setBadge('messages', n, 'info'); }
|
||||
setInterval(pollUnread, 60000);
|
||||
document.addEventListener('visibilitychange', () => { if (!document.hidden) pollUnread(); });
|
||||
// WebSocket hint {type:'message'} (ws.js forwards every push through api.emit): the unread count is stale, and so is the list on screen.
|
||||
let shown = false;
|
||||
App.api.on('push', (msg) => {
|
||||
if (!msg || msg.type !== 'message' || !App.state.user) return;
|
||||
pollUnread();
|
||||
if (!shown) return;
|
||||
if (thread) fetchThread(false); else if (tab === 'inbox' || tab === 'alliance') loadFeed(tab);
|
||||
});
|
||||
App.on('session', () => { setUnread(0); for (const k of Object.keys(feeds)) feeds[k] = blank(); blocks = { items: null, err: null }; thread = null; setTimeout(pollUnread, 800); });
|
||||
|
||||
// ------------------------------------------------------------------ loading
|
||||
|
|
@ -314,12 +323,13 @@
|
|||
h('div', { class: 'card-head page-head' }, h('h1', { id: 'soc-msg-h', text: App.t('screen.messages') }),
|
||||
h('div', { class: 'soc-head-actions' },
|
||||
h('button', { class: 'icon-btn', type: 'button', 'aria-label': App.t('common.retry'), onclick: () => { if (thread) fetchThread(false); else if (tab === 'blocked') loadBlocks(); else { feeds[tab] = blank(); loadFeed(tab); } } }, icon('refresh')),
|
||||
h('button', { class: 'btn small primary', type: 'button', onclick: () => openNew() }, icon('pencil'), App.t('soc.msg.new.go')))),
|
||||
h('button', { class: 'btn small primary soc-new-btn', type: 'button', onclick: () => openNew() }, icon('pencil'), App.t('soc.msg.new.go')))),
|
||||
tabsEl, listBox));
|
||||
},
|
||||
onShow(params) {
|
||||
gen++;
|
||||
gen++; shown = true;
|
||||
box.querySelector('#soc-msg-h').textContent = App.t('screen.messages');
|
||||
box.querySelector('.soc-new-btn').lastChild.textContent = App.t('soc.msg.new.go'); // built once in render(): follow a language switch
|
||||
const labels = { inbox: 'soc.msg.tab.inbox', sent: 'soc.msg.tab.sent', alliance: 'soc.msg.tab.alliance', blocked: 'soc.msg.tab.blocked' };
|
||||
for (const b of tabsEl.children) b.querySelector('.soc-tabt').textContent = App.t(labels[b.dataset.tab]);
|
||||
bc = null;
|
||||
|
|
@ -329,6 +339,6 @@
|
|||
startTick();
|
||||
pollUnread();
|
||||
},
|
||||
onHide() { if (offTick) { offTick(); offTick = null; } gen++; },
|
||||
onHide() { shown = false; if (offTick) { offTick(); offTick = null; } gen++; },
|
||||
});
|
||||
}());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue