From ada1a2756824d80ee004d1c1dcbcaba3ce34d2af Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 15 Feb 2015 18:09:18 +0300 Subject: eathena: impliment selling item to buying store. --- src/gui/windows/buyingstoreselldialog.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/gui/windows/buyingstoreselldialog.cpp') 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); } -- cgit v1.2.3-60-g2f50