aboutsummaryrefslogtreecommitdiff
path: root/backend/Player.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-02 20:57:37 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-02 20:57:37 +0100
commitb4507b3601bedcaa599673b9f9083d1574132157 (patch)
treea25a2f249f3434aa204da2095a26b220de188941 /backend/Player.cpp
parentc17df7d3e28e0eeb21f7a62d1c66f525b487a5fa (diff)
more fixes
Diffstat (limited to 'backend/Player.cpp')
-rw-r--r--backend/Player.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/backend/Player.cpp b/backend/Player.cpp
index 8a44a3a..46d924f 100644
--- a/backend/Player.cpp
+++ b/backend/Player.cpp
@@ -1,6 +1,7 @@
#include <assert.h>
#include "Player.h"
+#include "Exception.h"
#include "print.h"
#include "Dungeon.h"
#include "util.h"
@@ -46,6 +47,20 @@ void Player::set_location(Location & location) {
lprtf("Je staat nu bij de locatie %s.\n", location.get_name().c_str());
}
+void Player::equip(Object * object) {
+ if (object == nullptr) return;
+
+ auto weapon = dynamic_cast<WeaponObject *>(object);
+ if (weapon != nullptr)
+ return this->equip(weapon);
+
+ auto armor = dynamic_cast<ArmorObject *>(object);
+ if (armor != nullptr)
+ return this->equip(armor);
+
+ throw Exception("object \"%s\" is niet draagbaar", object->get_name().c_str());
+}
+
void Player::equip(WeaponObject * weapon) {
if (weapon == nullptr) return;