summaryrefslogtreecommitdiffstats
path: root/labb4/GameState.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'labb4/GameState.cpp')
-rw-r--r--labb4/GameState.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/labb4/GameState.cpp b/labb4/GameState.cpp
index f9f5c72..a21e49c 100644
--- a/labb4/GameState.cpp
+++ b/labb4/GameState.cpp
@@ -20,26 +20,26 @@ GameState::GameState(int numberOfRobots) {
teleportHero();
}
-GameState::GameState(const GameState &other) {
- for (const auto &robot : other.robots) {
+GameState::GameState(const GameState& other) {
+ for (const auto& robot : other.robots) {
robots.push_back(robot->clone());
}
hero = other.hero;
}
GameState::~GameState() {
- for (const auto &robot : robots) {
+ for (const auto& robot : robots) {
delete robot;
}
robots.clear();
}
-GameState &GameState::operator=(const GameState &other) {
- for (const auto &robot : robots) {
+GameState& GameState::operator=(const GameState& other) {
+ for (const auto& robot : robots) {
delete robot;
}
robots.clear();
- for (const auto &robot : other.robots) {
+ for (const auto& robot : other.robots) {
robots.push_back(robot->clone());
}
hero = other.hero;
@@ -47,7 +47,7 @@ GameState &GameState::operator=(const GameState &other) {
return *this;
}
-void GameState::draw(QGraphicsScene *scene) const {
+void GameState::draw(QGraphicsScene* scene) const {
scene->clear();
for (int i = 0; i < robots.size(); i++) {
robots[i]->draw(scene);
@@ -83,7 +83,7 @@ int GameState::countCollisions() {
}
bool GameState::anyRobotsLeft() const {
- for (const auto &robot : robots) {
+ for (const auto& robot : robots) {
if (robot->alive()) {
return true;
}
@@ -123,7 +123,7 @@ bool GameState::isEmpty(const Unit& unit) const {
* Is there junk at unit?
*/
bool GameState::junkAt(const Unit& unit) const {
- for (const auto &robot : robots) {
+ for (const auto& robot : robots) {
if (robot->at(unit) && !robot->alive()) {
return true;
}
@@ -136,7 +136,7 @@ bool GameState::junkAt(const Unit& unit) const {
*/
int GameState::countRobotsAt(const Unit& unit) const {
int count = 0;
- for (const auto &robot : robots) {
+ for (const auto& robot : robots) {
if (robot->at(unit) && robot->alive()) {
count++;
}