Scope the leaderboard to a selectable game
Elo ratings are stored per game type, so the leaderboard now always requests /api/leaderboard?game_type=<id> and shows only that game's players, Elo, wins, matches and points instead of mixing all games' aggregates with the default game's rating. - api::leaderboard takes the game type; - a "Game" dropdown next to the heading lists every registered game and reloads the board on change (stale in-flight responses are dropped); - move fallback_game_types() from the lobby to model.rs so both the lobby and leaderboard selectors work when /api/game-types fails.
This commit is contained in:
+2
-31
@@ -15,39 +15,10 @@ use crate::api;
|
||||
use crate::components::card::card_back;
|
||||
use crate::components::toast::toast;
|
||||
use crate::model::{
|
||||
AuthProvider, GameTypeInfo, JoinPreview, OptionField, OptionKind, PlayerRating, User,
|
||||
fallback_game_types, AuthProvider, GameTypeInfo, JoinPreview, OptionField, OptionKind,
|
||||
PlayerRating, User,
|
||||
};
|
||||
|
||||
/// Used when the game-types fetch fails: match creation must still work.
|
||||
fn fallback_game_types() -> Vec<GameTypeInfo> {
|
||||
vec![
|
||||
GameTypeInfo {
|
||||
id: "scopone_scientifico".to_string(),
|
||||
name: "Scopone scientifico".to_string(),
|
||||
description: String::new(),
|
||||
min_players: 4,
|
||||
max_players: 4,
|
||||
options_schema: serde_json::Value::Null,
|
||||
},
|
||||
GameTypeInfo {
|
||||
id: "briscola".to_string(),
|
||||
name: "Briscola".to_string(),
|
||||
description: String::new(),
|
||||
min_players: 2,
|
||||
max_players: 2,
|
||||
options_schema: serde_json::Value::Null,
|
||||
},
|
||||
GameTypeInfo {
|
||||
id: "briscola_a_quattro".to_string(),
|
||||
name: "Briscola a quattro".to_string(),
|
||||
description: String::new(),
|
||||
min_players: 4,
|
||||
max_players: 4,
|
||||
options_schema: serde_json::Value::Null,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
/// Human-readable label for a provider name ("google" -> "Google").
|
||||
fn provider_label(name: &str) -> String {
|
||||
let mut chars = name.chars();
|
||||
|
||||
Reference in New Issue
Block a user