| Crates.io | schafkopf-logic |
| lib.rs | schafkopf-logic |
| version | 0.1.1 |
| created_at | 2025-11-13 22:52:53.139071+00 |
| updated_at | 2025-11-13 22:52:53.139071+00 |
| description | Logic and rules for the Schafkopf card game: deck, suits, ranks and game modes. |
| homepage | https://git.heiserer.de/heiserer/schafkopf-logic |
| repository | https://git.heiserer.de/heiserer/schafkopf-logic |
| max_upload_size | |
| id | 1931994 |
| size | 35,200 |
Maintainer
Valentin Heiserer valentin@heiserer.de
Features
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
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);
}
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
This crate is licensed under the MIT license — see LICENSE-MIT for details.
Valentin Heiserer valentin@heiserer.de