From b4507b3601bedcaa599673b9f9083d1574132157 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 2 Nov 2024 20:57:37 +0100 Subject: more fixes --- frontend/cmd/equip.cpp | 20 ++------------------ frontend/cmd/hit.cpp | 3 +++ 2 files changed, 5 insertions(+), 18 deletions(-) (limited to 'frontend/cmd') diff --git a/frontend/cmd/equip.cpp b/frontend/cmd/equip.cpp index 8f37c0c..72795a8 100644 --- a/frontend/cmd/equip.cpp +++ b/frontend/cmd/equip.cpp @@ -15,23 +15,7 @@ void GameController::cmd_equip(string & target_name) { throw Exception("object \"%s\" niet gevonden", target_name.c_str()); Object & object = **it; - - try { - WeaponObject & weapon = dynamic_cast(object); - player.inventory.remove(&weapon); - player.equip(&weapon); - this->dungeon->update(); - return; - } catch (std::bad_cast &) {}; - - try { - ArmorObject & armor = dynamic_cast(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()); + player.equip(&object); + this->dungeon->update(); } diff --git a/frontend/cmd/hit.cpp b/frontend/cmd/hit.cpp index cb5c56e..f4a78fd 100644 --- a/frontend/cmd/hit.cpp +++ b/frontend/cmd/hit.cpp @@ -19,6 +19,9 @@ void GameController::cmd_hit(string & target_name) { throw Exception("vijand \"%s\" niet gevonden", target_name.c_str()); Enemy & enemy = **it; + if (enemy.is_dead()) + throw Exception("%s is al dood!", enemy.get_name().c_str()); + if (rng.rand_double() > player.get_attack()) { lprtf("Je hebt gemist!\n"); } else { -- cgit v1.2.3