-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
Overview
Implement configuration and utility methods for Round instances. This issue covers card management, duration calculation, and summary generation.
Requirements
Functions to Implement
set_cards()
- Assign Cards to Round
fn set_cards(
self: @Round,
cards: Span<u64>,
question_cards: Span<QuestionCard>
) -> Result<Round, RoundValidation>
- Assign card IDs and question cards to round
- Validate card count matches
cards_per_round
configuration - Validate both arrays have matching lengths
- Return updated round instance
- Used during round setup phase
get_duration()
- Calculate Round Duration
fn get_duration(self: @Round) -> Option<u64>
- Calculate round duration in seconds
- Only available for completed rounds
- Return
Some(duration)
if valid,None
otherwise - Duration = end_time - start_time
- Validate end_time > start_time
get_summary()
- Generate Round Summary
fn get_summary(self: @Round) -> RoundSummary
- Create lightweight summary for display/listing
- Include essential round information
- Convert enums to proper types
Business Logic
Card Assignment Rules
- Cards can only be set for valid rounds
- Card count must exactly match
cards_per_round
- Question cards array must match cards array length
- Both arrays must be non-empty if
cards_per_round > 0
Duration Calculation Rules
- Only completed rounds have duration
- Both start_time and end_time must be > 0
- end_time must be > start_time for valid duration
- Return None for invalid or incomplete rounds
Summary Generation Rules
- Always succeeds (no validation failures)
- Convert felt252 enums to proper enum types
- Include current joinability status
Acceptance Criteria
- All 3 configuration/utility methods implemented correctly
- Card assignment validation works properly
- Duration calculation handles all edge cases
- Summary generation is accurate and complete
- Comprehensive error handling with descriptive messages
- Complete test coverage
- All edge cases tested and handled
Dependencies
- Uses existing Round struct and helper methods(get_mode(), get_state(), is_joinable())
- Feat: Round State Queries Implementation #127
Note
Target Branch
refac/modular-architecture
File Location
src/models/round.cairo
Target Trait
RoundTrait
Metadata
Metadata
Assignees
Labels
No labels