simplify populate_self_from_children
This commit is contained in:
parent
967f1f6efb
commit
9342760d82
@ -57,18 +57,14 @@ impl MoveValueStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn populate_self_from_children(&mut self, others: &[Self]) {
|
pub fn populate_self_from_children(&mut self, others: &[Self]) {
|
||||||
self.wins = others
|
(self.wins, self.losses, self.ties) =
|
||||||
.iter()
|
others.iter().fold((0, 0, 0), |(wins, losses, ties), x| {
|
||||||
.map(|x| x.wins + (x.state == Some(MVSGameState::Win)) as u16)
|
(
|
||||||
.sum::<u16>();
|
wins + x.wins + (x.state == Some(MVSGameState::Win)) as u16,
|
||||||
self.losses = others
|
losses + x.losses + (x.state == Some(MVSGameState::Loss)) as u16,
|
||||||
.iter()
|
ties + x.ties + (x.state == Some(MVSGameState::Tie)) as u16,
|
||||||
.map(|x| x.losses + (x.state == Some(MVSGameState::Loss)) as u16)
|
)
|
||||||
.sum::<u16>();
|
});
|
||||||
self.ties = others
|
|
||||||
.iter()
|
|
||||||
.map(|x| x.ties + (x.state == Some(MVSGameState::Tie)) as u16)
|
|
||||||
.sum::<u16>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user