Files
schafkopf-logic/README.md
Valentin Heiserer 08872be58d
Some checks failed
Release crate / Publish to crates.io and create GitHub Release (release) Failing after 1m38s
update readme and add action
2025-11-11 18:43:01 +01:00

68 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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`](https://crates.io/crates/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
```rust
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:
```fish
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>