OSDN Git Service

Merge remote-tracking branch 'remotes/origin/feature/Fix-English-Bugs' into develop
[hengband/hengband.git] / src / birth / birth-wizard.c
index f1ca361..d8127d5 100644 (file)
 #include "cmd-io/cmd-gameoption.h"
 #include "cmd-io/cmd-help.h"
 #include "core/asking-player.h"
+#include "core/player-update-types.h"
 #include "game-option/birth-options.h"
 #include "io/input-key-acceptor.h"
 #include "main/sound-definitions-table.h"
 #include "main/sound-of-music.h"
-#include "player/avatar.h"
+#include "player-info/avatar.h"
 #include "player/patron.h"
+#include "player/player-class.h"
+#include "player/player-race.h"
 #include "player/player-sex.h"
 #include "player/process-name.h"
+#include "player/player-status-table.h"
 #include "system/game-option-types.h"
 #include "term/screen-processor.h"
 #include "term/term-color-types.h"
+#include "util/buffer-shaper.h"
+#include "util/int-char-converter.h"
 #include "view/display-birth.h" // 暫定。後で消す予定。
-#include "view/display-main-window.h" // 暫定。後で消す.
 #include "view/display-player.h" // 暫定。後で消す.
 #include "world/world.h"
 
  * system may have problems because the user can't stop the
  * autoroller for this number of rolls.
  */
-#define AUTOROLLER_STEP 5431L
+#define AUTOROLLER_STEP 54321L
 
 static void display_initial_birth_message(player_type *creature_ptr)
 {
-    Term_clear();
+    term_clear();
     put_str(_("名前  :", "Name  :"), 1, 26);
     put_str(_("性別        :", "Sex         :"), 3, 1);
     put_str(_("種族        :", "Race        :"), 4, 1);
     put_str(_("職業        :", "Class       :"), 5, 1);
     c_put_str(TERM_L_BLUE, creature_ptr->name, 1, 34);
-    put_str(_("キャラクターを作成します。('S'やり直す, 'Q'終了, '?'ヘルプ)", "Make your charactor. ('S' Restart, 'Q' Quit, '?' Help)"), 8, 10);
+    put_str(_("キャラクターを作成します。('S'やり直す, 'Q'終了, '?'ヘルプ)", "Make your character. ('S' Restart, 'Q' Quit, '?' Help)"), 8, 10);
     put_str(_("注意:《性別》の違いはゲーム上ほとんど影響を及ぼしません。", "Note: Your 'sex' does not have any significant gameplay effects."), 23, 5);
 }
 
@@ -159,7 +164,7 @@ static bool let_player_select_race(player_type *creature_ptr)
             return FALSE;
 
         clear_from(10);
-        roff_to_buf(race_explanations[creature_ptr->prace], 74, temp, sizeof(temp));
+        shape_buffer(race_explanations[creature_ptr->prace], 74, temp, sizeof(temp));
         concptr t = temp;
         for (int i = 0; i < 10; i++) {
             if (t[0] == 0)
@@ -189,7 +194,7 @@ static bool let_player_select_class(player_type *creature_ptr)
             return FALSE;
 
         clear_from(10);
-        roff_to_buf(class_explanations[creature_ptr->pclass], 74, temp, sizeof(temp));
+        shape_buffer(class_explanations[creature_ptr->pclass], 74, temp, sizeof(temp));
         concptr t = temp;
         for (int i = 0; i < 9; i++) {
             if (t[0] == 0)
@@ -218,7 +223,7 @@ static bool let_player_select_personality(player_type *creature_ptr)
             return FALSE;
 
         clear_from(10);
-        roff_to_buf(personality_explanations[creature_ptr->pseikaku], 74, temp, sizeof(temp));
+        shape_buffer(personality_explanations[creature_ptr->pseikaku], 74, temp, sizeof(temp));
         concptr t = temp;
         for (int i = 0; i < A_MAX; i++) {
             if (t[0] == 0)
@@ -276,16 +281,30 @@ static void display_auto_roller_success_rate(const int col)
     if (!autoroller)
         return;
 
-    put_str(_("最小値", " Limit"), 2, col + 5);
-    put_str(_("成功率", "  Freq"), 2, col + 13);
+    put_str(_("最小値", " Limit"), 2, col + 13);
     put_str(_("現在値", "  Roll"), 2, col + 24);
+
+    char buf[32];
+
+    if (autoroll_chance >= 1)
+        sprintf(buf, _("確率 :  1/%8d00", "Prob :  1/%8d00"), autoroll_chance);
+    else if (autoroll_chance == -999)
+        sprintf(buf, _("確率 :     不可能", "Prob :     Impossible"));
+    else
+        sprintf(buf, _("確率 :     1/10000以上", "Prob :     >1/10000"));
+    put_str(buf, 11, col + 10);
+
+    put_str(_(
+        "注意 : 体格等のオートローラを併用時は、上記確率より困難です。",
+        "Note : Prob may be lower when you use the 'autochara' option."
+        ), 22, 5);
+
     for (int i = 0; i < A_MAX; i++) {
-        put_str(stat_names[i], 3 + i, col);
+        put_str(stat_names[i], 3 + i, col + 8);
         int j = rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i];
         int m = adjust_stat(stat_limit[i], j);
-        char buf[32];
         cnv_stat(m, buf);
-        c_put_str(TERM_L_BLUE, buf, 3 + i, col + 5);
+        c_put_str(TERM_L_BLUE, buf, 3 + i, col + 13);
     }
 }
 
@@ -298,9 +317,7 @@ static void auto_roller_count(void)
     if (!autoroller)
         return;
 
-    for (int i = 0; i < A_MAX; i++) {
-        stat_match[i] = 0;
-    }
+    auto_upper_round++;
 }
 
 static bool decide_initial_stat(player_type *creature_ptr)
