diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-02 21:10:27 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-02 21:10:27 +0100 |
commit | d554cb39a2f1ec97dd214a5dd200ae5f03cf616d (patch) | |
tree | ba52e12e1791592ee7634b6a3e190d9bba950860 | |
parent | b4507b3601bedcaa599673b9f9083d1574132157 (diff) |
cleanup
-rw-r--r-- | backend/Exception.cpp | 9 | ||||
-rw-r--r-- | backend/Exception.h | 2 | ||||
-rw-r--r-- | backend/Location.cpp | 1 | ||||
-rw-r--r-- | backend/Player.cpp | 5 | ||||
-rw-r--r-- | backend/Player.h | 4 | ||||
-rw-r--r-- | backend/String.cpp | 1 | ||||
-rw-r--r-- | frontend/cmd/equip.cpp | 1 |
7 files changed, 7 insertions, 16 deletions
diff --git a/backend/Exception.cpp b/backend/Exception.cpp index bb7b7c4..beb7312 100644 --- a/backend/Exception.cpp +++ b/backend/Exception.cpp @@ -1,14 +1,5 @@ -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "backend/String.h" - #include "Exception.h" -using namespace std; - const char * Exception::what() { return this->error.c_str(); } diff --git a/backend/Exception.h b/backend/Exception.h index bc65aa0..93af96e 100644 --- a/backend/Exception.h +++ b/backend/Exception.h @@ -1,6 +1,6 @@ #pragma once -#include "backend/String.h" +#include "String.h" class Exception { public: diff --git a/backend/Location.cpp b/backend/Location.cpp index eadbef2..2177d8a 100644 --- a/backend/Location.cpp +++ b/backend/Location.cpp @@ -3,7 +3,6 @@ #include "ListIterator.h" #include "Enemy.h" #include "Object.h" -#include "util.h" Direction operator - (const Direction & rhs) { return static_cast<Direction>((rhs + 2) % 4); diff --git a/backend/Player.cpp b/backend/Player.cpp index 46d924f..6c2cf6b 100644 --- a/backend/Player.cpp +++ b/backend/Player.cpp @@ -42,6 +42,7 @@ Location & Player::get_location() const { assert(this->location != nullptr); return *this->location; } + void Player::set_location(Location & location) { this->location = &location; lprtf("Je staat nu bij de locatie %s.\n", location.get_name().c_str()); @@ -61,7 +62,7 @@ void Player::equip(Object * object) { throw Exception("object \"%s\" is niet draagbaar", object->get_name().c_str()); } -void Player::equip(WeaponObject * weapon) { +void Player::equip(WeaponObject * weapon) noexcept { if (weapon == nullptr) return; lprtf("Je "); @@ -73,7 +74,7 @@ void Player::equip(WeaponObject * weapon) { lprtf("pakt %s vast.\n", this->weapon->get_name().c_str()); } -void Player::equip(ArmorObject * armor) { +void Player::equip(ArmorObject * armor) noexcept { if (armor == nullptr) return; lprtf("Je "); diff --git a/backend/Player.h b/backend/Player.h index 8090063..e40f889 100644 --- a/backend/Player.h +++ b/backend/Player.h @@ -37,8 +37,8 @@ public: unsigned get_health() const; Location & get_location() const; void set_location(Location &); - void equip(WeaponObject *); - void equip(ArmorObject *); + void equip(WeaponObject *) noexcept; + void equip(ArmorObject *) noexcept; void equip(Object *); bool is_dead() const; diff --git a/backend/String.cpp b/backend/String.cpp index 8be6892..304e571 100644 --- a/backend/String.cpp +++ b/backend/String.cpp @@ -10,7 +10,6 @@ String::String() { this->set(""); } - String::String(const String & other) { this->set(other.data(), other.size()); } diff --git a/frontend/cmd/equip.cpp b/frontend/cmd/equip.cpp index 72795a8..b8caad8 100644 --- a/frontend/cmd/equip.cpp +++ b/frontend/cmd/equip.cpp @@ -16,6 +16,7 @@ void GameController::cmd_equip(string & target_name) { Object & object = **it; player.equip(&object); + player.inventory.remove(&object); this->dungeon->update(); } |