Files
schafkopf-logic/README.md
Valentin Heiserer 61f8ac1f56
Some checks failed
Release crate / Publish to crates.io and create GitHub Release (release) Failing after 1m46s
update readme and add action
2025-11-11 19:09:05 +01:00

1.8 KiB
Raw Blame History

Maintainer

Valentin Heiserer valentin@heiserer.de

Features

  • Deck construction and iteration
  • Shuffling and dealing (4 players × 8 cards)
  • Card and rank helpers (human-readable Display, point values)
  • Game mode rules to determine trick winners (Sauspiel, Solo, Wenz, Geier, Bettel, Ramsch)

schafkopf-logic

Logic and rules for the German card game Schafkopf. This crate provides types and helpers for deck construction, common game modes and basic trick-taking logic.

Crate: schafkopf-logic

Features

  • Deck and card types (suits, ranks, cards) with Display implementations
  • Shuffling and dealing (4 players × 8 cards)
  • Rank point values and helpers
  • Game mode logic to determine trick winners (Sauspiel, Solo, Wenz, Geier, Bettel, Ramsch)

Quick example

use schafkopf_logic::deck::{Deck, Suit, Rank};
use schafkopf_logic::gamemode::Gamemode;

fn main() {
    // Create, shuffle and deal a deck
    let mut deck = Deck::new();
    deck.shuffle();
    let hands = deck.deal_4x8().expect("deck should contain 32 cards");

    // Form a sample trick from the first card of each hand and print it
    let trick = [&hands[0][0], &hands[1][0], &hands[2][0], &hands[3][0]];
    println!("Trick: {}, {}, {}, {}", trick[0], trick[1], trick[2], trick[3]);

    // Determine the winner for a sample game mode (Sauspiel with Schell)
    let winner = Gamemode::Sauspiel(Suit::Schell).winning_card(trick);
    println!("Winning card: {}", winner);
}

Development

Build and run the tests locally:

cargo build
cargo test

If you contribute, please file issues or PRs against the repository: https://github.com/Vale54321/schafkopf-logic

License

This crate is licensed under the MIT license — see LICENSE-MIT for details.

Maintainer

Valentin Heiserer valentin@heiserer.de