NAME

Game::Dominoes::Tile - one bone of a double six set

VERSION

Version 0.01

SYNOPSIS

use Game::Dominoes::Tile;

my $tile = Game::Dominoes::Tile->of(4, 6);

$tile->high;         # 6
$tile->low;          # 4
$tile->pips;         # 10
$tile->is_double;    # 0
$tile->id;           # 25
$tile->other(6);     # 4
$tile->stringify;    # '6-4'

DESCRIPTION

An immutable value object. high is never less than low, so a tile has exactly one representation and two tiles are the same tile when their ids are equal: there is no separate 4-6 to keep in step with 6-4.

The id is the tile's place in the canonical order of the set, 0-0 first and 6-6 last, and it is what the event log and the notation store. It is stable across processes, machines and perls, so it is part of the wire format and is not to be renumbered.

Faces run from 0 to 6. A face outside that, or a high below low, is a programmer error and dies; nothing a player can do reaches this class.

FUNCTIONS

of

my $tile = Game::Dominoes::Tile->of(4, 6);

The tile carrying two faces, given in either order. This is the constructor to use: new wants them sorted already.

from_id

my $tile = Game::Dominoes::Tile->from_id(25);

The tile with that id, 1 to 28. Dies outside that range.

high, low

$tile->high;   # 6
$tile->low;    # 4

The larger and smaller face. Equal on a double.

id

$tile->id;     # 25

Its place in the canonical order of the set, from 1 to 28.

is_double

$tile->is_double;   # 1 for 5-5

Whether both faces are the same.

pips

$tile->pips;   # 10 for 6-4

The two faces added together. The whole set holds 168 pips, which is worth asserting as an invariant over the hands, the boneyard and the layout.

has_face

$tile->has_face(6);   # 1

Whether the tile carries that face, and so whether it can be played against an end showing it.

other

$tile->other(6);   # 4

The face left showing when $face is matched. A double leaves itself. Dies if the tile does not carry the face, because that is a programmer error: whether a tile can be played is settled before it is turned round.

equals

$tile->equals($other);

Whether two tiles are the same tile.

stringify

$tile->stringify;   # '6-4'

The tile as the notation writes it, higher face first.

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::Tile

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)