1 #include "info-reader/artifact-reader.h"
2 #include "info-reader/kind-info-tokens-table.h"
3 #include "object-enchant/artifact.h"
4 #include "object-enchant/tr-types.h"
5 #include "view/display-messages.h"
8 * @brief テキストトークンを走査してフラグを一つ得る(アーティファクト用) /
9 * Grab one activation index flag
10 * @param a_ptr 保管先のアーティファクト構造体参照ポインタ
11 * @param what 参照元の文字列ポインタ
12 * @return エラーがあった場合1、エラーがない場合0を返す
14 static errr grab_one_artifact_flag(artifact_type *a_ptr, concptr what)
16 for (int i = 0; i < TR_FLAG_MAX; i++) {
17 if (streq(what, k_info_flags[i])) {
18 add_flag(a_ptr->flags, i);
23 if (grab_one_flag(&a_ptr->gen_flags, k_info_gen_flags, what) == 0)
26 msg_format(_("未知の伝説のアイテム・フラグ '%s'。", "Unknown artifact flag '%s'."), what);
31 * @brief 固定アーティファクト情報(a_info)のパース関数 /
32 * Initialize the "a_info" array, by parsing an ascii "template" file
37 errr parse_a_info(char *buf, angband_header *head)
39 static artifact_type *a_ptr = NULL;
42 s = angband_strchr(buf + 2, ':');
51 int i = atoi(buf + 2);
54 if (i >= head->info_num)
59 add_flag(a_ptr->flags, TR_IGNORE_ACID);
60 add_flag(a_ptr->flags, TR_IGNORE_ELEC);
61 add_flag(a_ptr->flags, TR_IGNORE_FIRE);
62 add_flag(a_ptr->flags, TR_IGNORE_COLD);
64 if (!add_name(&a_ptr->name, head, s))
72 /* 'E' から始まる行は英語名としている */
73 else if (buf[0] == 'E') {
77 else if (buf[0] == 'E') {
79 if (!add_name(&a_ptr->name, head, s))
83 else if (buf[0] == 'D') {
93 if (!add_text(&a_ptr->text, head, s, TRUE))
95 } else if (buf[0] == 'I') {
97 if (3 != sscanf(buf + 2, "%d:%d:%d", &tval, &sval, &pval))
100 a_ptr->tval = (tval_type)tval;
101 a_ptr->sval = (OBJECT_SUBTYPE_VALUE)sval;
102 a_ptr->pval = (PARAMETER_VALUE)pval;
103 } else if (buf[0] == 'W') {
104 int level, rarity, wgt;
106 if (4 != sscanf(buf + 2, "%d:%d:%d:%ld", &level, &rarity, &wgt, &cost))
109 a_ptr->level = (DEPTH)level;
110 a_ptr->rarity = (RARITY)rarity;
111 a_ptr->weight = (WEIGHT)wgt;
112 a_ptr->cost = (PRICE)cost;
113 } else if (buf[0] == 'P') {
114 int ac, hd1, hd2, th, td, ta;
115 if (6 != sscanf(buf + 2, "%d:%dd%d:%d:%d:%d", &ac, &hd1, &hd2, &th, &td, &ta))
118 a_ptr->ac = (ARMOUR_CLASS)ac;
119 a_ptr->dd = (DICE_NUMBER)hd1;
120 a_ptr->ds = (DICE_SID)hd2;
121 a_ptr->to_h = (HIT_PROB)th;
122 a_ptr->to_d = (HIT_POINT)td;
123 a_ptr->to_a = (ARMOUR_CLASS)ta;
124 } else if (buf[0] == 'U') {
126 n = grab_one_activation_flag(buf + 2);
132 } else if (buf[0] == 'F') {
133 for (s = buf + 2; *s;) {
135 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
140 while ((*t == ' ') || (*t == '|'))
144 if (0 != grab_one_artifact_flag(a_ptr, s))