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