@@ -310,10 +327,10 @@ static bool decide_initial_stat(player_type *creature_ptr)
 
     bool accept = TRUE;
     for (int i = 0; i < A_MAX; i++) {
-        if (creature_ptr->stat_max[i] >= stat_limit[i])
-            stat_match[i]++;
-        else
+        if (creature_ptr->stat_max[i] < stat_limit[i]) {
             accept = FALSE;
+            break;
+        }
     }
 
     return accept;
@@ -347,8 +364,11 @@ static bool display_auto_roller_count(player_type *creature_ptr, const int col)
         return FALSE;
 
     birth_put_stats(creature_ptr);
-    put_str(format("%10ld", auto_round), 10, col + 20);
-    Term_fresh();
+    if (auto_upper_round)
+        put_str(format("%ld%09ld", auto_upper_round, auto_round), 10, col + 20);
+    else
+        put_str(format("%10ld", auto_round), 10, col + 20);
+    term_fresh();
     inkey_scan = TRUE;
     if (inkey()) {
         get_ahw(creature_ptr);
@@ -382,22 +402,22 @@ static bool display_auto_roller_result(player_type *creature_ptr, bool prev, cha
         update_creature(creature_ptr);
         creature_ptr->chp = creature_ptr->mhp;
         creature_ptr->csp = creature_ptr->msp;
-        display_player(creature_ptr, mode, map_name);
-        Term_gotoxy(2, 23);
+        display_player(creature_ptr, mode);
+        term_gotoxy(2, 23);
         const char b1 = '[';
-        Term_addch(TERM_WHITE, b1);
-        Term_addstr(-1, TERM_WHITE, _("'r' 次の数値", "'r'eroll"));
+        term_addch(TERM_WHITE, b1);
+        term_addstr(-1, TERM_WHITE, _("'r' 次の数値", "'r'eroll"));
         if (prev)
-            Term_addstr(-1, TERM_WHITE, _(", 'p' 前の数値", "'p'previous"));
+            term_addstr(-1, TERM_WHITE, _(", 'p' 前の数値", "'p'previous"));
 
         if (mode)
-            Term_addstr(-1, TERM_WHITE, _(", 'h' その他の情報", ", 'h' Misc."));
+            term_addstr(-1, TERM_WHITE, _(", 'h' その他の情報", ", 'h' Misc."));
         else
-            Term_addstr(-1, TERM_WHITE, _(", 'h' 生い立ちを表示", ", 'h'istory"));
+            term_addstr(-1, TERM_WHITE, _(", 'h' 生い立ちを表示", ", 'h'istory"));
 
-        Term_addstr(-1, TERM_WHITE, _(", Enter この数値に決定", ", or Enter to accept"));
+        term_addstr(-1, TERM_WHITE, _(", Enter この数値に決定", ", or Enter to accept"));
         const char b2 = ']';
-        Term_addch(TERM_WHITE, b2);
+        term_addch(TERM_WHITE, b2);
         *c = inkey();
         if (*c == 'Q')
             birth_quit();
@@ -428,14 +448,22 @@ static bool display_auto_roller_result(player_type *creature_ptr, bool prev, cha
     return TRUE;
 }
 
+/*
+ * @brief オートロールを回して結果を表示し、その数値に決めるかさらに回すか確認する。
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param chara_limit 社会的地位の要求水準
+ * @detail 2つめの結果以降は、'p'キーで1つ前のロール結果に戻せる。
+ */
 static bool display_auto_roller(player_type *creature_ptr, chara_limit_type chara_limit)
 {
+    bool prev = FALSE;
+
     while (TRUE) {
-        int col = 42;
+        int col = 22;
         if (autoroller || autochara) {
-            Term_clear();
-            put_str(_("回数 :", "Round:"), 10, col + 13);
-            put_str(_("(ESCで停止)", "(Hit ESC to stop)"), 12, col + 13);
+            term_clear();
+            put_str(_("回数 :", "Round:"), 10, col + 10);
+            put_str(_("(ESCで停止)", "(Hit ESC to stop)"), 13, col + 13);
         } else {
             get_stats(creature_ptr);
             get_ahw(creature_ptr);
@@ -452,7 +480,7 @@ static bool display_auto_roller(player_type *creature_ptr, chara_limit_type char
         get_extra(creature_ptr, TRUE);
         get_money(creature_ptr);
         creature_ptr->chaos_patron = (s16b)randint0(MAX_PATRON);
-        bool prev = FALSE;
+
         char c;
         if (!display_auto_roller_result(creature_ptr, prev, &c))
             return FALSE;
@@ -509,8 +537,11 @@ bool player_birth_wizard(player_type *creature_ptr, void (*process_autopick_file
         return FALSE;
 
     display_initial_options(creature_ptr);
-    if (autoroller || autochara)
+    if (autoroller || autochara) {
         auto_round = 0L;
+        auto_upper_round = 0L;
+        autoroll_chance = 0L;
+    }
 
     if (autoroller)
         if (!get_stat_limits(creature_ptr))