Browse Source

LPST.pm - added fix for tricking notation test.pl - updated test cases

master
gashapwn 3 years ago
parent
commit
8136c1e191
2 changed files with 15 additions and 5 deletions
  1. +14
    -4
      LPST.pm
  2. +1
    -1
      test.pl

+ 14
- 4
LPST.pm View File

@@ -780,11 +780,20 @@ sub check_valid_cell($$){
# } keys %board;
}

sub check_src_cell($$$){
my ($self, $hx1, $apl) = (shift, shift, shift);
sub check_match_pi($$$$){
my ($self, $hx1, $pi) = (shift, shift, shift);
my $hx2;

$hx2 = $self->cell_pi($hx1);
die "$pi - Wrong piece notation for $hx1 should be $hx2" if $hx2 ne $pi;
}

sub check_src_cell($$$$){
my ($self, $hx1, $apl, $pi) = (shift, shift, shift, shift);
$hx1 = uc $hx1;

$self->check_nonempty_cell($hx1);
$self->check_match_pi($hx1, $pi);
die "This cell is not owned by $apl" if $self->cell_pl($hx1) ne $apl;
}

@@ -867,11 +876,12 @@ sub ft_summon($$$){

sub mov($$$){
my ($self, $s0, $apl) = (shift, shift, shift);
my ($src, $dst) = $s0 =~ /([A-Za-z][0-9]{1,2})([A-Za-z][0-9]{1,2})$/;
my ($pi, $src, $dst) = $s0 =~ /([A-Za-z]){1,2}([A-Za-z][0-9]{1,2})([A-Za-z][0-9]{1,2})$/;

$src = uc $src;
$dst = uc $dst;
$self->check_valid_player($apl);
$self->check_src_cell($src, $apl);
$self->check_src_cell($src, $apl, $pi);
$self->check_empty_cell($dst);
$self->check_valid_mov($src, $dst);
$self->{"board"}{$dst} = $self->cell_pl($src).$DIV.$self->cell_pi($src);


+ 1
- 1
test.pl View File

@@ -31,7 +31,7 @@ $ns0 .= "A I H It N\n";
$ns0 .= "A I H It N\n";
$ns0 .= "Ac3*, Qd3*\n";
$ns0 .= "Ac11*, Qd11*\n";
$ns0 .= "Sc3c4";


sub roll_back($){


Loading…
Cancel
Save