OSDN Git Service

Merge branch 'develop' into feature/doxygen-main-win
[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/attack-defense-types.h"
8 #include "player/special-defense-types.h"
9 #include "status/action-setter.h"
10 #include "system/player-type-definition.h"
11 #include "term/screen-processor.h"
12 #include "util/int-char-converter.h"
13 #include "view/display-messages.h"
14
15 static void set_stance(player_type *creature_ptr, const int new_stance)
16 {
17     set_action(creature_ptr, ACTION_KAMAE);
18     if (creature_ptr->special_defense & (KAMAE_GENBU << new_stance)) {
19         msg_print(_("構え直した。", "You reassume a stance."));
20         return;
21     }
22
23     creature_ptr->special_defense &= ~(KAMAE_MASK);
24     creature_ptr->update |= PU_BONUS;
25     creature_ptr->redraw |= PR_STATE;
26     msg_format(_("%sの構えをとった。", "You assume the %s stance."), monk_stances[new_stance].desc);
27     creature_ptr->special_defense |= (KAMAE_GENBU << new_stance);
28 }
29
30 /*!
31  * @brief 修行僧の構え設定処理
32  * @return 構えを変化させたらTRUE、構え不能かキャンセルしたらFALSEを返す。
33  */
34 bool choose_monk_stance(player_type *creature_ptr)
35 {
36     if (cmd_limit_confused(creature_ptr))
37         return FALSE;
38
39     screen_save();
40     prt(_(" a) 構えをとく", " a) No form"), 2, 20);
41     for (int i = 0; i < MAX_KAMAE; i++) {
42         if (creature_ptr->lev >= monk_stances[i].min_level) {
43             char buf[80];
44             sprintf(buf, " %c) %-12s  %s", I2A(i + 1), monk_stances[i].desc, monk_stances[i].info);
45             prt(buf, 3 + i, 20);
46         }
47     }
48
49     prt("", 1, 0);
50     prt(_("        どの構えをとりますか?", "        Choose Stance: "), 1, 14);
51
52     int new_stance = 0;
53     while (TRUE) {
54         char choice = inkey();
55         if (choice == ESCAPE) {
56             screen_load();
57             return FALSE;
58         }
59         
60         if ((choice == 'a') || (choice == 'A')) {
61             if (creature_ptr->action == ACTION_KAMAE) {
62                 set_action(creature_ptr, ACTION_NONE);
63             } else
64                 msg_print(_("もともと構えていない。", "You are not in a special stance."));
65             screen_load();
66             return TRUE;
67         }
68         
69         if ((choice == 'b') || (choice == 'B')) {
70             new_stance = 0;
71             break;
72         } else if (((choice == 'c') || (choice == 'C')) && (creature_ptr->lev > 29)) {
73             new_stance = 1;
74             break;
75         } else if (((choice == 'd') || (choice == 'D')) && (creature_ptr->lev > 34)) {
76             new_stance = 2;
77             break;
78         } else if (((choice == 'e') || (choice == 'E')) && (creature_ptr->lev > 39)) {
79             new_stance = 3;
80             break;
81         }
82     }
83
84     set_stance(creature_ptr, new_stance);
85     creature_ptr->redraw |= PR_STATE;
86     screen_load();
87     return TRUE;
88 }