- BUGS AND LIMITATIONS
- COPYRIGHT AND LICENSE
Ordeal::Model::Deck - Class for representing decks of cards
use Ordeal::Model::Deck; my $card = Ordeal::Model::Deck->new( group => 'whatever', id => 'AAA-bb-1235', name => 'three of clubs', cards => \@cards, );
This class represents a deck of cards. The representation is considered ordered, see Ordeal::Model::Shuffle for a wrapper object for shuffling the cards.
"group" can be used to group decks together, e.g. for assigning them to owners. All in all it is opaque data that you can use.
"name" is a name you can associate to the deck. Again, it's treated as opaque data, so you can abuse it.
my $card = $deck->card_at($i);
get the card in position
$i. Positions are assumed to start from 0 and arrive up to "n_cards" minus one. Invalid indexes
$i trigger an exception.
my @cards = $deck->cards; $deck->cards(@cards);
accessor for the list of cards. Note that it accepts and returns a list not an array reference.
my $group = $deck->group; $deck->group($group);
accessor for some c<group> metadata you might want to associate to the deck. Treated as opaque data.
my $id = $deck->id; $deck->id($id);
accessor for a unique identifer associated to the deck.
my $name = $deck->name; $deck->name($name);
accessor for a name associated to the deck.
my $n = $deck->n_cards;
returns the number of cards in the deck.
The code leverages some experimental Perl features like signatures and postderef; for this reason, at least perl 5.20 will be needed.
Report bugs through GitHub (patches welcome) at https://github.com/polettix/Ordeal-Model.
Flavio Poletti <firstname.lastname@example.org>
Copyright (C) 2018 by Flavio Poletti <email@example.com>
This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.