Skip to content

Commit d79d067

Browse files
committed
Merge pull request #69 from Databean/road_refactoring
Road refactoring
2 parents 268eb2c + 7b8de2b commit d79d067

File tree

6 files changed

+552
-424
lines changed

6 files changed

+552
-424
lines changed

include/GameBoard.h

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include "DevelopmentCard.h"
2323

24-
2524
class GameVisitor;
2625

2726
/**
@@ -37,7 +36,7 @@ class GameBoard {
3736

3837
Deck deck;
3938

40-
std::map<Coordinate, std::vector<std::shared_ptr<Road>>> roads;
39+
std::map<Coordinate, std::vector<std::shared_ptr<Road>>>roads;
4140

4241
std::vector<std::unique_ptr<Player>> players;
4342
Coordinate robber;
@@ -46,12 +45,11 @@ class GameBoard {
4645
int maxVictoryPoints;
4746
int winner;
4847

49-
void addResource(int x, int y, resourceType res, int val);
50-
bool checkRolls(int* rolls);
48+
void addResource(int x, int y, resourceType res, int val);
49+
bool checkRolls(int* rolls);
5150

5251
bool isValidBoard() const;
5352

54-
5553
bool outOfBounds(const Coordinate& coord) const;
5654
bool roadExists(Coordinate start, Coordinate end) const;
5755
bool isRoadConnectionPoint(Coordinate point, Player& Owner) const;
@@ -64,11 +62,11 @@ class GameBoard {
6462

6563
void createRing(Coordinate topRight, int sideLength, std::vector<resourceType>& resources, std::vector<int>& rolls);
6664
void insertTile(Coordinate location, std::vector<resourceType>& resources, std::vector<int>& rolls);
67-
68-
std::pair<int, int> startTurn();
69-
void enableRobber();
70-
void payoutResources(int roll);
71-
65+
66+
std::pair<int, int> startTurn();
67+
void enableRobber();
68+
void payoutResources(int roll);
69+
7270
public:
7371
GameBoard(const std::vector<std::string>& playerNames);
7472
GameBoard(const std::vector<std::string>& playerNames, const std::map<Coordinate, std::pair<resourceType, int>>& resourceLocations);
@@ -112,16 +110,16 @@ class GameBoard {
112110
void PlaceSettlement(Coordinate location, Player& Owner);
113111
void UpgradeSettlement(Coordinate location);
114112
void UpgradeToWonder(Coordinate location);
115-
113+
116114
bool verifyRoadPlacement(Coordinate start, Coordinate end, Player& Owner) const;
117115
bool buyRoad(Coordinate start, Coordinate end, Player& Owner);
118-
116+
119117
bool canPlaceSettlement(const Coordinate& location, const Player& owner);
120118
bool buySettlement(const Coordinate& location, Player& owner);
121-
119+
122120
bool canUpgradeSettlement(Coordinate location, const Player& owner) const;
123121
bool buyUpgradeOnSettlement(Coordinate location, Player& owner);
124-
122+
125123
bool canUpgradeToWonder(Coordinate location, const Player& owner) const;
126124
bool buyUpgradeOnWonder(Coordinate location, Player& owner);
127125

@@ -136,15 +134,15 @@ class GameBoard {
136134
bool operator==(const GameBoard& other) const;
137135

138136
const std::vector<std::unique_ptr<Player>>& getPlayers() const;
139-
137+
140138
int getNoOfPlayers();
141139
Player& getPlayer(int index);
142140

143-
bool testRollChecking(int* rolls);
141+
bool testRollChecking(int* rolls);
144142

145-
bool moveRobber(Coordinate newRobber);
146-
Coordinate getRobber() const;
147-
bool canRobberRob(Player& opponent, Coordinate location);
143+
bool moveRobber(Coordinate newRobber);
144+
Coordinate getRobber() const;
145+
bool canRobberRob(Player& opponent, Coordinate location);
148146

149147
};
150148

include/Road.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Road {
1919
Player& owner;
2020
Coordinate start;
2121
Coordinate end;
22-
22+
2323
bool checkRoad();
2424
public:
2525

@@ -33,14 +33,13 @@ class Road {
3333
Coordinate getStart() const;
3434
Coordinate getEnd() const;
3535

36-
bool equals(const Road& otherRoad);
37-
bool equals(const Coordinate& otherStart, const Coordinate& otherEnd);
38-
36+
bool operator==(const Road&) const;
37+
bool equals(const Road& otherRoad) const;
38+
bool equals(const Coordinate& otherStart, const Coordinate& otherEnd) const;
39+
3940
Player& getOwner();
40-
const Player& getOwner() const;
41-
41+
4242
virtual void accept(GameVisitor& visitor);
43-
bool operator==(const Road&) const;
4443
};
4544

4645
#endif

0 commit comments

Comments
 (0)