NAME

Game::Mahjong::Meld - a chow, a pung or a kong

VERSION

Version 0.01

SYNOPSIS

my $chow = Game::Mahjong::Meld->new(kind => 'chow', tiles => [ 2, 3, 4 ],
    claimed_from => 3, claimed_tile => 3);
my $kong = Game::Mahjong::Meld->new(kind => 'kong', tiles => [ 28, 28, 28, 28 ],
    concealed => 1);
$chow->is_chow;        # 1
$kong->is_pung;        # 1, a kong counts wherever a pung does
$kong->counts_as;      # 3, for the fourteen-tile count

DESCRIPTION

A value object. Immutable after construction; promote returns a new one.

A kong is a pung

Every fan that says "pung or kong" (Big Four Winds, All Pungs, Dragon Pung, and the rest) counts a kong, so is_pung is true of a kong and is_kong tells the two apart. A kong is four tiles on the table and three in the fourteen-tile count (3.11.6.6: "not counting ... the 4th tile in a Kong"), which is what size and counts_as say.

Concealed

A concealed kong is declared from four tiles in hand and shown at the end; the hand stays concealed (3.6.8). A chow or pung with concealed set is a set the decomposer found inside a concealed hand and never a meld on the table; the rules never build one.

What it refuses

A chow with a gap, across suits, or of honours; a pung or kong of different tiles; a bonus tile in any meld; a claimed meld that does not name the tile it took; a concealed meld claimed from somebody; a promoted chow or pung. All die: these are programmer errors, and a player's mistake is refused by the rules before a meld is built.

ATTRIBUTES

kind

chow, pung or kong.

tiles

The kinds, sorted ascending.

concealed

1 for a concealed kong.

claimed_from

The seat, 0 to 3, whose discard made the meld; undef for a concealed kong.

claimed_tile

The kind that was claimed.

1 for a kong made by adding the fourth tile to an exposed pung.

METHODS

is_chow, is_pung, is_kong

As above.

size

3 or 4.

counts_as

3.

tile

The kind of a pung or kong; the lowest kind of a chow.

suit, rank

Of tile; undef for an honour.

is_honour

Whether the meld is of a wind or a dragon.

has_terminal

Whether any tile is a one or a nine (a 1-2-3 chow has one).

is_outside

Honour or terminal in it: what fan 55 asks of every set.

is_exposed

The opposite of concealed.

promote

A new kong from an exposed pung, keeping where the pung came from.

equals

Same kind, tiles and concealment.

to_hash, to_notation

The plain hash Game::Mahjong::Notation speaks, and its token.

SEE ALSO

Game::Mahjong::Hand, Game::Mahjong::Notation

AUTHOR

LNATION <email@lnation.org>

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.