1 #include "wizard/artifact-analyzer.h"
2 #include "flavor/flavor-describer.h"
3 #include "flavor/object-flavor-types.h"
4 #include "locale/japanese.h"
5 #include "object-enchant/object-ego.h"
6 #include "object-enchant/trc-types.h"
7 #include "object-enchant/trg-types.h"
8 #include "object/object-flags.h"
9 #include "object/object-info.h"
10 #include "system/artifact-type-definition.h"
11 #include "system/object-type-definition.h"
12 #include "util/bit-flags-calculator.h"
13 #include "util/enum-range.h"
14 #include "util/quarks.h"
15 #include "wizard/spoiler-util.h"
18 * @brief アーティファクトの特性一覧を出力する /
19 * Write a line to the spoiler file and then "underline" it with hypens
20 * @param art_flags アーティファクトのフラグ群
21 * @param flag_ptr フラグ記述情報の参照ポインタ
22 * @param desc_ptr 記述内容を返すための文字列参照ポインタ
23 * @param n_elmnts フラグの要素数
24 * @return desc_ptrと同じアドレス
27 * This function does most of the actual "analysis". Given a set of bit flags
28 * (which will be from one of the flags fields from the object in question),
29 * a "flag description structure", a "description list", and the number of
30 * elements in the "flag description structure", this function sets the
31 * "description list" members to the appropriate descriptions contained in
32 * the "flag description structure".
33 * The possibly updated description pointer is returned.
36 static concptr *spoiler_flag_aux(const TrFlags &art_flags, const flag_desc *flag_ptr, concptr *desc_ptr, const int n_elmnts)
38 for (int i = 0; i < n_elmnts; ++i) {
39 if (art_flags.has(flag_ptr[i].flag)) {
40 *desc_ptr++ = flag_ptr[i].desc;
48 * @brief アイテムの特定記述内容を返す /
49 * Acquire a "basic" description "The Cloak of Death [1,+10]"
50 * @param o_ptr 記述を得たいオブジェクトの参照ポインタ
51 * @param desc_ptr 記述内容を返すための文字列参照ポインタ
53 static void analyze_general(PlayerType *player_ptr, ObjectType *o_ptr, char *desc_ptr)
55 describe_flavor(player_ptr, desc_ptr, o_ptr, OD_NAME_AND_ENCHANT | OD_STORE | OD_DEBUG);
59 * @brief アーティファクトがプレイヤーに与えるpval修正を構造体に収める /
60 * List "player traits" altered by an artifact's pval. These include stats,
61 * speed, infravision, tunneling, stealth, searching, and extra attacks.
62 * @param o_ptr オブジェクト構造体の参照ポインタ
63 * @param pi_ptr pval修正構造体の参照ポインタ
65 static void analyze_pval(ObjectType *o_ptr, pval_info_type *pi_ptr)
67 concptr *affects_list;
69 pi_ptr->pval_desc[0] = '\0';
73 auto flgs = object_flags(o_ptr);
74 affects_list = pi_ptr->pval_affects;
75 sprintf(pi_ptr->pval_desc, "%s%d", o_ptr->pval >= 0 ? "+" : "", o_ptr->pval);
76 if (flgs.has_all_of(EnumRange(TR_STR, TR_CHR))) {
77 *affects_list++ = _("全能力", "All stats");
78 } else if (flgs.has_any_of(EnumRange(TR_STR, TR_CHR))) {
79 affects_list = spoiler_flag_aux(flgs, stat_flags_desc, affects_list, N_ELEMENTS(stat_flags_desc));
82 affects_list = spoiler_flag_aux(flgs, pval_flags1_desc, affects_list, N_ELEMENTS(pval_flags1_desc));
83 *affects_list = nullptr;
87 * @brief アーティファクトの種族スレイ特性を構造体に収める /
88 * Note the slaying specialties of a weapon
89 * @param o_ptr オブジェクト構造体の参照ポインタ
90 * @param slay_list 種族スレイ構造体の参照ポインタ
92 static void analyze_slay(ObjectType *o_ptr, concptr *slay_list)
94 auto flgs = object_flags(o_ptr);
95 slay_list = spoiler_flag_aux(flgs, slay_flags_desc, slay_list, N_ELEMENTS(slay_flags_desc));
100 * @brief アーティファクトの属性ブランド特性を構造体に収める /
101 * Note an object's elemental brands
102 * @param o_ptr オブジェクト構造体の参照ポインタ
103 * @param brand_list 属性ブランド構造体の参照ポインタ
105 static void analyze_brand(ObjectType *o_ptr, concptr *brand_list)
107 auto flgs = object_flags(o_ptr);
108 brand_list = spoiler_flag_aux(flgs, brand_flags_desc, brand_list, N_ELEMENTS(brand_flags_desc));
109 *brand_list = nullptr;
113 * @brief アーティファクトの通常耐性を構造体に収める /
114 * Note an object's elemental brands
115 * @param o_ptr オブジェクト構造体の参照ポインタ
116 * @param resist_list 通常耐性構造体の参照ポインタ
118 static void analyze_resist(ObjectType *o_ptr, concptr *resist_list)
120 auto flgs = object_flags(o_ptr);
121 resist_list = spoiler_flag_aux(flgs, resist_flags_desc, resist_list, N_ELEMENTS(resist_flags_desc));
122 *resist_list = nullptr;
126 * @brief アーティファクトの免疫特性を構造体に収める /
127 * Note the immunities granted by an object
128 * @param o_ptr オブジェクト構造体の参照ポインタ
129 * @param immune_list 免疫構造体の参照ポインタ
131 static void analyze_immune(ObjectType *o_ptr, concptr *immune_list)
133 auto flgs = object_flags(o_ptr);
134 immune_list = spoiler_flag_aux(flgs, immune_flags_desc, immune_list, N_ELEMENTS(immune_flags_desc));
135 *immune_list = nullptr;
139 * @brief アーティファクトの弱点付与を構造体に収める /
140 * Note the immunities granted by an object
141 * @param o_ptr オブジェクト構造体の参照ポインタ
142 * @param immune_list 弱点構造体の参照ポインタ
144 static void analyze_vulnerable(ObjectType *o_ptr, concptr *vulnerable_list)
146 auto flgs = object_flags(o_ptr);
147 vulnerable_list = spoiler_flag_aux(flgs, vulnerable_flags_desc, vulnerable_list, N_ELEMENTS(vulnerable_flags_desc));
148 *vulnerable_list = nullptr;
152 * @brief アーティファクトの維持特性を構造体に収める /
153 * Note which stats an object sustains
154 * @param o_ptr オブジェクト構造体の参照ポインタ
155 * @param sustain_list 維持特性構造体の参照ポインタ
157 static void analyze_sustains(ObjectType *o_ptr, concptr *sustain_list)
159 auto flgs = object_flags(o_ptr);
160 if (flgs.has_all_of(EnumRange(TR_SUST_STR, TR_SUST_CHR))) {
161 *sustain_list++ = _("全能力", "All stats");
162 } else if (flgs.has_any_of(EnumRange(TR_SUST_STR, TR_SUST_CHR))) {
163 sustain_list = spoiler_flag_aux(flgs, sustain_flags_desc, sustain_list, N_ELEMENTS(sustain_flags_desc));
166 *sustain_list = nullptr;
170 * @brief アーティファクトのその他の特性を構造体に収める /
171 * Note miscellaneous powers bestowed by an artifact such as see invisible,
172 * free action, permanent light, etc.
173 * @param o_ptr オブジェクト構造体の参照ポインタ
174 * @param misc_list その他の特性構造体の参照ポインタ
176 static void analyze_misc_magic(ObjectType *o_ptr, concptr *misc_list)
180 auto flgs = object_flags(o_ptr);
181 misc_list = spoiler_flag_aux(flgs, misc_flags2_desc, misc_list, N_ELEMENTS(misc_flags2_desc));
182 misc_list = spoiler_flag_aux(flgs, misc_flags3_desc, misc_list, N_ELEMENTS(misc_flags3_desc));
184 if (flgs.has(TR_LITE_1)) {
188 if (flgs.has(TR_LITE_2)) {
192 if (flgs.has(TR_LITE_3)) {
196 if (flgs.has(TR_LITE_M1)) {
200 if (flgs.has(TR_LITE_M2)) {
204 if (flgs.has(TR_LITE_M3)) {
208 if (o_ptr->ego_idx == EgoType::LITE_SHINE) {
212 if (flgs.has(TR_LITE_FUEL)) {
214 sprintf(desc, _("それは燃料補給によって明かり(半径 %d)を授ける。", "It provides light (radius %d) when fueled."), (int)rad);
218 sprintf(desc, _("永久光源(半径 %d)", "Permanent Light(radius %d)"), (int)rad);
222 sprintf(desc, _("永久光源(半径-%d)。", "Permanent Light(radius -%d)"), (int)-rad);
227 *misc_list++ = quark_str(quark_add(desc));
230 if (flgs.has(TR_TY_CURSE)) {
231 *misc_list++ = _("太古の怨念", "Ancient Curse");
234 if (o_ptr->curse_flags.has(CurseTraitType::PERMA_CURSE)) {
235 *misc_list++ = _("永遠の呪い", "Permanently Cursed");
236 } else if (o_ptr->curse_flags.has(CurseTraitType::HEAVY_CURSE)) {
237 *misc_list++ = _("強力な呪い", "Heavily Cursed");
238 } else if (o_ptr->curse_flags.has(CurseTraitType::CURSED)) {
239 *misc_list++ = _("呪い", "Cursed");
242 if (flgs.has(TR_ADD_L_CURSE)) {
243 *misc_list++ = _("呪いを増やす", "Cursing");
246 if (flgs.has(TR_ADD_H_CURSE)) {
247 *misc_list++ = _("強力な呪いを増やす", "Heavily Cursing");
250 *misc_list = nullptr;
254 * @brief アーティファクトの追加ランダム特性を構造体に収める /
255 * Note additional ability and/or resistance of fixed artifacts
256 * @param o_ptr オブジェクト構造体の参照ポインタ
257 * @param addition 追加ランダム耐性構造体の参照ポインタ
259 static void analyze_addition(ObjectType *o_ptr, char *addition)
261 auto *a_ptr = &a_info[o_ptr->fixed_artifact_idx];
262 strcpy(addition, "");
264 if (a_ptr->gen_flags.has_all_of({ ItemGenerationTraitType::XTRA_POWER, ItemGenerationTraitType::XTRA_H_RES })) {
265 strcat(addition, _("能力and耐性", "Ability and Resistance"));
266 } else if (a_ptr->gen_flags.has(ItemGenerationTraitType::XTRA_POWER)) {
267 strcat(addition, _("能力", "Ability"));
268 if (a_ptr->gen_flags.has(ItemGenerationTraitType::XTRA_RES_OR_POWER)) {
269 strcat(addition, _("(1/2でand耐性)", "(plus Resistance about 1/2)"));
271 } else if (a_ptr->gen_flags.has(ItemGenerationTraitType::XTRA_H_RES)) {
272 strcat(addition, _("耐性", "Resistance"));
273 if (a_ptr->gen_flags.has(ItemGenerationTraitType::XTRA_RES_OR_POWER)) {
274 strcat(addition, _("(1/2でand能力)", "(plus Ability about 1/2)"));
276 } else if (a_ptr->gen_flags.has(ItemGenerationTraitType::XTRA_RES_OR_POWER)) {
277 strcat(addition, _("能力or耐性", "Ability or Resistance"));
280 if (a_ptr->gen_flags.has(ItemGenerationTraitType::XTRA_DICE)) {
281 if (strlen(addition) > 0) {
282 strcat(addition, _("、", ", "));
284 strcat(addition, _("ダイス数", "Dice number"));
289 * @brief アーティファクトの基本情報を文字列に収める /
290 * Determine the minimum depth an artifact can appear, its rarity, its weight,
291 * and its value in gold pieces
292 * @param o_ptr オブジェクト構造体の参照ポインタ
293 * @param misc_desc 基本情報を収める文字列参照ポインタ
295 static void analyze_misc(ObjectType *o_ptr, char *misc_desc)
297 auto *a_ptr = &a_info[o_ptr->fixed_artifact_idx];
298 sprintf(misc_desc, _("レベル %d, 希少度 %u, %d.%d kg, $%ld", "Level %d, Rarity %u, %d.%d lbs, %ld Gold"), (int)a_ptr->level, a_ptr->rarity,
299 _(lb_to_kg_integer(a_ptr->weight), a_ptr->weight / 10), _(lb_to_kg_fraction(a_ptr->weight), a_ptr->weight % 10), (long int)a_ptr->cost);
303 * @brief アーティファクトの情報全体を構造体に収める /
304 * Fill in an object description structure for a given object
305 * and its value in gold pieces
306 * @param player_ptr プレイヤーへの参照ポインタ
307 * @param o_ptr オブジェクト構造体の参照ポインタ
308 * @param desc_ptr 全アーティファクト情報を収める文字列参照ポインタ
310 void object_analyze(PlayerType *player_ptr, ObjectType *o_ptr, obj_desc_list *desc_ptr)
312 analyze_general(player_ptr, o_ptr, desc_ptr->description);
313 analyze_pval(o_ptr, &desc_ptr->pval_info);
314 analyze_brand(o_ptr, desc_ptr->brands);
315 analyze_slay(o_ptr, desc_ptr->slays);
316 analyze_immune(o_ptr, desc_ptr->immunities);
317 analyze_resist(o_ptr, desc_ptr->resistances);
318 analyze_vulnerable(o_ptr, desc_ptr->vulnerables);
319 analyze_sustains(o_ptr, desc_ptr->sustains);
320 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
321 analyze_addition(o_ptr, desc_ptr->addition);
322 analyze_misc(o_ptr, desc_ptr->misc_desc);
323 desc_ptr->activation = activation_explanation(o_ptr);
327 * @brief ランダムアーティファクト1件を解析する /
328 * Fill in an object description structure for a given object
329 * @param player_ptr プレイヤーへの参照ポインタ
330 * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
331 * @param desc_ptr 記述内容を収める構造体参照ポインタ
333 void random_artifact_analyze(PlayerType *player_ptr, ObjectType *o_ptr, obj_desc_list *desc_ptr)
335 analyze_general(player_ptr, o_ptr, desc_ptr->description);
336 analyze_pval(o_ptr, &desc_ptr->pval_info);
337 analyze_brand(o_ptr, desc_ptr->brands);
338 analyze_slay(o_ptr, desc_ptr->slays);
339 analyze_immune(o_ptr, desc_ptr->immunities);
340 analyze_resist(o_ptr, desc_ptr->resistances);
341 analyze_vulnerable(o_ptr, desc_ptr->vulnerables);
342 analyze_sustains(o_ptr, desc_ptr->sustains);
343 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
344 desc_ptr->activation = activation_explanation(o_ptr);
345 sprintf(desc_ptr->misc_desc, _("重さ %d.%d kg", "Weight %d.%d lbs"), _(lb_to_kg_integer(o_ptr->weight), o_ptr->weight / 10),
346 _(lb_to_kg_fraction(o_ptr->weight), o_ptr->weight % 10));