mirror of
https://git.alemi.dev/mood.git
synced 2024-11-12 20:09:20 +01:00
feat: also show chance of mood
This commit is contained in:
parent
6726a69379
commit
acc8824600
1 changed files with 5 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue