NAME

Game::Dominoes::Hand - one seat's tiles

VERSION

Version 0.01

SYNOPSIS

use Game::Dominoes::Hand;

my $hand = Game::Dominoes::Hand->new(tiles => \@dealt);

$hand->count;             # public: everybody sees how many
$hand->tiles;             # private: only the seat sees which
$hand->holds($tile);
$hand->remove($tile);
$hand->matching(6, 4);    # the tiles that could go on those ends
$hand->pips;              # what it is worth to an opponent at the end

DESCRIPTION

A seat's tiles, and the smallest class in the distribution that carries a secret.

count exists beside tiles on purpose. How many tiles a seat holds is public and which tiles they are is not, so a view carries the first and never the second, and having two methods makes the difference visible at every call site rather than hiding it inside a scalar @{...}.

PROPERTIES

tiles

$hand->tiles;

The tiles, as an arrayref. Private. A view carries count, not this.

FUNCTIONS

count, is_empty

$hand->count;      # 9
$hand->is_empty;   # the seat has gone out

How many tiles are held. Public.

pips

$hand->pips;

The pips held, which is what the hand is worth to whoever goes out, and part of the running total that must always come to 168 across the hands, the boneyard and the layout.

add

$hand->add($tile, $another);

Puts tiles in, from the deal or from a draw.

holds

$hand->holds($tile);

Whether the seat holds that tile.

remove

my $gone = $hand->remove($tile);

Takes one tile out and returns it, or undef if the seat did not hold it. The undef is the caller's cue to refuse the play.

matching

$hand->matching(6, 4);

The tiles carrying any of those faces, as an arrayref: the seat's candidate plays against a set of open ends, before anything is said about which arm.

sorted

$hand->sorted;

The tiles in canonical order, for printing and for a stable test.

clone

$hand->clone;

A copy with its own arrayref. The tiles inside are immutable and shared.

stringify

$hand->stringify;   # '6-6 6-4 5-0'

The hand in canonical order, as the notation writes each tile.

SEE ALSO

Game::Dominoes::Tile, Game::Dominoes::Boneyard.

AUTHOR

LNATION <email@lnation.org>

BUGS

Please report any bugs or feature requests to bug-game-dominoes at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Game-Dominoes.

SUPPORT

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

perldoc Game::Dominoes::Hand

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION <email@lnation.org>.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)