1 #include "market/play-gamble.h"
2 #include "avatar/avatar.h"
3 #include "core/asking-player.h"
4 #include "core/show-file.h"
5 #include "io/input-key-acceptor.h"
6 #include "market/building-actions-table.h"
7 #include "market/building-util.h"
8 #include "market/poker.h"
9 #include "system/player-type-definition.h"
10 #include "term/screen-processor.h"
11 #include "term/term-color-types.h"
12 #include "view/display-fruit.h"
13 #include "view/display-messages.h"
16 * @brief カジノ1プレイごとのメインルーチン / gamble_comm
17 * @param player_ptr プレイヤーへの参照ポインタ
18 * @param cmd プレイするゲームID
19 * @return プレイ成立やルール説明のみ等ならTRUE、賭け金不足で不成立ならFALSE
21 bool gamble_comm(PlayerType *player_ptr, int cmd)
24 int roll1, roll2, roll3, choice, odds, win;
29 char out_val[160], tmp_str[80], again;
34 if (cmd == BACT_GAMBLE_RULES) {
35 (void)show_file(player_ptr, true, _("jgambling.txt", "gambling.txt"), nullptr, 0, 0);
40 if (player_ptr->au < 1) {
41 msg_print(_("おい!おまえ一文なしじゃないか!こっから出ていけ!", "Hey! You don't have gold - get out of here!"));
48 maxbet = player_ptr->lev * 200;
49 maxbet = std::min(maxbet, player_ptr->au);
52 sprintf(tmp_str, _("賭け金 (1-%ld)?", "Your wager (1-%ld) ? "), (long int)maxbet);
55 * Use get_string() because we may need more than
56 * the int16_t value returned by get_quantity().
58 if (!get_string(tmp_str, out_val, 32)) {
64 for (p = out_val; *p == ' '; p++) {
69 if (wager > player_ptr->au) {
70 msg_print(_("おい!金が足りないじゃないか!出ていけ!", "Hey! You don't have the gold - get out of here!"));
74 } else if (wager > maxbet) {
75 msg_format(_("%ldゴールドだけ受けよう。残りは取っときな。", "I'll take %ld gold of that. Keep the rest."), (long int)maxbet);
77 } else if (wager < 1) {
78 msg_print(_("OK、1ゴールドからはじめよう。", "Ok, we'll start with 1 gold."));
84 oldgold = player_ptr->au;
86 sprintf(tmp_str, _("ゲーム前の所持金: %9ld", "Gold before game: %9ld"), (long int)oldgold);
88 sprintf(tmp_str, _("現在の掛け金: %9ld", "Current Wager: %9ld"), (long int)wager);
92 player_ptr->au -= wager;
94 case BACT_IN_BETWEEN: /* Game of In-Between */
95 c_put_str(TERM_GREEN, _("イン・ビトイーン", "In Between"), 5, 2);
100 roll2 = randint1(10);
101 choice = randint1(10);
102 sprintf(tmp_str, _("黒ダイス: %d 黒ダイス: %d", "Black die: %d Black Die: %d"), roll1, roll2);
105 sprintf(tmp_str, _("赤ダイス: %d", "Red die: %d"), choice);
107 prt(tmp_str, 11, 14);
108 if (((choice > roll1) && (choice < roll2)) || ((choice < roll1) && (choice > roll2))) {
112 case BACT_CRAPS: /* Game of Craps */
113 c_put_str(TERM_GREEN, _("クラップス", "Craps"), 5, 2);
119 roll3 = roll1 + roll2;
121 sprintf(tmp_str, _("1振りめ: %d %d Total: %d", "First roll: %d %d Total: %d"), roll1, roll2, roll3);
123 if ((roll3 == 7) || (roll3 == 11)) {
125 } else if ((roll3 == 2) || (roll3 == 3) || (roll3 == 12)) {
129 msg_print(_("なにかキーを押すともう一回振ります。", "Hit any key to roll again"));
134 roll3 = roll1 + roll2;
135 sprintf(tmp_str, _("出目: %d %d 合計: %d", "Roll result: %d %d Total: %d"), roll1, roll2, roll3);
137 if (roll3 == choice) {
139 } else if (roll3 == 7) {
142 } while ((win != 1) && (win != 0));
147 case BACT_SPIN_WHEEL: /* Spin the Wheel Game */
150 c_put_str(TERM_GREEN, _("ルーレット", "Wheel"), 5, 2);
152 prt("0 1 2 3 4 5 6 7 8 9", 7, 5);
153 prt("--------------------------------", 8, 3);
155 get_string(_("何番? (0-9): ", "Pick a number (0-9): "), out_val, 32);
157 for (p = out_val; iswspace(*p); p++) {
162 msg_print(_("0番にしとくぜ。", "I'll put you down for 0."));
164 } else if (choice > 9) {
165 msg_print(_("OK、9番にしとくぜ。", "Ok, I'll put you down for 9."));
169 roll1 = randint0(10);
170 sprintf(tmp_str, _("ルーレットは回り、止まった。勝者は %d番だ。", "The wheel spins to a stop and the winner is %d"), roll1);
173 prt("*", 9, (3 * roll1 + 5));
174 if (roll1 == choice) {
179 case BACT_DICE_SLOTS: /* The Dice Slots */
180 c_put_str(TERM_GREEN, _("ダイス・スロット", "Dice Slots"), 5, 2);
181 c_put_str(TERM_YELLOW, _("レモン レモン 2", "Lemon Lemon 2"), 6, 37);
182 c_put_str(TERM_YELLOW, _("レモン レモン レモン 5", "Lemon Lemon Lemon 5"), 7, 37);
183 c_put_str(TERM_ORANGE, _("オレンジ オレンジ オレンジ 10", "Orange Orange Orange 10"), 8, 37);
184 c_put_str(TERM_UMBER, _("剣 剣 剣 20", "Sword Sword Sword 20"), 9, 37);
185 c_put_str(TERM_SLATE, _("盾 盾 盾 50", "Shield Shield Shield 50"), 10, 37);
186 c_put_str(TERM_VIOLET, _("プラム プラム プラム 200", "Plum Plum Plum 200"), 11, 37);
187 c_put_str(TERM_RED, _("チェリー チェリー チェリー 1000", "Cherry Cherry Cherry 1000"), 12, 37);
190 roll1 = randint1(21);
191 for (i = 6; i > 0; i--) {
192 if ((roll1 - i) < 1) {
198 roll2 = randint1(21);
199 for (i = 6; i > 0; i--) {
200 if ((roll2 - i) < 1) {
206 choice = randint1(21);
207 for (i = 6; i > 0; i--) {
208 if ((choice - i) < 1) {
214 put_str("/--------------------------\\", 7, 2);
215 prt("\\--------------------------/", 17, 2);
216 display_fruit(8, 3, roll1 - 1);
217 display_fruit(8, 12, roll2 - 1);
218 display_fruit(8, 21, choice - 1);
219 if ((roll1 == roll2) && (roll2 == choice)) {
241 } else if ((roll1 == 1) && (roll2 == 1)) {
256 prt(_("あなたの勝ち", "YOU WON"), 16, 37);
258 player_ptr->au += odds * wager;
259 sprintf(tmp_str, _("倍率: %d", "Payoff: %d"), odds);
261 prt(tmp_str, 17, 37);
263 prt(_("あなたの負け", "You Lost"), 16, 37);
267 sprintf(tmp_str, _("現在の所持金: %9ld", "Current Gold: %9ld"), (long int)player_ptr->au);
270 prt(_("もう一度(Y/N)?", "Again(Y/N)?"), 18, 37);
277 if (wager > player_ptr->au) {
278 msg_print(_("おい!金が足りないじゃないか!ここから出て行け!", "Hey! You don't have the gold - get out of here!"));
284 } while ((again == 'y') || (again == 'Y'));
287 if (player_ptr->au >= oldgold) {
288 msg_print(_("「今回は儲けたな!でも次はこっちが勝ってやるからな、絶対に!」", "You came out a winner! We'll win next time, I'm sure."));
289 chg_virtue(player_ptr, V_CHANCE, 3);
291 msg_print(_("「金をスッてしまったな、わはは!うちに帰った方がいいぜ。」", "You lost gold! Haha, better head home."));
292 chg_virtue(player_ptr, V_CHANCE, -3);