13 releases (stable)
Uses new Rust 2024
| new 1.2.8 | Mar 4, 2026 |
|---|---|
| 1.2.7 | Mar 2, 2026 |
| 1.2.6 | Feb 27, 2026 |
| 1.0.0 | Jul 18, 2018 |
| 0.1.2 | Jul 9, 2018 |
#151 in Game dev
260KB
6K
SLoC
Spades
Rust implementation of the four-player trick-taking card game Spades. Rules: pagat.com/auctionwhist/spades.html.
Installation
[dependencies]
spades = "1.1"
Library Usage
use spades::{Game, GameTransition, State};
use rand::seq::SliceRandom;
use rand::thread_rng;
let mut g = Game::new(
uuid::Uuid::new_v4(),
[uuid::Uuid::new_v4(),
uuid::Uuid::new_v4(),
uuid::Uuid::new_v4(),
uuid::Uuid::new_v4()],
500,
None, // optional TimerConfig
);
g.play(GameTransition::Start);
while *g.get_state() != State::Completed {
let mut rng = thread_rng();
if let State::Trick(_) = *g.get_state() {
let hand = g.get_current_hand().unwrap().clone();
let card = hand.as_slice().choose(&mut rng).unwrap();
g.play(GameTransition::Card(card.clone()));
} else {
g.play(GameTransition::Bet(3));
}
}
Server Mode
Optional HTTP server for hosting concurrent multiplayer games. Includes matchmaking, challenge links, WebSocket game subscriptions, SSE event streams, optional SQLite persistence, and Fischer increment timers.
cargo run --features server -- --port 3000
cargo run --features server -- --port 3000 --db games.sqlite
See SERVER.md for the full API reference.
Bidding
Nil bids are supported (bet zero for +/-100 point bonus/penalty). Blind bids are not yet supported.
Documentation
Contributing
Issues and pull requests welcome.
Dependencies
~2–21MB
~242K SLoC