Skip to content

Commit be3a3c2

Browse files
committed
Merged changes
2 parents 7945832 + b1a3e1a commit be3a3c2

35 files changed

+3662
-445
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ warsofcatan
1919
*.test
2020
/Default
2121
*.wocs
22+
23+
documentation/*
24+
/Debug

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ language: cpp
22
before_install:
33
- sudo add-apt-repository ppa:antumdeluge/sdl2 -y
44
- sudo apt-get update -y
5-
- sudo apt-get install libsdl2 libsdl2-dev -y
5+
- sudo apt-get install libsdl2 libsdl2-dev libsdl2-ttf libsdl2-ttf-dev -y
66
script: make tests

Doxyfile

Lines changed: 2304 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ALLFILES := $(wildcard $(SRC_HOME)/*) $(wildcard $(INCL_HOME)/*)
88
export CXX := g++
99
export LD := g++
1010
export CXXFLAGS := -g -I$(INCL_HOME) -std=c++0x -Wall
11-
export LDFLAGS := -L/usr/local/lib -lSDL2 -lGL -lGLU
11+
export LDFLAGS := -L/usr/local/lib -lSDL2 -lSDL2_ttf -lGL -lGLU
1212

1313
.PHONY: all
1414
all: $(EXECUTABLE)

include/City.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
* Upgraded from a Settlement. Exists on the board, and receives two resources from adjacent tiles when their number is rolled.
88
*/
99
class City : public CornerPiece {
10-
private:
10+
private:
1111

12-
public:
13-
City(GameBoard& board, Coordinate location, Player& owner);
14-
City(City&) = delete;
15-
~City();
16-
City(CornerPiece& sett);
17-
City& operator=(City&) = delete;
18-
19-
virtual void accept(GameVisitor&);
20-
virtual bool operator==(const GamePiece& piece) const;
12+
public:
13+
City(GameBoard& board, Coordinate location, Player& owner);
14+
City(City&) = delete;
15+
~City();
16+
City(CornerPiece& sett);
17+
City& operator=(City&) = delete;
2118

22-
int getResourceModifier();
23-
int getVictoryPoints();
19+
virtual void accept(GameVisitor&);
20+
virtual bool operator==(const GamePiece& piece) const;
21+
22+
int getResourceModifier();
23+
int getVictoryPoints();
2424
};
2525

2626
#endif

include/CornerPiece.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ class CornerPiece : public GamePiece {
2020
Player& getOwner();
2121
const Player& getOwner() const;
2222

23+
virtual void accept(GameVisitor& visitor)=0;
24+
2325
virtual int getResourceModifier();
2426

2527
virtual int getVictoryPoints();
28+
29+
virtual bool operator==(const GamePiece&) const;
2630
};
2731

2832
#endif

