dou_dizhu 0.2.0

Rust toolkit for the Chinese card game Dou Dizhu (斗地主)
Documentation
  • Coverage
  • 68.18%
    75 out of 110 items documented7 out of 33 items with examples
  • Size
  • Source code size: 67.48 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.05 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 18s Average build duration of successful builds.
  • all releases: 18s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • zhangheqi/dou_dizhu
    5 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • zhangheqi

dou_dizhu

Crates.io Documentation License

A Rust toolkit for the Chinese card game Dou Dizhu (斗地主).

This crate implements Dou Dizhu strictly following the Pagat rules, though it uses different terminology.

Features

  • Hand representation
  • Compile-time and runtime validation
  • All standard Dou Dizhu play kinds (solo, pair, trio, chain, airplane, rocket, etc.)
  • Play kind recognition
  • Play comparison
  • Enumerating all plays of specified characteristics within a hand

Usage

Add this to your Cargo.toml:

[dependencies]
dou_dizhu = "0.2"

Then:

use dou_dizhu::*;

fn main() {
    // Construct a play
    let airplane_with_solos = play!(const {
        Queen: 3,
        King: 3,
        Three,
        Four,
    })
    .unwrap();

    // Count how many stronger plays of the same kind exist in a full deck
    assert_eq!(
        Hand::FULL_DECK
            .plays(airplane_with_solos.kind())
            .filter(|p| p > &airplane_with_solos)
            .count(),
        77,
    );
}

License

Licensed under either of:

at your option.