diff options
Diffstat (limited to 'frontend/cmd/equip.cpp')
-rw-r--r-- | frontend/cmd/equip.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/frontend/cmd/equip.cpp b/frontend/cmd/equip.cpp index 25a375f..578db0e 100644 --- a/frontend/cmd/equip.cpp +++ b/frontend/cmd/equip.cpp @@ -1,33 +1,35 @@ -#include "backend/print.h" #include "backend/ListIterator.h" +#include "backend/Dungeon.h" #include "../GameController.h" #include "../strings.h" +#include "../Exception.h" using namespace std; -FollowupAction GameController::cmd_equip(string & target_name) { - for (Object * object : this->player.inventory) { +void GameController::cmd_equip(string & target_name) { + Player & player = this->dungeon->get_player(); + for (Object * object : player.inventory) { if (str_lower(object->get_name().c_str()) != str_lower(target_name)) continue; WeaponObject * weapon = dynamic_cast<WeaponObject *>(object); if (weapon != nullptr) { - this->player.inventory.remove(weapon); - this->player.equip(weapon); - return FollowupAction::UPDATE; + player.inventory.remove(weapon); + player.equip(weapon); + this->dungeon->update(); + return; } ArmorObject * armor = dynamic_cast<ArmorObject *>(object); if (armor != nullptr) { - this->player.inventory.remove(armor); - this->player.equip(armor); - return FollowupAction::UPDATE; + player.inventory.remove(armor); + player.equip(armor); + this->dungeon->update(); + return; } - lprtf("Object %s is niet draagbaar.\n", target_name.c_str()); - return FollowupAction::NONE; + throw Exception("Object \"%s\" is niet draagbaar.", target_name.c_str()); } - lprtf("Object \"%s\" niet gevonden.\n", target_name.c_str()); - return FollowupAction::NONE; + throw Exception("Object \"%s\" niet gevonden.", target_name.c_str()); } |