OSDN Git Service

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