Support current battle choice promises and persistent notices
Verify and publish checkpoint container / container (push) Successful in 11m42s

This commit is contained in:
Quintine committed 2026-11-16 21:49:48 +11:00
1 parent 77d02b3231
commit bd8377d87b
16 files changed
+684 -32

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
/** Local presentation state for messages which need a player's acknowledgement. */
export type ActionableNotice = { id: number; text: string };
export type ActionableNoticeQueue = { nextId: number; items: ActionableNotice[] };
export type ActionableNoticeUpdate =
| { type: 'enqueue'; text: string }
| { type: 'dismiss'; id: number };
export const initialActionableNotices: ActionableNoticeQueue = { nextId: 1, items: [] };
/** Repeated identical messages coalesce while pending; a stale button cannot
* dismiss a later message, including another occurrence of the same text. */
export function updateActionableNotices(
state: ActionableNoticeQueue,
update: ActionableNoticeUpdate,
): ActionableNoticeQueue {
if (update.type === 'dismiss') return state.items[0]?.id === update.id
? { ...state, items: state.items.slice(1) } : state;
if (!update.text || state.items.some(item => item.text === update.text)) return state;
return { nextId: state.nextId + 1, items: [...state.items, { id: state.nextId, text: update.text }] };
}