1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
//! Uh-oh, a `util.rs` file. That can't be good.
use crate::database::{BoardRow, Placement};
pub fn tiebreak_shared_positions(board: Vec<BoardRow>) -> Vec<Placement> {
let first = match board.first() {
Some(r) => r.clone(),
None => return vec![],
};
let mut last_score = first.points;
let mut last_placed = 1;
let mut placed = vec![Placement {
row: first,
placement: 1,
placement_tie: 1,
placement_first_of_tie: true,
}];
for (idx, row) in board.into_iter().enumerate().skip(1) {
if row.points == last_score {
placed.push(Placement {
row,
placement: idx + 1,
placement_tie: last_placed,
placement_first_of_tie: false,
});
} else {
last_score = row.points;
last_placed = idx + 1;
placed.push(Placement {
row,
placement: idx + 1,
placement_tie: last_placed,
placement_first_of_tie: true,
});
}
}
placed
}
|