OSDN Git Service

Merge branch 'master' of https://github.com/hengband/hengband
[hengbandforosx/hengbandosx.git] / src / spell / spells-status.cpp
1 /*!
2  * @brief スピード等のステータスに影響のある魔法の処理
3  * @date 2019/01/22
4  * @author deskull
5  */
6
7 #include "spell/spells-status.h"
8 #include "avatar/avatar.h"
9 #include "cmd-action/cmd-spell.h"
10 #include "cmd-item/cmd-magiceat.h"
11 #include "core/stuff-handler.h"
12 #include "core/window-redrawer.h"
13 #include "effect/attribute-types.h"
14 #include "effect/effect-characteristics.h"
15 #include "flavor/flavor-describer.h"
16 #include "flavor/object-flavor-types.h"
17 #include "floor/cave.h"
18 #include "floor/floor-object.h"
19 #include "floor/geometry.h"
20 #include "grid/feature-flag-types.h"
21 #include "hpmp/hp-mp-processor.h"
22 #include "inventory/inventory-object.h"
23 #include "inventory/inventory-slot-types.h"
24 #include "main/sound-definitions-table.h"
25 #include "main/sound-of-music.h"
26 #include "mind/mind-force-trainer.h"
27 #include "monster/monster-describer.h"
28 #include "player-base/player-class.h"
29 #include "player-info/class-info.h"
30 #include "player-info/magic-eater-data-type.h"
31 #include "player-status/player-energy.h"
32 #include "player/attack-defense-types.h"
33 #include "spell-kind/spells-launcher.h"
34 #include "spell-kind/spells-teleport.h"
35 #include "spell-kind/spells-world.h"
36 #include "status/action-setter.h"
37 #include "status/bad-status-setter.h"
38 #include "status/base-status.h"
39 #include "status/body-improvement.h"
40 #include "status/buff-setter.h"
41 #include "status/experience.h"
42 #include "status/shape-changer.h"
43 #include "status/sight-setter.h"
44 #include "system/baseitem-info.h"
45 #include "system/floor-type-definition.h"
46 #include "system/grid-type-definition.h"
47 #include "system/item-entity.h"
48 #include "system/monster-entity.h"
49 #include "system/player-type-definition.h"
50 #include "system/redrawing-flags-updater.h"
51 #include "target/target-getter.h"
52 #include "timed-effect/timed-effects.h"
53 #include "util/bit-flags-calculator.h"
54 #include "view/display-messages.h"
55
56 /*!
57  * @brief モンスター回復処理
58  * @param player_ptr プレイヤーへの参照ポインタ
59  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
60  * @param dam 威力
61  * @return 作用が実際にあった場合TRUEを返す
62  */
63 bool heal_monster(PlayerType *player_ptr, DIRECTION dir, int dam)
64 {
65     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
66     return project_hook(player_ptr, AttributeType::OLD_HEAL, dir, dam, flg);
67 }
68
69 /*!
70  * @brief モンスター加速処理
71  * @param player_ptr プレイヤーへの参照ポインタ
72  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
73  * @param power 効力
74  * @return 作用が実際にあった場合TRUEを返す
75  */
76 bool speed_monster(PlayerType *player_ptr, DIRECTION dir, int power)
77 {
78     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
79     return project_hook(player_ptr, AttributeType::OLD_SPEED, dir, power, flg);
80 }
81
82 /*!
83  * @brief モンスター減速処理
84  * @param player_ptr プレイヤーへの参照ポインタ
85  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
86  * @param power 効力
87  * @return 作用が実際にあった場合TRUEを返す
88  */
89 bool slow_monster(PlayerType *player_ptr, DIRECTION dir, int power)
90 {
91     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
92     return project_hook(player_ptr, AttributeType::OLD_SLOW, dir, power, flg);
93 }
94
95 /*!
96  * @brief モンスター催眠処理
97  * @param player_ptr プレイヤーへの参照ポインタ
98  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
99  * @param power 効力
100  * @return 作用が実際にあった場合TRUEを返す
101  */
102 bool sleep_monster(PlayerType *player_ptr, DIRECTION dir, int power)
103 {
104     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
105     return project_hook(player_ptr, AttributeType::OLD_SLEEP, dir, power, flg);
106 }
107
108 /*!
109  * @brief モンスター拘束(STASIS)処理
110  * @param player_ptr プレイヤーへの参照ポインタ
111  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
112  * @return 作用が実際にあった場合TRUEを返す
113  * @details 威力はプレイヤーレベル*2に固定
114  */
115 bool stasis_monster(PlayerType *player_ptr, DIRECTION dir)
116 {
117     return fire_ball_hide(player_ptr, AttributeType::STASIS, dir, player_ptr->lev * 2, 0);
118 }
119
120 /*!
121  * @brief 邪悪なモンスター拘束(STASIS)処理
122  * @param player_ptr プレイヤーへの参照ポインタ
123  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
124  * @return 作用が実際にあった場合TRUEを返す
125  * @details 威力はプレイヤーレベル*2に固定
126  */
127 bool stasis_evil(PlayerType *player_ptr, DIRECTION dir)
128 {
129     return fire_ball_hide(player_ptr, AttributeType::STASIS_EVIL, dir, player_ptr->lev * 2, 0);
130 }
131
132 /*!
133  * @brief モンスター混乱処理
134  * @param player_ptr プレイヤーへの参照ポインタ
135  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
136  * @param plev プレイヤーレベル(=効力)
137  * @return 作用が実際にあった場合TRUEを返す
138  */
139 bool confuse_monster(PlayerType *player_ptr, DIRECTION dir, PLAYER_LEVEL plev)
140 {
141     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
142     return project_hook(player_ptr, AttributeType::OLD_CONF, dir, plev, flg);
143 }
144
145 /*!
146  * @brief モンスター朦朧処理
147  * @param player_ptr プレイヤーへの参照ポインタ
148  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
149  * @param plev プレイヤーレベル(=効力)
150  * @return 作用が実際にあった場合TRUEを返す
151  */
152 bool stun_monster(PlayerType *player_ptr, DIRECTION dir, PLAYER_LEVEL plev)
153 {
154     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
155     return project_hook(player_ptr, AttributeType::STUN, dir, plev, flg);
156 }
157
158 /*!
159  * @brief チェンジモンスター処理
160  * @param player_ptr プレイヤーへの参照ポインタ
161  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
162  * @param power 効力
163  * @return 作用が実際にあった場合TRUEを返す
164  */
165 bool poly_monster(PlayerType *player_ptr, DIRECTION dir, int power)
166 {
167     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
168     bool tester = (project_hook(player_ptr, AttributeType::OLD_POLY, dir, power, flg));
169     if (tester) {
170         chg_virtue(player_ptr, Virtue::CHANCE, 1);
171     }
172     return tester;
173 }
174
175 /*!
176  * @brief クローンモンスター処理
177  * @param player_ptr プレイヤーへの参照ポインタ
178  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
179  * @return 作用が実際にあった場合TRUEを返す
180  */
181 bool clone_monster(PlayerType *player_ptr, DIRECTION dir)
182 {
183     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
184     return project_hook(player_ptr, AttributeType::OLD_CLONE, dir, 0, flg);
185 }
186
187 /*!
188  * @brief モンスター恐慌処理
189  * @param player_ptr プレイヤーへの参照ポインタ
190  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
191  * @param plev プレイヤーレベル(=効力)
192  * @return 作用が実際にあった場合TRUEを返す
193  */
194 bool fear_monster(PlayerType *player_ptr, DIRECTION dir, PLAYER_LEVEL plev)
195 {
196     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
197     return project_hook(player_ptr, AttributeType::TURN_ALL, dir, plev, flg);
198 }
199
200 bool time_walk(PlayerType *player_ptr)
201 {
202     if (player_ptr->timewalk) {
203         msg_print(_("既に時は止まっている。", "Time is already stopped."));
204         return false;
205     }
206
207     player_ptr->timewalk = true;
208     msg_print(_("「時よ!」", "You yell 'Time!'"));
209     //  msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
210     msg_print(nullptr);
211
212     player_ptr->energy_need -= 1000 + (100 + player_ptr->csp - 50) * TURNS_PER_TICK / 10;
213     auto &rfu = RedrawingFlagsUpdater::get_instance();
214     rfu.set_flag(MainWindowRedrawingFlag::MAP);
215     rfu.set_flag(StatusRecalculatingFlag::MONSTER_STATUSES);
216     static constexpr auto flags = {
217         SubWindowRedrawingFlag::OVERHEAD,
218         SubWindowRedrawingFlag::DUNGEON,
219     };
220     rfu.set_flags(flags);
221     handle_stuff(player_ptr);
222     return true;
223 }
224
225 /*!
226  * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
227  * @param player_ptr プレイヤーへの参照ポインタ
228  * @param options スペル共通オプション
229  */
230 void roll_hitdice(PlayerType *player_ptr, spell_operation options)
231 {
232     constexpr auto roll_num = 3 + PY_MAX_LEVEL - 1;
233     const auto expected_hp = player_ptr->hit_dice.maxroll() + player_ptr->hit_dice.floored_expected_value_multiplied_by(roll_num);
234     const auto min_value = expected_hp * 3 / 4;
235     const auto max_value = expected_hp * 5 / 4;
236
237     /* Rerate */
238     while (true) {
239         /* Pre-calculate level 1 hitdice */
240         player_ptr->player_hp[0] = player_ptr->hit_dice.maxroll();
241
242         for (int i = 1; i < 4; i++) {
243             player_ptr->player_hp[0] += player_ptr->hit_dice.roll();
244         }
245
246         /* Roll the hitpoint values */
247         for (int i = 1; i < PY_MAX_LEVEL; i++) {
248             player_ptr->player_hp[i] = player_ptr->player_hp[i - 1] + player_ptr->hit_dice.roll();
249         }
250
251         /* Require "valid" hitpoints at highest level */
252         if ((player_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) && (player_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) {
253             break;
254         }
255     }
256
257     player_ptr->knowledge &= ~(KNOW_HPRATE);
258
259     auto &rfu = RedrawingFlagsUpdater::get_instance();
260     rfu.set_flag(StatusRecalculatingFlag::HP);
261     rfu.set_flag(MainWindowRedrawingFlag::HP);
262     rfu.set_flag(SubWindowRedrawingFlag::PLAYER);
263     if (!(options & SPOP_NO_UPDATE)) {
264         handle_stuff(player_ptr);
265     }
266
267     if (!(options & SPOP_DISPLAY_MES)) {
268         return;
269     }
270
271     if (options & SPOP_DEBUG) {
272         msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), player_ptr->calc_life_rating());
273         player_ptr->knowledge |= KNOW_HPRATE;
274         return;
275     }
276
277     msg_print(_("体力ランクが変わった。", "Life rate has changed."));
278 }
279
280 bool life_stream(PlayerType *player_ptr, bool message, bool virtue_change)
281 {
282     if (virtue_change) {
283         chg_virtue(player_ptr, Virtue::VITALITY, 1);
284         chg_virtue(player_ptr, Virtue::UNLIFE, -5);
285     }
286
287     if (message) {
288         msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
289     }
290
291     restore_level(player_ptr);
292     BadStatusSetter bss(player_ptr);
293     (void)bss.set_poison(0);
294     (void)bss.set_blindness(0);
295     (void)bss.set_confusion(0);
296     (void)bss.hallucination(0);
297     (void)bss.set_stun(0);
298     (void)bss.set_cut(0);
299     (void)bss.set_paralysis(0);
300     (void)restore_all_status(player_ptr);
301     (void)set_shero(player_ptr, 0, true);
302     handle_stuff(player_ptr);
303     hp_player(player_ptr, 5000);
304
305     return true;
306 }
307
308 bool heroism(PlayerType *player_ptr, int base)
309 {
310     auto ident = false;
311     if (BadStatusSetter(player_ptr).set_fear(0)) {
312         ident = true;
313     }
314
315     if (set_hero(player_ptr, player_ptr->hero + randint1(base) + base, false)) {
316         ident = true;
317     }
318
319     if (hp_player(player_ptr, 10)) {
320         ident = true;
321     }
322
323     return ident;
324 }
325
326 bool berserk(PlayerType *player_ptr, int base)
327 {
328     auto ident = false;
329     if (BadStatusSetter(player_ptr).set_fear(0)) {
330         ident = true;
331     }
332
333     if (set_shero(player_ptr, player_ptr->shero + randint1(base) + base, false)) {
334         ident = true;
335     }
336
337     if (hp_player(player_ptr, 30)) {
338         ident = true;
339     }
340
341     return ident;
342 }
343
344 bool cure_light_wounds(PlayerType *player_ptr, int pow)
345 {
346     auto ident = false;
347     if (hp_player(player_ptr, pow)) {
348         ident = true;
349     }
350
351     BadStatusSetter bss(player_ptr);
352     if (bss.set_blindness(0)) {
353         ident = true;
354     }
355
356     if (bss.mod_cut(-10)) {
357         ident = true;
358     }
359
360     if (set_shero(player_ptr, 0, true)) {
361         ident = true;
362     }
363
364     return ident;
365 }
366
367 bool cure_serious_wounds(PlayerType *player_ptr, int pow)
368 {
369     auto ident = false;
370     if (hp_player(player_ptr, pow)) {
371         ident = true;
372     }
373
374     BadStatusSetter bss(player_ptr);
375     if (bss.set_blindness(0)) {
376         ident = true;
377     }
378
379     if (bss.set_confusion(0)) {
380         ident = true;
381     }
382
383     if (bss.set_cut((player_ptr->effects()->cut().current() / 2) - 50)) {
384         ident = true;
385     }
386
387     if (set_shero(player_ptr, 0, true)) {
388         ident = true;
389     }
390
391     return ident;
392 }
393
394 bool cure_critical_wounds(PlayerType *player_ptr, int pow)
395 {
396     auto ident = false;
397     if (hp_player(player_ptr, pow)) {
398         ident = true;
399     }
400
401     BadStatusSetter bss(player_ptr);
402     if (bss.set_blindness(0)) {
403         ident = true;
404     }
405
406     if (bss.set_confusion(0)) {
407         ident = true;
408     }
409
410     if (bss.set_poison(0)) {
411         ident = true;
412     }
413
414     if (bss.set_stun(0)) {
415         ident = true;
416     }
417
418     if (bss.set_cut(0)) {
419         ident = true;
420     }
421
422     if (set_shero(player_ptr, 0, true)) {
423         ident = true;
424     }
425
426     return ident;
427 }
428
429 bool true_healing(PlayerType *player_ptr, int pow)
430 {
431     auto ident = false;
432     if (hp_player(player_ptr, pow)) {
433         ident = true;
434     }
435
436     BadStatusSetter bss(player_ptr);
437     if (bss.set_blindness(0)) {
438         ident = true;
439     }
440
441     if (bss.set_confusion(0)) {
442         ident = true;
443     }
444
445     if (bss.set_poison(0)) {
446         ident = true;
447     }
448
449     if (bss.set_stun(0)) {
450         ident = true;
451     }
452
453     if (bss.set_cut(0)) {
454         ident = true;
455     }
456
457     if (bss.hallucination(0)) {
458         ident = true;
459     }
460
461     return ident;
462 }
463
464 bool restore_mana(PlayerType *player_ptr, bool magic_eater)
465 {
466     auto &rfu = RedrawingFlagsUpdater::get_instance();
467     if (PlayerClass(player_ptr).equals(PlayerClassType::MAGIC_EATER) && magic_eater) {
468         // 魔力復活による、魔道具術師の取り込んだ魔法の回復量
469         // 取り込み数が10回未満: 3 回分回復
470         // 取り込み数が10回以上: 取り込み回数/3 回分回復
471         auto magic_eater_data = PlayerClass(player_ptr).get_specific_data<magic_eater_data_type>();
472         for (auto tval : { ItemKindType::STAFF, ItemKindType::WAND }) {
473             for (auto &item : magic_eater_data->get_item_group(tval)) {
474                 item.charge += (item.count < 10) ? EATER_CHARGE * 3 : item.count * EATER_CHARGE / 3;
475                 item.charge = std::min(item.charge, item.count * EATER_CHARGE);
476             }
477         }
478
479         auto sval = 0;
480         const auto &baseitems = BaseitemList::get_instance();
481         for (auto &item : magic_eater_data->get_item_group(ItemKindType::ROD)) {
482             const auto &baseitem = baseitems.lookup_baseitem({ ItemKindType::ROD, sval });
483             item.charge -= ((item.count < 10) ? EATER_ROD_CHARGE * 3 : item.count * EATER_ROD_CHARGE / 3) * baseitem.pval;
484             item.charge = std::max(item.charge, 0);
485             ++sval;
486         }
487
488         msg_print(_("頭がハッキリとした。", "You feel your head clear."));
489         rfu.set_flag(SubWindowRedrawingFlag::PLAYER);
490         return true;
491     }
492
493     if (player_ptr->csp >= player_ptr->msp) {
494         return false;
495     }
496
497     player_ptr->csp = player_ptr->msp;
498     player_ptr->csp_frac = 0;
499     msg_print(_("頭がハッキリとした。", "You feel your head clear."));
500     rfu.set_flag(MainWindowRedrawingFlag::MP);
501     static constexpr auto flags_swrf = {
502         SubWindowRedrawingFlag::SPELL,
503         SubWindowRedrawingFlag::PLAYER,
504     };
505     rfu.set_flags(flags_swrf);
506     return true;
507 }
508
509 bool restore_all_status(PlayerType *player_ptr)
510 {
511     bool ident = false;
512     if (do_res_stat(player_ptr, A_STR)) {
513         ident = true;
514     }
515     if (do_res_stat(player_ptr, A_INT)) {
516         ident = true;
517     }
518     if (do_res_stat(player_ptr, A_WIS)) {
519         ident = true;
520     }
521     if (do_res_stat(player_ptr, A_DEX)) {
522         ident = true;
523     }
524     if (do_res_stat(player_ptr, A_CON)) {
525         ident = true;
526     }
527     if (do_res_stat(player_ptr, A_CHR)) {
528         ident = true;
529     }
530     return ident;
531 }
532
533 bool fishing(PlayerType *player_ptr)
534 {
535     const auto dir = get_direction(player_ptr);
536     if (!dir) {
537         return false;
538     }
539
540     const auto pos = player_ptr->get_neighbor(*dir);
541     player_ptr->fishing_dir = *dir;
542     const auto &floor = *player_ptr->current_floor_ptr;
543     if (!cave_has_flag_bold(&floor, pos.y, pos.x, TerrainCharacteristics::WATER)) {
544         msg_print(_("そこは水辺ではない。", "You can't fish here."));
545         return false;
546     }
547
548     const auto &grid = floor.get_grid(pos);
549     if (grid.has_monster()) {
550         const auto m_name = monster_desc(player_ptr, &floor.m_list[grid.m_idx], 0);
551         msg_format(_("%sが邪魔だ!", "%s^ is standing in your way."), m_name.data());
552         PlayerEnergy(player_ptr).reset_player_turn();
553         return false;
554     }
555
556     set_action(player_ptr, ACTION_FISH);
557     RedrawingFlagsUpdater::get_instance().set_flag(MainWindowRedrawingFlag::ACTION);
558     return true;
559 }
560
561 /*!
562  * @brief 装備を脱ぎ捨てて小宇宙を燃やす
563  * @param player_ptr プレイヤー情報への参照ポインタ
564  * @param o_ptr_ptr 脱ぐ装備品への参照ポインタのポインタ
565  * @return 脱いだらTRUE、脱がなかったらFALSE
566  * @details
567  * 脱いで落とした装備にtimeoutを設定するために装備品のアドレスを返す。
568  */
569 bool cosmic_cast_off(PlayerType *player_ptr, ItemEntity **o_ptr_ptr)
570 {
571     auto *o_ptr = (*o_ptr_ptr);
572
573     /* Cast off activated item */
574     INVENTORY_IDX slot;
575     for (slot = INVEN_MAIN_HAND; slot <= INVEN_FEET; slot++) {
576         if (o_ptr == &player_ptr->inventory_list[slot]) {
577             break;
578         }
579     }
580
581     if (slot > INVEN_FEET) {
582         return false;
583     }
584
585     ItemEntity forge;
586     (&forge)->copy_from(o_ptr);
587     inven_item_increase(player_ptr, slot, (0 - o_ptr->number));
588     inven_item_optimize(player_ptr, slot);
589
590     OBJECT_IDX old_o_idx = drop_near(player_ptr, &forge, 0, player_ptr->y, player_ptr->x);
591     *o_ptr_ptr = &player_ptr->current_floor_ptr->o_list[old_o_idx];
592
593     const auto item_name = describe_flavor(player_ptr, &forge, OD_NAME_ONLY);
594     msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), item_name.data());
595     sound(SOUND_TAKE_OFF);
596
597     /* Get effects */
598     msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
599     TIME_EFFECT t = 20 + randint1(20);
600     BadStatusSetter bss(player_ptr);
601     (void)bss.mod_blindness(t);
602     (void)bss.set_fear(0);
603     (void)set_tim_esp(player_ptr, player_ptr->tim_esp + t, false);
604     (void)set_tim_regen(player_ptr, player_ptr->tim_regen + t, false);
605     (void)set_hero(player_ptr, player_ptr->hero + t, false);
606     (void)set_blessed(player_ptr, player_ptr->blessed + t, false);
607     (void)mod_acceleration(player_ptr, t, false);
608     (void)set_shero(player_ptr, player_ptr->shero + t, false);
609     if (PlayerClass(player_ptr).equals(PlayerClassType::FORCETRAINER)) {
610         set_current_ki(player_ptr, true, player_ptr->lev * 5 + 190);
611         msg_print(_("気が爆発寸前になった。", "Your force absorbs the explosion."));
612     }
613
614     return true;
615 }
616
617 /*!
618  * @brief プレイヤーの因果混乱処理 / Apply Nexus
619  * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
620  */
621 void apply_nexus(MonsterEntity *m_ptr, PlayerType *player_ptr)
622 {
623     switch (randint1(7)) {
624     case 1:
625     case 2:
626     case 3: {
627         teleport_player(player_ptr, 200, TELEPORT_PASSIVE);
628         break;
629     }
630
631     case 4:
632     case 5: {
633         teleport_player_to(player_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
634         break;
635     }
636
637     case 6: {
638         if (evaluate_percent(player_ptr->skill_sav)) {
639             msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
640             break;
641         }
642
643         teleport_level(player_ptr, 0);
644         break;
645     }
646
647     case 7: {
648         if (evaluate_percent(player_ptr->skill_sav)) {
649             msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
650             break;
651         }
652
653         msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
654         status_shuffle(player_ptr);
655         break;
656     }
657     }
658 }
659
660 /*!
661  * @brief プレイヤーのステータスシャッフル処理
662  * @param player_ptr プレイヤーへの参照ポインタ
663  */
664 void status_shuffle(PlayerType *player_ptr)
665 {
666     /* Pick a pair of stats */
667     int i = randint0(A_MAX);
668     int j;
669
670     //!< @todo ここのループは一体何をしている?
671     for (j = i; j == i; j = randint0(A_MAX)) { /* loop */
672         ;
673     }
674
675     const auto max1 = player_ptr->stat_max[i];
676     const auto cur1 = player_ptr->stat_cur[i];
677     const auto max2 = player_ptr->stat_max[j];
678     const auto cur2 = player_ptr->stat_cur[j];
679
680     player_ptr->stat_max[i] = max2;
681     player_ptr->stat_cur[i] = cur2;
682     player_ptr->stat_max[j] = max1;
683     player_ptr->stat_cur[j] = cur1;
684
685     for (int k = 0; k < A_MAX; k++) {
686         if (player_ptr->stat_max[k] > player_ptr->stat_max_max[k]) {
687             player_ptr->stat_max[k] = player_ptr->stat_max_max[k];
688         }
689         if (player_ptr->stat_cur[k] > player_ptr->stat_max_max[k]) {
690             player_ptr->stat_cur[k] = player_ptr->stat_max_max[k];
691         }
692     }
693
694     RedrawingFlagsUpdater::get_instance().set_flag(StatusRecalculatingFlag::BONUS);
695 }