WIP: Majority converted to event queue, continuing to work on others.

The bottom newsbar still needs conversion, as do numerous other pieces,
but we're working our way there. Attempting adding some tests with
Claude, but they aren't functioning yet, making them effectively
useless. Continuing to iterate.
This commit is contained in:
Tyler Marques 2025-06-10 10:49:47 -07:00
parent 2b52a9cbf9
commit a929bf5ee6
No known key found for this signature in database
GPG key ID: CB99EDCF41D3016F
9 changed files with 611 additions and 32 deletions

View file

@ -203,8 +203,8 @@ export function updateChatWindows(stepMessages = false) {
console.log(`Found ${relevantMessages.length} messages for player ${gameState.currentPower} in phase ${gameState.currentPhase.name}`);
}
if (!stepMessages || config.isInstantMode) {
// Normal mode or instant chat mode: show all messages at once
if (!stepMessages) {
// Normal mode: show all messages at once
relevantMessages.forEach(msg => {
const isNew = addMessageToChat(msg);
if (isNew) {
@ -267,7 +267,7 @@ export function updateChatWindows(stepMessages = false) {
index++; // Only increment after animation completes
// Schedule next message with proper delay
gameState.eventQueue.scheduleDelay(config.effectivePlaybackSpeed, showNext, `show-next-message-${index}-${Date.now()}`);
gameState.eventQueue.scheduleDelay(config.messageBetweenDelay, showNext, `show-next-message-${index}-${Date.now()}`);
};
// Add the message with word animation
@ -409,7 +409,7 @@ function animateMessageWords(message: string, contentSpanId: string, targetPower
console.log(`Finished animating message with ${words.length} words in ${targetPower} chat`);
// Add a slight delay after the last word for readability
gameState.eventQueue.scheduleDelay(Math.min(config.effectivePlaybackSpeed / 3, 150), () => {
gameState.eventQueue.scheduleDelay(config.messageCompletionDelay, () => {
if (onComplete) {
onComplete(); // Call the completion callback
}
@ -430,9 +430,8 @@ function animateMessageWords(message: string, contentSpanId: string, targetPower
// Calculate delay based on word length and playback speed
// Longer words get slightly longer display time
const wordLength = words[wordIndex - 1].length;
// In streaming mode, use a more consistent delay to prevent overlap
const baseDelay = config.effectivePlaybackSpeed
const delay = Math.max(50, Math.min(200, baseDelay * (wordLength / 4)));
// Use consistent word delay from config
const delay = Math.max(config.messageWordDelay, Math.min(200, config.messageWordDelay * (wordLength / 4)));
gameState.eventQueue.scheduleDelay(delay, addNextWord, `add-word-${wordIndex}-${Date.now()}`);
// Scroll to ensure newest content is visible
@ -744,12 +743,12 @@ export function addToNewsBanner(newText: string): void {
console.log(`Adding to news banner: "${newText}"`);
}
// Add a fade-out transition (instant in instant mode)
const transitionDuration = config.isInstantMode ? 0 : 0.3;
// Add a fade-out transition
const transitionDuration = config.uiTransitionDuration;
bannerEl.style.transition = `opacity ${transitionDuration}s ease-out`;
bannerEl.style.opacity = '0';
gameState.eventQueue.scheduleDelay(config.isInstantMode ? 0 : 300, () => {
gameState.eventQueue.scheduleDelay(config.uiFadeDelay, () => {
// If the banner only has the default text or is empty, replace it
if (
bannerEl.textContent?.trim() === 'Diplomatic actions unfolding...' ||