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

36
lpst.pl
View File

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