Tag committed ordinary movement, shipping, revival, collection, battle, native Guild transport and HMS relocation for the existing house notices and optional sounds. Keep pending and canceled actions free of false completion notices and preserve richer Smuggler and card-specific labels. Bound feedback to three 1.5-second notices including the active notice. Summarize older pending events with an exact count and retain individual chronicle entries. Consume stale, duplicate, muted and hidden updates without replay; clear visible and queued feedback when the page hides. These changes add log metadata and cosmetic presentation only. Validation: types, lint, 5137 offline tests and production build passed. Independent review resolved one duplicate Smuggler notice. Nine engine regressions and six queue/cursor/component tests cover the new behavior. Two Basic/Advanced four-player games completed with 821 legal actions, 21 JSON restores and zero rejected actions; no AI tuning was done. Browser QA 76CMLL8Z used genuine Basic setup and private real-action batches. A seven-event burst displayed Revival plus four earlier actions, then drained. Chronicle navigation and silent toggle/refresh were checked; refresh kept the saved row identical. Phone notice bounds fit without overflow. Transient phone text and actual background visibility were not captured; screenshot and full visual acceptance remain open. All 1,585 prior rooms, 3,353 seats and auxiliary records stayed unchanged. One QA room and human seat were added; no reset, restart or automation.
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import type { FactionId } from '@/game/catalog';
|
|
|
|
export type AutomaticActionEvent = {
|
|
id: string;
|
|
seq: number;
|
|
faction: FactionId;
|
|
name: string;
|
|
};
|
|
|
|
export type QueuedActionNotice = AutomaticActionEvent & { count: number };
|
|
|
|
export type ActionNoticeCursor = { seenSeq: number; pending: QueuedActionNotice[] };
|
|
|
|
/** Consume every observed sequence, even when presentation is disabled. */
|
|
export function advanceActionNotices(
|
|
cursor: ActionNoticeCursor,
|
|
events: readonly AutomaticActionEvent[],
|
|
options: { active: boolean; show: boolean },
|
|
): ActionNoticeCursor {
|
|
let seenSeq = cursor.seenSeq;
|
|
const fresh: AutomaticActionEvent[] = [];
|
|
for (const event of events.filter(event => event.seq > seenSeq).toSorted((a, b) => a.seq - b.seq)) {
|
|
if (event.seq <= seenSeq) continue;
|
|
seenSeq = event.seq;
|
|
fresh.push(event);
|
|
}
|
|
return {
|
|
seenSeq,
|
|
pending: options.show ? appendActionNotices(cursor.pending, fresh, options.active) : [],
|
|
};
|
|
}
|
|
|
|
/** Keep at most three 1.5-second notices, including the one already on screen. */
|
|
export function appendActionNotices(
|
|
pending: readonly QueuedActionNotice[],
|
|
incoming: readonly AutomaticActionEvent[],
|
|
active: boolean,
|
|
): QueuedActionNotice[] {
|
|
const notices = [...pending, ...incoming.map(event => ({ ...event, count: 1 }))];
|
|
const capacity = active ? 2 : 3;
|
|
if (notices.length <= capacity) return notices;
|
|
const mergedLength = notices.length - capacity + 1;
|
|
const merged = notices.slice(0, mergedLength);
|
|
return [
|
|
{ ...merged[merged.length - 1], count: merged.reduce((sum, notice) => sum + notice.count, 0) },
|
|
...notices.slice(mergedLength),
|
|
];
|
|
}
|