From b6a6d40a904cd093073789b8a06697f78a4fddc8 Mon Sep 17 00:00:00 2001 From: Hourier <66951241+Hourier@users.noreply.github.com> Date: Sat, 24 Jun 2023 15:01:49 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#3453=20arena.cpp=20=E3=81=8B?= =?utf8?q?=E3=82=89=E5=91=BC=E3=81=B0=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8Bg?= =?utf8?q?et=5Fstring()=20=E3=82=92input=5Fvalue()=20=E3=81=AB=E5=A4=89?= =?utf8?q?=E3=81=88=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/market/arena.cpp | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/src/market/arena.cpp b/src/market/arena.cpp index ef87e8fd2..bf6bfdfcc 100644 --- a/src/market/arena.cpp +++ b/src/market/arena.cpp @@ -264,11 +264,6 @@ void update_gambling_monsters(PlayerType *player_ptr) */ bool monster_arena_comm(PlayerType *player_ptr) { - PRICE maxbet; - PRICE wager; - char out_val[MAX_MONSTER_NAME]; - concptr p; - if ((w_ptr->game_turn - w_ptr->arena_start_turn) > TURNS_PER_TICK * 250) { update_gambling_monsters(player_ptr); w_ptr->arena_start_turn = w_ptr->game_turn; @@ -329,40 +324,21 @@ bool monster_arena_comm(PlayerType *player_ptr) } } - maxbet = player_ptr->lev * 200; - - /* We can't bet more than we have */ + auto maxbet = player_ptr->lev * 200; maxbet = std::min(maxbet, player_ptr->au); - - /* - * Get the wager - * Use get_string() because we may need more than - * the int16_t value returned by get_quantity(). - */ - out_val[0] = '\0'; - if (!get_string(format(_("賭け金 (1-%ld)?", "Your wager (1-%ld) ? "), (long int)maxbet), out_val, 32)) { + constexpr auto prompt = _("賭け金?", "Your wager? "); + const auto wager_opt = input_value_int(prompt, 1, maxbet, 1); + if (!wager_opt.has_value()) { screen_load(); return false; } - for (p = out_val; *p == ' '; p++) { - ; - } - - wager = atol(p); + auto wager = wager_opt.value(); if (wager > player_ptr->au) { msg_print(_("おい!金が足りないじゃないか!出ていけ!", "Hey! You don't have the gold - get out of here!")); - msg_print(nullptr); screen_load(); return false; - } else if (wager > maxbet) { - msg_format(_("%ldゴールドだけ受けよう。残りは取っときな。", "I'll take %ld gold of that. Keep the rest."), (long int)maxbet); - - wager = maxbet; - } else if (wager < 1) { - msg_print(_("OK、1ゴールドでいこう。", "Ok, we'll start with 1 gold.")); - wager = 1; } msg_print(nullptr); -- 2.11.0