NAME

Game::Oware::Result - how a game ended

VERSION

Version 0.02

SYNOPSIS

my $result = $game->result;

$result->winner;     # p1
$result->result;     # score
$result->reason;     # cycle
$result->natural;    # 1
$result->score;      # { p1 => 26, p2 => 22 }

DESCRIPTION

result is one of five tokens and reason is the finer word

result is score, draw, timeout, abandoned or resign, and nothing else, ever. The site this engine was written for constrains a database column to exactly those five, so a game class inventing a sixth for a terminology quibble is not a nicer name, it is a failed insert.

That matters here because Oware has four natural endings and only two tokens for them. A game that ended because nobody could feed and a game that ended because a store reached twenty-five are both score. What separates them is reason, which carries target, even, no_feed or cycle, and which is what a consumer turns into a sentence.

The split is deliberate: the token is for machines that rank games, the reason is for a reader who wants to know what happened.

An interrupted game has no score

natural is true only for score and draw. A timeout, an abandonment or a resignation ends a game without finishing it, and score is undef rather than whatever the stores happened to hold. BUILD refuses a score on an unnatural ending rather than trusting the caller not to pass one.

captured is still filled in every case, because the seeds really were captured and a log page will want to show them. It is a running total that stopped, not a result.

Who owns a timeout: not this distribution

Published conventions disagree about what a clock does to an Oware game and there are several of them, so this engine implements none. It accepts an instruction that a seat timed out, finishes with the other seat as the winner, and leaves every question of forfeit policy to whatever is running the clock.

places may repeat

Oware draws at twenty-four all, so both seats can be first. A consumer that assumes the two values are distinct will be wrong roughly as often as a game ends level.

PROPERTIES

winner

p1, p2, or undef on a draw or an abandonment.

result

One of score, draw, timeout, abandoned, resign.

reason

One of target, even, no_feed, cycle, timeout, abandon, resign.

captured

{ p1 => N, p2 => N }, filled whatever the ending.

score

The official result, or undef unless the ending was natural.

places

{ p1 => 1, p2 => 2 }. Ranks repeat on a draw.

METHODS

natural

True for score and draw.

results

An arrayref of every result token.

reasons

An arrayref of every reason.

stringify

One line, for a log or a terminal.

SEE ALSO

Game::Oware, Game::Oware::Scoring

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.