Add victory card type
This commit is contained in:
parent
d78b8b1416
commit
9ab7d7fcfb
34
src/main.rs
34
src/main.rs
@ -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,14 +428,12 @@ 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)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user