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