Skip to main content

Crate go_fish

Crate go_fish 

Source
Expand description

§go-fish

go-fish is a library providing core engine functionality for the classic Go Fish card game.

It provides types for cards, decks, and players, and manages the game logic including turns, drawing, and completing books.

§Example

use go_fish::{Game, Deck, Hook, PlayerId, Rank};

// Initialize a new game with 3 players
let deck = Deck::new().shuffle();
let mut game = Game::new(deck, 3);

// Current player takes a turn
let hook = Hook {
    target: PlayerId::new(1),
    rank: Rank::Ace,
};

match game.take_turn(hook) {
    Ok(result) => println!("Turn result: {:?}", result),
    Err(e) => eprintln!("Error: {:?}", e),
}

Structs§

Card
A playing card
CompleteBook
A collection of four Cards of the same Rank
Deck
A deck of Cards
Game
Handling for a game of Go Fish
GameResult
Hand
A players hand
Hook
A request for another players cards
HookOutcome
The full outcome of a take_turn call, including who fished, who was targeted, what rank was requested, and whether the catch succeeded.
InactivePlayer
A player who no longer has any viable moves. They can still win the game, if they have more Completed Books than any other player at the end of the game
IncompleteBook
A collection of three or fewer Cards of the same Rank
Player
A player actively trying to win the game
PlayerId

Enums§

HookResult
Rank
The rank (or value) of a Card
Suit
The suit of a Card
TurnError