Crate libcoinche

Crate libcoinche 

Source
Expand description

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());
    // ...
}

Modules§

bid
Auctions and bidding during the first phase of the game.
cards
This module represents a basic, rule-agnostic 32-cards system.
game
Module for the card game, after auctions are complete.
points
Manage points and scores
pos
Player position in the table
trick
This module implements a trick in a game of coinche.

Functions§

deal_hands
Quick method to get cards for 4 players.
deal_seeded_hands
Deal cards for 4 players deterministically.