Skip to content

Commit 652b598

Browse files
committed
Integrated new Settlement, Road, City, and CornerPiece classes
1 parent 4a564ec commit 652b598

File tree

12 files changed

+63
-56
lines changed

12 files changed

+63
-56
lines changed

include/City.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#ifndef CITY_H
22
#define CITY_H
33

4-
class City public CornerPiece {
4+
#include "CornerPiece.h"
5+
6+
class City : public CornerPiece {
57
private:
68

79
public:
8-
City();
10+
City(GameBoard& board, Coordinate location);
911
City(City&) = delete;
1012
~City();
1113
City& operator=(City&) = delete;

include/CornerPiece.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#ifndef CORNERPIECE_H
22
#define CORNERPIECE_H
33

4-
class CornerPiece {
4+
#include "GamePiece.h"
5+
6+
class CornerPiece : public GamePiece {
57
private:
68

79
public:
8-
CornerPiece();
10+
CornerPiece(GameBoard& board, Coordinate location);
911
CornerPiece(CornerPiece&) = delete;
1012
~CornerPiece();
1113
CornerPiece& operator=(CornerPiece&) = delete;

include/GameBoard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
#include "Util.h"
1414
#include "GamePiece.h"
15+
#include "Settlement.h"
1516
#include "tinyxml2.h"
17+
#include "Road.h"
1618

1719
class GameBoard {
1820
private:

include/GamePiece.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,5 @@ class ResourceTile : public GamePiece {
4040
virtual ~ResourceTile();
4141
};
4242

43-
class Settlement : public GamePiece {
44-
private:
45-
Player& owner;
46-
public:
47-
Settlement(GameBoard& board, Coordinate location, Player& owner);
48-
Settlement(Settlement&) = delete;
49-
virtual ~Settlement();
50-
//virtual Settlement& operator=(Settlement&) = delete;
51-
52-
bool city;
53-
};
54-
55-
class Road {
56-
private:
57-
GameBoard& board;
58-
Player& owner;
59-
Coordinate start;
60-
Coordinate end;
61-
public:
62-
Road(GameBoard& board, Player& owner, Coordinate start, Coordinate end);
63-
Road(Road&);
64-
~Road();
65-
//Road& operator=(Road&) = delete;
66-
};
67-
6843
#endif
6944

include/Road.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#ifndef ROAD_H
22
#define ROAD_H
33

4-
class Road public CornerPiece {
5-
private:
4+
#include "Util.h"
65

6+
class Road {
7+
private:
8+
Coordinate start;
9+
Coordinate end;
710
public:
8-
Road();
11+
Road(Coordinate start, Coordinate end);
912
Road(Road&) = delete;
1013
~Road();
1114
Road& operator=(Road&) = delete;

include/Settlement.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#ifndef SETTLEMENT_H
22
#define SETTLEMENT_H
33

4-
class Settlement: public CornerPiece {
4+
#include "CornerPiece.h"
5+
6+
class Settlement : public CornerPiece {
57
private:
68

79
public:
8-
Settlement();
10+
Settlement(GameBoard& board, Coordinate location);
911
Settlement(Settlement&) = delete;
1012
~Settlement();
1113
Settlement& operator=(Settlement&) = delete;

src/City.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "City.h"
2+
3+
City::City(GameBoard& board, Coordinate location) : CornerPiece(board, location) {
4+
5+
}
6+
7+
City::~City() {
8+
9+
}

src/CornerPiece.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "CornerPiece.h"
2+
3+
CornerPiece::CornerPiece(GameBoard& board, Coordinate location) : GamePiece(board, location) {
4+
5+
}
6+
7+
CornerPiece::~CornerPiece() {
8+
9+
}

src/GameBoard.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,6 @@ void GameBoard::init_resources()
158158
}
159159

160160
void GameBoard::PlaceSettlement(Coordinate location, Player& Owner){
161-
corners[location] = std::unique_ptr<GamePiece>(new Settlement(*this, location, Owner));
161+
corners[location] = std::unique_ptr<GamePiece>(new Settlement(*this, location));
162162
}
163163

src/GamePiece.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,3 @@ void ResourceTile::Payout() {
4141
}
4242
}
4343
*/
44-
45-
Settlement::Settlement(GameBoard& board, Coordinate location, Player& owner) :
46-
GamePiece(board, location), owner(owner), city(0) {
47-
48-
}
49-
50-
Settlement::~Settlement() {
51-
52-
}
53-
54-
Road::Road(GameBoard& board, Player& owner, Coordinate start, Coordinate end) : board(board), owner(owner), start(start), end(end) {
55-
56-
}
57-
58-
Road::Road(Road& other) : board(other.board), owner(other.owner), start(other.start), end(other.end) {
59-
60-
}
61-
62-
Road::~Road() {
63-
64-
}

0 commit comments

Comments
 (0)