NAME

Game::Brandubh::Result - how a game of brandubh ended

VERSION

Version 0.01

SYNOPSIS

my $result = $game->result;         # undef while the game is on

if ($result) {
    print $result->how, "\n";                       # corner
    print $result->winner // 'nobody', "\n";        # defenders
    print "a draw\n" if $result->is_draw;
}

DESCRIPTION

A finished game's ending, as a value that cannot be changed: how it ended, who won if anybody did, after how many moves, and the position it stopped in.

Game::Brandubh makes these. There is no result while a game is on.

How a game ends

corner

The king reached a corner. The defenders win.

edge

The king reached the edge, in a rule set where the edge is the way out. The defenders win.

capture

The king was captured. The attackers win.

no_pieces

The attackers have no piece left. The defenders win.

resign

A seat resigned. The other side wins.

repetition

A position occurred for the last time the rule set allows. A draw.

no_move

The side to move could not move. A draw.

ply_cap

The game reached its limit of moves. A draw.

agreed

The two seats agreed a draw.

METHODS

new

Made by Game::Brandubh. Croaks on an ending that is not one of the nine, on a win with no winner, and on a draw with one.

how

One of the nine words above.

winner

attackers or defenders, or undef for a draw.

loser

The other side, or undef for a draw.

seat

The seat that won, p1 or p2, or undef for a draw.

is_draw

True for repetition, no_move, ply_cap and agreed.

by_players

True for resign and agreed: the two endings the board cannot show, because they are something the players did.

ply

How many moves had been made when the game ended, counting both sides'.

position

The position the game stopped in, as a string.

hows

my @words = Game::Brandubh::Result->hows;

The nine endings.

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 (GPL Compatible)