OSDN Git Service

6bd3191cf9441e6afcccb385fb9e671cc4b801b8
[hengbandforosx/hengbandosx.git] / src / mind / mind-monk.cpp
1 #include "mind/mind-monk.h"
2 #include "action/action-limited.h"
3 #include "core/player-redraw-types.h"
4 #include "core/player-update-types.h"
5 #include "io/input-key-acceptor.h"
6 #include "mind/stances-table.h"
7 #include "player-base/player-class.h"
8 #include "player-info/monk-data-type.h"
9 #include "player/attack-defense-types.h"
10 #include "player/special-defense-types.h"
11 #include "status/action-setter.h"
12 #include "system/player-type-definition.h"
13 #include "system/redrawing-flags-updater.h"
14 #include "term/screen-processor.h"
15 #include "term/z-form.h"
16 #include "util/int-char-converter.h"
17 #include "view/display-messages.h"
18
19 static void set_stance(PlayerType *player_ptr, const MonkStanceType new_stance)
20 {
21     set_action(player_ptr, ACTION_MONK_STANCE);
22     PlayerClass pc(player_ptr);
23     if (pc.monk_stance_is(new_stance)) {
24         msg_print(_("構え直した。", "You reassume a stance."));
25         return;
26     }
27
28     auto &rfu = RedrawingFlagsUpdater::get_instance();
29     rfu.set_flag(StatusRedrawingFlag::BONUS);
30     player_ptr->redraw |= PR_ACTION;
31     msg_format(_("%sの構えをとった。", "You assume the %s stance."), monk_stances[enum2i(new_stance) - 1].desc);
32     pc.set_monk_stance(new_stance);
33 }
34
35 /*!
36  * @brief 修行僧の構え設定処理
37  * @return 構えを変化させたらTRUE、構え不能かキャンセルしたらFALSEを返す。
38  */
39 bool choose_monk_stance(PlayerType *player_ptr)
40 {
41     if (cmd_limit_confused(player_ptr)) {
42         return false;
43     }
44
45     screen_save();
46     prt(_(" a) 構えをとく", " a) No form"), 2, 20);
47     for (auto i = 0U; i < monk_stances.size(); i++) {
48         if (player_ptr->lev >= monk_stances[i].min_level) {
49             char buf[80];
50             strnfmt(buf, sizeof(buf), " %c) %-12s  %s", I2A(i + 1), monk_stances[i].desc, monk_stances[i].info);
51             prt(buf, 3 + i, 20);
52         }
53     }
54
55     prt("", 1, 0);
56     prt(_("        どの構えをとりますか?", "        Choose Stance: "), 1, 14);
57
58     auto new_stance = MonkStanceType::NONE;
59     while (true) {
60         char choice = inkey();
61         if (choice == ESCAPE) {
62             screen_load();
63             return false;
64         }
65
66         if ((choice == 'a') || (choice == 'A')) {
67             if (player_ptr->action == ACTION_MONK_STANCE) {
68                 set_action(player_ptr, ACTION_NONE);
69             } else {
70                 msg_print(_("もともと構えていない。", "You are not in a special stance."));
71             }
72             screen_load();
73             return true;
74         }
75
76         if ((choice == 'b') || (choice == 'B')) {
77             new_stance = MonkStanceType::GENBU;
78             break;
79         } else if (((choice == 'c') || (choice == 'C')) && (player_ptr->lev > 29)) {
80             new_stance = MonkStanceType::BYAKKO;
81             break;
82         } else if (((choice == 'd') || (choice == 'D')) && (player_ptr->lev > 34)) {
83             new_stance = MonkStanceType::SEIRYU;
84             break;
85         } else if (((choice == 'e') || (choice == 'E')) && (player_ptr->lev > 39)) {
86             new_stance = MonkStanceType::SUZAKU;
87             break;
88         }
89     }
90
91     set_stance(player_ptr, new_stance);
92     player_ptr->redraw |= PR_ACTION;
93     screen_load();
94     return true;
95 }