OSDN Git Service

[Refactor] #39970 Renamed core.c/h to system-variables.c/h
[hengband/hengband.git] / src / view / display-player.c
index 4176478..9db9e84 100644 (file)
@@ -7,17 +7,18 @@
  */
 
 #include "display-player.h"
+#include "player/mimic-info-table.h"
 #include "player-personality.h"
-#include "term.h"
+#include "gameterm.h"
 #include "status-first-page.h"
 #include "player-sex.h"
 #include "patron.h"
-#include "world.h"
+#include "world/world.h"
 #include "quest.h"
-#include "core.h" // 暫定。後で消す
-#include "mutation.h"
-#include "dungeon-file.h"
-#include "objectkind.h"
+#include "core/system-variables.h" // 暫定。後で消す
+#include "knowledge/knowledge-mutations.h"
+#include "dungeon/dungeon-file.h"
+#include "object/object-kind.h"
 #include "view/display-util.h"
 #include "view/display-characteristic.h"
 #include "view/display-player-stat-info.h"
@@ -77,48 +78,33 @@ static void display_player_basic_info(player_type *creature_ptr)
 
 
 /*!
- * @brief プレイヤーのステータス表示メイン処理
- * Display the character on the screen (various modes)
+ * @brief 魔法領域を表示する
  * @param creature_ptr プレーヤーへの参照ポインタ
- * @param mode 表示モードID
  * @return なし
- * @details
- * <pre>
- * The top one and bottom two lines are left blank.
- * Mode 0 = standard display with skills
- * Mode 1 = standard display with history
- * Mode 2 = summary of various things
- * Mode 3 = summary of various things (part 2)
- * Mode 4 = mutations
- * </pre>
  */
-void display_player(player_type *creature_ptr, int mode, map_name_pf map_name)
+static void display_magic_realms(player_type *creature_ptr)
 {
-       if ((creature_ptr->muta1 || creature_ptr->muta2 || creature_ptr->muta3) && display_mutations)
-               mode = (mode % 5);
-       else
-               mode = (mode % 4);
-
-       clear_from(0);
-       if (display_player_info(creature_ptr, mode)) return;
-
-       display_player_basic_info(creature_ptr);
+       if (creature_ptr->realm1 == 0) return;
 
        char tmp[64];
-       if (creature_ptr->realm1)
-       {
-               if (creature_ptr->realm2)
-                       sprintf(tmp, "%s, %s", realm_names[creature_ptr->realm1], realm_names[creature_ptr->realm2]);
-               else
-                       strcpy(tmp, realm_names[creature_ptr->realm1]);
-               display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
-       }
+       if (creature_ptr->realm2)
+               sprintf(tmp, "%s, %s", realm_names[creature_ptr->realm1], realm_names[creature_ptr->realm2]);
+       else
+               strcpy(tmp, realm_names[creature_ptr->realm1]);
+
+       display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
+}
 
-       if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || (creature_ptr->muta2 & MUT2_CHAOS_GIFT))
-               display_player_one_line(ENTRY_PATRON, chaos_patrons[creature_ptr->chaos_patron], TERM_L_BLUE);
 
-       /* Age, Height, Weight, Social */
-       /* 身長はセンチメートルに、体重はキログラムに変更してあります */
+/*!
+ * @ brief 年齢、身長、体重、社会的地位を表示する
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ * @details
+ * 日本語版では、身長はcmに、体重はkgに変更してある
+ */
+static void display_phisique(player_type *creature_ptr)
+{
 #ifdef JP
        display_player_one_line(ENTRY_AGE, format("%d才", (int)creature_ptr->age), TERM_L_BLUE);
        display_player_one_line(ENTRY_HEIGHT, format("%dcm", (int)((creature_ptr->ht * 254) / 100)), TERM_L_BLUE);
@@ -131,7 +117,15 @@ void display_player(player_type *creature_ptr, int mode, map_name_pf map_name)
        display_player_one_line(ENTRY_SOCIAL, format("%d", (int)creature_ptr->sc), TERM_L_BLUE);
 #endif
        display_player_one_line(ENTRY_ALIGN, format("%s", your_alignment(creature_ptr)), TERM_L_BLUE);
+}
+
 
+/*!
+ * @brief 能力値を (減少していたら色を変えて)表示する
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ */
+static void display_player_stats(player_type *creature_ptr)
+{
        char buf[80];
        for (int i = 0; i < A_MAX; i++)
        {
@@ -153,103 +147,125 @@ void display_player(player_type *creature_ptr, int mode, map_name_pf map_name)
                }
 
                if (creature_ptr->stat_max[i] == creature_ptr->stat_max_max[i])
-               {
                        c_put_str(TERM_WHITE, "!", 3 + i, _(58, 58 - 2));
-               }
        }
+}
 
-       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
-       if (mode == 0)
-       {
-               display_player_middle(creature_ptr);
-               display_player_various(creature_ptr);
-               return;
-       }
 
