NAME

Game::Cribbage::Deck - deck of cards

VERSION

Version 0.15

SYNOPSIS

use Game::Cribbage::Deck;

my $deck = Game::Cribbage::Deck->new();

$deck->shuffle();

$deck->from_order([1 .. 52]);   # a deck in a known order

$deck->draw();

$deck->get($index);

PROPERTIES

deck

ArrayRef property that contains Game::Cribbage::Deck::Card cards that represent the deck.

FUNCTIONS

cards

Returns all cards in the current deck. This is just a wrapper around calling the deck property.

$deck->cards;

reset

Reset the deck to 52 cards. This is just a wrapper around the shuffle function.

$deck->reset;

shuffle

Resets the deck to 52 cards and shuffles them. Each time this function is called it resets the deck property.

$deck->shuffle;

from_order

Replace the deck with the 52 cards in the order of the given card ids, the first id on top. Ids are the ones shuffle assigns: suit-major hearts, spades, diamonds, clubs, ace to king, so 1 is the ace of hearts and 52 the king of clubs. A list that is not a permutation of 1 to 52 dies. This is how a game dealt from a recorded or seeded order is replayed.

$deck->from_order(\@ids);

draw

Draw a card from the deck. This shifts the first item from the deck property.

$deck->draw;

force_draw

Force draw a specific card from the deck. This splices the found item from the deck.

$deck->force_draw({ suit => 'H', symbol => 7 });

get

Get a card by index from the deck property.

$deck->get(15);

card_exists

Check whether a card exists in the deck, aka it has not been drawn yet.

$deck->card_exists({ suit => 'H', symbol => 7 });

generate_card

Utility function to generate a new Game::Cribbage::Deck::Card.

$deck->generate_card({
	id => 7,
	used => 1,
	suit => 'H',
	symbol => 7
});

AUTHOR

LNATION, <email at lnation.org>

BUGS

Please report any bugs or feature requests to bug-game-cribbage at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Game-Cribbage. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Game::Cribbage

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2024 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)