feat: also show chance of mood

This commit is contained in:
əlemi 2023-11-18 04:53:54 +01:00
parent 6726a69379
commit acc8824600
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -30,16 +30,17 @@ fn main() {
.collect();
let mut pool = Vec::new();
pool.reserve(lines.iter().map(|(x,_)| x).sum::<u64>() as usize);
let sum = lines.iter().map(|(x,_)| x).sum::<u64>();
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);
}