ソースを参照

lpst.pl - get_block_cell() returns all cells being blocked by pieces in play

master
gashapwn 3年前
コミット
700e0364b3
1個のファイルの変更52行の追加9行の削除
  1. +52
    -9
      lpst.pl

+ 52
- 9
lpst.pl ファイルの表示

@@ -376,6 +376,7 @@ sub shade_cell($$){
$sc{$not} = $en unless (grep /^$not$/, keys(%sc)); $sc{$not} = $en unless (grep /^$not$/, keys(%sc));
} }


# TODO rename/rethink these 3 functions
sub shade_t($){ 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));
@@ -574,6 +575,44 @@ sub disp_board(){


# Caclulate movement # Caclulate movement
#================================================== #==================================================

# TODO: rename / rethink these 4 functions
sub gm1($){
my $not = shift;
my $pi;

$pi = cell_pi($not);

if($pi){
return gm2($pi);
}
return ();
}
sub gm2(){
my $pi = shift;
return grep {
$_ if ($_->{"type"} & $MOVE_ENUM) eq $MOVE_ENUM
} @{$MOVE{$pi}}
}

sub gb1($){
my $not = shift;
my $pi;

$pi = cell_pi($not);

if($pi){
return gb2($pi);
}
return ();
}
sub gb2($){
my $pi = shift;
return grep {
$_ if ($_->{"type"} & $BLOCK_ENUM) eq $BLOCK_ENUM
} @{$MOVE{$pi}}
}

sub not_split($$){ sub not_split($$){
my ($not, $i0) = (shift, shift); my ($not, $i0) = (shift, shift);
return (split(/$DIV/, $board{$not}))[$i0]; return (split(/$DIV/, $board{$not}))[$i0];
@@ -666,20 +705,20 @@ sub shade_mvmt($$){
@mv1 = grep { @mv1 = grep {
($_->{"type"} & $en) eq $_->{"type"} ($_->{"type"} & $en) eq $_->{"type"}
} @{$MOVE{$c1}}; } @{$MOVE{$c1}};
@mv1 = find_all_mov(\@mv1, $not);
@mv1 = find_all_mov(\@mv1, $not);
for my $mv (@mv1){ for my $mv (@mv1){
shade_cell($mv->[0], $mv->[1]); shade_cell($mv->[0], $mv->[1]);
} }
} }


# sub get_block_cell(){
# map {
# cell_pi($_)
# } keys($board);
# }
sub get_block_cell(){
return map {
$_->[0]
} map {
( find_all_mov([gb1($_)], $_) );
} keys(%board);
}






@@ -708,8 +747,12 @@ my $c2 = $MG_A;
$board{$m1} = $P1.$DIV.$c1; $board{$m1} = $P1.$DIV.$c1;
$board{$m2} = $P1.$DIV.$c2; $board{$m2} = $P1.$DIV.$c2;


shade_mvmt($m1, $MOVBLOCK_ENUM);


for my $el (get_block_cell()){
printf("%s\n", $el);
}

shade_mvmt($m1, $MOVBLOCK_ENUM);
disp_board(); disp_board();






読み込み中…
キャンセル
保存