summaryrefslogtreecommitdiffstats
path: root/labb4/GameState.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'labb4/GameState.cpp')
-rw-r--r--labb4/GameState.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/labb4/GameState.cpp b/labb4/GameState.cpp
index 6de11dd..47842a1 100644
--- a/labb4/GameState.cpp
+++ b/labb4/GameState.cpp
@@ -27,6 +27,28 @@ GameState::GameState(const GameState &other) {
hero = other.hero;
}
+/*
+*/
+GameState::~GameState() {
+ for (const auto &robot : robots) {
+ delete robot;
+ }
+ robots.clear();
+}
+
+GameState &GameState::operator=(const GameState &other) {
+ for (const auto &robot : robots) {
+ delete robot;
+ }
+ robots.clear();
+ for (const auto &robot : other.robots) {
+ robots.push_back(robot->clone());
+ }
+ hero = other.hero;
+
+ return *this;
+}
+
void GameState::draw(QGraphicsScene *scene) const {
scene->clear();
for (int i = 0; i < robots.size(); i++) {