-       char statmsg[1000];
-       put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
+/*!
+ * @brief ゲームオーバーの原因を探る (生きていたら何もしない)
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param statmsg メッセージバッファ
+ * @param map_name マップ名へのコールバック
+ * @return 生きていたらFALSE、死んでいたらTRUE
+ */
+static bool search_death_cause(player_type *creature_ptr, char *statmsg, map_name_pf map_name)
+{
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       if (!creature_ptr->is_dead) return FALSE;
 
-       for (int i = 0; i < 4; i++)
+       if (current_world_ptr->total_winner)
        {
-               put_str(creature_ptr->history[i], i + 12, 10);
-       }
-
-       *statmsg = '\0';
+               sprintf(statmsg, _("…あなたは勝利の後%sした。", "...You %s after winning."),
+                       streq(creature_ptr->died_from, "Seppuku") ? _("切腹", "committed seppuku") : _("引退", "retired from the adventure"));
 
-       if (creature_ptr->is_dead)
+               return TRUE;
+       }
+       
+       if (!floor_ptr->dun_level)
        {
-               if (current_world_ptr->total_winner)
-               {
 #ifdef JP
-                       sprintf(statmsg, "…あなたは勝利の後%sした。", streq(creature_ptr->died_from, "Seppuku") ? "切腹" : "引退");
+               sprintf(statmsg, "…あなたは%sで%sに殺された。", (*map_name)(creature_ptr), creature_ptr->died_from);
 #else
-                       sprintf(statmsg, "...You %s after winning.", streq(creature_ptr->died_from, "Seppuku") ? "committed seppuku" : "retired from the adventure");
+               sprintf(statmsg, "...You were killed by %s in %s.", creature_ptr->died_from, map_name(creature_ptr));
 #endif
-               }
-               else if (!floor_ptr->dun_level)
-               {
+               return TRUE;
+       }
+       
+       if (floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest))
+       {
+               /* Get the quest text */
+               /* Bewere that INIT_ASSIGN resets the cur_num. */
+               init_flags = INIT_NAME_ONLY;
+               process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
 #ifdef JP
-                       sprintf(statmsg, "…あなたは%sで%sに殺された。", (*map_name)(creature_ptr), creature_ptr->died_from);
+               sprintf(statmsg, "…あなたは、クエスト「%s」で%sに殺された。", quest[floor_ptr->inside_quest].name, creature_ptr->died_from);
 #else
-                       sprintf(statmsg, "...You were killed by %s in %s.", creature_ptr->died_from, map_name(creature_ptr));
+               sprintf(statmsg, "...You were killed by %s in the quest '%s'.", creature_ptr->died_from, quest[floor_ptr->inside_quest].name);
 #endif
-               }
-               else if (floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest))
-               {
-                       /* Get the quest text */
-                       /* Bewere that INIT_ASSIGN resets the cur_num. */
-                       init_flags = INIT_NAME_ONLY;
-
-                       process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
+               return TRUE;
+       }
 
 #ifdef JP
-                       sprintf(statmsg, "…あなたは、クエスト「%s」で%sに殺された。", quest[floor_ptr->inside_quest].name, creature_ptr->died_from);
+       sprintf(statmsg, "…あなたは、%sの%d階で%sに殺された。", (*map_name)(creature_ptr), (int)floor_ptr->dun_level, creature_ptr->died_from);
 #else
-                       sprintf(statmsg, "...You were killed by %s in the quest '%s'.", creature_ptr->died_from, quest[floor_ptr->inside_quest].name);
+       sprintf(statmsg, "...You were killed by %s on level %d of %s.", creature_ptr->died_from, floor_ptr->dun_level, map_name(creature_ptr));
 #endif
