Chess-PGN-EPD
view release on metacpan or search on metacpan
lib/Chess/PGN/EPD.pm view on Meta::CPAN
my %board;
my $hashref = $parameters{'board'};
for ( keys %$hashref ) {
$board{$_} = $$hashref{$_};
}
$parameters{'epd'} = epd( 0, 0, 0, 0, 0, 0, %board );
}
my $epd = $parameters{'epd'};
my $type = lc( $parameters{'type'} );
my ( $border, $corner, $legend ) = ( 'single', 'square', 'no' );
$border = lc( $parameters{'border'} ) if exists( $parameters{'border'} );
$corner = lc( $parameters{'corner'} ) if exists( $parameters{'corner'} );
$legend = lc( $parameters{'legend'} ) if exists( $parameters{'legend'} );
my @array = split( /\/|\s/, $epd );
my @board;
if ( $type eq 'diagram' ) {
for ( 0 .. 7 ) {
$array[$_] =~ s/(\d+)/'_' x $1/ge;
$array[$_]
=~ s/_/(((pos $array[$_]) % 2) xor ($_ % 2)) ? '-' : ' '/ge;
push( @board, 8 - $_ . " " . $array[$_] );
}
push( @board, ' abcdefgh' );
lib/Chess/PGN/EPD.pm view on Meta::CPAN
elsif ( $type eq 'tilburg' ) {
for ( 0 .. 7 ) {
$array[$_] =~ s/(\d+)/'_' x $1/ge;
$array[$_]
=~ s/([pnbrqkPNBRQK_])/_mappiece(pos $array[$_],$_,$1,"\341\345\351\355\361\365\337\343\347\353\357\363
\335","\340\344\350\354\360\364\336\342\346\352\356\362\334")/ge;
push( @board, $array[$_] );
}
}
else {
@board = _configureboard( $type, $border, $corner, $legend );
for ( 0 .. 7 ) {
$array[$_] =~ s/(\d+)/'_' x $1/ge;
$array[$_]
=~ s/([pnbrqkPNBRQK_])/_mappiece(pos $array[$_],$_,$1,$FontMap{$type}{'OnBlack'},$FontMap{$type}
{'OnWhite'})/ge;
substr( $board[ $_ + 1 ], 1, 8 ) = $array[$_];
}
}
return @board;
}
sub _configureboard {
my $type = shift;
my $border = shift;
my $corner = shift;
my $legend = shift;
my $single = $border eq 'single';
my $box = $FontMap{$type}{ $single ? 'SingleBox' : 'DoubleBox' };
my @board;
if ( $corner eq 'rounded' ) {
my $corners
= $FontMap{$type}{ $single ? 'SingleRounded' : 'DoubleRounded' };
substr( $box, 0, 1 ) = substr( $corners, 0, 1 );
substr( $box, 2, 1 ) = substr( $corners, 1, 1 );
lib/Chess/PGN/EPD.pm view on Meta::CPAN
substr( $box, 0, 1 )
. substr( $box, 1, 1 ) x 8
. substr( $box, 2, 1 ) );
for ( 0 .. 7 ) {
push( @board, substr( $box, 3, 1 ) . ' ' x 8 . substr( $box, 4, 1 ) );
}
push( @board,
substr( $box, 5, 1 )
. substr( $box, 6, 1 ) x 8
. substr( $box, 7, 1 ) );
if ( $legend eq 'yes' ) {
my $left = $FontMap{$type}{
$single
? 'SingleLeftLegend'
: 'DoubleLeftLegend'
};
my $bottom = $FontMap{$type}{
$single
? 'SingleBottomLegend'
: 'DoubleBottomLegend'
};
lib/Chess/PGN/EPD.pm view on Meta::CPAN
wasn't one and it wasn't the other, that left it up to me to choose--besides, who would want
a module named after a swamp?!
=head2 epdset(I<epd>)
For those instances where the game in question does not begin
with a complete move list, this function allows the user to
set the starting position using a 'EPD' string as described
elsewhere in the document.
=head2 epdstr(I<epd>|I<board>,I<type> [I<border>,I<corner>,I<legend>])
Returns an array of strings that represent a diagramatic conversion of the
specified B<epd> string or board postion to the specified B<type>. Parameters are passed as
a anonymous hash, i.e. epdstr(epd => $position,type => 'diagram') or similar.
=head3 Types Supported
The following types are understood by B<epdstr>:
=over
lib/Chess/PGN/EPD.pm view on Meta::CPAN
{RNBQKBNR}
\end{diagram}
%%
%% end of fragment
%%
\end{document}
=item 'linares'
Alpine Electronics' LinaresDiagram font. Mapping also works with both HastingsDiagram
and ZurichDiagram fonts. Single or double border, With or without algebraic legend.
=item 'linares1'
Standard mapping, single border, squares offset.
=item 'linares2'
Standard mapping, thick single border.
=item 'tilburg'
lib/Chess/PGN/EPD.pm view on Meta::CPAN
=item Steve Smith
=item Piet Tutelaers
=back
=head3 Borders and Such Like
Some fonts, for example those designed by Armondo H. Marroquin support a variety of border
styles and decorations. The border may be single or double, with square corners or rounded,
and with an algebraic legend. These effects are supported by the addition of the necessary
parameters to the allowed parameter list. In particular:
=over
=item * Border, values can be either 'single' or 'double' (default is 'single')
=item * Corner, values can be either 'square' or 'rounded' (default is 'square')
=item * Legend, values can be either 'yes' or 'no' (default is 'no')
( run in 1.015 second using v1.01-cache-2.11-cpan-49f99fa48dc )