Coder Social home page Coder Social logo

rust-spades's Introduction

Spades · MIT Licence · Build Status

Spades is a four person trick-taking card game. For the complete rules of spades, click here.

Getting Started

Add this line to your Cargo.toml:

[dependencies]
spades = "1.0"

Bidding Features

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.

How to use

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));

//...

Documentation

For a complete description of the crate, check the docs.rs page.

Contributing

If there is a feature you would like to see added, please feel free to make an open an issue or pull request!

rust-spades's People

Contributors

wlim33 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

targrub

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.