#include "backend/ListIterator.h" #include "backend/Dungeon.h" #include "backend/Exception.h" #include "../GameController.h" #include "../strings.h" using namespace std; 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(object); if (weapon != nullptr) { player.inventory.remove(weapon); player.equip(weapon); this->dungeon->update(); return; } ArmorObject * armor = dynamic_cast(object); if (armor != nullptr) { player.inventory.remove(armor); player.equip(armor); this->dungeon->update(); return; } throw Exception("object \"%s\" is niet draagbaar", target_name.c_str()); } throw Exception("object \"%s\" niet gevonden", target_name.c_str()); }