summaryrefslogtreecommitdiff
path: root/src/actions/commands.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-09 13:10:54 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-09 13:10:54 +0300
commit4a6ffbd08067b64143e0535518a3822953943d80 (patch)
tree43121fb8f6690dbda227b9839aeb54837a6e53ad /src/actions/commands.cpp
parent9ea847e15b281dda88a4014010bc28e58befeb4c (diff)
downloadplus-4a6ffbd08067b64143e0535518a3822953943d80.tar.gz
plus-4a6ffbd08067b64143e0535518a3822953943d80.tar.bz2
plus-4a6ffbd08067b64143e0535518a3822953943d80.tar.xz
plus-4a6ffbd08067b64143e0535518a3822953943d80.zip
Add buy action.
New chat command: /buy [name]
Diffstat (limited to 'src/actions/commands.cpp')
-rw-r--r--src/actions/commands.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index c8d4f2b21..cd35ba9aa 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -37,9 +37,11 @@
#include "gui/widgets/tabs/chat/whispertab.h"
#include "net/adminhandler.h"
+#include "net/buysellhandler.h"
#include "net/chathandler.h"
#include "net/guildhandler.h"
#include "net/homunculushandler.h"
+#include "net/npchandler.h"
#include "net/pethandler.h"
#include "net/serverfeatures.h"
@@ -711,4 +713,33 @@ impHandler0(fireHomunculus)
return true;
}
+impHandler(buy)
+{
+ const std::string args = event.args;
+ Being *being = nullptr;
+ if (args.empty())
+ {
+ being = localPlayer->getTarget();
+ }
+ else
+ {
+ being = actorManager->findBeingByName(
+ args, ActorType::Unknown);
+ }
+ if (!being)
+ return false;
+
+ if (being->getType() == ActorType::Npc)
+ {
+ npcHandler->buy(being->getId());
+ return true;
+ }
+ else if (being->getType() == ActorType::Player)
+ {
+ buySellHandler->requestSellList(being->getName());
+ return true;
+ }
+ return false;
+}
+
} // namespace Actions