Card Timing & State Management Implementation - #156
Merged
manlikeHB merged 2 commits intoAug 27, 2025
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Card Timing and State Management to RoundPlayer
🎯 Overview
This PR implements the required card timing and state management functionality for the
RoundPlayermodel, enabling proper card progression, timeout detection, and state tracking in the lyrics guessing game.📋 Changes Made
Enhanced RoundPlayer Model
RoundPlayerTraitin src/models/round/round_player.cairoRoundPlayerValidationenumNew Functions Implemented
start_next_card()- Validates player state and starts next card with proper state transitionsis_answering_card()- Simple boolean check for active card statecurrent_card_timed_out()- Robust timeout detection with edge case handlingget_time_remaining()- Accurate time calculation for UI countdown functionalityValidation & Error Handling
RoundPlayerValidationenum with specific error types:PlayerNotReady- Player must be in ready state to start cardsRoundCompleted- Cannot start cards in completed roundsCardAlreadyActive- Only one card can be active at a timeNoActiveCard- For operations requiring an active cardRoundPlayerValidationResultstruct for backward compatibility🧪 Testing
Comprehensive Test Coverage
Key Test Scenarios
🔧 Business Logic
Card Start Rules
ready_state = trueround_completed = false)current_card_start_time = 0)next_card_index += 1)Timing Logic
start_next_card()is calledelapsed_time >= card_timeoutmax(0, card_timeout - elapsed_time)current_card_start_time > 0State Management
next_card_index0indicates no active card🎮 Integration
The implementation integrates seamlessly with the existing modular architecture:
RoundPlayerTraitwithout breaking changes📊 Performance
🔍 Code Quality
✅ Acceptance Criteria Met
closes #135