OSDN Git Service

[Refactor] #3461 gamble_comm() の戻り値が誰にも使われていないので削除した、他空行調整等
authorHourier <66951241+Hourier@users.noreply.github.com>
Sat, 24 Jun 2023 15:46:58 +0000 (00:46 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Tue, 27 Jun 2023 08:42:50 +0000 (17:42 +0900)
src/market/play-gamble.cpp
src/market/play-gamble.h

index 1111dd8..be9b5ee 100644 (file)
  * @brief カジノ1プレイごとのメインルーチン / gamble_comm
  * @param player_ptr プレイヤーへの参照ポインタ
  * @param cmd プレイするゲームID
- * @return プレイ成立やルール説明のみ等ならTRUE、賭け金不足で不成立ならFALSE
  */
-bool gamble_comm(PlayerType *player_ptr, int cmd)
+void gamble_comm(PlayerType *player_ptr, int cmd)
 {
     screen_save();
     if (cmd == BACT_GAMBLE_RULES) {
         (void)show_file(player_ptr, true, _("jgambling.txt", "gambling.txt"), 0, 0);
         screen_load();
-        return true;
+        return;
     }
 
     if (player_ptr->au < 1) {
         msg_print(_("おい!おまえ一文なしじゃないか!こっから出ていけ!", "Hey! You don't have gold - get out of here!"));
         msg_print(nullptr);
         screen_load();
-        return false;
+        return;
     }
 
     clear_bldg(5, 23);
@@ -44,7 +43,7 @@ bool gamble_comm(PlayerType *player_ptr, int cmd)
     if (!wager_opt.has_value()) {
         msg_print(nullptr);
         screen_load();
-        return true;
+        return;
     }
 
     auto wager = wager_opt.value();
@@ -52,31 +51,26 @@ bool gamble_comm(PlayerType *player_ptr, int cmd)
         msg_print(_("おい!金が足りないじゃないか!出ていけ!", "Hey! You don't have the gold - get out of here!"));
         msg_print(nullptr);
         screen_load();
-        return false;
+        return;
     }
 
     msg_print(nullptr);
     auto win = 0;
     auto odds = 0;
     auto oldgold = player_ptr->au;
-
     prt(format(_("ゲーム前の所持金: %9d", "Gold before game: %9d"), oldgold), 20, 2);
     prt(format(_("現在の掛け金:     %9d", "Current Wager:    %9d"), wager), 21, 2);
-
     while (true) {
         player_ptr->au -= wager;
         switch (cmd) {
         case BACT_IN_BETWEEN: {
             c_put_str(TERM_GREEN, _("イン・ビトイーン", "In Between"), 5, 2);
-
             odds = 4;
             win = 0;
             auto roll1 = randint1(10);
             auto roll2 = randint1(10);
             auto choice = randint1(10);
-
             prt(format(_("黒ダイス: %d        黒ダイス: %d", "Black die: %d       Black Die: %d"), roll1, roll2), 8, 3);
-
             prt(format(_("赤ダイス: %d", "Red die: %d"), choice), 11, 14);
             if (((choice > roll1) && (choice < roll2)) || ((choice < roll1) && (choice > roll2))) {
                 win = 1;
@@ -86,7 +80,6 @@ bool gamble_comm(PlayerType *player_ptr, int cmd)
         }
         case BACT_CRAPS: {
             c_put_str(TERM_GREEN, _("クラップス", "Craps"), 5, 2);
-
             win = 3;
             odds = 2;
             auto roll1 = randint1(6);
@@ -96,32 +89,34 @@ bool gamble_comm(PlayerType *player_ptr, int cmd)
             prt(format(_("1振りめ: %d %d      Total: %d", "First roll: %d %d    Total: %d"), roll1, roll2, roll3), 7, 5);
             if ((roll3 == 7) || (roll3 == 11)) {
                 win = 1;
-            } else if ((roll3 == 2) || (roll3 == 3) || (roll3 == 12)) {
-                win = 0;
-            } else {
-                do {
-                    msg_print(_("なにかキーを押すともう一回振ります。", "Hit any key to roll again"));
+                break;
+            }
 
-                    msg_print(nullptr);
-                    roll1 = randint1(6);
-                    roll2 = randint1(6);
-                    roll3 = roll1 + roll2;
-                    prt(format(_("出目: %d %d          合計:      %d", "Roll result: %d %d   Total:     %d"), roll1, roll2, roll3), 8, 5);
-                    if (roll3 == choice) {
-                        win = 1;
-                    } else if (roll3 == 7) {
-                        win = 0;
-                    }
-                } while ((win != 1) && (win != 0));
+            if ((roll3 == 2) || (roll3 == 3) || (roll3 == 12)) {
+                win = 0;
+                break;
             }
 
+            do {
+                msg_print(_("なにかキーを押すともう一回振ります。", "Hit any key to roll again"));
+
+                msg_print(nullptr);
+                roll1 = randint1(6);
+                roll2 = randint1(6);
+                roll3 = roll1 + roll2;
+                prt(format(_("出目: %d %d          合計:      %d", "Roll result: %d %d   Total:     %d"), roll1, roll2, roll3), 8, 5);
+                if (roll3 == choice) {
+                    win = 1;
+                } else if (roll3 == 7) {
+                    win = 0;
+                }
+            } while ((win != 1) && (win != 0));
             break;
         }
         case BACT_SPIN_WHEEL: {
             win = 0;
             odds = 9;
             c_put_str(TERM_GREEN, _("ルーレット", "Wheel"), 5, 2);
-
             prt("0  1  2  3  4  5  6  7  8  9", 7, 5);
             prt("--------------------------------", 8, 3);
             while (true) {
@@ -164,6 +159,7 @@ bool gamble_comm(PlayerType *player_ptr, int cmd)
                 }
                 roll1 -= i;
             }
+
             auto roll2 = randint1(21);
             for (auto i = 6; i > 0; i--) {
                 if ((roll2 - i) < 1) {
@@ -172,6 +168,7 @@ bool gamble_comm(PlayerType *player_ptr, int cmd)
                 }
                 roll2 -= i;
             }
+
             auto choice = randint1(21);
             for (auto i = 6; i > 0; i--) {
                 if ((choice - i) < 1) {
@@ -180,6 +177,7 @@ bool gamble_comm(PlayerType *player_ptr, int cmd)
                 }
                 choice -= i;
             }
+
             put_str("/--------------------------\\", 7, 2);
             prt("\\--------------------------/", 17, 2);
             display_fruit(8, 3, roll1 - 1);
@@ -207,7 +205,11 @@ bool gamble_comm(PlayerType *player_ptr, int cmd)
                     odds = 1000;
                     break;
                 }
-            } else if ((roll1 == 1) && (roll2 == 1)) {
+
+                break;
+            }
+
+            if ((roll1 == 1) && (roll2 == 1)) {
                 win = 1;
                 odds = 2;
             }
@@ -226,9 +228,7 @@ bool gamble_comm(PlayerType *player_ptr, int cmd)
 
         if (win) {
             prt(_("あなたの勝ち", "YOU WON"), 16, 37);
-
             player_ptr->au += odds * wager;
-
             prt(format(_("倍率: %d", "Payoff: %d"), odds), 17, 37);
         } else {
             prt(_("あなたの負け", "You Lost"), 16, 37);
@@ -237,7 +237,6 @@ bool gamble_comm(PlayerType *player_ptr, int cmd)
 
         prt(format(_("現在の所持金:     %9d", "Current Gold:     %9d"), player_ptr->au), 22, 2);
         prt(_("もう一度(Y/N)?", "Again(Y/N)?"), 18, 37);
-
         move_cursor(18, 52);
         auto again = inkey();
         prt("", 16, 37);
@@ -267,5 +266,4 @@ bool gamble_comm(PlayerType *player_ptr, int cmd)
 
     msg_print(nullptr);
     screen_load();
-    return true;
 }
index 0090cc6..ef790a2 100644 (file)
@@ -1,4 +1,4 @@
 #pragma once
 
 class PlayerType;
-bool gamble_comm(PlayerType *player_ptr, int cmd);
+void gamble_comm(PlayerType *player_ptr, int cmd);