aboutsummaryrefslogtreecommitdiff
path: root/frontend/cmd/get.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/get.cpp
parent815ec66a68c01dc4a8f0c5ec6c9193a71e7547e2 (diff)
more cleanup + add give command to test things
Diffstat (limited to 'frontend/cmd/get.cpp')
-rw-r--r--frontend/cmd/get.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/frontend/cmd/get.cpp b/frontend/cmd/get.cpp
index e774168..ea1f69b 100644
--- a/frontend/cmd/get.cpp
+++ b/frontend/cmd/get.cpp
@@ -22,13 +22,13 @@ void GameController::cmd_get(string & target_name) {
location.remove_visible_object(object.get());
// gold objects are collected and (implicitly) destroyed
- GoldObject * gold = dynamic_cast<GoldObject *>(object.get());
- if (gold != nullptr) {
- int count = gold->get_count();
+ try {
+ GoldObject & gold = dynamic_cast<GoldObject &>(*object);
+ int count = gold.get_count();
player.gold += count;
lprtf("Je bent %d goudstuk%s rijker.\n", count, count == 1 ? "" : "ken");
return;
- }
+ } catch (std::bad_cast &) {};
// other objects go in the inventory
lprtf("Je voegt %s toe aan je bezit.\n", object->get_name().c_str());