Skip to content

Add game performance leaderboard with fair scoring system#352

Merged
Pierre-Demessence merged 4 commits into
masterfrom
copilot/fix-350
Jul 26, 2025
Merged

Add game performance leaderboard with fair scoring system#352
Pierre-Demessence merged 4 commits into
masterfrom
copilot/fix-350

Conversation

Copilot AI commented Jul 26, 2025

Copy link
Copy Markdown

This PR implements a new game leaderboard feature that combines aspects of the existing token leaderboard and individual statistics commands to show the best performing players across casino games.

New Command

/casino tokens game-leaderboard [game]

  • Without game parameter: Shows global leaderboard across all games
  • With game parameter: Shows leaderboard for specific game (Blackjack, Poker, Rock Paper Scissors)

Key Features

Fair Scoring Formula

Uses winrate × log₁₀(totalGames + 1) to rank players, which solves the core issue where players with just 1 game and 100% winrate would dominate leaderboards. The logarithmic scaling rewards both skill and game volume:

  • 1 game, 100% winrate → Score: 30.10 (prevents domination)
  • 100 games, 55% winrate → Score: 110.24 (rewards consistency + volume)
  • 5 games, 100% winrate → Score: 77.82 (balanced recognition)

Rich Display

Shows top 10 players with:

  • 🥇🥈🥉 Medal rankings
  • Performance score and game statistics
  • Win/loss records and winrates
  • Net profit/loss with appropriate icons (💰/💸)

Example Output

🏆 Blackjack Leaderboard
Ranked by performance score (Win Rate × log₁₀(Total Games + 1))

🥇 PlayerName
Score: 110.24
Games: 100 | W/L: 55/45
Win Rate: 55.0% | 💰 Profit: +1,250

Implementation Details

  • New service method: CasinoService.GetGameLeaderboard() aggregates user statistics across all users
  • New domain model: GameLeaderboardEntry stores calculated scores and performance metrics
  • Game name mapping: Properly maps enum values to database-stored game names
  • Consistent patterns: Follows existing casino command structure, error handling, and channel permissions

Testing

  • ✅ Project builds successfully without errors
  • ✅ Scoring formula tested with various scenarios
  • ✅ Game name mapping verified against actual database values
  • ✅ No breaking changes to existing functionality

Fixes #350.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits July 26, 2025 22:08
Co-authored-by: Pierre-Demessence <1756398+Pierre-Demessence@users.noreply.github.com>
Co-authored-by: Pierre-Demessence <1756398+Pierre-Demessence@users.noreply.github.com>
Copilot AI changed the title [WIP] Leaderboard of players Add game performance leaderboard with fair scoring system Jul 26, 2025
Copilot AI requested a review from Pierre-Demessence July 26, 2025 22:15
- 🔧 Mark UserID as required in CasinoUser and TokenTransaction classes
- 🔄 Change Details and DetailsJson properties to nullable types
- 📊 Update GameStatistics and GameLeaderboard methods to handle nullable game names
- 🗑️ Remove redundant GameLeaderboard and GameStatistics methods from CasinoSlashModule.cs
- 🔍 Refactor CapitalizeWords method for better readability
@Pierre-Demessence Pierre-Demessence marked this pull request as ready for review July 26, 2025 22:49
Copilot AI review requested due to automatic review settings July 26, 2025 22:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a new game performance leaderboard feature that provides a fair ranking system for casino players by combining win rate with game volume using a logarithmic scoring formula. The new /casino tokens game-leaderboard command shows top performers either globally or for specific games.

  • Adds GetGameLeaderboard() service method with fair scoring algorithm (winrate × log₁₀(totalGames + 1))
  • Implements new /casino leaderboard slash command with optional game filtering
  • Creates GameLeaderboardEntry domain model for leaderboard data structure

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
CasinoService.cs Adds new GetGameLeaderboard() method and updates method signatures to use nullable parameters
CasinoSlashModule.cs Removes old statistics command and helper method (moved to Games module)
CasinoSlashModule.Games.cs Adds new leaderboard command, moves statistics command from main module, and adds helper methods
CasinoUser.cs Adds GameLeaderboardEntry model and updates existing models with nullable reference types

Comment thread DiscordBot/Services/Casino/CasinoService.cs
Comment thread DiscordBot/Modules/Casino/CasinoSlashModule.Games.cs
Comment thread DiscordBot/Modules/Casino/CasinoSlashModule.Games.cs
Comment thread DiscordBot/Services/Casino/CasinoService.cs
@Pierre-Demessence Pierre-Demessence merged commit f2df705 into master Jul 26, 2025
5 checks passed
@Pierre-Demessence Pierre-Demessence deleted the copilot/fix-350 branch July 26, 2025 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Leaderboard of players

3 participants