Crates.io | rummy |
lib.rs | rummy |
version | 0.1.4 |
source | src |
created_at | 2024-06-18 14:52:37.830081 |
updated_at | 2024-07-07 09:09:53.93897 |
description | a crate for the card game Rummy |
homepage | |
repository | https://github.com/mhbka/rummy-rs |
max_upload_size | |
id | 1275536 |
size | 108,685 |
This crate models the card game Rummy. It supports configuration and different popular variants (WIP).
NOTE: this crate is in early development; expect nothing to stay stable.
A typical import of this crate will look like this:
use rummy::game::{
actions::{
AllActions, DiscardActions, DrawActions, PlayActions, PlayableActions, RoundEndActions,
TransitionResult,
},
phases::{DiscardPhase, DrawPhase, GamePhase, PlayPhase, PlayablePhase, RoundEndPhase},
state::{Score, State},
variants::standard::{StandardRummy, StandardRummyGame},
};
A breakdown of the modules:
// initialize a list of player IDs
let player_ids = vec![1, 2, 3, 4];
// pass it into a variant's `quickstart`
let game = StandardRummyGame::quickstart(player_ids);
// we initialize at round 0 in `RoundEndPhase`, so we must advance to the next round
let game = game.to_next_round();
Alternatively, you can configure the game by setting a config:
// the config struct for standard Rummy
let game_config = StandardRummyConfig { /* ... */ };
// and for the deck itself
let deck_config = DeckConfig { /* ... */ };
// we pass both into the variant's `new`
let game = StandardRummyGame::quickstart(player_ids, game_config, deck_config);
Certain actions, such as forming melds, can result in immediate transitions to a different gamephase. Calling these functions consumes the game and returns a TransitionResult
.
WIP
Use cargo run --examples rummy
to run a command-line implementation of this crate.