|
/home/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Games-Mines/blib/lib/Games/Mines/Play.pm
|
Games::Mines::Play;
require Games::Mines::Play;
# get new 30x40 mine field with 50 mines
my($game) = Games::Mines->new(30,40,50);
# use color text
$game->set_ANSI_Color;
# fill with mines, except at the four corners
$game->fill_mines([0,0],[0,40],[30,0],[30,40]);
# print out playing field
$game->print_out("field");
$game->print_status_line;
This module is he basis for mine finding game. It builds on the
Games::Mines base class to with all the various methods needed to play
a text version of the game.
- $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.
- $class->
default(%opts)
-
Returns an array of width, height, and number of mines, based on some
common arguments. It takes a has with the some combination of six
keys. The first three are small, medium, and large. These
are boolean keys, who's value are only checked to see if they
contain a true value. The small field is 8x8 with 10 mines, the medium
field is 16x16 with 40 mines, and the large field is 16x30 with 99
mines. The other three are width, height, and mines, which
sets the corresponding term. Note that this is designed to work with
Getopt::Long, so any other keys are ignored. The default is to return
a large field.
- $obj->
print_out($arg)
-
Prints out the game field. It takes one argument, saying what to
print. The ``field'' argument prints out the current visible
field. The ``solution'' argument prints out the actual location of
the mines. The ``check'' argument prints out the field, marking any
mistakes that where made. Default is is to print a ``field''.
- $obj->print_status_line
-
Prints out a status line of how many mines have been located. If the
game has ended, it also prints out the ending text saying why.
- $obj->set_ASCII
-
Set the default mapping of the internal representation to the actual
characters printed out, to a plain ascii characters.
- $obj->set_ANSI_Color
-
Set the default mapping of the internal representation to the actual
characters printed out, to ascii characters with ANSI colors. If
Term::ANSIColor is not installed on your machine, this will quietly
fail.
- $obj->
save_game($filename,$number)
-
Saves the current game. Takes two arguments: The filename to save it
to, and the game number to save it under. Note that if you give it
a game number that already exists within that file, that game will
get over written by this one. If no such game number exists, then
it is simply added to the end.
- $obj->
load_game($filename,$number)
-
Loads a previously saved game to replace the current game. It takes
two arguments: the file name to get the game from and the game
number to load. If it can't open the file or find the given game
number will leave the current game unchanged, and return undefined.
Games::Mines for more details of the base class.
Martyn W. Peck <mwp@mwpnet.com>
None known. But if you find any, let me know.
Copyright 2003, Martyn Peck. All Rights Reserves.
This program is free software. You may copy or redistribute
it under the same terms as Perl itself.
|
/home/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Games-Mines/blib/lib/Games/Mines/Play.pm
|