commit 8d54dfced999ddcb2d236f9664fd13d27cccf6d7
parent 6a1e84ca8a55c63f8fb752708b3e9a590d97c173
Author: masayoshi <masayoshi@example.com>
Date: Wed, 25 Feb 2026 16:56:52 +0900
Add arashi
Diffstat:
| M | oichokabu.raku | | | 75 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------- |
1 file changed, 55 insertions(+), 20 deletions(-)
diff --git a/oichokabu.raku b/oichokabu.raku
@@ -1,43 +1,67 @@
#!/usr/bin/env raku
-# 1. 札の準備(1..10を4セット、確実に平らにする)
+# 1. 札の準備
my @base = 1..10;
my @deck = (@base, @base, @base, @base).flat.pick(*);
-# 2. 点数計算(下一桁を返す)
+# 2. 点数計算
sub get-kabustats(@hand) {
+ if check-arashi(@hand) { return 100 }
return @hand.sum % 10;
}
-# 3. 特殊役(しっぴん・くっぴん)の判定
-sub check-special(@hand) {
+
+# 3. 特殊役判定(ここを修正!)
+sub check-special(@hand, $is-dealer) {
+ return "None" if @hand.elems != 2;
my @sorted = @hand.sort;
- # (1, 4) という「数字の組み合わせ」を厳密にチェックします
- if @sorted[0] == 1 && @sorted[1] == 4 { return "Shippin" }
- if @sorted[0] == 1 && @sorted[1] == 9 { return "Kuppin" }
- return False;
+
+ # 親(Dealer)はクッピン(1,9)のみ
+ if $is-dealer && @sorted[0] == 1 && @sorted[1] == 9 {
+ return "Kuppin";
+ }
+
+ # 子(Player)はシッピン(1,4)のみ
+ if !$is-dealer && @sorted[0] == 1 && @sorted[1] == 4 {
+ return "Shippin";
+ }
+
+ return "None";
+}
+
+sub check-arashi(@hand) {
+ return @hand.elems == 3 && @hand[0] == @hand[1] == @hand[2];
}
# --- ゲーム開始 ---
say "🇬🇧 Welcome to Oicho-Kabu on OpenBSD!";
say "-" x 40;
-# 親と子に2枚ずつ配る
my @player = @deck.pop, @deck.pop;
my @dealer = @deck.pop, @deck.pop;
-# 親の特殊役チェック
-if my $special = check-special(@dealer) {
+# 親のクッピンチェック
+if check-special(@dealer, True) eq "Kuppin" {
say "Dealer's hand: {@dealer.join('-')}";
- say "🇬🇧 Oh no! Dealer got $special! You lose instantly.";
+ say "🇬🇧 Dreadful! Dealer got Kuppin! You lose instantly.";
exit;
}
# 4. プレイヤーの番
loop {
+ # 子のシッピンチェック(最初の2枚の時だけ)
+ if @player.elems == 2 && check-special(@player, False) eq "Shippin" {
+ say "Your hand: {@player.join('-')} (🇬🇧 Shippin! Lucky!)";
+ last;
+ }
+
+ if check-arashi(@player) {
+ say "Your hand: {@player.join('-')} (🇬🇧 Arashi!)";
+ last;
+ }
+
my $score = get-kabustats(@player);
say "Your hand: {@player.join('-')} (Score: $score)";
- # 3枚目を引くか選択(おいちょかぶは最大3枚)
if @player.elems < 3 {
my $choice = prompt "Do you want to draw a 3rd card? (y/n): ";
if $choice.lc.starts-with('y') {
@@ -48,21 +72,32 @@ loop {
last;
}
-# 5. 親(CPU)の番
-# 一般的に親は4以下なら引き、5以上なら勝負(スタンド)します
-while get-kabustats(@dealer) < 5 && @dealer.elems < 3 {
- @dealer.push: @deck.pop;
+# 5. 親(CPU)の番(あらし狙いロジック込み)
+while @dealer.elems < 3 {
+ my $current_score = get-kabustats(@dealer);
+ my $is_pair = @dealer.elems == 2 && @dealer[0] == @dealer[1];
+
+ if $is_pair || $current_score < 5 {
+ @dealer.push: @deck.pop;
+ next;
+ }
+ last;
}
# 6. 最終判定
+# (ここでは簡略化のため、シッピンを持っていれば問答無用でプレイヤー勝ちとしています)
+my $p-special = check-special(@player, False);
my $p-final = get-kabustats(@player);
my $d-final = get-kabustats(@dealer);
say "-" x 40;
-say "Your final: {@player.join('-')} (Score: $p-final)";
-say "Dealer final: {@dealer.join('-')} (Score: $d-final)";
+say "Your final: {@player.join('-')} (Score: {$p-special eq 'Shippin' ?? 'Shippin' !! $p-final})";
+say "Dealer final: {@dealer.join('-')} (Score: {$d-final == 100 ?? 'Arashi' !! $d-final})";
-if $p-final > $d-final {
+if $p-special eq "Shippin" {
+ say "🇬🇧 Brilliant! Shippin beats all!";
+}
+elsif $p-final > $d-final {
say "🇬🇧 Brilliant! You win!";
}
elsif $p-final < $d-final {