Chess::Piece::Pawn - a class representing a pawn in a chess game
$pawn = Chess::Piece::Pawn->new("e2", "White King's pawn"); $true = $pawn->can_reach("e4"); $true = $pawn->can_reach("e3"); $true = $pawn->can_reach("f3"); $false = $pawn->can_reach("e5"); $queen = $pawn->promote("queen");
The Chess module provides a framework for writing chess programs with Perl. This class is part of that framework, representing a pawn in a Chess::Game.
Constructs a new Chess::Piece::Pawn. Requires a two scalar parameters containing the square on which the pawn is to be constucted and its color, Optionally takes a third parameter containing a text description of the pawn.
$pawn = Chess::Piece::Pawn->new("d2", "white"); $pawn = Chess::Piece::Pawn->new("e2", "white", "White King's pawn");
There are no class methods for this class.
Overrides base class version. Returns a list of squares that this pawn can reach from its current position. See "reachable_squares()" in Chess::Piece for more details on this method.
Takes a parameter containing the type of piece to promote to. Returns itself blessed as that type of piece. Returns undef and produces a warning (see "DIAGNOSTICS" if the piece is not one of 'bishop', 'knight', 'queen' or 'rook'.
- Can't promote a pawn to a 'king'
You may only promote a pawn to a 'bishop', 'knight', 'queen' or 'rook'.
Please report any bugs to the author.
Brian Richardson <email@example.com>
Copyright (c) 2002, 2005 Brian Richardson. All rights reserved. This module is Free Software. It may be modified and redistributed under the same terms as Perl itself.
3 POD Errors
The following errors were encountered while parsing the POD:
- Around line 36:
You forgot a '=back' before '=head2'
- Around line 42:
'=item' outside of any '=over'
- Around line 55:
You forgot a '=back' before '=head1'