OSDN Git Service

[Refactor] #38862 Moved angband.h, h-*.h and system-variables.c/h
[hengband/hengband.git] / src / market / say-comments.c
1 #include "system/angband.h"
2 #include "say-comments.h"
3 #include "main/sound-definitions-table.h"
4 #include "market/store-owner-comments.h"
5 #include "market/store-util.h"
6 #include "avatar.h"
7 #include "rumor.h"
8
9 #define RUMOR_CHANCE 8
10
11 /*!
12  * @brief 取引成功時の店主のメッセージ処理 /
13  * ブラックマーケットのときは別のメッセージを出す
14  * Successful haggle.
15  * @param player_ptr プレーヤーへの参照ポインタ
16  * @return なし
17  */
18 void say_comment_1(player_type *player_ptr)
19 {
20 #ifdef JP
21         if (cur_store_num == STORE_BLACK)
22         {
23                 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
24         }
25         else
26         {
27                 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
28         }
29 #else
30         msg_print(comment_1[randint0(MAX_COMMENT_1)]);
31 #endif
32
33         if (one_in_(RUMOR_CHANCE))
34         {
35                 msg_print(_("店主は耳うちした:", "The shopkeeper whispers something into your ear:"));
36                 display_rumor(player_ptr, TRUE);
37         }
38 }
39
40
41 /*!
42  * @brief プレイヤーがアイテムを買う時の価格代案メッセージ処理 /
43  * Continue haggling (player is buying)
44  * @param value 店主の提示価格
45  * @param annoyed 店主のいらつき度
46  * @return なし
47  */
48 void say_comment_2(PRICE value, int annoyed)
49 {
50         char tmp_val[80];
51         sprintf(tmp_val, "%ld", (long)value);
52
53         if (annoyed > 0)
54         {
55                 msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
56                 return;
57         }
58
59 #ifdef JP
60         if (cur_store_num == STORE_BLACK)
61         {
62                 msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
63         }
64         else
65         {
66                 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
67         }
68 #else
69         msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
70 #endif
71 }
72
73
74 /*!
75  * @brief プレイヤーがアイテムを売る時の価格代案メッセージ処理 /
76  * ブラックマーケットのときは別のメッセージを出す
77  * Continue haggling (player is selling)
78  * @param value 店主の提示価格
79  * @param annoyed 店主のいらつき度
80  * @return なし
81  */
82 void say_comment_3(PRICE value, int annoyed)
83 {
84         char tmp_val[80];
85         sprintf(tmp_val, "%ld", (long)value);
86         if (annoyed > 0)
87         {
88                 msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val);
89         }
90         else
91         {
92 #ifdef JP
93                 if (cur_store_num == STORE_BLACK)
94                 {
95                         msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
96                 }
97                 else
98                 {
99                         msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
100                 }
101 #else
102                 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
103 #endif
104         }
105 }
106
107
108 /*!
109  * @brief 店主がプレイヤーを追い出す時のメッセージ処理 /
110  * ブラックマーケットの時は別のメッセージを出す
111  * Kick 'da bum out.                                    -RAK-
112  * @return なし
113  */
114 void say_comment_4(void)
115 {
116 #ifdef JP
117         if (cur_store_num == STORE_BLACK)
118         {
119                 msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
120                 msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
121         }
122         else
123         {
124                 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
125                 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
126         }
127 #else
128         msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
129         msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
130 #endif
131
132 }
133
134
135 /*!
136  * @brief 店主がプレイヤーに取り合わない時のメッセージ処理 /
137  * ブラックマーケットの時は別のメッセージを出す
138  * You are insulting me
139  * @return なし
140  */
141 void say_comment_5(void)
142 {
143 #ifdef JP
144         if (cur_store_num == STORE_BLACK)
145         {
146                 msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
147         }
148         else
149         {
150                 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
151         }
152 #else
153         msg_print(comment_5[randint0(MAX_COMMENT_5)]);
154 #endif
155
156 }
157
158
159 /*!
160  * @brief 店主がプレイヤーの提示を理解できなかった時のメッセージ処理 /
161  * That makes no sense.
162  * @return なし
163  */
164 void say_comment_6(void)
165 {
166         msg_print(comment_6[randint0(MAX_COMMENT_6)]);
167 }
168
169 /*!
170  * @brief 店主が交渉を終えた際の反応を返す処理 /
171  * Let a shop-keeper React to a purchase
172  * @param price アイテムの取引額
173  * @param value アイテムの実際価値
174  * @param guess 店主が当初予想していた価値
175  * @return なし
176  * @details
177  * We paid "price", it was worth "value", and we thought it was worth "guess"
178  */
179 void purchase_analyze(player_type *player_ptr, PRICE price, PRICE value, PRICE guess)
180 {
181         /* Item was worthless, but we bought it */
182         if ((value <= 0) && (price > value))
183         {
184                 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
185                 chg_virtue(player_ptr, V_HONOUR, -1);
186                 chg_virtue(player_ptr, V_JUSTICE, -1);
187                 sound(SOUND_STORE1);
188                 return;
189         }
190
191         /* Item was cheaper than we thought, and we paid more than necessary */
192         if ((value < guess) && (price > value))
193         {
194                 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
195                 chg_virtue(player_ptr, V_JUSTICE, -1);
196                 if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, -1);
197                 sound(SOUND_STORE2);
198                 return;
199         }
200
201         /* Item was a good bargain, and we got away with it */
202         if ((value > guess) && (value < (4 * guess)) && (price < value))
203         {
204                 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
205                 if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, -1);
206                 else if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, 1);
207                 sound(SOUND_STORE3);
208                 return;
209         }
210
211         /* Item was a great bargain, and we got away with it */
212         if ((value > guess) && (price < value))
213         {
214                 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
215                 if (one_in_(2)) chg_virtue(player_ptr, V_HONOUR, -1);
216                 if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, 1);
217                 if (10 * price < value) chg_virtue(player_ptr, V_SACRIFICE, 1);
218                 sound(SOUND_STORE4);
219                 return;
220         }
221 }