14 releases (stable)
Uses new Rust 2024
| new 2.0.0 | May 12, 2026 |
|---|---|
| 1.2.8 | Mar 4, 2026 |
| 1.2.6 | Feb 27, 2026 |
| 1.0.0 | Jul 18, 2018 |
| 0.1.2 | Jul 9, 2018 |
#149 in Game dev
Used in spades-server
175KB
4K
SLoC
Spades
Rust implementation of the four-player trick-taking card game Spades. Rules: pagat.com/auctionwhist/spades.html.
Installation
[dependencies]
spades = "2.0"
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(); 4],
500,
None, // optional TimerConfig
);
g.play(GameTransition::Start).unwrap();
let mut rng = thread_rng();
while *g.get_state() != State::Completed {
if let State::Trick(_) = *g.get_state() {
let legal = g.get_legal_cards().unwrap();
let card = *legal.choose(&mut rng).unwrap();
g.play(GameTransition::Card(card)).unwrap();
} else {
g.play(GameTransition::Bet(3)).unwrap();
}
}
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. Ships as a separate crate (spades-server) so library consumers don't pull in axum/tokio/sqlite.
cargo run -p spades-server -- --port 3000
cargo run -p spades-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. The repo ships an opt-in pre-push hook that runs clippy, the full test suite, and a per-crate coverage regression check via cargo tarpaulin. See docs/coverage.md for how to enable it and how the coverage baseline ratchets.
Dependencies
~1.5–3MB
~60K SLoC