aboutsummaryrefslogtreecommitdiff
path: root/frontend/cmd/equip.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-02 14:44:25 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-02 14:44:25 +0100
commit369e3d71aa79783d95166739cfa93a480defe6ea (patch)
treecc4e590da6d98fc891ce3488cc150ffa10173520 /frontend/cmd/equip.cpp
parent815ec66a68c01dc4a8f0c5ec6c9193a71e7547e2 (diff)
more cleanup + add give command to test things
Diffstat (limited to 'frontend/cmd/equip.cpp')
-rw-r--r--frontend/cmd/equip.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/frontend/cmd/equip.cpp b/frontend/cmd/equip.cpp
index fe951b1..8f37c0c 100644
--- a/frontend/cmd/equip.cpp
+++ b/frontend/cmd/equip.cpp
@@ -16,21 +16,21 @@ void GameController::cmd_equip(string & target_name) {
Object & object = **it;
- WeaponObject * weapon = dynamic_cast<WeaponObject *>(&object);
- if (weapon != nullptr) {
- player.inventory.remove(weapon);
- player.equip(weapon);
+ try {
+ WeaponObject & weapon = dynamic_cast<WeaponObject &>(object);
+ player.inventory.remove(&weapon);
+ player.equip(&weapon);
this->dungeon->update();
return;
- }
+ } catch (std::bad_cast &) {};
- ArmorObject * armor = dynamic_cast<ArmorObject *>(&object);
- if (armor != nullptr) {
- player.inventory.remove(armor);
- player.equip(armor);
+ try {
+ ArmorObject & armor = dynamic_cast<ArmorObject &>(object);
+ player.inventory.remove(&armor);
+ player.equip(&armor);
this->dungeon->update();
return;
- }
+ } catch (std::bad_cast &) {};
throw Exception("object \"%s\" is niet draagbaar", target_name.c_str());
}