OSDN Git Service

[Fix] 店舗の表示価格と店主の提示価格が異なる #1257
authorHabu <habu1010+github@gmail.com>
Sat, 10 Jul 2021 18:18:09 +0000 (03:18 +0900)
committerHabu <habu1010+github@gmail.com>
Sat, 10 Jul 2021 18:18:09 +0000 (03:18 +0900)
価格交渉を削除した時の価格設定として従来の価格交渉で
ベストだった値段に対し売値は10%引き買値は10%増しと
するようにしたようだが、この処理を price_item 関数の
外で行っているため首記の不具合が生じている。
割引/割増の処理を price_item 関数の中に含めるようにする。

src/store/pricing.cpp
src/store/purchase-order.cpp
src/store/sell-order.cpp
src/view/display-store.cpp

index 465fc02..0cb3860 100644 (file)
@@ -62,5 +62,8 @@ PRICE price_item(player_type *player_ptr, object_type *o_ptr, int greed, bool fl
     if (price <= 0L)
         return 1L;
 
+    if (price >= LOW_PRICE_THRESHOLD)
+        price += (flip ? -1 : 1) * price / 10;
+
     return price;
 }
index 5198f51..c920763 100644 (file)
 static std::optional<PRICE> prompt_to_buy(player_type *player_ptr, object_type *o_ptr)
 {
     auto price_ask = price_item(player_ptr, o_ptr, ot_ptr->inflate, false);
-    auto is_low_price = price_ask < LOW_PRICE_THRESHOLD;
-
-    if (!is_low_price)
-        price_ask += price_ask / 10;
 
     price_ask *= o_ptr->number;
     concptr s = format(_("買値 $%ld で買いますか?", "Do you buy for $%ld? "), static_cast<long>(price_ask));
index d1287f1..5c390f6 100644 (file)
 static std::optional<PRICE> prompt_to_sell(player_type *player_ptr, object_type *o_ptr)
 {
     auto price_ask = price_item(player_ptr, o_ptr, ot_ptr->inflate, true);
-    auto is_low_price = price_ask < LOW_PRICE_THRESHOLD;
-
-    if (!is_low_price)
-        price_ask -= price_ask / 10;
 
     price_ask *= o_ptr->number;
     concptr s = format(_("売値 $%ld で売りますか?", "Do you sell for $%ld? "), static_cast<long>(price_ask));
index b4fb573..43ff4af 100644 (file)
@@ -105,8 +105,6 @@ void display_entry(player_type *player_ptr, int pos)
     }
 
     x = price_item(player_ptr, o_ptr, ot_ptr->inflate, false);
-    if (x >= LOW_PRICE_THRESHOLD)
-        x += x / 10;
 
     (void)sprintf(out_val, "%9ld  ", (long)x);
     put_str(out_val, i + 6, 68);