Skip to content

Commit

Permalink
fish: fold case (#551)
Browse files Browse the repository at this point in the history
* I am lazy to type shift+a for ace; do what I expect whether I type A or a
* This could've been done in less code, but I decided to make a table of valid card names instead of using grep()
* Catch^C^Cgoing fish is so much more fun now
  • Loading branch information
mknos committed Apr 13, 2024
1 parent c32d49c commit fd78b39
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin/fish
Expand Up @@ -20,6 +20,7 @@ my(@DECK, @PLAYERS_HAND, @COMPUTERS_HAND, %BOOKS, %opt);
my(@HIS_PAST_GUESSES, @MY_PAST_GUESSES);
my($asker, $opponent, $professional, $whoseturn, $status, $myb, $yourb);
my %so=( 'A'=>1, 'J'=>11, 'Q'=>12, 'K'=>13 ); # For sort ranking, below.
my %iscard = map { $_ => 1 } qw(A J Q K 2 3 4 5 6 7 8 9 10);

sub pickone { # Computer's card-picking routine. Dumb or smart.
my($myarr)=@_;
Expand Down Expand Up @@ -92,20 +93,21 @@ sub draw {

sub askfor {
my($askarr, $vicarr, $card)=@_; # The asker, the victim, and the card
$card = uc $card;

if ($card eq "") {
print "I have ", scalar(@COMPUTERS_HAND), " cards in my hand ";
printhand(\@COMPUTERS_HAND, 'I', 1);
print "There are ", scalar(@DECK), " cards remaining in the stock\n";
return;
}
exit if ($card eq 'quit');
if ($card eq 'p') {
exit if ($card eq 'QUIT');
if ($card eq 'P') {
$professional=!$professional;
print $professional?"Entering":"Leaving", " professional mode\n";
return;
}
if (! grep($card eq $_, (keys %so, 2..10) )) {
unless (exists $iscard{$card}) {
print "I don't understand!\n";
return;
}
Expand Down

0 comments on commit fd78b39

Please sign in to comment.