lpst.pl - added some unicode characters to make the columns more clear

This commit is contained in:
gashapwn 2021-04-04 02:38:20 +00:00
parent 60550fc47c
commit d3cb948956

40
lpst.pl
View File

@ -3,6 +3,7 @@
use warnings; use warnings;
use strict; use strict;
use utf8;
my $PAD_AXIS = " "; my $PAD_AXIS = " ";
my $PAD_EVEN = " "; my $PAD_EVEN = " ";
@ -12,7 +13,15 @@ my $HEX_1 = '-/--\-';
my $HEX_2 = '| __ |'; my $HEX_2 = '| __ |';
my $HEX_3 = '| |'; my $HEX_3 = '| |';
my $SHADE_CHR = chr(0x2592);
my $ALT_US = chr(0x2017);
my $ALT_PIPE = chr(0x2016);
my $HL_1 = "|_____";
my $HL_2 = $ALT_PIPE.$ALT_US.$ALT_US.$ALT_US.$ALT_US.$ALT_US;
my $SUB_CHR = "_"; my $SUB_CHR = "_";
my $ALT_SUB_CHR = $ALT_US;
my $PREF_1 = substr($HEX_1, -2, 2); my $PREF_1 = substr($HEX_1, -2, 2);
my $PREF_2 = ' '; my $PREF_2 = ' ';
@ -214,15 +223,20 @@ my %board;
# Display pieces # Display pieces
#================================================== #==================================================
sub f_1($){ sub f_1($$){
my $p = shift; my $p = shift;
my $c0 = shift;
my $s0; my $s0;
$p =~ s/($P1|$P2)$DIV//; $p =~ s/($P1|$P2)$DIV//;
$p .= "_" if length($p) < 2; $p .= "_" if length($p) < 2;
$s0 = $HEX_2; $s0 = $HEX_2;
$s0 =~ s/$SUB_CHR{1,2}/$p/; $s0 =~ s/$SUB_CHR{1,2}/$p/;
if($c0 % 2 == 0){
$s0 =~ s/$SUB_CHR/$ALT_SUB_CHR/g;
}
return $s0; return $s0;
} }
@ -245,7 +259,7 @@ sub disp_2($$){
$p = $board{$not}; $p = $board{$not};
return f_1($p); return f_1($p, $c0);
# my ($r0, $c0) = (shift, shift); # my ($r0, $c0) = (shift, shift);
# return $HEX_2; # return $HEX_2;
} }
@ -274,11 +288,16 @@ sub disp_y_axis($$$$){
sub add_cell($$$$$){ sub add_cell($$$$$){
my ($s0, $s1, $s2, $r0, $c0) = @_; my ($s0, $s1, $s2, $r0, $c0) = @_;
$s0 .= disp_1($r0, $c0); $s0 .= disp_1($r0, $c0);
$s1 .= disp_2($r0, $c0); $s1 .= disp_2($r0, $c0);
$s2 .= disp_3($r0, $c0); $s2 .= disp_3($r0, $c0);
# if($c0 % 2 == 0){
# $s0 =~ s/ /$SHADE_CHR/g;
# $s1 =~ s/ /$SHADE_CHR/g;
# $s2 =~ s/ /$SHADE_CHR/g;
# }
return ($s0, $s1, $s2); return ($s0, $s1, $s2);
} }
@ -359,6 +378,13 @@ sub disp_x_axis(){
}(1..11)); }(1..11));
$s0 .= "\n"; $s0 .= "\n";
$s0 .= $PAD_AXIS;
$s0 .= join(
"", map{
$_ % 2 == 1 ? $HL_1 : $HL_2
}(1..11));
$s0 .= "\n";
return $s0 return $s0
} }
@ -390,6 +416,10 @@ sub cell_index($){
return ($AXIS{$chr1}, $chr2); return ($AXIS{$chr1}, $chr2);
} }
# Main starts here!
binmode(STDOUT, ":utf8");
# Creates a hash of the the form # Creates a hash of the the form
# $board{cell_notation} = piece_enum # $board{cell_notation} = piece_enum
%board = map { %board = map {
@ -402,7 +432,7 @@ sub cell_index($){
$AXIS_RV{$_} $AXIS_RV{$_}
}(1...11); }(1...11);
$board{"D2"} = $P1.$DIV.$MG_A; $board{"F5"} = $P1.$DIV.$MG_QS;
disp_board(); disp_board();