Valentin Heiserer valentin
  • Joined on 2024-09-20

schafkopf-logic (0.1.1)

Published 2025-11-13 23:52:50 +01:00 by valentin in valentin/schafkopf-logic

Installation

[registry]
default = "gitea"

[registries.gitea]
index = "sparse+" # Sparse index
# index = "" # Git

[net]
git-fetch-with-cli = true
cargo add schafkopf-logic@0.1.1

About this package

Logic and rules for the Schafkopf card game: deck, suits, ranks and game modes.

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

Dependencies

ID Version
rand ^0.9
strum ^0.27
strum_macros ^0.27

Keywords

schafkopf card-game trick-taking
Details
Cargo
2025-11-13 23:52:50 +01:00
2
Valentin Heiserer <valentin@heiserer.de>
MIT
8.9 KiB
Assets (1)
Versions (2) View all
0.1.1 2025-11-13
0.1.0 2025-11-11