NAME
Game::Mahjong::Result - the settlement of a hand, and the standings of a game
VERSION
Version 0.01
SYNOPSIS
my $deltas = Game::Mahjong::Result::settle(winner => 2, by => 'discard', from => 0, points => 16);
# [ -24, -8, 40, -8 ]: the discarder gives 8 + 16, the other two give 8 each
Game::Mahjong::Result::places([ 40, -10, 40, -70 ]); # [ 1, 3, 1, 4 ]
Game::Mahjong::Result::winner([ 40, -10, 40, -70 ]); # undef: a shared first
DESCRIPTION
The rulebook's settlement (3.9.1.3), as signed deltas that sum to zero:
self-drawn every other seat gives BASE + points
discard the discarder gives BASE + points, the other two give BASE
exhausted nobody moves
BASE is 8 (3.9.1.2, "Non-winning players must pay 8 points"), and points are the hand's including its flowers. Robbing the kong is a win by discard whose discarder is the seat that promoted the kong. Totals may go below zero; nothing clamps them. The words are "gives" and "loses".
The standings
Competition ranking of the totals, highest first: equal totals share a place and the next place is skipped. The winner is the sole first place, or undef when first is shared. A game is sixteen hands, four rounds of four (3.4.3, 3.4.4), and the deal passes every hand (3.4.8), so finished is a count.
FUNCTIONS
settle
my $deltas = settle(winner => $seat, by => 'self' | 'discard' | 'rob' | 'exhausted',
from => $seat, points => $n);
Four signed deltas indexed by seat. Dies on a bad seat, a discard win with no discarder, or a way to win it does not know.
places
Places by seat, 1 the highest.
winner
The sole first place, or undef.
finished
Whether the hands played reach HANDS.
BASE, SEATS, HANDS, ROUNDS
8, 4, 16, 4.
SEE ALSO
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.