diff options
author | Fedja Beader <fedja@protonmail.ch> | 2025-03-10 17:53:26 +0000 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2025-03-10 17:53:26 +0000 |
commit | 6c500b492e4b82caa5b1ec420a41beaecdd426ae (patch) | |
tree | 1986bfe9db14142a3d92266c10f2481d91dc7f19 | |
parent | bfde5ad692a7e9f5abc866170aad4170875072ac (diff) | |
download | mv-6c500b492e4b82caa5b1ec420a41beaecdd426ae.tar.gz mv-6c500b492e4b82caa5b1ec420a41beaecdd426ae.tar.bz2 mv-6c500b492e4b82caa5b1ec420a41beaecdd426ae.tar.xz mv-6c500b492e4b82caa5b1ec420a41beaecdd426ae.zip |
Slight cleanup in shopitem.cpp
****
mana/plus!140
-rw-r--r-- | src/resources/item/shopitem.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/resources/item/shopitem.cpp b/src/resources/item/shopitem.cpp index c724be7ca..2ed6299cb 100644 --- a/src/resources/item/shopitem.cpp +++ b/src/resources/item/shopitem.cpp @@ -105,13 +105,16 @@ void ShopItem::updateDisplayName(const int quantity) else #endif // TMWA_SUPPORT mDisplayName = std::string(getInfo().getName(mColor)); + if (mPrice != 0) { mDisplayName.append(" (").append( UnitsDb::formatCurrency(mCurrency, mPrice)).append(") "); } + if (mShowQuantity && quantity > 1) mDisplayName.append("[").append(toString(quantity)).append("]"); + if (mUsedQuantity > 0) mDisplayName.append(" +").append(toString(mUsedQuantity)); } @@ -144,8 +147,7 @@ int ShopItem::sellCurrentDuplicate(const int quantity) if (dupl == nullptr) return 0; - const int sellCount = quantity <= dupl->quantity - ? quantity : dupl->quantity; + const int sellCount = std::min(quantity, dupl->quantity); dupl->quantity -= sellCount; mQuantity -= sellCount; if (dupl->quantity == 0) @@ -158,18 +160,18 @@ int ShopItem::sellCurrentDuplicate(const int quantity) void ShopItem::increaseUsedQuantity(const int amount) { + const int newUsedQuantity = mUsedQuantity + amount; if (mShowQuantity && (mQuantity != 0)) { - if (mQuantity < mUsedQuantity + amount || - mUsedQuantity + amount < 0) + if (newUsedQuantity < 0 || mQuantity < newUsedQuantity) { return; } } - else if (mUsedQuantity + amount < 0) + else if (newUsedQuantity < 0) { return; } - mUsedQuantity += amount; + mUsedQuantity = newUsedQuantity; } |