summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs31
-rw-r--r--static/bike.mp3bin0 -> 33436 bytes
-rw-r--r--static/cough.mp3bin0 -> 35108 bytes
-rw-r--r--static/o.mp3bin0 -> 13440 bytes
-rw-r--r--static/pop.mp3bin0 -> 12480 bytes
-rw-r--r--static/wow.mp3bin0 -> 10080 bytes
6 files changed, 27 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index caf01c4..a6963c4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -87,6 +87,7 @@ struct Game {
next_rounds: Vec<UserId>,
/// Data for each round
rounds: Vec<Round>,
+ user_to_sound: HashMap<UserId, String>,
/// Sender to broadcast things
broadcast_tx: Sender<String>,
@@ -140,6 +141,26 @@ impl Game {
info!("All users have submitted");
let users = self.submissions.keys().cloned();
self.next_rounds = users.collect();
+
+ let mut rng = rand::thread_rng();
+ let sound_fx = [
+ "cough.mp3",
+ "wow.mp3",
+ "cat.mp3",
+ "pop.mp3",
+ "car.mp3",
+ "bike.mp3",
+ "dog.mp3",
+ "o.mp3",
+ ]
+ .choose_multiple(&mut rng, self.next_rounds.len());
+ self.user_to_sound = self
+ .next_rounds
+ .iter()
+ .zip(sound_fx)
+ .map(|(u, s)| (*u, s.to_string()))
+ .collect();
+
self.new_round();
} else {
self.message_screen(uid, self.screen_submitted())
@@ -154,10 +175,11 @@ impl Game {
return;
};
- let mut rng = rand::thread_rng();
- let sound_fx = ["dog.mp3", "cat.mp3", "car.mp3"]
- .choose(&mut rng)
- .expect("not empty");
+ let sound_fx = self
+ .user_to_sound
+ .get(&uid)
+ .cloned()
+ .unwrap_or_else(|| format!("cough.mp3"));
self.rounds.push(Round {
author: uid,
@@ -424,6 +446,7 @@ impl ServerState {
active_users: HashSet::new(),
submissions: HashMap::new(),
next_rounds: Vec::new(),
+ user_to_sound: HashMap::new(),
rounds: Vec::new(),
broadcast_rx: rx,
broadcast_tx: tx,
diff --git a/static/bike.mp3 b/static/bike.mp3
new file mode 100644
index 0000000..666e194
--- /dev/null
+++ b/static/bike.mp3
Binary files differ
diff --git a/static/cough.mp3 b/static/cough.mp3
new file mode 100644
index 0000000..a499ad3
--- /dev/null
+++ b/static/cough.mp3
Binary files differ
diff --git a/static/o.mp3 b/static/o.mp3
new file mode 100644
index 0000000..58fd01e
--- /dev/null
+++ b/static/o.mp3
Binary files differ
diff --git a/static/pop.mp3 b/static/pop.mp3
new file mode 100644
index 0000000..fff12a8
--- /dev/null
+++ b/static/pop.mp3
Binary files differ
diff --git a/static/wow.mp3 b/static/wow.mp3
new file mode 100644
index 0000000..f3e53dc
--- /dev/null
+++ b/static/wow.mp3
Binary files differ