Skip to content

Commit 4f91e02

Browse files
committed
Added an owner to CornerPiece
1 parent 652b598 commit 4f91e02

File tree

7 files changed

+21
-9
lines changed

7 files changed

+21
-9
lines changed

include/City.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class City : public CornerPiece {
77
private:
88

99
public:
10-
City(GameBoard& board, Coordinate location);
10+
City(GameBoard& board, Coordinate location, Player& owner);
1111
City(City&) = delete;
1212
~City();
1313
City& operator=(City&) = delete;

include/CornerPiece.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
#define CORNERPIECE_H
33

44
#include "GamePiece.h"
5+
#include "Player.h"
56

67
class CornerPiece : public GamePiece {
78
private:
8-
9+
Player& owner;
910
public:
10-
CornerPiece(GameBoard& board, Coordinate location);
11+
CornerPiece(GameBoard& board, Coordinate location, Player& owner);
1112
CornerPiece(CornerPiece&) = delete;
1213
~CornerPiece();
1314
CornerPiece& operator=(CornerPiece&) = delete;
15+
16+
Player& getOwner();
17+
const Player& getOwner() const;
1418
};
1519

1620
#endif

include/Settlement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Settlement : public CornerPiece {
77
private:
88

99
public:
10-
Settlement(GameBoard& board, Coordinate location);
10+
Settlement(GameBoard& board, Coordinate location, Player& owner);
1111
Settlement(Settlement&) = delete;
1212
~Settlement();
1313
Settlement& operator=(Settlement&) = delete;

src/City.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "City.h"
22

3-
City::City(GameBoard& board, Coordinate location) : CornerPiece(board, location) {
3+
City::City(GameBoard& board, Coordinate location, Player& owner) : CornerPiece(board, location, owner) {
44

55
}
66

src/CornerPiece.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
#include "CornerPiece.h"
22

3-
CornerPiece::CornerPiece(GameBoard& board, Coordinate location) : GamePiece(board, location) {
3+
CornerPiece::CornerPiece(GameBoard& board, Coordinate location, Player& owner) : GamePiece(board, location), owner(owner) {
44

55
}
66

77
CornerPiece::~CornerPiece() {
88

9-
}
9+
}
10+
11+
Player& CornerPiece::getOwner() {
12+
return owner;
13+
}
14+
15+
const Player& CornerPiece::getOwner() const {
16+
return owner;
17+
}

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));
161+
corners[location] = std::unique_ptr<GamePiece>(new Settlement(*this, location, Owner));
162162
}
163163

src/Settlement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "Settlement.h"
22

3-
Settlement::Settlement(GameBoard& board, Coordinate location) : CornerPiece(board, location) {
3+
Settlement::Settlement(GameBoard& board, Coordinate location, Player& owner) : CornerPiece(board, location, owner) {
44

55
}
66

0 commit comments

Comments
 (0)