2 * @brief オブジェクトの記述処理 / Mbject flavor code
5 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research,\n
8 * and not for profit purposes provided that this copyright and statement\n
9 * are included in all such copies. Other copyrights may also apply.\n
12 #include "flavor/object-flavor.h"
13 #include "combat/shoot.h"
14 #include "flavor/flag-inscriptions-table.h"
15 #include "flavor/flavor-util.h"
16 #include "flavor/object-flavor-types.h"
17 #include "game-option/text-display-options.h"
18 #include "grid/trap.h"
19 #include "inventory/inventory-slot-types.h"
20 #include "io/files-util.h"
21 #include "locale/english.h"
22 #include "locale/japanese.h"
23 #include "mind/mind-sniper.h"
24 #include "mind/mind-weaponsmith.h"
25 #include "monster-race/monster-race.h"
26 #include "object-enchant/object-ego.h"
27 #include "object-enchant/special-object-flags.h"
28 #include "object-enchant/tr-types.h"
29 #include "object-enchant/trg-types.h"
30 #include "object-hook/hook-quest.h"
31 #include "object/object-info.h"
32 #include "perception/object-perception.h"
33 #include "player-info/class-info.h"
34 #include "player/player-status.h"
35 #include "sv-definition/sv-food-types.h"
36 #include "sv-definition/sv-lite-types.h"
37 #include "system/baseitem-info.h"
38 #include "util/bit-flags-calculator.h"
39 #include "util/string-processor.h"
45 * @brief 各種語彙からランダムな名前を作成する
46 * @return std::string 作成した名前
47 * @details 日本語の場合 aname_j.txt 英語の場合確率に応じて
48 * syllables 配列と elvish.txt を組み合わせる
50 std::string get_table_name_aux()
54 ss << *get_random_line("aname_j.txt", 1);
55 ss << *get_random_line("aname_j.txt", 2);
58 static const std::vector<std::string_view> syllables = {
59 "a", "ab", "ag", "aks", "ala", "an", "ankh", "app", "arg", "arze", "ash", "aus", "ban", "bar", "bat", "bek",
60 "bie", "bin", "bit", "bjor", "blu", "bot", "bu", "byt", "comp", "con", "cos", "cre", "dalf", "dan", "den", "der", "doe", "dok", "eep", "el", "eng",
61 "er", "ere", "erk", "esh", "evs", "fa", "fid", "flit", "for", "fri", "fu", "gan", "gar", "glen", "gop", "gre", "ha", "he", "hyd", "i", "ing", "ion",
62 "ip", "ish", "it", "ite", "iv", "jo", "kho", "kli", "klis", "la", "lech", "man", "mar", "me", "mi", "mic", "mik", "mon", "mung", "mur", "nag", "nej",
63 "nelg", "nep", "ner", "nes", "nis", "nih", "nin", "o", "od", "ood", "org", "orn", "ox", "oxy", "pay", "pet", "ple", "plu", "po", "pot", "prok", "re",
64 "rea", "rhov", "ri", "ro", "rog", "rok", "rol", "sa", "san", "sat", "see", "sef", "seh", "shu", "ski", "sna", "sne", "snik", "sno", "so", "sol", "sri",
65 "sta", "sun", "ta", "tab", "tem", "ther", "ti", "tox", "trol", "tue", "turs", "u", "ulk", "um", "un", "uni", "ur", "val", "viv", "vly", "vom", "wah",
66 "wed", "werg", "wex", "whon", "wun", "x", "yerg", "yp", "zun", "tri", "blaa", "jah", "bul", "on", "foo", "ju", "xuxu"
69 int testcounter = randint1(3) + 1;
70 if (randint1(3) == 2) {
71 while (testcounter--) {
72 ss << rand_choice(syllables);
75 testcounter = randint1(2) + 1;
76 while (testcounter--) {
77 ss << *get_random_line("elvish.txt", 0);
82 name[0] = toupper(name[0]);
88 * @brief ランダムな名前をアーティファクト銘として整形する。 / Create a name from random parts with quotes.
89 * @return std::string 作成した名前
90 * @details get_table_name_aux()ほぼ完全に実装を依存している。
92 std::string get_table_name()
94 return std::string(_("『", "'")).append(get_table_name_aux()).append(_("』", "'"));
98 * @brief ランダムなシンダリン銘を作成する / Make random Sindarin name
99 * @return std::string 作成した名前
100 * @details sname.txtが語幹の辞書となっている。
102 std::string get_table_sindarin_aux()
104 std::stringstream ss;
105 ss << *get_random_line("sname.txt", 1);
106 ss << *get_random_line("sname.txt", 2);
107 auto name = ss.str();
108 return _(sindarin_to_kana(name), name);
112 * @brief シンダリン銘をアーティファクト用に整形する。 / Make random Sindarin name with quotes
113 * @param out_string 作成した名を保管する参照ポインタ
114 * @return std::string 作成した名前
115 * @details get_table_sindarin_aux()ほぼ完全に実装を依存している。
117 std::string get_table_sindarin()
119 return std::string(_("『", "'")).append(get_table_sindarin_aux()).append(_("』", "'"));
123 * @brief nameバッファ内からベースアイテム名を返す / Strip an "object name" into a buffer
124 * @param buf ベースアイテム格納先の参照ポインタ
125 * @param bi_id ベースアイテムID
127 std::string strip_name(short bi_id)
129 const auto &baseitem = baseitems_info[bi_id];
130 auto tok = str_split(baseitem.name, ' ');
131 std::stringstream name;
132 for (const auto &s : tok) {
133 if (s == "" || s == "~" || s == "&" || s == "#") {
138 auto endpos = s.size();
139 auto is_kanji = false;
141 if (s[0] == '~' || s[0] == '#') {
146 is_kanji = iskanji(s[endpos - 2]);
150 if (!is_kanji && (s[endpos - 1] == '~' || s[endpos - 1] == '#')) {
154 name << s.substr(offset, endpos);