diff --git a/src/main.rs b/src/main.rs index 428b23d..f1427c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,16 +30,17 @@ fn main() { .collect(); let mut pool = Vec::new(); - pool.reserve(lines.iter().map(|(x,_)| x).sum::() as usize); + let sum = lines.iter().map(|(x,_)| x).sum::(); + pool.reserve(sum as usize); for (count, line) in lines { for _ in 0..count { - pool.push(line); + pool.push((line, count / sum)); } } - let choice = pool[index % pool.len()]; + let (choice, chance) = pool[index % pool.len()]; println!("Content-type: application/json"); println!(); - println!("{{\"id\":{},\"mood\":\"{}\"}}", index, choice); + println!("{{\"id\":{},\"mood\":\"{}\",\"chance\":{}}}", index, choice, chance); }