OSDN Git Service

[Refactor] #2141 floor_type *floor_ptrの宣言をautoに差し替えた
[hengbandforosx/hengbandosx.git] / src / spell-realm / spells-trump.cpp
1 #include "spell-realm/spells-trump.h"
2 #include "avatar/avatar.h"
3 #include "monster-floor/monster-summon.h"
4 #include "monster-floor/place-monster-types.h"
5 #include "mutation/mutation-investor-remover.h"
6 #include "player-base/player-class.h"
7 #include "spell-kind/earthquake.h"
8 #include "spell-kind/spells-charm.h"
9 #include "spell-kind/spells-floor.h"
10 #include "spell-kind/spells-lite.h"
11 #include "spell-kind/spells-neighbor.h"
12 #include "spell-kind/spells-random.h"
13 #include "spell-kind/spells-sight.h"
14 #include "spell-kind/spells-teleport.h"
15 #include "spell/spells-status.h"
16 #include "spell/spells-summon.h"
17 #include "spell/summon-types.h"
18 #include "status/base-status.h"
19 #include "status/buff-setter.h"
20 #include "status/experience.h"
21 #include "system/floor-type-definition.h"
22 #include "system/player-type-definition.h"
23 #include "target/target-getter.h"
24 #include "view/display-messages.h"
25
26 /*!
27  * @brief トランプ領域の「シャッフル」の効果をランダムに決めて処理する。
28  * @param player_ptr プレイヤーへの参照ポインタ
29  */
30 void cast_shuffle(PlayerType *player_ptr)
31 {
32     PLAYER_LEVEL plev = player_ptr->lev;
33     DIRECTION dir;
34     int die;
35     int vir = virtue_number(player_ptr, V_CHANCE);
36     int i;
37
38     PlayerClass pc(player_ptr);
39     auto is_good_shuffle = PlayerClass(player_ptr).equals(PlayerClassType::ROGUE);
40     is_good_shuffle |= PlayerClass(player_ptr).equals(PlayerClassType::HIGH_MAGE);
41     is_good_shuffle |= PlayerClass(player_ptr).equals(PlayerClassType::SORCERER);
42     if (is_good_shuffle)
43         die = (randint1(110)) + plev / 5;
44     else
45         die = randint1(120);
46
47     if (vir) {
48         if (player_ptr->virtues[vir - 1] > 0) {
49             while (randint1(400) < player_ptr->virtues[vir - 1])
50                 die++;
51         } else {
52             while (randint1(400) < (0 - player_ptr->virtues[vir - 1]))
53                 die--;
54         }
55     }
56
57     msg_print(_("あなたはカードを切って一枚引いた...", "You shuffle the deck and draw a card..."));
58
59     if (die < 30) {
60         chg_virtue(player_ptr, V_CHANCE, 1);
61     }
62
63     auto *floor_ptr = player_ptr->current_floor_ptr;
64     if (die < 7) {
65         msg_print(_("なんてこった!《死》だ!", "Oh no! It's Death!"));
66
67         for (i = 0; i < randint1(3); i++) {
68             activate_hi_summon(player_ptr, player_ptr->y, player_ptr->x, false);
69         }
70
71         return;
72     }
73
74     if (die < 14) {
75         msg_print(_("なんてこった!《悪魔》だ!", "Oh no! It's the Devil!"));
76         summon_specific(player_ptr, 0, player_ptr->y, player_ptr->x, floor_ptr->dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
77         return;
78     }
79
80     if (die < 18) {
81         int count = 0;
82         msg_print(_("なんてこった!《吊られた男》だ!", "Oh no! It's the Hanged Man."));
83         activate_ty_curse(player_ptr, false, &count);
84         return;
85     }
86
87     if (die < 22) {
88         msg_print(_("《不調和の剣》だ。", "It's the swords of discord."));
89         aggravate_monsters(player_ptr, 0);
90         return;
91     }
92
93     if (die < 26) {
94         msg_print(_("《愚者》だ。", "It's the Fool."));
95         do_dec_stat(player_ptr, A_INT);
96         do_dec_stat(player_ptr, A_WIS);
97         return;
98     }
99
100     if (die < 30) {
101         msg_print(_("奇妙なモンスターの絵だ。", "It's the picture of a strange monster."));
102         trump_summoning(player_ptr, 1, false, player_ptr->y, player_ptr->x, (floor_ptr->dun_level * 3 / 2),
103             SUMMON_UNIQUE + randint1(6), PM_ALLOW_GROUP | PM_ALLOW_UNIQUE);
104         return;
105     }
106
107     if (die < 33) {
108         msg_print(_("《月》だ。", "It's the Moon."));
109         unlite_area(player_ptr, 10, 3);
110         return;
111     }
112
113     if (die < 38) {
114         msg_print(_("《運命の輪》だ。", "It's the Wheel of Fortune."));
115         wild_magic(player_ptr, randint0(32));
116         return;
117     }
118
119     if (die < 40) {
120         msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
121         teleport_player(player_ptr, 10, TELEPORT_PASSIVE);
122         return;
123     }
124
125     if (die < 42) {
126         msg_print(_("《正義》だ。", "It's Justice."));
127         set_blessed(player_ptr, player_ptr->lev, false);
128         return;
129     }
130
131     if (die < 47) {
132         msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
133         teleport_player(player_ptr, 100, TELEPORT_PASSIVE);
134         return;
135     }
136
137     if (die < 52) {
138         msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
139         teleport_player(player_ptr, 200, TELEPORT_PASSIVE);
140         return;
141     }
142
143     if (die < 60) {
144         msg_print(_("《塔》だ。", "It's the Tower."));
145         wall_breaker(player_ptr);
146         return;
147     }
148
149     if (die < 72) {
150         msg_print(_("《節制》だ。", "It's Temperance."));
151         sleep_monsters_touch(player_ptr);
152         return;
153     }
154
155     if (die < 80) {
156         msg_print(_("《塔》だ。", "It's the Tower."));
157         earthquake(player_ptr, player_ptr->y, player_ptr->x, 5, 0);
158         return;
159     }
160
161     if (die < 82) {
162         msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
163         trump_summoning(player_ptr, 1, true, player_ptr->y, player_ptr->x, (floor_ptr->dun_level * 3 / 2), SUMMON_MOLD, 0L);
164         return;
165     }
166
167     if (die < 84) {
168         msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
169         trump_summoning(player_ptr, 1, true, player_ptr->y, player_ptr->x, (floor_ptr->dun_level * 3 / 2), SUMMON_BAT, 0L);
170         return;
171     }
172
173     if (die < 86) {
174         msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
175         trump_summoning(player_ptr, 1, true, player_ptr->y, player_ptr->x, (floor_ptr->dun_level * 3 / 2), SUMMON_VORTEX, 0L);
176         return;
177     }
178
179     if (die < 88) {
180         msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
181         trump_summoning(player_ptr, 1, true, player_ptr->y, player_ptr->x, (floor_ptr->dun_level * 3 / 2), SUMMON_COIN_MIMIC, 0L);
182         return;
183     }
184
185     if (die < 96) {
186         msg_print(_("《恋人》だ。", "It's the Lovers."));
187
188         if (get_aim_dir(player_ptr, &dir)) {
189             charm_monster(player_ptr, dir, std::min<short>(player_ptr->lev, 20));
190         }
191
192         return;
193     }
194
195     if (die < 101) {
196         msg_print(_("《隠者》だ。", "It's the Hermit."));
197         wall_stone(player_ptr);
198         return;
199     }
200
201     if (die < 111) {
202         msg_print(_("《審判》だ。", "It's Judgement."));
203         roll_hitdice(player_ptr, SPOP_NONE);
204         lose_all_mutations(player_ptr);
205         return;
206     }
207
208     if (die < 120) {
209         msg_print(_("《太陽》だ。", "It's the Sun."));
210         chg_virtue(player_ptr, V_KNOWLEDGE, 1);
211         chg_virtue(player_ptr, V_ENLIGHTEN, 1);
212         wiz_lite(player_ptr, false);
213         return;
214     }
215
216     msg_print(_("《世界》だ。", "It's the World."));
217     if (player_ptr->exp >= PY_MAX_EXP) {
218         return;
219     }
220
221     int32_t ee = (player_ptr->exp / 25) + 1;
222     if (ee > 5000)
223         ee = 5000;
224     msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
225     gain_exp(player_ptr, ee);
226 }
227
228 void become_living_trump(PlayerType *player_ptr)
229 {
230     /* 1/7 Teleport control and 6/7 Random teleportation (uncontrolled) */
231     MUTATION_IDX mutation = one_in_(7) ? 12 : 77;
232     if (gain_mutation(player_ptr, mutation))
233         msg_print(_("あなたは生きているカードに変わった。", "You have turned into a Living Trump."));
234 }