Browse Source

lpst.pl - refactored cell shading into function

master
gashapwn 3 years ago
parent
commit
d05f746d64
1 changed files with 29 additions and 15 deletions
  1. +29
    -15
      lpst.pl

+ 29
- 15
lpst.pl View File

@@ -235,10 +235,6 @@ sub shade_t($){
my $not = shift;
return $sc{$not} if (grep /^$not$/, keys(%sc));
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($){
@@ -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($$){
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!
binmode(STDOUT, ":utf8");

@@ -509,13 +525,11 @@ binmode(STDOUT, ":utf8");
$AXIS_RV{$_}
}(1...11);

my $m1 = "E6";
my $c1 = $MG_SY;
my $m1 = "F7";
my $c1 = $MG_QS;

$board{$m1} = $P1.$DIV.$c1;
for my $mv (@{$MOVE{$c1}}){
shade_cell(calc_move($m1, $mv), $SHADE_1_ENUM);
}
shade_move($m1);

disp_board();



Loading…
Cancel
Save