summaryrefslogtreecommitdiff
path: root/src/shopitem.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-03 21:54:44 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-04 02:14:03 +0300
commit2288a403ad4377fbb552243e805aaf0b5a4f5a0d (patch)
treead081047290fb6cc101f43833de6f565a368cf29 /src/shopitem.cpp
parentcd636f7e367cfb7fa2c348d00071301a480d62c3 (diff)
downloadmv-2288a403ad4377fbb552243e805aaf0b5a4f5a0d.tar.gz
mv-2288a403ad4377fbb552243e805aaf0b5a4f5a0d.tar.bz2
mv-2288a403ad4377fbb552243e805aaf0b5a4f5a0d.tar.xz
mv-2288a403ad4377fbb552243e805aaf0b5a4f5a0d.zip
Allow buy from npc shop or from market more than one of item at one transaction.
Diffstat (limited to 'src/shopitem.cpp')
-rw-r--r--src/shopitem.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/shopitem.cpp b/src/shopitem.cpp
index faf635fbd..0430e4d0f 100644
--- a/src/shopitem.cpp
+++ b/src/shopitem.cpp
@@ -22,6 +22,7 @@
#include "shopitem.h"
+#include "logger.h"
#include "units.h"
#include "resources/iteminfo.h"
@@ -47,6 +48,7 @@ ShopItem::ShopItem(const int inventoryIndex,
mDisplayName(),
mDuplicates(),
mPrice(price),
+ mUsedQuantity(0),
mShowQuantity(true),
mVisible(true)
{
@@ -68,6 +70,7 @@ ShopItem::ShopItem(const int id,
mDisplayName(),
mDuplicates(),
mPrice(price),
+ mUsedQuantity(0),
mShowQuantity(false),
mVisible(true)
{
@@ -97,14 +100,15 @@ void ShopItem::updateDisplayName(const int quantity)
mDisplayName.append(" (").append(
Units::formatCurrency(mPrice)).append(") ");
}
- if (quantity > 1)
+ if (mShowQuantity && quantity > 1)
mDisplayName.append("[").append(toString(quantity)).append("]");
+ if (mUsedQuantity > 0)
+ mDisplayName.append(" +").append(toString(mUsedQuantity));
}
void ShopItem::update()
{
- if (mShowQuantity)
- updateDisplayName(mQuantity);
+ updateDisplayName(mQuantity);
}
void ShopItem::addDuplicate(const int inventoryIndex, const int quantity)
@@ -141,3 +145,21 @@ int ShopItem::sellCurrentDuplicate(const int quantity)
}
return sellCount;
}
+
+void ShopItem::increaseUsedQuantity(const int amount)
+{
+ if (mShowQuantity && mQuantity)
+ {
+ if (mQuantity < mUsedQuantity + amount ||
+ mUsedQuantity + amount < 0)
+ {
+ return;
+ }
+ }
+ else if (mUsedQuantity + amount < 0)
+ {
+ return;
+ }
+
+ mUsedQuantity += amount;
+}