#include "store/owner-insults.h"
+#include "core/asking-player.h"
#include "game-option/birth-options.h"
#include "store/say-comments.h"
-#include "store/store.h" // todo 相互参照している.
+#include "store/store.h"
#include "store/store-util.h"
+#include "term/screen-processor.h"
+#include "view/display-messages.h"
#include "world/world.h"
+/* Last "increment" during haggling */
+static s32b last_inc = 0L;
+
/*!
* @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
* Increase the insult counter and get angry if too many -RAK-
}
}
}
+
+/*!
+ * @brief 交渉価格を確認と認証の是非を行う /
+ * Get a haggle
+ * @param pmt メッセージ
+ * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
+ * @param price 現在の交渉価格
+ * @param final 最終確定価格ならばTRUE
+ * @return プレイヤーを締め出す場合TRUEを返す
+ */
+static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final)
+{
+ GAME_TEXT buf[128];
+ if (!allow_inc)
+ last_inc = 0L;
+
+ if (final) {
+ sprintf(buf, _("%s [承諾] ", "%s [accept] "), pmt);
+ } else if (last_inc < 0) {
+ sprintf(buf, _("%s [-$%ld] ", "%s [-%ld] "), pmt, (long)(ABS(last_inc)));
+ } else if (last_inc > 0) {
+ sprintf(buf, _("%s [+$%ld] ", "%s [+%ld] "), pmt, (long)(ABS(last_inc)));
+ } else {
+ sprintf(buf, "%s ", pmt);
+ }
+
+ msg_print(NULL);
+ GAME_TEXT out_val[160];
+ while (TRUE) {
+ bool res;
+ prt(buf, 0, 0);
+ strcpy(out_val, "");
+
+ /*
+ * Ask the user for a response.
+ * Don't allow to use numpad as cursor key.
+ */
+ res = askfor_aux(out_val, 32, FALSE);
+ prt("", 0, 0);
+ if (!res)
+ return FALSE;
+
+ concptr p;
+ for (p = out_val; *p == ' '; p++) /* loop */
+ ;
+
+ if (*p == '\0') {
+ if (final) {
+ *poffer = price;
+ last_inc = 0L;
+ break;
+ }
+
+ if (allow_inc && last_inc) {
+ *poffer += last_inc;
+ break;
+ }
+
+ msg_print(_("値がおかしいです。", "Invalid response."));
+ msg_print(NULL);
+ continue;
+ }
+
+ s32b i = atol(p);
+ if ((*p == '+' || *p == '-')) {
+ if (allow_inc) {
+ *poffer += i;
+ last_inc = i;
+ break;
+ }
+ } else {
+ *poffer = i;
+ last_inc = 0L;
+ break;
+ }
+ }
+
+ return TRUE;
+}
+
+/*!
+ * @brief 店主がプレイヤーからの交渉価格を判断する /
+ * Receive an offer (from the player)
+ * @param pmt メッセージ
+ * @param poffer 店主からの交渉価格を返す参照ポインタ
+ * @param last_offer 現在の交渉価格
+ * @param factor 店主の価格基準倍率
+ * @param price アイテムの実価値
+ * @param final 最終価格確定ならばTRUE
+ * @return プレイヤーの価格に対して不服ならばTRUEを返す /
+ * Return TRUE if offer is NOT okay
+ */
+bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final)
+{
+ while (TRUE) {
+ if (!get_haggle(pmt, poffer, price, final))
+ return TRUE;
+ if (((*poffer) * factor) >= (last_offer * factor))
+ break;
+ if (haggle_insults())
+ return TRUE;
+
+ (*poffer) = last_offer;
+ }
+
+ return FALSE;
+}
void decrease_insults(void);
int haggle_insults(void);
void updatebargain(PRICE price, PRICE minprice, int num);
+bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final);
#include "spell-kind/spells-perception.h"
#include "store/black-market.h"
#include "store/home.h"
-#include "store/owner-insults.h" // todo 相互参照している.
#include "store/rumor.h"
#include "store/say-comments.h"
#include "store/store-owners.h"
return TRUE;
}
-/*
- * Mega-Hack -- Last "increment" during haggling
- */
-static s32b last_inc = 0L;
-
-/*!
- * @brief 交渉価格を確認と認証の是非を行う /
- * Get a haggle
- * @param pmt メッセージ
- * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
- * @param price 現在の交渉価格
- * @param final 最終確定価格ならばTRUE
- * @return プレイヤーを締め出す場合TRUEを返す
- */
-static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final)
-{
- GAME_TEXT buf[128];
- if (!allow_inc)
- last_inc = 0L;
-
- if (final) {
- sprintf(buf, _("%s [承諾] ", "%s [accept] "), pmt);
- } else if (last_inc < 0) {
- sprintf(buf, _("%s [-$%ld] ", "%s [-%ld] "), pmt, (long)(ABS(last_inc)));
- } else if (last_inc > 0) {
- sprintf(buf, _("%s [+$%ld] ", "%s [+%ld] "), pmt, (long)(ABS(last_inc)));
- } else {
- sprintf(buf, "%s ", pmt);
- }
-
- msg_print(NULL);
- GAME_TEXT out_val[160];
- while (TRUE) {
- bool res;
- prt(buf, 0, 0);
- strcpy(out_val, "");
-
- /*
- * Ask the user for a response.
- * Don't allow to use numpad as cursor key.
- */
- res = askfor_aux(out_val, 32, FALSE);
- prt("", 0, 0);
- if (!res)
- return FALSE;
-
- concptr p;
- for (p = out_val; *p == ' '; p++) /* loop */
- ;
-
- if (*p == '\0') {
- if (final) {
- *poffer = price;
- last_inc = 0L;
- break;
- }
-
- if (allow_inc && last_inc) {
- *poffer += last_inc;
- break;
- }
-
- msg_print(_("値がおかしいです。", "Invalid response."));
- msg_print(NULL);
- continue;
- }
-
- s32b i = atol(p);
- if ((*p == '+' || *p == '-')) {
- if (allow_inc) {
- *poffer += i;
- last_inc = i;
- break;
- }
- } else {
- *poffer = i;
- last_inc = 0L;
- break;
- }
- }
-
- return TRUE;
-}
-
-/*!
- * @brief 店主がプレイヤーからの交渉価格を判断する /
- * Receive an offer (from the player)
- * @param pmt メッセージ
- * @param poffer 店主からの交渉価格を返す参照ポインタ
- * @param last_offer 現在の交渉価格
- * @param factor 店主の価格基準倍率
- * @param price アイテムの実価値
- * @param final 最終価格確定ならばTRUE
- * @return プレイヤーの価格に対して不服ならばTRUEを返す /
- * Return TRUE if offer is NOT okay
- */
-bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final)
-{
- while (TRUE) {
- if (!get_haggle(pmt, poffer, price, final))
- return TRUE;
- if (((*poffer) * factor) >= (last_offer * factor))
- break;
- if (haggle_insults())
- return TRUE;
-
- (*poffer) = last_offer;
- }
-
- return FALSE;
-}
-
/*!
* @brief 店のアイテムを調べるコマンドのメインルーチン /
* Examine an item in a store -JDL-
void museum_remove_object(player_type *player_ptr);
int store_check_num(object_type *o_ptr);
int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j);
-bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final);