1 #include "info-reader/ego-reader.h"
2 #include "info-reader/kind-info-tokens-table.h"
3 #include "object-enchant/object-ego.h"
4 #include "object-enchant/tr-types.h"
5 #include "util/bit-flags-calculator.h"
6 #include "view/display-messages.h"
9 * @brief テキストトークンを走査してフラグを一つ得る(エゴ用) /
10 * Grab one flag in a ego-item_type from a textual string
11 * @param e_ptr 保管先のエゴ構造体参照ポインタ
12 * @param what 参照元の文字列ポインタ
13 * @return エラーがあった場合1、エラーがない場合0を返す
15 static bool grab_one_ego_item_flag(ego_item_type *e_ptr, concptr what)
17 for (int i = 0; i < TR_FLAG_MAX; i++) {
18 if (streq(what, k_info_flags[i])) {
19 add_flag(e_ptr->flags, i);
24 if (grab_one_flag(&e_ptr->gen_flags, k_info_gen_flags, what) == 0)
27 msg_format(_("未知の名のあるアイテム・フラグ '%s'。", "Unknown ego-item flag '%s'."), what);
32 * @brief アイテムエゴ情報(e_info)のパース関数 /
33 * Initialize the "e_info" array, by parsing an ascii "template" file
38 errr parse_e_info(char *buf, angband_header *head)
40 static ego_item_type *e_ptr = NULL;
45 s = angband_strchr(buf + 2, ':');
54 int i = atoi(buf + 2);
57 if (i >= head->info_num)
63 if (!add_name(&e_ptr->name, head, s))
72 else if (buf[0] == 'E') {
76 else if (buf[0] == 'E') {
78 if (!add_name(&e_ptr->name, head, s))
82 else if (buf[0] == 'X') {
84 if (2 != sscanf(buf + 2, "%d:%d", &slot, &rating))
87 e_ptr->slot = (INVENTORY_IDX)slot;
88 e_ptr->rating = (PRICE)rating;
89 } else if (buf[0] == 'W') {
90 int level, rarity, pad2;
93 if (4 != sscanf(buf + 2, "%d:%d:%d:%ld", &level, &rarity, &pad2, &cost))
97 e_ptr->rarity = (RARITY)rarity;
99 } else if (buf[0] == 'C') {
100 int th, td, ta, pval;
102 if (4 != sscanf(buf + 2, "%d:%d:%d:%d", &th, &td, &ta, &pval))
105 e_ptr->max_to_h = (HIT_PROB)th;
106 e_ptr->max_to_d = (HIT_POINT)td;
107 e_ptr->max_to_a = (ARMOUR_CLASS)ta;
108 e_ptr->max_pval = (PARAMETER_VALUE)pval;
109 } else if (buf[0] == 'U') {
111 n = grab_one_activation_flag(buf + 2);
117 } else if (buf[0] == 'F') {
118 for (s = buf + 2; *s;) {
120 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
125 while ((*t == ' ') || (*t == '|'))
129 if (0 != grab_one_ego_item_flag(e_ptr, s))