Add victory card type

This commit is contained in:
Markus Wagner 2021-01-08 19:04:39 +01:00
parent d78b8b1416
commit 9ab7d7fcfb

View File

@ -56,7 +56,7 @@ enum ServerMessage {
text: String,
},
GameOver {
score: Vec<(usize, usize)>,
score: Vec<(usize, u32)>,
},
}
@ -208,22 +208,8 @@ impl Game {
(silver(), 40),
(gold(), 30),
(estate(), victory_qty),
(
Card {
name: "Duchy".into(),
cost: 5,
types: vec![],
},
victory_qty,
),
(
Card {
name: "Province".into(),
cost: 8,
types: vec![],
},
victory_qty,
),
(duchy(), victory_qty),
(province(), victory_qty),
(
Card {
name: "Curse".into(),
@ -442,15 +428,13 @@ async fn broadcast_state(game: &Game) {
.iter()
.enumerate()
.map(|(i, p)| {
let score = p
.draw_pile
.iter()
.fold(0, |acc, card| match card.name.as_str() {
"Province" => acc + 6,
"Duchery" => acc + 3,
"Estate" => acc + 1,
_ => acc,
});
let score = p.draw_pile.iter().fold(0, |acc, card| {
if let Some(points) = card.victory() {
acc + points
} else {
acc
}
});
(i, score)
})
.sorted_by(|a, b| Ord::cmp(&b.1, &a.1))