1 #include "store/owner-insults.h"
2 #include "core/asking-player.h"
3 #include "game-option/birth-options.h"
4 #include "store/say-comments.h"
5 #include "store/store.h"
6 #include "store/store-util.h"
7 #include "term/screen-processor.h"
8 #include "view/display-messages.h"
9 #include "world/world.h"
11 /* Last "increment" during haggling */
12 static s32b last_inc = 0L;
15 * @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
16 * Increase the insult counter and get angry if too many -RAK-
17 * @return プレイヤーを締め出す場合TRUEを返す
19 int increase_insults(void)
22 if (st_ptr->insult_cur <= ot_ptr->insult_max)
26 st_ptr->insult_cur = 0;
29 st_ptr->store_open = current_world_ptr->game_turn + TURNS_PER_TICK * TOWN_DAWN / 8 + randint1(TURNS_PER_TICK * TOWN_DAWN / 8);
35 * Decrease insults -RAK-
36 * @return プレイヤーを締め出す場合TRUEを返す
38 void decrease_insults(void)
40 if (st_ptr->insult_cur)
45 * @brief 店主の不満度が増えた場合のみのメッセージを表示する /
46 * Have insulted while haggling -RAK-
47 * @return プレイヤーを締め出す場合TRUEを返す
49 int haggle_insults(void)
51 if (increase_insults())
59 * @brief 店主の持つプレイヤーに対する売買の良し悪し経験を記憶する /
60 * Update the bargain info
61 * @param price 実際の取引価格
62 * @param minprice 店主の提示した価格
66 void updatebargain(PRICE price, PRICE minprice, int num)
70 if ((minprice / num) < 10L)
72 if (price == minprice) {
73 if (st_ptr->good_buy < MAX_SHORT) {
77 if (st_ptr->bad_buy < MAX_SHORT) {
84 * @brief 交渉価格を確認と認証の是非を行う /
87 * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
88 * @param price 現在の交渉価格
89 * @param final 最終確定価格ならばTRUE
90 * @return プレイヤーを締め出す場合TRUEを返す
92 static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final)
99 sprintf(buf, _("%s [承諾] ", "%s [accept] "), pmt);
100 } else if (last_inc < 0) {
101 sprintf(buf, _("%s [-$%ld] ", "%s [-%ld] "), pmt, (long)(ABS(last_inc)));
102 } else if (last_inc > 0) {
103 sprintf(buf, _("%s [+$%ld] ", "%s [+%ld] "), pmt, (long)(ABS(last_inc)));
105 sprintf(buf, "%s ", pmt);
109 GAME_TEXT out_val[160];
116 * Ask the user for a response.
117 * Don't allow to use numpad as cursor key.
119 res = askfor_aux(out_val, 32, FALSE);
125 for (p = out_val; *p == ' '; p++) /* loop */
135 if (allow_inc && last_inc) {
140 msg_print(_("値がおかしいです。", "Invalid response."));
146 if ((*p == '+' || *p == '-')) {
163 * @brief 店主がプレイヤーからの交渉価格を判断する /
164 * Receive an offer (from the player)
166 * @param poffer 店主からの交渉価格を返す参照ポインタ
167 * @param last_offer 現在の交渉価格
168 * @param factor 店主の価格基準倍率
169 * @param price アイテムの実価値
170 * @param final 最終価格確定ならばTRUE
171 * @return プレイヤーの価格に対して不服ならばTRUEを返す /
172 * Return TRUE if offer is NOT okay
174 bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final)
177 if (!get_haggle(pmt, poffer, price, final))
180 if (((*poffer) * factor) >= (last_offer * factor))
183 if (haggle_insults())
186 *poffer = last_offer;