summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2020-11-10 15:02:21 +0100
committerGustav Sörnäs <gustav@sornas.net>2020-11-10 15:02:21 +0100
commitde4e4f7694bb4ba07f543b214c67b85f0a3f0d49 (patch)
treefb78d8905d42e09a6d3201d4ef7d0abcc19b03b8
parent00b84ef1485204e03395e7c90634bc7de16cd9fb (diff)
downloadtddd86-de4e4f7694bb4ba07f543b214c67b85f0a3f0d49.tar.gz
consistent formatting
-rw-r--r--labb4/GameState.cpp20
-rw-r--r--labb4/GameState.h4
-rw-r--r--labb4/Junk.cpp2
-rw-r--r--labb4/Junk.h2
-rw-r--r--labb4/Robot.cpp2
5 files changed, 15 insertions, 15 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++;
}
diff --git a/labb4/GameState.h b/labb4/GameState.h
index dfd7ac5..17b86de 100644
--- a/labb4/GameState.h
+++ b/labb4/GameState.h
@@ -27,7 +27,7 @@ public:
/*
* Copy assignment.
*/
- GameState &operator=(const GameState &other);
+ GameState& operator=(const GameState& other);
/*
* Clear and redraw entire playing field.
@@ -75,7 +75,7 @@ public:
Hero getHero () const;
private:
- std::vector<Robot *> robots; // the robots and the junk combined
+ std::vector<Robot*> robots; // the robots and the junk combined
Hero hero; // the hero
// private helpers
diff --git a/labb4/Junk.cpp b/labb4/Junk.cpp
index 5c467da..6e80a06 100644
--- a/labb4/Junk.cpp
+++ b/labb4/Junk.cpp
@@ -9,7 +9,7 @@
Junk::Junk() : Robot() {}
Junk::Junk(Robot c) : Robot(c) {}
-void Junk::draw(QGraphicsScene *scene) const {
+void Junk::draw(QGraphicsScene* scene) const {
Point corner = asPoint();
scene->addEllipse(QRectF(corner.x * UNIT_WIDTH, corner.y * UNIT_HEIGHT,
JUNK_RADIUS, JUNK_RADIUS), QPen(), QBrush(JUNK_COLOR));
diff --git a/labb4/Junk.h b/labb4/Junk.h
index 65201c4..8e3c357 100644
--- a/labb4/Junk.h
+++ b/labb4/Junk.h
@@ -20,7 +20,7 @@ public:
*/
void draw(QGraphicsScene* scene) const override;
- void moveTowards(const Unit& u) override {}
+ void moveTowards(const Unit&) override {}
/*
* Junk can't attack in any direction.
diff --git a/labb4/Robot.cpp b/labb4/Robot.cpp
index 444f938..6cc3c4c 100644
--- a/labb4/Robot.cpp
+++ b/labb4/Robot.cpp
@@ -8,7 +8,7 @@
Robot::Robot() : Unit() {}
-void Robot::draw(QGraphicsScene *scene) const {
+void Robot::draw(QGraphicsScene* scene) const {
Point corner = asPoint();
scene->addEllipse(QRectF(corner.x * UNIT_WIDTH, corner.y * UNIT_HEIGHT,
JUNK_RADIUS, JUNK_RADIUS), QPen(), QBrush(ROBOT_COLOR));