From b20f46c15dce8b196dbb8890890978947745e094 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 1 Nov 2024 17:32:53 +0100 Subject: change flow architecture --- frontend/cmd/equip.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'frontend/cmd/equip.cpp') 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(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(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()); } -- cgit v1.2.3