OSDN Git Service

Merge pull request #765 from sikabane-works/release/3.0.0Alpha17
[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 store_owner_says_comment(player_type *player_ptr)
20 {
21         if (cur_store_num == STORE_BLACK)
22                 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
23         else
24                 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
25
26         if (one_in_(RUMOR_CHANCE))
27         {
28                 msg_print(_("店主は耳うちした:", "The shopkeeper whispers something into your ear:"));
29                 display_rumor(player_ptr, TRUE);
30         }
31 }
32
33 /*!
34  * @brief 店主が交渉を終えた際の反応を返す処理 /
35  * Let a shop-keeper React to a purchase
36  * @param price アイテムの取引額
37  * @param value アイテムの実際価値
38  * @param guess 店主が当初予想していた価値
39  * @return なし
40  * @details
41  * We paid "price", it was worth "value", and we thought it was worth "guess"
42  */
43 void purchase_analyze(player_type *player_ptr, PRICE price, PRICE value, PRICE guess)
44 {
45         /* Item was worthless, but we bought it */
46         if ((value <= 0) && (price > value))
47         {
48                 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
49                 chg_virtue(player_ptr, V_HONOUR, -1);
50                 chg_virtue(player_ptr, V_JUSTICE, -1);
51                 sound(SOUND_STORE1);
52                 return;
53         }
54
55         /* Item was cheaper than we thought, and we paid more than necessary */
56         if ((value < guess) && (price > value))
57         {
58                 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
59                 chg_virtue(player_ptr, V_JUSTICE, -1);
60                 if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, -1);
61                 sound(SOUND_STORE2);
62                 return;
63         }
64
65         /* Item was a good bargain, and we got away with it */
66         if ((value > guess) && (value < (4 * guess)) && (price < value))
67         {
68                 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
69                 if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, -1);
70                 else if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, 1);
71                 sound(SOUND_STORE3);
72                 return;
73         }
74
75         /* Item was a great bargain, and we got away with it */
76         if ((value > guess) && (price < value))
77         {
78                 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
79                 if (one_in_(2)) chg_virtue(player_ptr, V_HONOUR, -1);
80                 if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, 1);
81                 if (10 * price < value) chg_virtue(player_ptr, V_SACRIFICE, 1);
82                 sound(SOUND_STORE4);
83                 return;
84         }
85 }