Skip to content

Commit

Permalink
added leaderboard recovery tool
Browse files Browse the repository at this point in the history
  • Loading branch information
ana_rchy committed May 31, 2024
1 parent 385244a commit 78895fb
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
114 changes: 114 additions & 0 deletions leaderboard-recovery-tool/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions leaderboard-recovery-tool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "leaderboard-recovery-tool"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rmp-serde = "1.3.0"
22 changes: 22 additions & 0 deletions leaderboard-recovery-tool/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use std::collections::HashMap;
use std::io;
use std::fs;
use rmp_serde::encode;

fn main() {
let mut leaderboard = HashMap::<u64, u16>::new();

println!("enter entries in format [user_id],[count]");
loop {
let mut input = String::new();
io::stdin().read_line(&mut input).expect("cant read input");

let mut params = input.split(",");
let id = params.next().unwrap().parse::<u64>().unwrap();
let count = params.next().unwrap().parse::<u16>().unwrap();
leaderboard.insert(id, count);

let leaderboard_bytes = encode::to_vec(&leaderboard).expect("couldnt serialize leaderboard");
_ = fs::write("leaderboard.bin", leaderboard_bytes);
}
}

0 comments on commit 78895fb

Please sign in to comment.