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