Skip to content

Feat: Utility Helpers Implementation #141

@manlikeHB

Description

@manlikeHB

Overview

Implement utility helper methods for RoundPlayer. This issue covers simple access methods and utility functions that support other functionality and provide convenient data access.

Requirements

Functions to Implement

get_player() - Extract Player Address

fn get_player(self: @RoundPlayer) -> ContractAddress
  • Extract player address from composite key
  • Simple tuple destructuring operation
  • Used for player identification and lookups
  • No validation or side effects

get_round_id() - Extract Round ID

fn get_round_id(self: @RoundPlayer) -> RoundId
  • Extract round ID from composite key
  • Simple tuple destructuring operation
  • Used for round association and lookups
  • No validation or side effects

reset() - Reset Player State

fn reset(self: @RoundPlayer) -> RoundPlayer
  • Reset player to initial state for same round
  • Preserve player address, round ID, and card timeout
  • Clear all progress, scores, and timing data
  • Used for testing, admin functions, or round restart

Business Logic

Access Methods

  • Read-Only Operations: No side effects or state changes
  • Simple Extraction: Direct access to composite key components
  • Performance Optimized: Lightweight operations for frequent use
  • No Validation: Assume valid player instance

Reset Functionality

  • Preserve Identity: Keep player, round ID, and timeout
  • Clear Progress: Reset all counters and scores to zero
  • Initialize State: Return to fresh player state
  • Maintain Structure: Keep same data structure format

Acceptance Criteria

  • All 3 utility methods implemented correctly
  • Player address extraction working accurately
  • Round ID extraction working accurately
  • Reset functionality preserving identity correctly
  • Reset functionality clearing progress completely
  • No side effects in accessor methods
  • Complete test coverage for all utility functions

Dependencies

Note

Target Branch

  • refac/modular-architecture

File Location

  • src/models/round/round_player.cairo

Target Trait

  • RoundPlayerTrait

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions