diff options
| author | LLLL Colonq <llll@colonq> | 2026-08-04 17:58:22 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-08-04 17:58:22 -0400 |
| commit | ad2524a89f2a0e29088873b18eb458760fa796b1 (patch) | |
| tree | d0aa7066821b73b291f27a9c02addc89cf4518c3 /2026/src | |
| parent | cc8514251ee1828908161756228fa1c8357effc2 (diff) | |
Fix
Diffstat (limited to '2026/src')
| -rw-r--r-- | 2026/src/main.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/2026/src/main.rs b/2026/src/main.rs index ad37e4a..07adb93 100644 --- a/2026/src/main.rs +++ b/2026/src/main.rs @@ -1,4 +1,5 @@ use axum::http::StatusCode; +use rand::Rng; use tower_http::services::ServeDir; use clap::{command, Arg, ArgAction}; @@ -47,7 +48,11 @@ pub async fn main() { axum::response::Html(include_str!("../index.html")) })) .route("/games.js", axum::routing::get(move || { - let gs = format!("window.MICROGAMES = {:?};\n", games); + let mut rng = rand::thread_rng(); + let mut keyed: Vec<_> = games.iter().map(|x| (x, rng.r#gen::<i32>())).collect(); + keyed.sort_by_key(|(_, i)| *i); + let shuffled: Vec<_> = keyed.iter().map(|(x, _)| *x).collect(); + let gs = format!("window.MICROGAMES = {:?};\n", shuffled); async { ([(axum::http::header::CONTENT_TYPE, "text/javascript".to_string())], gs) } |
