Skip to content

Feat: Performance Analytics & Comparison Implementation #139

@manlikeHB

Description

@manlikeHB

Overview

Implement performance analytics and player comparison functionality for RoundPlayer. This issue covers performance summary generation and player ranking comparison logic.

Requirements

Functions to Implement

get_performance() - Generate Performance Summary

fn get_performance(self: @RoundPlayer, total_cards: u64) -> RoundPlayerPerformance
  • Create comprehensive performance summary for display
  • Aggregate multiple performance metrics
  • Calculate derived statistics
  • Note: is_leading field set externally by comparison logic
  • Used for leaderboards and player dashboards

outperforms() - Compare Player Performance

fn outperforms(self: @RoundPlayer, other: @RoundPlayer) -> bool
  • Compare this player's performance against another player
  • Multi-tier ranking system for fair comparison
  • Determine who is performing better overall
  • Used for leaderboard sorting and ranking

Business Logic

Performance Summary Components

  • Accuracy Percentage: Player's correct answer rate (0-100)
  • Wrong Answers: Total number of incorrect responses
  • Completion Percentage: Progress through total cards (0-100)
  • Cards Remaining: Number of cards left to answer
  • Is Leading: External flag for leaderboard position (set by caller)

Player Comparison Hierarchy

  1. Primary: Total Score (higher wins)
  2. Secondary: Accuracy Percentage (higher wins)
  3. Tertiary: Best Time (lower wins, 0 = no best time)
  4. Quaternary: Average Time (lower wins)

Comparison Logic Rules

  • Higher total score always wins
  • If scores equal, higher accuracy wins
  • If accuracy equal, faster best time wins
  • If best times equal, faster average time wins
  • Players with no best time (0) lose to those with times
  • All factors considered for comprehensive ranking

Acceptance Criteria

  • Performance summary generation working correctly
  • All performance metrics included and accurate
  • Player comparison logic implemented properly
  • Multi-tier ranking system functioning correctly
  • Score-based primary comparison working
  • Accuracy-based secondary comparison working
  • Time-based tertiary and quaternary comparisons working
  • Edge cases handled properly (zero values, ties)
  • Complete test coverage including complex scenarios

Dependencies

Note

Target Branch

  • refac/modular-architecture

File Location

  • src/models/round/round_player.cairo

Target Trait

  • RoundPlayerTrait

Metadata

Metadata

Assignees

No one assigned

    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