OSDN Git Service

[Refactor] #37353 VARTUE_LARGE, VARTUE_SMALL を avatar.h へ移動.
[hengband/hengband.git] / src / cmd-magiceat.c
index 00e398b..8b2652e 100644 (file)
@@ -35,8 +35,8 @@
  * 400 item comparisons, but only occasionally.
  *
  * There may be a BIG problem with any "effect" that can cause "changes"
- * to the inventory.  For example, a "scroll of recharging" can cause
- * a wand/staff to "disappear", moving the inventory up.  Luckily, the
+ * to the p_ptr->inventory_list.  For example, a "scroll of recharging" can cause
+ * a wand/staff to "disappear", moving the p_ptr->inventory_list up.  Luckily, the
  * scrolls all appear BEFORE the staffs/wands, so this is not a problem.
  * But, for example, a "staff of recharging" could cause MAJOR problems.
  * In such a case, it will be best to either (1) "postpone" the effect
  */
 
 #include "angband.h"
+#include "util.h"
+#include "term.h"
+
+#include "cmd-basic.h"
 #include "cmd-usestaff.h"
 #include "cmd-zaprod.h"
 #include "cmd-zapwand.h"
-
+#include "cmd-magiceat.h"
+#include "avatar.h"
+#include "player-status.h"
+#include "spells.h"
+#include "player-class.h"
+#include "objectkind.h"
+#include "targeting.h"
 
 /*!
  * @brief 魔道具術師の取り込んだ魔力一覧から選択/閲覧する /
@@ -75,7 +85,6 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse)
 
        int menu_line = (use_menu ? 1 : 0);
 
-#ifdef ALLOW_REPEAT
        COMMAND_CODE sn;
        if (repeat_pull(&sn))
        {
@@ -86,8 +95,6 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse)
                        return sn;
        }
        
-#endif /* ALLOW_REPEAT */
-
        for (i = 0; i < 108; i++)
        {
                if (p_ptr->magic_num2[i]) break;
@@ -198,13 +205,10 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse)
                                                                                        "(*=List, ESC=exit) Browse which power? "));
        else strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの魔力を使いますか?",
                                                                "(*=List, ESC=exit) Use which power? "));
-       
-       /* Save the screen */
        screen_save();
 
        request_list = always_show_list;
 
-       /* Get a spell from the user */
        while (!flag)
        {
                /* Show the list */
@@ -213,10 +217,10 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse)
                        byte y, x = 0;
                        OBJECT_SUBTYPE_VALUE ctr;
                        PERCENTAGE chance;
-                       IDX k_idx;
+                       KIND_OBJECT_IDX k_idx;
                        char dummy[80];
                        POSITION x1, y1;
-                       int level;
+                       DEPTH level;
                        byte col;
 
                        strcpy(dummy, "");
@@ -392,9 +396,7 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse)
                        {
                                /* Hide list */
                                request_list = FALSE;
-                               
-                               /* Restore the screen */
-                               screen_load();
+                                                               screen_load();
                                screen_save();
                        }
                        else
@@ -492,15 +494,11 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse)
                /* Stop the loop */
                flag = TRUE;
        }
-
-       /* Restore the screen */
        screen_load();
 
        if (!flag) return -1;
 
-#ifdef ALLOW_REPEAT
        repeat_push(ext+i);
-#endif /* ALLOW_REPEAT */
        return ext+i;
 }
 
@@ -517,22 +515,17 @@ bool do_cmd_magic_eater(bool only_browse, bool powerful)
        OBJECT_SUBTYPE_VALUE item;
        PERCENTAGE chance;
        DEPTH level;
-       IDX k_idx;
+       KIND_OBJECT_IDX k_idx;
        OBJECT_TYPE_VALUE tval;
        OBJECT_SUBTYPE_VALUE sval;
        bool use_charge = TRUE;
 
-       /* Not when confused */
-       if (!only_browse && p_ptr->confused)
-       {
-               msg_print(_("混乱していて唱えられない!", "You are too confused!"));
-               return FALSE;
-       }
+       if (cmd_limit_confused(p_ptr)) return FALSE;
 
        item = select_magic_eater(only_browse);
        if (item == -1)
        {
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                return FALSE;
        }
        if (item >= EATER_EXT*2) {tval = TV_ROD;sval = item - EATER_EXT*2;}
@@ -566,13 +559,13 @@ bool do_cmd_magic_eater(bool only_browse, bool powerful)
                sound(SOUND_FAIL);
                if (randint1(100) >= chance)
                        chg_virtue(V_CHANCE,-1);
-               p_ptr->energy_use = 100;
+               take_turn(p_ptr, 100);
 
                return TRUE;
        }
        else
        {
-               int dir = 0;
+               DIRECTION dir = 0;
 
                if (tval == TV_ROD)
                {
@@ -594,7 +587,7 @@ bool do_cmd_magic_eater(bool only_browse, bool powerful)
                if (randint1(100) < chance)
                        chg_virtue(V_CHANCE,1);
        }
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);
        if (tval == TV_ROD) p_ptr->magic_num1[item] += k_info[k_idx].pval * EATER_ROD_CHARGE;
        else p_ptr->magic_num1[item] -= EATER_CHARGE;