lpst.pl - renamed + refactored shade functions

This commit is contained in:
gashapwn 2021-04-06 02:16:44 +00:00
parent efb3e9ec1e
commit f90bf078ef

22
lpst.pl
View File

@ -369,31 +369,30 @@ sub sub_pi_str($$$){
# Display shade # Display shade
#================================================== #==================================================
sub shade_cell($$){ sub apply_shade($$){
my $not = shift; my $not = shift;
my $en = shift; my $en = shift;
$sc{$not} = $en unless (grep /^$not$/, keys(%sc)); $sc{$not} = $en unless (grep /^$not$/, keys(%sc));
} }
# TODO rename/rethink these 3 functions sub get_shade_en($){
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;
} }
sub get_shade_chr($){ sub get_shade_hex($){
my $en = shift; my $en = shift;
return $SHADE{$en}; return $SHADE{$en};
} }
sub shade_lookup($$){ sub get_cell_shade($$){
my ($r0, $c0) = (shift, shift); my ($r0, $c0) = (shift, shift);
my $not; my $not;
$not = cell_index_rev($c0, $r0); $not = cell_index_rev($c0, $r0);
return get_shade_chr(shade_t($not)); return get_shade_hex(get_shade_en($not));
} }
@ -406,10 +405,9 @@ sub disp_1($$){
my ($r0, $c0) = (shift, shift); my ($r0, $c0) = (shift, shift);
my $hex; my $hex;
$hex = shade_lookup($r0, $c0)->[0]; $hex = get_cell_shade($r0, $c0)->[0];
return $hex; return $hex;
# return $HEX_1;
} }
sub disp_2($$){ sub disp_2($$){
@ -418,21 +416,19 @@ sub disp_2($$){
my $not; my $not;
my $hex; my $hex;
$hex = shade_lookup($r0, $c0)->[1]; $hex = get_cell_shade($r0, $c0)->[1];
$not = cell_index_rev($c0, $r0); $not = cell_index_rev($c0, $r0);
$p = $board{$not}; $p = $board{$not};
return sub_pi_str($p, $c0, $hex); return sub_pi_str($p, $c0, $hex);
# my ($r0, $c0) = (shift, shift);
# return $HEX_2;
} }
sub disp_3($$){ sub disp_3($$){
my ($r0, $c0) = (shift, shift); my ($r0, $c0) = (shift, shift);
my $hex; my $hex;
$hex = shade_lookup($r0, $c0)->[2]; $hex = get_cell_shade($r0, $c0)->[2];
return $hex; return $hex;
} }
@ -675,7 +671,7 @@ sub shade_pi_mvmt($$){
@mv1 = find_all_mov($not, $en); @mv1 = find_all_mov($not, $en);
for my $mv (@mv1){ for my $mv (@mv1){
shade_cell($mv->[0], $mv->[1]); apply_shade($mv->[0], $mv->[1]);
} }
} }