style(core): apply cargo fmt across routes, services, models, tests
CI / Build, lint & test (push) Successful in 2m19s
CI / Build, lint & test (push) Successful in 2m19s
Pure rustfmt reflow (import grouping, array/match-arm/call-arg wrapping, alphabetized module decls, comment realignment). No semantic change: full-diff and `git diff -w` both confirm logic byte-identical to 271c363; workspace builds and all 74 core tests pass. Retained pre-existing WIP brought forward after verification.
This commit is contained in:
+35
-11
@@ -37,13 +37,19 @@ pub async fn get_division(State(state): State<AppState>, game: GameId) -> AppRes
|
||||
})))
|
||||
}
|
||||
|
||||
pub async fn get_division_history(State(state): State<AppState>, game: GameId) -> AppResult<Json<Value>> {
|
||||
pub async fn get_division_history(
|
||||
State(state): State<AppState>,
|
||||
game: GameId,
|
||||
) -> AppResult<Json<Value>> {
|
||||
let profile = profile_svc::get_active_profile(&state.pool, game.as_str()).await?;
|
||||
let history = season_svc::get_history(&state.pool, &profile.id).await?;
|
||||
Ok(Json(json!({ "history": history, "total": history.len() })))
|
||||
}
|
||||
|
||||
pub async fn get_division_leaderboard(State(state): State<AppState>, game: GameId) -> AppResult<Json<Value>> {
|
||||
pub async fn get_division_leaderboard(
|
||||
State(state): State<AppState>,
|
||||
game: GameId,
|
||||
) -> AppResult<Json<Value>> {
|
||||
let profile = profile_svc::get_active_profile(&state.pool, game.as_str()).await?;
|
||||
let club = club_svc::get_club_by_profile(&state.pool, &profile.id).await?;
|
||||
let season = season_svc::get_or_create(&state.pool, &profile.id).await?;
|
||||
@@ -53,11 +59,26 @@ pub async fn get_division_leaderboard(State(state): State<AppState>, game: GameI
|
||||
let mut rng = rand::rngs::SmallRng::seed_from_u64(seed);
|
||||
|
||||
const NPC_NAMES: &[&str] = &[
|
||||
"Riverside FC", "City Athletic", "County United", "Valley Rangers",
|
||||
"Harbor Town FC", "Mountside City", "Lakewood Athletic", "Eastbrook United",
|
||||
"Westfield Rovers", "Northgate FC", "Southport Athletic", "Ironbridge City",
|
||||
"Milldale United", "Hillcrest Rangers", "Bayside FC", "Thornfield Athletic",
|
||||
"Greenhill United", "Coldwater City", "Redbury Rangers", "Ashdown FC",
|
||||
"Riverside FC",
|
||||
"City Athletic",
|
||||
"County United",
|
||||
"Valley Rangers",
|
||||
"Harbor Town FC",
|
||||
"Mountside City",
|
||||
"Lakewood Athletic",
|
||||
"Eastbrook United",
|
||||
"Westfield Rovers",
|
||||
"Northgate FC",
|
||||
"Southport Athletic",
|
||||
"Ironbridge City",
|
||||
"Milldale United",
|
||||
"Hillcrest Rangers",
|
||||
"Bayside FC",
|
||||
"Thornfield Athletic",
|
||||
"Greenhill United",
|
||||
"Coldwater City",
|
||||
"Redbury Rangers",
|
||||
"Ashdown FC",
|
||||
];
|
||||
|
||||
// Pick 9 NPC names without repetition using the seeded RNG
|
||||
@@ -75,10 +96,13 @@ pub async fn get_division_leaderboard(State(state): State<AppState>, game: GameI
|
||||
// Quality bias: index 0-2 = stronger, 6-8 = weaker
|
||||
let quality: f64 = 1.0 - (idx as f64 / 8.0); // 1.0 → 0.0
|
||||
let expected_win_rate = 0.2 + quality * 0.6; // 0.2–0.8
|
||||
let wins = (npc_matches as f64 * expected_win_rate * (0.8 + rng.gen::<f64>() * 0.4)) as i64;
|
||||
let losses = (npc_matches as f64 * (1.0 - expected_win_rate) * (0.8 + rng.gen::<f64>() * 0.4)) as i64;
|
||||
let draws = (npc_matches - wins - losses).max(0);
|
||||
let pts = wins * 3 + draws;
|
||||
let wins =
|
||||
(npc_matches as f64 * expected_win_rate * (0.8 + rng.gen::<f64>() * 0.4)) as i64;
|
||||
let losses = (npc_matches as f64
|
||||
* (1.0 - expected_win_rate)
|
||||
* (0.8 + rng.gen::<f64>() * 0.4)) as i64;
|
||||
let draws = (npc_matches - wins - losses).max(0);
|
||||
let pts = wins * 3 + draws;
|
||||
json!({
|
||||
"club_name": name,
|
||||
"wins": wins,
|
||||
|
||||
Reference in New Issue
Block a user