NAME

Game::Fanorona::Error - why a game of fanorona refused something

VERSION

Version 0.03

SYNOPSIS

use Game::Fanorona;

my $game = Game::Fanorona->new;
if (!$game->play('a1-a2')) {
    my $error = $game->error;
    print $error->code, ': ', $error->message, "\n";
    # point_taken: a stone is standing there
}

DESCRIPTION

A refusal: a code a program can switch on, a sentence a person can read, and the move it was about. Game::Fanorona never dies because a move was not legal. It returns nothing and leaves one of these in error.

The codes

In the order they are looked for. When more than one would apply, the first is the one given.

game_over

The game has ended.

not_a_side

A side was asked for and what was given is neither white nor black.

offer_standing

A draw was offered while an offer was already on the table.

no_offer

A draw was accepted or declined and none had been offered.

own_offer

A side tried to answer its own offer.

chain_open

A whole move was played while a move was in progress.

nothing_to_stop

A stop was asked for and no move was in progress.

bad_move

Not a move at all: its shape is wrong.

off_board

A point that is not on this board.

no_stone

Nothing stands on the point the move starts from.

not_your_stone

The stone belongs to the side that is not to move.

not_the_stone

A move is in progress and this is a different stone.

not_adjacent

A step between points that are not next to each other.

no_line

No line runs that way from there: the edge of the board, or a diagonal from a point that has none.

point_taken

A stone stands where the step would go.

same_direction

The direction of the step directly before, in the same move.

point_revisited

A point the stone has already stood on in this move.

paika_in_chain

A step that takes nothing, after one that took.

takes_nothing

The move says the step takes by approach or by withdrawal, and nothing is there to take that way.

choose_capture

The step was written with no letter and could take two ways.

must_capture

A step that takes nothing, while some stone of the mover's could take.

CONSTRUCTORS

of

my $error = Game::Fanorona::Error->of('point_taken', move => 'a1-a2');

A refusal by its code. Croaks on a code that is not one. Not by new, which croaks.

METHODS

code

message

move

The code, its sentence, and the move as it was given, when there was one.

is

$error->is('must_capture')

True when that is the code.

CLASS METHODS

codes

Every code, in the order above.

message_for

Game::Fanorona::Error->message_for('point_taken')

The sentence for a code, or undef.

known

True for a code that is one.

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)