summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-02-15 18:09:18 +0300
committerAndrei Karas <akaras@inbox.ru>2015-02-15 18:28:12 +0300
commitada1a2756824d80ee004d1c1dcbcaba3ce34d2af (patch)
treefb955ddb69bac7b41e07e22a93aeba95df09164d /src/gui
parentd8da9ebe28dc38fa9c7e5bd859913faa4460a25d (diff)
downloadplus-ada1a2756824d80ee004d1c1dcbcaba3ce34d2af.tar.gz
plus-ada1a2756824d80ee004d1c1dcbcaba3ce34d2af.tar.bz2
plus-ada1a2756824d80ee004d1c1dcbcaba3ce34d2af.tar.xz
plus-ada1a2756824d80ee004d1c1dcbcaba3ce34d2af.zip
eathena: impliment selling item to buying store.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/windows/buyingstoreselldialog.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gui/windows/buyingstoreselldialog.cpp b/src/gui/windows/buyingstoreselldialog.cpp
index e3d6cbf88..29b24f638 100644
--- a/src/gui/windows/buyingstoreselldialog.cpp
+++ b/src/gui/windows/buyingstoreselldialog.cpp
@@ -22,6 +22,8 @@
#include "gui/windows/buyingstoreselldialog.h"
+#include "actormanager.h"
+#include "inventory.h"
#include "shopitem.h"
#include "being/being.h"
@@ -45,4 +47,23 @@ BuyingStoreSellDialog::BuyingStoreSellDialog(const int accountId,
void BuyingStoreSellDialog::sellAction(const ActionEvent &event A_UNUSED)
{
+ if (mAmountItems <= 0 || mAmountItems > mMaxItems)
+ return;
+
+ const int selectedItem = mShopItemList->getSelected();
+ ShopItem *const item1 = mShopItems->at(selectedItem);
+ if (!item1 || PlayerInfo::isItemProtected(item1->getId()))
+ return;
+ Being *const being = actorManager->findBeing(mAccountId);
+ if (!being)
+ return;
+ // +++ need add colors
+ Item *const item2 = PlayerInfo::getInventory()->findItem(
+ item1->getId(), 1);
+ if (!item2)
+ return;
+
+ mPlayerMoney += mAmountItems * item1->getPrice();
+ mMaxItems -= mAmountItems;
+ buyingStoreHandler->sell(being, mStoreId, item2, mAmountItems);
}