-               }
-               else
-               {
-#ifdef JP
-                       sprintf(statmsg, "…あなたは、%sの%d階で%sに殺された。", (*map_name)(creature_ptr), (int)floor_ptr->dun_level, creature_ptr->died_from);
-#else
-                       sprintf(statmsg, "...You were killed by %s on level %d of %s.", creature_ptr->died_from, floor_ptr->dun_level, map_name(creature_ptr));
-#endif
-               }
-       }
-       else if (current_world_ptr->character_dungeon)
+
+       return TRUE;
+}
+
+
+/*!
+ * @brief クエストフロアで生きている場合、クエスト名をバッファに詰める
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param statmsg メッセージバッファ
+ * @return クエスト内であればTRUE、いなければFALSE
+ */
+static bool decide_death_in_quest(player_type *creature_ptr, char *statmsg)
+{
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       if (!floor_ptr->inside_quest || !is_fixed_quest_idx(floor_ptr->inside_quest))
+               return FALSE;
+
+       for (int i = 0; i < 10; i++)
+               quest_text[i][0] = '\0';
+
+       quest_text_line = 0;
+       init_flags = INIT_NAME_ONLY;
+       process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
+       sprintf(statmsg, _("…あなたは現在、 クエスト「%s」を遂行中だ。", "...Now, you are in the quest '%s'."), quest[floor_ptr->inside_quest].name);
+       return TRUE;
+}
+
+
+/*!
+ * @brief 現在いるフロアを、または死んでいたらどこでどう死んだかをバッファに詰める
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param statmsg メッセージバッファ
+ * @param map_name マップ名へのコールバック
+ * @return なし
+ */
+static void decide_current_floor(player_type *creature_ptr, char *statmsg, map_name_pf map_name)
+{
+       if (search_death_cause(creature_ptr, statmsg, map_name)) return;
+       if (!current_world_ptr->character_dungeon) return;
+
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       if (floor_ptr->dun_level == 0)
        {
-               if (!floor_ptr->dun_level)
-               {
-                       sprintf(statmsg, _("…あなたは現在、 %s にいる。", "...Now, you are in %s."), map_name(creature_ptr));
-               }
-               else if (floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest))
-               {
-                       /* Clear the text */
-                       /* Must be done before doing INIT_SHOW_TEXT */
-                       for (int i = 0; i < 10; i++)
-                       {
-                               quest_text[i][0] = '\0';
-                       }
-
-                       quest_text_line = 0;
-                       init_flags = INIT_NAME_ONLY;
-                       process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
-                       sprintf(statmsg, _("…あなたは現在、 クエスト「%s」を遂行中だ。", "...Now, you are in the quest '%s'."), quest[floor_ptr->inside_quest].name);
-               }
-               else
-               {
+               sprintf(statmsg, _("…あなたは現在、 %s にいる。", "...Now, you are in %s."), map_name(creature_ptr));
+               return;
+       }
+       
+       if (decide_death_in_quest(creature_ptr, statmsg)) return;
+
 #ifdef JP
-                       sprintf(statmsg, "…あなたは現在、 %s の %d 階で探索している。", map_name(creature_ptr), (int)floor_ptr->dun_level);
+       sprintf(statmsg, "…あなたは現在、 %s の %d 階で探索している。", map_name(creature_ptr), (int)floor_ptr->dun_level);
 #else
-                       sprintf(statmsg, "...Now, you are exploring level %d of %s.", floor_ptr->dun_level, map_name(creature_ptr));
+       sprintf(statmsg, "...Now, you are exploring level %d of %s.", (int)floor_ptr->dun_level, map_name(creature_ptr));
 #endif
-               }
-       }
+}
 
-       if (!*statmsg) return;
 
-       char temp[64 * 2];
+/*!
+ * @brief 今いる、または死亡した場所を表示する
+ * @param statmsg メッセージバッファ
+ * @return なし
+ */
+static void display_current_floor(char *statmsg)
+{
+       char temp[128];
        roff_to_buf(statmsg, 60, temp, sizeof(temp));
        char  *t;
        t = temp;
@@ -264,6 +280,61 @@ void display_player(player_type *creature_ptr, int mode, map_name_pf map_name)
 
 
 /*!
+ * @brief プレイヤーのステータス表示メイン処理
+ * Display the character on the screen (various modes)
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param mode 表示モードID
+ * @return なし
+ * @details
+ * <pre>
+ * The top one and bottom two lines are left blank.
+ * Mode 0 = standard display with skills
+ * Mode 1 = standard display with history
+ * Mode 2 = summary of various things
+ * Mode 3 = summary of various things (part 2)
+ * Mode 4 = mutations
+ * </pre>
+ */
+void display_player(player_type *creature_ptr, int mode, map_name_pf map_name)
+{
+       if ((creature_ptr->muta1 || creature_ptr->muta2 || creature_ptr->muta3) && display_mutations)
+               mode = (mode % 5);
+       else
+               mode = (mode % 4);
+
+       clear_from(0);
+       if (display_player_info(creature_ptr, mode)) return;
+
+       display_player_basic_info(creature_ptr);
+       display_magic_realms(creature_ptr);
+
+       if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || (creature_ptr->muta2 & MUT2_CHAOS_GIFT))
+               display_player_one_line(ENTRY_PATRON, chaos_patrons[creature_ptr->chaos_patron], TERM_L_BLUE);
+
+       display_phisique(creature_ptr);
+       display_player_stats(creature_ptr);
+
+       if (mode == 0)
+       {
+               display_player_middle(creature_ptr);
+               display_player_various(creature_ptr);
+               return;
+       }
+
+       char statmsg[1000];
+       put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
+       for (int i = 0; i < 4; i++)
+               put_str(creature_ptr->history[i], i + 12, 10);
+
+       *statmsg = '\0';
+       decide_current_floor(creature_ptr, statmsg, map_name);
+       if (!*statmsg) return;
+
+       display_current_floor(statmsg);
+}
+
+
+/*!
  * todo y = 6、x = 0、mode = 0で固定。何とかする
  * @brief プレイヤーの装備一覧をシンボルで並べる
  * Equippy chars