Attached Files |
0001-Ignore-bargaining-when-adding-to-the-shopping-list.patch [^] (1,521 bytes) 2013-04-12 12:10 [Show Content] [Hide Content]From 120db0f74fb07e5d822d1a15165fb0d591965105 Mon Sep 17 00:00:00 2001
From: Pekka Lampila <pekka.lampila@iki.fi>
Date: Fri, 12 Apr 2013 12:58:35 +0300
Subject: [PATCH] Ignore bargaining when adding to the shopping list
---
crawl-ref/source/shopping.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc
index a8b6189..5200964 100644
--- a/crawl-ref/source/shopping.cc
+++ b/crawl-ref/source/shopping.cc
@@ -675,7 +675,7 @@ static bool _in_a_shop(int shopidx, int &num_in_list)
{
const item_def& item = mitm[stock[i]];
const int cost = _shop_get_item_value(item, shop.greed,
- id_stock);
+ id_stock, true);
unsigned int num = shopping_list.cull_identical_items(item,
cost);
@@ -898,7 +898,7 @@ static bool _in_a_shop(int shopidx, int &num_in_list)
{
// Ignore Bargaining.
const int cost = _shop_get_item_value(item,
- shop.greed, id_stock, false);
+ shop.greed, id_stock, true);
shopping_list.add_thing(item, cost);
}
in_list[i] = true;
--
1.7.10.4
0002-Show-lowered-prices-on-shopping-list-with-bargain.patch [^] (2,239 bytes) 2013-04-12 13:56 [Show Content] [Hide Content]From a7a3abc1dba7a26e4e6a4e36a26eb03244e1b56d Mon Sep 17 00:00:00 2001
From: Pekka Lampila <pekka.lampila@iki.fi>
Date: Fri, 12 Apr 2013 14:52:35 +0300
Subject: [PATCH 2/2] Show lowered prices on shopping list with bargain
Also don't give invalid "You cannot afford" prompt if the item is only
affordable thanks to bargain status.
---
crawl-ref/source/shopping.cc | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc
index 5200964..1c35dce 100644
--- a/crawl-ref/source/shopping.cc
+++ b/crawl-ref/source/shopping.cc
@@ -426,20 +426,24 @@ static vector<int> _shop_get_stock(int shopidx)
return result;
}
+static int _bargain_cost(int value)
+{
+ // 20% discount
+ value *= 8;
+ value /= 10;
+
+ return max(value, 1);
+}
+
static int _shop_get_item_value(const item_def& item, int greed, bool id,
bool ignore_bargain = false)
{
int result = (greed * item_value(item, id) / 10);
- if (you.duration[DUR_BARGAIN] && !ignore_bargain) // 20% discount
- {
- result *= 8;
- result /= 10;
- }
- if (result < 1)
- result = 1;
+ if (you.duration[DUR_BARGAIN] && !ignore_bargain)
+ result = _bargain_cost(result);
- return result;
+ return max(result, 1);
}
static string _shop_print_stock(const vector<int>& stock,
@@ -2951,6 +2955,10 @@ void ShoppingList::fill_out_menu(Menu& shopmenu)
CrawlHashTable &thing = (*list)[i];
level_pos pos = thing_pos(thing);
int cost = thing_cost(thing);
+ string normal;
+
+ if (you.duration[DUR_BARGAIN])
+ cost = _bargain_cost(cost);
string etitle =
make_stringf("[%s] %s (%d gp)", short_place_name(pos.id).c_str(),
@@ -3027,7 +3035,9 @@ void ShoppingList::display()
if (shopmenu.menu_action == Menu::ACT_EXECUTE)
{
- const int cost = thing_cost(*thing);
+ int cost = thing_cost(*thing);
+ if (you.duration[DUR_BARGAIN])
+ cost = _bargain_cost(cost);
if (cost > you.gold)
{
--
1.7.10.4
|