lpst.pl - updated code to trim ASCII from off by one errors. .gitignore - added pattern for my test perl script
This commit is contained in:
parent
65fbe479bb
commit
7645532e15
4
.gitignore
vendored
4
.gitignore
vendored
@ -1 +1,3 @@
|
||||
*~
|
||||
*~
|
||||
p[0-9].pl
|
||||
p[0-9][0-9].pl
|
43
lpst.pl
43
lpst.pl
@ -11,10 +11,14 @@ my $HEX_1 = '-/--\-';
|
||||
my $HEX_2 = '| __ |';
|
||||
my $HEX_3 = '| |';
|
||||
|
||||
my $PREF_1 = '\-';
|
||||
my $PREF_1 = substr($HEX_1, -2, 2);
|
||||
my $PREF_2 = ' ';
|
||||
my $PREF_3 = ' ';
|
||||
|
||||
my $TRAIL_1 = substr($HEX_1, 0, 1);
|
||||
my $TRAIL_2 = substr($HEX_1, -1, 1);
|
||||
my $TRAIL_3 = substr($HEX_1, 0, 2);
|
||||
|
||||
# Pieces
|
||||
my $MG_A = 0; # Apprentice
|
||||
my $MG_I = 1; # Iron Maiden
|
||||
@ -207,7 +211,7 @@ sub disp_3(){
|
||||
return $HEX_3;
|
||||
}
|
||||
|
||||
sub add_pad($$$$){
|
||||
sub disp_x_axis($$$$){
|
||||
my ($s0, $s1, $s2, $r0) = @_;
|
||||
my $n0;
|
||||
|
||||
@ -238,7 +242,7 @@ sub disp_0($){
|
||||
|
||||
$r0 = shift;
|
||||
|
||||
($s0, $s1, $s2) = add_pad($s0, $s1, $s2, $r0);
|
||||
($s0, $s1, $s2) = disp_x_axis($s0, $s1, $s2, $r0);
|
||||
for my $i (1..11){
|
||||
($s0, $s1, $s2) = add_cell($s0, $s1, $s2, $r0, $i);
|
||||
}
|
||||
@ -247,15 +251,35 @@ sub disp_0($){
|
||||
}
|
||||
|
||||
sub disp_row($){
|
||||
return disp_0(shift);
|
||||
my $row;
|
||||
my $r0;
|
||||
|
||||
$r0 = shift;
|
||||
|
||||
$row = disp_0($r0);
|
||||
# Trim the start of the first line
|
||||
$row =~ s/$TRAIL_1/ /;
|
||||
if($r0 % 2 == 1){
|
||||
# Trim the end of the first line
|
||||
$row =~ s/\n/$TRAIL_3\n/
|
||||
}else{
|
||||
# Trim the end of the last line
|
||||
$row =~ s/$TRAIL_2\n/ \n/m;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
sub disp_board(){
|
||||
for my $i (map {11-$_+1} (1..11)) {
|
||||
printf("%s", disp_row($i));
|
||||
}
|
||||
}
|
||||
my $b;
|
||||
|
||||
for my $i (map {11-$_+1} (1..11)) {
|
||||
$b .= disp_row($i);
|
||||
}
|
||||
$b =~ s/$TRAIL_1$TRAIL_3\n/\n/m;
|
||||
printf("%s", $b);
|
||||
|
||||
}
|
||||
|
||||
sub cell_index($){
|
||||
my ($chr1, $chr2) = (split(//, $_[0]));
|
||||
@ -270,8 +294,7 @@ sub cell_index($){
|
||||
(map {$l0.$_} ("1".."11"))
|
||||
} ("A".."K");
|
||||
|
||||
disp_board()
|
||||
disp_board();
|
||||
|
||||
# disp_0("C1");
|
||||
|
||||
# printf(">>%s, %s\n", cell_index("C1"));
|
||||
|
Loading…
Reference in New Issue
Block a user