lpst.pl - refactored cell shading into function

This commit is contained in:
gashapwn 2021-04-04 20:37:10 +00:00
parent 81072e8dc4
commit d05f746d64

44
lpst.pl
View File

@ -235,10 +235,6 @@ sub shade_t($){
my $not = shift; my $not = shift;
return $sc{$not} if (grep /^$not$/, keys(%sc)); return $sc{$not} if (grep /^$not$/, keys(%sc));
return $EMPTY_ENUM; return $EMPTY_ENUM;
# return $SHADE_1_ENUM if grep /^$not$/, @sc0;
# return $SHADE_2_ENUM if grep /^$not$/, @sc1;
# return $EMPTY_ENUM;
} }
sub get_shade_chr($){ sub get_shade_chr($){
@ -431,13 +427,17 @@ sub disp_board(){
# Caclulate movement
#==================================================
sub cell_pi($){
my $not = shift;
return (split(/$DIV/, $board{$not}))[1]
}
sub cell_pl($){
my $not = shift;
return (split(/$DIV/, $board{$not}))[0]
}
sub cell_index_rev($$){ sub cell_index_rev($$){
return $AXIS_RV{$_[0]}.$_[1]; return $AXIS_RV{$_[0]}.$_[1];
@ -494,6 +494,22 @@ sub calc_move($$){
} }
sub shade_move($){
my $not = shift;
my $c1;
$c1 = cell_pi($not);
for my $mv (@{$MOVE{$c1}}){
shade_cell(calc_move($not, $mv), $SHADE_1_ENUM);
}
}
# sub shade_block(){
# }
# Main starts here! # Main starts here!
binmode(STDOUT, ":utf8"); binmode(STDOUT, ":utf8");
@ -509,13 +525,11 @@ binmode(STDOUT, ":utf8");
$AXIS_RV{$_} $AXIS_RV{$_}
}(1...11); }(1...11);
my $m1 = "E6"; my $m1 = "F7";
my $c1 = $MG_SY; my $c1 = $MG_QS;
$board{$m1} = $P1.$DIV.$c1; $board{$m1} = $P1.$DIV.$c1;
for my $mv (@{$MOVE{$c1}}){ shade_move($m1);
shade_cell(calc_move($m1, $mv), $SHADE_1_ENUM);
}
disp_board(); disp_board();