12 releases

0.4.0 Jun 24, 2022
0.2.0 May 18, 2017
0.1.9 Jan 16, 2016
0.1.4 Dec 27, 2015

#15 in #cards

MIT license

55KB
1.5K SLoC

libcoinche

Build Status MIT licensed

Rust library to model a game of coinche.

Documentation

To use, add libcoinche to your Cargo dependencies:

[dependencies]
libcoinche = "0.1.9"

Check coinched for an example of usage.


lib.rs:

Models a game of coinche (a french card game).

See coinched for an example of usage.

Here is a simple example:

extern crate libcoinche;
use libcoinche::{bid,cards,pos};

fn main() {
    // The first player
    let first = pos::PlayerPos::P0;

    // Start the first phase with an auction
    let mut auction = bid::Auction::new(first);

    // Check their cards
    let hands = auction.hands();

    // Players bid or pass
    auction.bid(pos::PlayerPos::P0, cards::Suit::Heart, bid::Target::Contract80).unwrap();
    auction.pass(pos::PlayerPos::P1).unwrap();
    auction.pass(pos::PlayerPos::P2).unwrap();
    // The result is `Over` when the auction is ready to complete
    match auction.pass(pos::PlayerPos::P3) {
        Ok(bid::AuctionState::Over) => (),
        _ => panic!("Should not happen"),
    };

    // Complete the auction to enter the second phase
    let mut game = auction.complete().unwrap();

    // Play some cards
    game.play_card(pos::PlayerPos::P0, hands[0].get_card());
    // ...
}

Dependencies

~0.7–1.3MB
~28K SLoC