The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Games::Mines - a mine finding game

SYNOPSIS

    require Games::Mines;

    # get new 30x40 mine field with 50 mines
    my($game) = Games::Mines->new(30,40,50); 

    # fill with mines, except at the four corners
    $game->fill_mines([0,0],[0,40],[30,0],[30,40]);

DESCRIPTION

This module is the basis for mine finding game. It contains the basic methods necessary for a game.

Class and object Methods

$Class->new;

The new method creates a new mine field object. It takes three arguments: The width of the field, the height of the field, and the number of mines.

$obj->width

Returns the width of a mine field.

$obj->height

Returns the height of the mine field.

$obj->count

Returns the total number of mines within the field.

$obj->running

Returns a boolean that says if game play is still possible. Returns false after field is create, but before fill_mines is called. Also returns false if the whole field has been solved, or a mine has been stepped on.

$obj->why

Returns a human readable status of the current game. Mostly useful after a game has ended to say why it has ended.

$obj->fill_mines

Randomly fills the field with mines. It takes any number of arguments, which should be array references to a pair of coordinates of where NOT to put a mine.

$obj->at($col,$row)

Returns what is visible at the coordinates given. Takes two arguments: the col and the row coordinates.

$obj->hidden($col,$row)

Returns a boolean saying if the position has not been stepped on and exposed. Takes two arguments: the col and the row coordinates.

$obj->shown($col,$row)

Returns a boolean saying if the position has been stepped on and exposed. Takes two arguments: the col and the row coordinates.

$obj->step($col,$row)

Steps on a particular square, exposing what was underneath. Takes two arguments: the col and the row coordinates. Note that if the particular field is blank, indicating it has no mines in any of the surrounding squares, it will also automatically step on those squares as well. Returns false if already stepped on that square, or if a mine is under it. Returns true otherwise.

$obj->flag($col,$row)

Place a flag on a particular unexposed square. Takes two arguments: the col and the row coordinates. Returns true if square can and has been flagged.

$obj->unflag($col,$row)

Removes a flag from a particular unexposed square. Takes two arguments: the col and the row coordinates. Returns true if square can and has been unflagged.

$obj->flagged($col,$row)

Returners a boolean based on whether a flag has been placed on a particular square. Takes two arguments: the col and the row coordinates.

$obj->flags

Return the total number of flags throughout the whole field.

$obj->found_all

Returners a boolean saying whether all mines have been found or not.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 53:

=over without closing =back

Around line 554:

'=end for developers' is invalid. (Stack: =over; =begin for)