Crates.io | spades |
lib.rs | spades |
version | 1.0.0 |
source | src |
created_at | 2018-07-09 19:04:59.319252 |
updated_at | 2018-07-18 19:20:49.891613 |
description | A popular four person card game implemented in Rust. |
homepage | |
repository | https://github.com/wlim33/rust-spades |
max_upload_size | |
id | 73526 |
size | 50,070 |
Spades is a four person trick-taking card game. For the complete rules of spades, click here.
Add this line to your Cargo.toml
:
[dependencies]
spades = "1.0"
Currently allows bidding nil by placing a bet of zero (the bonus is +100 points, and penalty is -100 points), but blind bets are not yet supported.
extern crate spades;
extern crate uuid;
use spades::{Game, GameTransition};
use spades::result::{TransitionSuccess, TransitionError, GetError};
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);
g.play(GameTransition::Start);
//Each round starts with a round of betting
assert_eq!(g.play(GameTransition::Bet(3)), TransitionSuccess::Bet);
g.play(GameTransition::Bet(4));
g.play(GameTransition::Bet(4));
g.play(GameTransition::Bet(2));
//The game is now in the card playing stage
assert_eq!(g.play(GameTransition::Bet(3)), TransitionFailure::Bet);
let hand = g.get_hand(g.current_player).clone();
let valid_card = g.last().unwrap().clone();
g.play(GameTransition::Card(valid_card));
//...
For a complete description of the crate, check the docs.rs page.
If there is a feature you would like to see added, please feel free to make an open an issue or pull request!