OSDN Git Service

d1f883c831a720822a27e179e7d14495d75fa9e2
[hengbandforosx/hengbandosx.git] / src / status / action-setter.cpp
1 /*!
2  * @brief プレイヤーの継続行動処理
3  * @date 2014/01/01
4  * @author
5  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6  *
7  * This software may be copied and distributed for educational, research,
8  * and not for profit purposes provided that this copyright and statement
9  * are included in all such copies.  Other copyrights may also apply.
10  *
11  * 2013 Deskull rearranged comment for Doxygen.
12  */
13
14 #include "status/action-setter.h"
15 #include "core/player-redraw-types.h"
16 #include "player-base/player-class.h"
17 #include "player-info/bluemage-data-type.h"
18 #include "player-info/monk-data-type.h"
19 #include "player-info/samurai-data-type.h"
20 #include "player-status/player-energy.h"
21 #include "player/attack-defense-types.h"
22 #include "player/special-defense-types.h"
23 #include "spell-realm/spells-hex.h"
24 #include "spell-realm/spells-song.h"
25 #include "system/player-type-definition.h"
26 #include "system/redrawing-flags-updater.h"
27 #include "view/display-messages.h"
28
29 /*!
30  * @brief プレイヤーの継続行動を設定する。
31  * @param typ 継続行動のID
32  * NONE / SEARCH / REST / LEARN / FISH / MONK_STANCE / SAMURAI_STANCE / SING / HAYAGAKE / SPELL
33  * から選択。
34  */
35 void set_action(PlayerType *player_ptr, uint8_t typ)
36 {
37     auto prev_typ = player_ptr->action;
38     if (typ == prev_typ) {
39         return;
40     }
41
42     auto &rfu = RedrawingFlagsUpdater::get_instance();
43     switch (prev_typ) {
44     case ACTION_SEARCH:
45         msg_print(_("探索をやめた。", "You no longer walk carefully."));
46         rfu.set_flag(MainWindowRedrawingFlag::SPEED);
47         break;
48     case ACTION_REST:
49         player_ptr->resting = 0;
50         break;
51     case ACTION_LEARN: {
52         msg_print(_("学習をやめた。", "You stop learning."));
53         auto bluemage_data = PlayerClass(player_ptr).get_specific_data<bluemage_data_type>();
54         bluemage_data->new_magic_learned = false;
55         break;
56     }
57     case ACTION_MONK_STANCE:
58         msg_print(_("構えをといた。", "You stop assuming the special stance."));
59         PlayerClass(player_ptr).set_monk_stance(MonkStanceType::NONE);
60         break;
61     case ACTION_SAMURAI_STANCE:
62         msg_print(_("型を崩した。", "You stop assuming the special stance."));
63         PlayerClass(player_ptr).set_samurai_stance(SamuraiStanceType::NONE);
64         rfu.set_flag(StatusRedrawingFlag::MONSTER_STATUSES);
65         rfu.set_flag(MainWindowRedrawingFlag::TIMED_EFFECT);
66         break;
67     case ACTION_SING:
68         msg_print(_("歌うのをやめた。", "You stop singing."));
69         break;
70     case ACTION_HAYAGAKE:
71         msg_print(_("足が重くなった。", "You are no longer walking extremely fast."));
72         PlayerEnergy(player_ptr).set_player_turn_energy(100);
73         break;
74     case ACTION_SPELL:
75         msg_print(_("呪文の詠唱を中断した。", "You stopped casting."));
76         break;
77     }
78
79     player_ptr->action = typ;
80
81     /* If we are requested other action, stop singing */
82     if (prev_typ == ACTION_SING) {
83         stop_singing(player_ptr);
84     }
85
86     if (prev_typ == ACTION_SPELL) {
87         SpellHex spell_hex(player_ptr);
88         if (spell_hex.is_spelling_any()) {
89             spell_hex.stop_all_spells();
90         }
91     }
92
93     switch (player_ptr->action) {
94     case ACTION_SEARCH:
95         msg_print(_("注意深く歩き始めた。", "You begin to walk carefully."));
96         rfu.set_flag(MainWindowRedrawingFlag::SPEED);
97         break;
98     case ACTION_LEARN:
99         msg_print(_("学習を始めた。", "You begin learning"));
100         break;
101     case ACTION_FISH:
102         msg_print(_("水面に糸を垂らした...", "You begin fishing..."));
103         break;
104     case ACTION_HAYAGAKE:
105         msg_print(_("足が羽のように軽くなった。", "You begin to walk extremely fast."));
106         break;
107     default:
108         break;
109     }
110
111     rfu.set_flag(StatusRedrawingFlag::BONUS);
112     rfu.set_flag(MainWindowRedrawingFlag::ACTION);
113 }