include/Deck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Deck {
2727
void reshuffleDeck();
2828

2929
public:
30-
Deck();
30+
Deck(GameBoard& board);
3131
virtual ~Deck();
3232

3333
int getSize();

include/DevelopmentCard.h

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,93 +20,82 @@
2020
enum DevCardType { KNIGHT, VICTORYPOINT, YEAROFPLENTY, MONOPOLY, ROADBUILDING };
2121

2222

23-
/**
24-
* A card which can be held in a player's hand and be used to perform an action.
25-
*/
23+
2624
class DevelopmentCard {
2725

28-
private:
29-
Player* owner;
26+
protected:
3027
DevCardType type;
28+
GameBoard& board;
3129
public:
32-
DevelopmentCard(Player* player);
30+
DevelopmentCard(GameBoard& board);
3331
virtual ~DevelopmentCard();
3432

3533
virtual DevCardType getType() const = 0;
36-
virtual void playCard() = 0;
3734

38-
virtual Player* getOwner();
3935
virtual void accept(GameVisitor& visitor);
4036
virtual bool operator==(const DevelopmentCard&);
4137
};
4238

43-
/**
44-
* A development card used to move the robber and take a resource from another player.
45-
*/
39+
40+
4641
class KnightCard : public DevelopmentCard {
4742
private:
4843

4944
public:
50-
KnightCard(Player* player);
45+
KnightCard(GameBoard& board);
5146
// virtual ~KnightCard();
5247

5348
virtual DevCardType getType() const;
54-
virtual void playCard();
49+
void playCard(Player *player, Coordinate target);
5550

5651
};
5752

58-
/**
59-
* A development card that gives a permanent victory point on usage.
60-
*/
53+
54+
6155
class VictoryPointCard : public DevelopmentCard {
6256
public:
63-
VictoryPointCard(Player* player);
57+
VictoryPointCard(GameBoard& board);
6458
// virtual ~VictoryPointCard();
6559

6660
virtual DevCardType getType() const;
67-
virtual void playCard();
6861

6962
};
7063

71-
/**
72-
* A development card used to retrieve two resources of any type from the bank.
73-
*/
64+
7465
class YearOfPlentyCard : public DevelopmentCard {
7566
public:
76-
YearOfPlentyCard(Player* player);
67+
YearOfPlentyCard(GameBoard& board);
7768
// virtual ~YearOfPlentyCard();
7869

7970
virtual DevCardType getType() const;
80-
virtual void playCard();
71+
void playCard(Player *player, int rType1, int rType2);
8172

8273
};
8374

84-
/**
85-
* A development card used to take all resources of a particular type from all players.
86-
*/
75+
76+
77+
8778
class MonopolyCard : public DevelopmentCard {
8879
public:
89-
MonopolyCard(Player* player);
80+
MonopolyCard(GameBoard& board);
9081
// virtual ~MonopolyCard();
9182

9283
virtual DevCardType getType() const;
93-
virtual void playCard();
84+
void playCard(Player *player, int rType);
9485

9586
};
9687

97-
/**
98-
* A development card used to build two roads at no cost.
99-
*/
88+
89+
10090
class RoadBuildingCard : public DevelopmentCard {
10191
private:
10292

10393
public:
104-
RoadBuildingCard(Player* player);
94+
RoadBuildingCard(GameBoard& board);
10595
// virtual ~RoadBuildingCard();
10696

10797
virtual DevCardType getType() const;
108-
virtual void playCard();
109-
void playCard(Coordinate start1, Coordinate end1, Coordinate start2, Coordinate end2);
98+
void playCard(Player* player, Coordinate start1, Coordinate end1, Coordinate start2, Coordinate end2);
11099
};
111100

112101

include/GameBoard.h

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ class GameBoard {
3838
std::vector<std::unique_ptr<Player>> players;
3939
Coordinate robber;
4040

41-
41+
4242
void addResource(int x, int y, resourceType res, int val);
4343
bool checkRolls(int* rolls);
44-
44+
4545
bool isValidBoard() const;
46-
46+
4747

4848
bool verifyRoadPlacement(Coordinate start, Coordinate end, Player& Owner) const;
4949
bool outOfBounds(const Coordinate& coord) const;
@@ -55,7 +55,7 @@ class GameBoard {
5555

5656
void removeRoadEnd(std::shared_ptr<Road> startRoad);
5757
int FindLongestRoad_FromPoint(Coordinate curr, const Player & owner, std::map<Coordinate, bool>& marked, std::map<Road*, bool>& markedRoads, int length) const;
58-
58+
5959
void createRing(Coordinate topRight, int sideLength, std::vector<resourceType>& resources, std::vector<int>& rolls);
6060
void insertTile(Coordinate location, std::vector<resourceType>& resources, std::vector<int>& rolls);
6161

@@ -64,15 +64,15 @@ class GameBoard {
6464
void payoutResources(int roll);
6565

6666
public:
67-
GameBoard(std::vector<std::unique_ptr<Player>>&& players);
68-
GameBoard(std::vector<std::unique_ptr<Player>>&& players, const std::map<Coordinate, std::pair<resourceType, int>>& resourceLocations);
67+
GameBoard(const std::vector<std::string>& playerNames);
68+
GameBoard(const std::vector<std::string>& playerNames, const std::map<Coordinate, std::pair<resourceType, int>>& resourceLocations);
6969
GameBoard(std::istream& in);
7070
GameBoard(GameBoard&) = delete;
7171
~GameBoard();
7272
GameBoard& operator=(GameBoard&) = delete;
73-
73+
7474
void save(std::ostream& out);
75-
75+
7676
ResourceTile& getResourceTile(Coordinate location) const;
7777

7878
const std::map<Coordinate, std::unique_ptr<ResourceTile>>& getResources() const;
@@ -81,7 +81,7 @@ class GameBoard {
8181

8282
const std::shared_ptr<Road> getRoad(Coordinate start, Coordinate end) const;
8383
const std::vector<std::shared_ptr<Road>>& getRoads(Coordinate loc) const;
84-
84+
8585
int FindLongestRoad(const Player & owner) const;
8686

8787
std::vector<Settlement*> GetNeighboringSettlements(Coordinate location) const;
@@ -91,21 +91,25 @@ class GameBoard {
9191

9292
void PlaceSettlement(Coordinate location, Player& Owner);
9393
void UpgradeSettlement(Coordinate location);
94-
//void PlaceRoad(Coordinate start, Coordinate end, Player& Owner);
94+
void UpgradeToWonder(Coordinate location);
9595

9696

9797
bool buyRoad(Coordinate start, Coordinate end, Player& Owner);
9898

9999
//void PlaceSettlement(Coordinate location, Player& Owner);
100100
void PlaceCity(Coordinate location, Player& Owner);
101+
void PlaceWonder(Coordinate location, Player& Owner);
101102
bool PlaceRoad(Coordinate start, Coordinate end, Player& Owner);
102-
103+
103104
void accept(GameVisitor& visitor);
104-
105+
105106
bool operator==(const GameBoard& other) const;
106-
107+
107108
const std::vector<std::unique_ptr<Player>>& getPlayers() const;
108-
109+
110+
int getNoOfPlayers();
111+
Player& getPlayer(int index);
112+
109113
bool testRollChecking(int* rolls);
110114

111115
void moveRobber(Coordinate newRobber);

include/GameView.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class DrawingGameVisitor : public GameVisitor {
8080
virtual void visit(ResourceTile&);
8181
virtual void visit(DevelopmentCard&);
8282
virtual void visit(GameDice&);
83+
virtual void visit(Wonder&);
8384
};
8485

8586
/**
@@ -156,4 +157,4 @@ std::unique_ptr<ViewElement> makeViewButtonColor(Fn fn, std::pair<ScreenCoordina
156157
return std::unique_ptr<ViewElement>(new ViewButtonColor<Fn>(fn, rect, color));
157158
}
158159

159-
#endif
160+
#endif

0 commit comments

Comments
 (0)