Skip to content

Commit 0765d9a

Browse files
committed
Fixed merge conflicts
2 parents 3449b67 + b1a3e1a commit 0765d9a

19 files changed

+838
-69
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ warsofcatan
2121
*.wocs
2222

2323
documentation/*
24+
/Debug

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/GameBoard.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,14 @@ class GameBoard {
8888

8989
void PlaceSettlement(Coordinate location, Player& Owner);
9090
void UpgradeSettlement(Coordinate location);
91-
//void PlaceRoad(Coordinate start, Coordinate end, Player& Owner);
91+
void UpgradeToWonder(Coordinate location);
9292

9393

9494
bool buyRoad(Coordinate start, Coordinate end, Player& Owner);
9595

9696
//void PlaceSettlement(Coordinate location, Player& Owner);
9797
void PlaceCity(Coordinate location, Player& Owner);
98+
void PlaceWonder(Coordinate location, Player& Owner);
9899
bool PlaceRoad(Coordinate start, Coordinate end, Player& Owner);
99100

100101
void accept(GameVisitor& visitor);

include/GameView.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class DrawingGameVisitor : public GameVisitor {
8686
virtual void visit(Player&);
8787
virtual void visit(ResourceTile&);
8888
virtual void visit(DevelopmentCard&);
89+
virtual void visit(Wonder&);
8990
};
9091

9192
/**
@@ -200,4 +201,4 @@ class TradingView : public ViewElement {
200201
void render();
201202
};
202203

203-
#endif
204+
#endif

include/GameVisitor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Road;
88
class City;
99
class Player;
1010
class DevelopmentCard;
11+
class Wonder;
1112

1213
/**
1314
* A class to be extended with callbacks to handle the different classes in the model.
@@ -28,6 +29,7 @@ class GameVisitor {
2829
virtual void visit(Player&) = 0;
2930
virtual void visit(ResourceTile&) = 0;
3031
virtual void visit(DevelopmentCard&) = 0;
32+
virtual void visit(Wonder&) = 0;
3133
};
3234

33-
#endif
35+
#endif

include/Player.h

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,45 @@ class Player {
5454
Player(GameBoard& board, tinyxml2::XMLElement*);
5555
~Player();
5656

57+
int getArmySize();
58+
int getLongestRoad();
5759
int getVictoryPoints();
60+
5861
void updateVictoryPoints();
5962

6063
int getVictoryPointsWithoutCards();
6164
int getVictoryPointCards();
6265

6366
int getDevCardsInHand();
6467

65-
void buyCard(std::unique_ptr<DevelopmentCard> card);
6668
std::string getName() const;
6769

6870
// void playCard(int index);
6971
// void playCard(DevelopmentCard* card);
7072

7173
bool canBuyRoad();
7274
bool buyRoad();
73-
75+
bool canBuySettlement();
76+
bool buySettlement();
77+
bool canBuyCity();
78+
bool buyCity();
79+
bool canBuyWonder();
80+
bool buyWonder();
81+
bool canBuyCard();
82+
bool buyCard();
83+
84+
int getWoodModifier();
7485
void setWoodModifier();
86+
int getBrickModifier();
7587
void setBrickModifier();
88+
int getOreModifier();
7689
void setOreModifier();
90+
int getWheatModifier();
7791
void setWheatModifier();
92+
int getWoolModifier();
7893
void setWoolModifier();
7994

80-
void setGenralModifier(); //3:1 port
95+
void setGeneralModifier(); //3:1 port
8196

8297
bool offerBankTrade(std::array<int, 5> offer, std::array<int, 5> demand);
8398

@@ -98,10 +113,15 @@ class Player {
98113
void addOre(int resource);
99114
void addWheat(int resource);
100115
void addWool(int resource);
116+
void addMultiple(int wood, int brick, int ore, int wheat, int wool);
101117

102118
int getResource(int resourceType) const; //
103119
void addResource(int resourceType, int delta);
104120

121+
bool validateResourceAmount(int wood, int brick, int ore, int wheat, int wool);
122+
bool validateTradeModifiers(int wood, int brick, int ore, int wheat, int wool);
123+
124+
105125
void accept(GameVisitor& visitor);
106126
bool operator==(const Player& player) const;
107127
};

include/Serialization.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ class XMLVisitor : public GameVisitor {
3333
virtual void visit(Player&);
3434
virtual void visit(ResourceTile&);
3535
virtual void visit(DevelopmentCard&);
36+
virtual void visit(Wonder&);
3637

3738
const tinyxml2::XMLDocument& getXMLDoc() const;
3839
};
3940

4041
Coordinate xmlElementToCoord(const tinyxml2::XMLElement& element);
4142

42-
#endif
43+
#endif

include/Wonder.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Wonder.h
3+
*
4+
* Created on: Apr 10, 2014
5+
* Author: Kyle Grage
6+
*/
7+
8+
#ifndef WONDER_H_
9+
#define WONDER_H_
10+
11+
#include "CornerPiece.h"
12+
13+
class Wonder : public CornerPiece {
14+
private:
15+
16+
public:
17+
Wonder(GameBoard& board, Coordinate location, Player& owner);
18+
Wonder(Wonder&) = delete;
19+
~Wonder();
20+
Wonder(CornerPiece& sett);
21+
Wonder& operator=(City&) = delete;
22+
23+
virtual void accept(GameVisitor&);
24+
virtual bool operator==(const GamePiece& piece) const;
25+
26+
int getResourceModifier();
27+
int getVictoryPoints();
28+
29+
};
30+
31+
#endif /* WONDER_H_ */

src/City.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ City::~City() {
2020
}
2121

2222
/**
23-
*
2423
* @param visitor The visiting member.
2524
*/
2625
void City::accept(GameVisitor& visitor) {
@@ -29,11 +28,16 @@ void City::accept(GameVisitor& visitor) {
2928

3029
/**
3130
* Test for equality with another game piece.
32-
* @param p The piece to test with
31+
* @param other The piece to test with
3332
* @return True if this object is equal to the other, false if not.
3433
*/
35-
bool City::operator==(const GamePiece& p) const {
36-
return false; //TODO: Actually compare.
34+
bool City::operator==(const GamePiece& other) const {
35+
auto city = dynamic_cast<const City*>(&other);
36+
if(city) {
37+
return getOwner().getName() == city->getOwner().getName() && getLocation() == city->getLocation();
38+
} else {
39+
return false;
40+
}
3741
}
3842

3943
/**
@@ -49,7 +53,7 @@ int City::getResourceModifier() {
4953
* @return The victory points the player gets from the city.
5054
*/
5155
int City::getVictoryPoints() {
52-
return 2; //TODO: implement robber check here
56+
return 2;
5357
}
5458

5559
/**
@@ -59,3 +63,5 @@ int City::getVictoryPoints() {
5963
City::City(CornerPiece& sett) : CornerPiece(sett.getBoard(), sett.getLocation(), sett.getOwner()) {
6064

6165
}
66+
67+

0 commit comments

Comments
 (0)