OSDN Git Service

[Refactor] ボール系魔法のコピペを低減
[hengbandforosx/hengbandosx.git] / src / store / say-comments.cpp
1 #include "store/say-comments.h"
2 #include "avatar/avatar.h"
3 #include "main/sound-definitions-table.h"
4 #include "main/sound-of-music.h"
5 #include "store/rumor.h"
6 #include "store/store-owner-comments.h"
7 #include "store/store-util.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  */
18 void store_owner_says_comment(PlayerType *player_ptr, StoreSaleType store_num)
19 {
20     if (store_num == StoreSaleType::BLACK) {
21         msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
22     } else {
23         msg_print(comment_1[randint0(MAX_COMMENT_1)]);
24     }
25
26     if (one_in_(RUMOR_CHANCE)) {
27         msg_print(_("店主は耳うちした:", "The shopkeeper whispers something into your ear:"));
28         display_rumor(player_ptr, true);
29     }
30 }
31
32 /*!
33  * @brief 店主が交渉を終えた際の反応を返す処理 /
34  * Let a shop-keeper React to a purchase
35  * @param price アイテムの取引額
36  * @param value アイテムの実際価値
37  * @param guess 店主が当初予想していた価値
38  * @details
39  * We paid "price", it was worth "value", and we thought it was worth "guess"
40  */
41 void purchase_analyze(PlayerType *player_ptr, PRICE price, PRICE value, PRICE guess)
42 {
43     /* Item was worthless, but we bought it */
44     if ((value <= 0) && (price > value)) {
45         msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
46         chg_virtue(player_ptr, V_HONOUR, -1);
47         chg_virtue(player_ptr, V_JUSTICE, -1);
48         sound(SOUND_STORE1);
49         return;
50     }
51
52     /* Item was cheaper than we thought, and we paid more than necessary */
53     if ((value < guess) && (price > value)) {
54         msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
55         chg_virtue(player_ptr, V_JUSTICE, -1);
56         if (one_in_(4)) {
57             chg_virtue(player_ptr, V_HONOUR, -1);
58         }
59         sound(SOUND_STORE2);
60         return;
61     }
62
63     /* Item was a good bargain, and we got away with it */
64     if ((value > guess) && (value < (4 * guess)) && (price < value)) {
65         msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
66         if (one_in_(4)) {
67             chg_virtue(player_ptr, V_HONOUR, -1);
68         } else if (one_in_(4)) {
69             chg_virtue(player_ptr, V_HONOUR, 1);
70         }
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         msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
78         if (one_in_(2)) {
79             chg_virtue(player_ptr, V_HONOUR, -1);
80         }
81         if (one_in_(4)) {
82             chg_virtue(player_ptr, V_HONOUR, 1);
83         }
84         if (10 * price < value) {
85             chg_virtue(player_ptr, V_SACRIFICE, 1);
86         }
87         sound(SOUND_STORE4);
88         return;
89     }
90 }