aboutsummaryrefslogtreecommitdiff
path: root/frontend/cmd/put.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-01 17:32:53 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-01 17:32:53 +0100
commitb20f46c15dce8b196dbb8890890978947745e094 (patch)
treed9defa84717ffa843fd11b05d0e856473d6d8d59 /frontend/cmd/put.cpp
parenta7e84b60366c78b131d43157980fbe4c2df655e6 (diff)
change flow architecture
Diffstat (limited to 'frontend/cmd/put.cpp')
-rw-r--r--frontend/cmd/put.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/frontend/cmd/put.cpp b/frontend/cmd/put.cpp
index dabac19..35de352 100644
--- a/frontend/cmd/put.cpp
+++ b/frontend/cmd/put.cpp
@@ -1,22 +1,25 @@
#include "../GameController.h"
#include "../strings.h"
+#include "../Exception.h"
#include "backend/print.h"
#include "backend/Location.h"
+#include "backend/Dungeon.h"
using namespace std;
-FollowupAction GameController::cmd_put(string & target_name) {
- Location & location = this->player.get_location();
- for (Object * object : this->player.inventory) {
+void GameController::cmd_put(string & target_name) {
+ Player & player = this->dungeon->get_player();
+ Location & location = player.get_location();
+ for (Object * object : player.inventory) {
if (str_lower(object->get_name().c_str()) != str_lower(target_name)) continue;
lprtf("Je legt %s neer op de locatie %s.\n", object->get_displayname().c_str(), location.get_name().c_str());
- this->player.inventory.remove(object);
+ player.inventory.remove(object);
location.add_visible_object(object);
- return FollowupAction::NONE;
+ return;
}
- lprtf("Object \"%s\" niet gevonden.\n", target_name.c_str());
- return FollowupAction::NONE;
+
+ throw Exception("Object \"%s\" niet gevonden.", target_name.c_str());
}