プレーヤーの処理を行う

player は、プレーヤーの処理を行うサブルーチンです。

プレーヤーは、スタンド(ステイ)とドロー(ヒット)はできますが、以下の選択肢(オプション)はありません。

  • ダブル・ダウン
  • スプリット
  • サレンダー
  • インシュランス

#プレーヤーの処理を行う
sub player {
  local($input);

  while (1) {
    #カードを画面に表示する
    &display(0);

    #プレーヤーの処理を行う
    printf "  Draw(D, d) or Stand(S, s) or Quit(Q, q)? : ";
    chop($input = <STDIN>);
    if      (($input eq "D") || ($input eq "d")) {#カードを引く
      printf "  Draw\n";
      push(@PlayerHands, shift(@stack));
      $PlayerPoint = &calc(@PlayerHands);
      last if ($PlayerPoint == 0);
    } elsif (($input eq "S") || ($input eq "s")) {#カードを引かない
      printf "  Stand\n";
      last;
    } elsif (($input eq "Q") || ($input eq "q")) {#終了する
      exit;
    } else {
      printf "Input Error!\n";
    }
  }
}