1 #include "birth/auto-roller.h"
2 #include "birth/birth-stat.h"
3 #include "birth/birth-util.h"
4 #include "cmd-io/cmd-gameoption.h"
5 #include "io/input-key-acceptor.h"
6 #include "main/sound-of-music.h"
7 #include "player/player-class.h"
8 #include "player/player-personality.h"
9 #include "player/player-race.h"
10 #include "player/player-status-table.h"
11 #include "system/game-option-types.h"
12 #include "term/screen-processor.h"
13 #include "term/term-color-types.h"
14 #include "util/int-char-converter.h"
16 /*! オートローラの能力値的要求水準 / Autoroll limit */
19 /*! オートローラの試行回数 / Autoroll round */
21 s32b auto_upper_round;
27 * @breif オートローラーで指定した能力値以上が出る確率を計算する。
30 static s32b get_autoroller_prob(int *minval)
32 /* 1 percent of the valid random space (60^6 && 72<sum<87) */
33 s32b tot_rand_1p = 320669745;
42 /* random combinations out of 60 (1d3+1d4+1d5) patterns */
44 0, 0, 0, 0, 0, 0, 0, 0, /* 0-7 */
45 1, 3, 6, 9, 11, 11, 9, 6, 3, 1 /* 8-17 */
49 for (i = 0; i < 6; i++) {
50 tval[i] = MAX(8, minval[i]);
58 /* bubble sort for speed-up */
59 for (i = 0; i < 5; i++) {
60 for (j = 5; j > i; j--) {
61 if (tval[j - 1] < tval[j]) {
63 tval[j - 1] = tval[j];
72 for (ii[0] = tval[0]; ii[0] < 18; ii[0]++) {
73 for (ii[1] = tval[1]; ii[1] < 18; ii[1]++) {
74 for (ii[2] = tval[2]; ii[2] < 18; ii[2]++) {
75 for (ii[3] = tval[3]; ii[3] < 18; ii[3]++) {
76 for (ii[4] = tval[4]; ii[4] < 18; ii[4]++) {
77 for (ii[5] = tval[5]; ii[5] < 18; ii[5]++) {
78 tot = ii[0] + ii[1] + ii[2] + ii[3] + ii[4] + ii[5];
85 succ += (pp[ii[0]] * pp[ii[1]] * pp[ii[2]] * pp[ii[3]] * pp[ii[4]] * pp[ii[5]]);
87 /* If given condition is easy enough, quit calc. to save CPU. */
97 return tot_rand_1p / succ;
101 * @brief オートローラで得たい能力値の基準を決める。
102 * @param creature_ptr プレーヤーへの参照ポインタ
105 bool get_stat_limits(player_type *creature_ptr)
110 put_str(_("最低限得たい能力値を設定して下さい。", "Set minimum stats."), 10, 10);
111 put_str(_("2/8で項目選択、4/6で値の増減、Enterで次へ", "2/8 for Select, 4/6 for Change value, Enter for Goto next"), 11, 10);
112 put_str(_(" 基本値 種族 職業 性格 合計値 最大値", " Base Rac Cla Per Total Maximum"), 13, 10);
114 put_str(_("確率: 非常に容易(1/10000以上)", "Prob: Quite Easy(>1/10000)"), 23, col_stat);
120 for (int i = 0; i < A_MAX; i++) {
122 int j = rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i];
123 int m = adjust_stat(17, j);
125 sprintf(cur, "18/%02d", (m - 18));
127 sprintf(cur, "%2d", m);
129 m = adjust_stat(cval[i], j);
131 sprintf(inp, "18/%02d", (m - 18));
133 sprintf(inp, "%2d", m);
135 sprintf(buf, "%6s %2d %+3d %+3d %+3d = %6s %6s", stat_names[i], cval[i], rp_ptr->r_adj[i], cp_ptr->c_adj[i], ap_ptr->a_adj[i], inp, cur);
136 put_str(buf, 14 + i, 10);
144 autoroll_chance = get_autoroller_prob(cval);
145 if (autoroll_chance == -999)
146 sprintf(buf, _("確率: 不可能(合計86超) ", "Prob: Impossible(>86 tot stats)"));
147 else if (autoroll_chance < 1)
148 sprintf(buf, _("確率: 非常に容易(1/10000以上)", "Prob: Quite Easy(>1/10000) "));
150 sprintf(buf, _("確率: 約 1/%8d00 ", "Prob: ~ 1/%8d00 "), autoroll_chance);
151 put_str(buf, 23, col_stat);
154 c_put_str(TERM_WHITE, _("決定する", "Accept"), 21, 35);
155 } else if (os < A_MAX) {
156 c_put_str(TERM_WHITE, cur, 14 + os, 10);
159 c_put_str(TERM_YELLOW, _("決定する", "Accept"), 21, 35);
161 int j = rp_ptr->r_adj[cs] + cp_ptr->c_adj[cs] + ap_ptr->a_adj[cs];
162 int m = adjust_stat(cval[cs], j);
164 sprintf(inp, "18/%02d", (m - 18));
166 sprintf(inp, "%2d", m);
169 cur, "%6s %2d %+3d %+3d %+3d = %6s", stat_names[cs], cval[cs], rp_ptr->r_adj[cs], cp_ptr->c_adj[cs], ap_ptr->a_adj[cs], inp);
170 c_put_str(TERM_YELLOW, cur, 14 + cs, 10);
209 } else if (cval[cs] > 3) {
220 if (cval[cs] == 17) {
223 } else if (cval[cs] < 17) {
247 show_help(creature_ptr, "jbirth.txt#AutoRoller");
249 show_help(creature_ptr, "birth.txt#AutoRoller");
255 do_cmd_options_aux(creature_ptr, OPT_PAGE_BIRTH, "初期オプション((*)はスコアに影響)");
257 do_cmd_options_aux(creature_ptr, OPT_PAGE_BIRTH, "Birth Options ((*)) affect score");
267 if (c == ESCAPE || ((c == ' ' || c == '\r' || c == '\n') && cs == 6 && autoroll_chance != -999))
271 for (int i = 0; i < A_MAX; i++)
272 stat_limit[i] = (s16b)cval[i];
277 void initialize_chara_limit(chara_limit_type *chara_limit_ptr)
279 chara_limit_ptr->agemin = 0;
280 chara_limit_ptr->agemax = 0;
281 chara_limit_ptr->htmin = 0;
282 chara_limit_ptr->htmax = 0;
283 chara_limit_ptr->wtmin = 0;
284 chara_limit_ptr->wtmax = 0;
285 chara_limit_ptr->scmin = 0;
286 chara_limit_ptr->scmax = 0;
290 * @brief オートローラで得たい年齢、身長、体重、社会的地位の基準を決める。
293 bool get_chara_limits(player_type *creature_ptr, chara_limit_type *chara_limit_ptr)
297 char buf[80], cur[80];
298 concptr itemname[] = { _("年齢", "age"), _("身長(インチ)", "height"), _("体重(ポンド)", "weight"), _("社会的地位", "social class") };
301 put_str(_("2/4/6/8で項目選択、+/-で値の増減、Enterで次へ", "2/4/6/8 for Select, +/- for Change value, Enter for Goto next"), 11, 10);
303 _("注意:身長と体重の最大値/最小値ぎりぎりの値は非常に出現確率が低くなります。", "Caution: Values near minimum or maximum are extremely rare."), 23, 2);
305 int max_percent, min_percent;
306 if (creature_ptr->psex == SEX_MALE) {
307 max_percent = (int)(rp_ptr->m_b_ht + rp_ptr->m_m_ht * 4 - 1) * 100 / (int)(rp_ptr->m_b_ht);
308 min_percent = (int)(rp_ptr->m_b_ht - rp_ptr->m_m_ht * 4 + 1) * 100 / (int)(rp_ptr->m_b_ht);
310 max_percent = (int)(rp_ptr->f_b_ht + rp_ptr->f_m_ht * 4 - 1) * 100 / (int)(rp_ptr->f_b_ht);
311 min_percent = (int)(rp_ptr->f_b_ht - rp_ptr->f_m_ht * 4 + 1) * 100 / (int)(rp_ptr->f_b_ht);
314 put_str(_("体格/地位の最小値/最大値を設定して下さい。", "Set minimum/maximum attribute."), 10, 10);
315 put_str(_(" 項 目 最小値 最大値", " Parameter Min Max"), 13, 20);
318 for (int i = 0; i < MAXITEMS; i++) {
321 case 0: /* Minimum age */
322 m = rp_ptr->b_age + 1;
324 case 1: /* Maximum age */
325 m = rp_ptr->b_age + rp_ptr->m_age;
328 case 2: /* Minimum height */
329 if (creature_ptr->psex == SEX_MALE)
330 m = rp_ptr->m_b_ht - rp_ptr->m_m_ht * 4 + 1;
332 m = rp_ptr->f_b_ht - rp_ptr->f_m_ht * 4 + 1;
334 case 3: /* Maximum height */
335 if (creature_ptr->psex == SEX_MALE)
336 m = rp_ptr->m_b_ht + rp_ptr->m_m_ht * 4 - 1;
338 m = rp_ptr->f_b_ht + rp_ptr->f_m_ht * 4 - 1;
340 case 4: /* Minimum weight */
341 if (creature_ptr->psex == SEX_MALE)
342 m = (rp_ptr->m_b_wt * min_percent / 100) - (rp_ptr->m_m_wt * min_percent / 75) + 1;
344 m = (rp_ptr->f_b_wt * min_percent / 100) - (rp_ptr->f_m_wt * min_percent / 75) + 1;
346 case 5: /* Maximum weight */
347 if (creature_ptr->psex == SEX_MALE)
348 m = (rp_ptr->m_b_wt * max_percent / 100) + (rp_ptr->m_m_wt * max_percent / 75) - 1;
350 m = (rp_ptr->f_b_wt * max_percent / 100) + (rp_ptr->f_m_wt * max_percent / 75) - 1;
352 case 6: /* Minimum social class */
355 case 7: /* Maximum social class */
367 for (int i = 0; i < 4; i++) {
368 sprintf(buf, "%-12s (%3d - %3d)", itemname[i], mval[i * 2], mval[i * 2 + 1]);
369 put_str(buf, 14 + i, 20);
370 for (int j = 0; j < 2; j++) {
371 sprintf(buf, " %3d", cval[i * 2 + j]);
372 put_str(buf, 14 + i, 45 + 8 * j);
380 const char accept[] = _("決定する", "Accept");
382 c_put_str(TERM_WHITE, accept, 19, 35);
384 c_put_str(TERM_WHITE, cur, 14 + os / 2, 45 + 8 * (os % 2));
386 if (cs == MAXITEMS) {
387 c_put_str(TERM_YELLOW, accept, 19, 35);
389 sprintf(cur, " %3d", cval[cs]);
390 c_put_str(TERM_YELLOW, cur, 14 + cs / 2, 45 + 8 * (cs % 2));
404 break; /*後でもう一回breakせんと*/
437 if (cs != MAXITEMS) {
439 if (cval[cs] > cval[cs - 1]) {
444 if (cval[cs] > mval[cs]) {
454 if (cs != MAXITEMS) {
456 if (cval[cs] < mval[cs]) {
461 if (cval[cs] < cval[cs + 1]) {
470 if (cs != MAXITEMS) {
472 if (cval[cs] < mval[cs]) {
477 if (cval[cs] < cval[cs + 1]) {
478 cval[cs] = cval[cs + 1];
486 if (cs != MAXITEMS) {
488 if (cval[cs] > cval[cs - 1]) {
489 cval[cs] = cval[cs - 1];
493 if (cval[cs] > mval[cs]) {
503 show_help(creature_ptr, "jbirth.txt#AutoRoller");
505 show_help(creature_ptr, "birth.txt#AutoRoller");
510 do_cmd_options_aux(creature_ptr, OPT_PAGE_BIRTH, _("初期オプション((*)はスコアに影響)", "Birth Options ((*)) affect score"));
518 if (c == ESCAPE || ((c == ' ' || c == '\r' || c == '\n') && cs == MAXITEMS))
522 chara_limit_ptr->agemin = (s16b)cval[0];
523 chara_limit_ptr->agemax = (s16b)cval[1];
524 chara_limit_ptr->htmin = (s16b)cval[2];
525 chara_limit_ptr->htmax = (s16b)cval[3];
526 chara_limit_ptr->wtmin = (s16b)cval[4];
527 chara_limit_ptr->wtmax = (s16b)cval[5];
528 chara_limit_ptr->scmin = (s16b)cval[6];
529 chara_limit_ptr->scmax = (s16b)cval[7];