summaryrefslogtreecommitdiff
path: root/src/actions/pets.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-28 00:11:59 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-28 00:11:59 +0300
commit4e7669dd6e07658fa86878d1e64c482a094b3b19 (patch)
tree8ffc8cb8621fef8a40615ef17e7b39abd885a000 /src/actions/pets.cpp
parenta065831539e63dc6e25f4743b3a548aadf92304a (diff)
downloadmanaplus-4e7669dd6e07658fa86878d1e64c482a094b3b19.tar.gz
manaplus-4e7669dd6e07658fa86878d1e64c482a094b3b19.tar.bz2
manaplus-4e7669dd6e07658fa86878d1e64c482a094b3b19.tar.xz
manaplus-4e7669dd6e07658fa86878d1e64c482a094b3b19.zip
Add fake pet moving commands.
Actual moving will be implimented after.
Diffstat (limited to 'src/actions/pets.cpp')
-rw-r--r--src/actions/pets.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/actions/pets.cpp b/src/actions/pets.cpp
index 30cfc9613..e30e7f529 100644
--- a/src/actions/pets.cpp
+++ b/src/actions/pets.cpp
@@ -62,6 +62,17 @@
namespace Actions
{
+static const Being *getPet()
+{
+ if (!localPlayer)
+ return nullptr;
+
+ const std::vector<Being*> &pets = localPlayer->getPets();
+ if (pets.empty())
+ return nullptr;
+ return *pets.begin();
+}
+
impHandler(commandEmotePet)
{
// need use actual pet id
@@ -130,4 +141,40 @@ impHandler(catchPet)
return true;
}
+impHandler0(petMoveUp)
+{
+ const Being *const pet = getPet();
+ if (!pet)
+ return false;
+ petHandler->move(pet->getId(), pet->getTileX(), pet->getTileY() - 1);
+ return true;
+}
+
+impHandler0(petMoveDown)
+{
+ const Being *const pet = getPet();
+ if (!pet)
+ return false;
+ petHandler->move(pet->getId(), pet->getTileX(), pet->getTileY() + 1);
+ return true;
+}
+
+impHandler0(petMoveLeft)
+{
+ const Being *const pet = getPet();
+ if (!pet)
+ return false;
+ petHandler->move(pet->getId(), pet->getTileX() - 1, pet->getTileY());
+ return true;
+}
+
+impHandler0(petMoveRight)
+{
+ const Being *const pet = getPet();
+ if (!pet)
+ return false;
+ petHandler->move(pet->getId(), pet->getTileX() + 1, pet->getTileY());
+ return true;
+}
+
} // namespace Actions