MNU.pm - tried to implement show available moves. found bug in LPST.pm

This commit is contained in:
gashapwn 2021-04-12 00:54:12 +00:00
parent b0ec1b2d42
commit 42c9b7e56c
2 changed files with 15 additions and 4 deletions

17
MNU.pm
View File

@ -69,11 +69,20 @@ sub parse_cmd($){
return -1 if $in =~ /^q(uit)?$/i; return -1 if $in =~ /^q(uit)?$/i;
return 1 if($in =~ /^save$/i); return 1 if($in =~ /^save$/i);
return 2 if($in =~ /^load$/i); return 2 if($in =~ /^load$/i);
return 3 if($in =~ /^show$/i);
return 0; return 0;
} }
sub prompt($){ sub show($$){
my $game_str = shift; my ($b, $game_str) = (shift, shift);
$b->shade_all_p1_mvmt();
disp_board($b);
return prompt($b, $game_str);
}
sub prompt($$){
my ($b, $game_str) = (shift, shift);
printf("> "); printf("> ");
my $in; my $in;
@ -83,6 +92,7 @@ sub prompt($){
return "QUIT" if(parse_cmd($in) == -1); return "QUIT" if(parse_cmd($in) == -1);
return save($game_str) if parse_cmd($in) == 1; return save($game_str) if parse_cmd($in) == 1;
return load() if parse_cmd($in) == 2; return load() if parse_cmd($in) == 2;
return show($b, $game_str) if parse_cmd($in) == 3;
$game_str .= $in."\n"; $game_str .= $in."\n";
return $game_str; return $game_str;
@ -92,12 +102,13 @@ sub prompt($){
sub loop($$){ sub loop($$){
my ($class, $game_str) = (shift, shift); my ($class, $game_str) = (shift, shift);
my $in; my $in;
my $b;
$b = LPST->new(); $b = LPST->new();
$game_str = eval_game_str($b, $game_str); $game_str = eval_game_str($b, $game_str);
printf("%s\n", $game_str); printf("%s\n", $game_str);
$game_str = prompt($game_str); $game_str = prompt($b, $game_str);
return $game_str; return $game_str;
} }

2
drv.pl
View File

@ -11,6 +11,6 @@ my $game_str;
$game_str = ""; $game_str = "";
while(($game_str = MNU->loop($game_str)) ne "QUIT"){ while(($game_str = MNU->loop($game_str)) ne "QUIT"){
# printf("XXXX%s\n", $game_str); printf("blah\n");
} }