diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-01 10:18:22 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-01 10:18:22 +0100 |
commit | 798948dbe6f012e194f053c4e862cf697f30b793 (patch) | |
tree | 32c71420d1188f98cfb41b6f0d9536c5fa4bf5a7 /frontend/cmd/view.cpp | |
parent | d7012045bb61f117fb7b9c51ddd03e4c54f25fe6 (diff) |
more WIP (move some Player things to backend)
Diffstat (limited to 'frontend/cmd/view.cpp')
-rw-r--r-- | frontend/cmd/view.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/frontend/cmd/view.cpp b/frontend/cmd/view.cpp index 1152efe..69eb96e 100644 --- a/frontend/cmd/view.cpp +++ b/frontend/cmd/view.cpp @@ -1,4 +1,4 @@ -#include "../Player.h" +#include "../GameController.h" #include "../strings.h" #include "backend/print.h" @@ -6,33 +6,35 @@ using namespace std; -FollowupAction Player::cmd_view(string & target) { +FollowupAction GameController::cmd_view(string & target) { if (target.size() == 0) { lprtf("Fout, gebruik: Bekijk <Zelf|VIJHAND|OBJECT>\n"); return FollowupAction::NONE; } + Location & location = this->player.get_location(); + // view self if (str_lower(target) == "zelf") { - lprtf("Je hebt %d levenspunten.\n", this->get_health()); + lprtf("Je hebt %d levenspunten.\n", this->player.get_health()); - lprtf("Je hebt een aanvalskans van %.0f%%.\n", this->get_attack() * 100); + lprtf("Je hebt een aanvalskans van %.0f%%.\n", this->player.get_attack() * 100); - if (this->weapon == nullptr) + if (this->player.weapon == nullptr) lprtf("Je hebt geen wapen vast.\n"); else - lprtf("Je hebt het volgende wapen vast: %s.\n", this->weapon->get_displayname().c_str()); + lprtf("Je hebt het volgende wapen vast: %s.\n", this->player.weapon->get_displayname().c_str()); - if (this->armor == nullptr) + if (this->player.armor == nullptr) lprtf("Je draagt geen wapenrusting.\n"); else - lprtf("Je draagt de volgende wapenrusting: %s.\n", this->armor->get_displayname().c_str()); + lprtf("Je draagt de volgende wapenrusting: %s.\n", this->player.armor->get_displayname().c_str()); - lprtf("Je hebt %u goundstuk%s.\n", this->gold, this->gold == 1 ? "" : "ken"); + lprtf("Je hebt %u goundstuk%s.\n", this->player.gold, this->player.gold == 1 ? "" : "ken"); - size_t items = this->inventory.size(); + size_t items = this->player.inventory.size(); lprtf("Je hebt %d overige object%s%s\n", items, items == 1 ? "" : "en", items > 0 ? ":" : "."); - for (auto & object : this->inventory) { + for (auto & object : this->player.inventory) { lprtf("- %s\n", object->get_displayname().c_str()); } @@ -40,7 +42,7 @@ FollowupAction Player::cmd_view(string & target) { } // try to find visible object in location - for (Object * object : this->location.get_visible_objects()) { + for (Object * object : location.get_visible_objects()) { if (str_lower(object->get_name().c_str()) != str_lower(target)) continue; lprtf("%s\n", object->get_description().c_str()); @@ -48,7 +50,7 @@ FollowupAction Player::cmd_view(string & target) { } // try to find object in inventory - for (auto & object : this->inventory) { + for (auto & object : this->player.inventory) { if (str_lower(object->get_name().c_str()) != str_lower(target)) continue; lprtf("%s\n", object->get_description().c_str()); @@ -56,7 +58,7 @@ FollowupAction Player::cmd_view(string & target) { } // try to find enemy by name - for (Enemy * enemy : this->location.get_enemies()) { + for (Enemy * enemy : location.get_enemies()) { if (str_lower(enemy->get_name().c_str()) != str_lower(target)) continue; lprtf("%s\n", enemy->get_description().c_str()); |