Skip to content

Commit ce7e273

Browse files
committed
Merge branch 'master' into move_dice_again
Conflicts: src/main.cpp
2 parents be2a151 + a06e423 commit ce7e273

29 files changed

+1289
-453
lines changed

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CornerPiece : public GamePiece {
1616
CornerPiece(CornerPiece&) = delete;
1717
~CornerPiece();
1818
CornerPiece& operator=(CornerPiece&) = delete;
19-
19+
2020
Player& getOwner();
2121
const Player& getOwner() const;
2222

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(GameBoard& board);
30+
Deck();
3131
virtual ~Deck();
3232

3333
int getSize();

include/DevelopmentCard.h

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
enum DevCardType { KNIGHT, VICTORYPOINT, YEAROFPLENTY, MONOPOLY, ROADBUILDING };
2121

2222

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

26-
protected:
28+
private:
2729
DevCardType type;
28-
GameBoard& board;
2930
public:
30-
DevelopmentCard(GameBoard& board);
31+
DevelopmentCard() {}
3132
virtual ~DevelopmentCard();
3233

3334
virtual DevCardType getType() const = 0;
@@ -36,66 +37,53 @@ class DevelopmentCard {
3637
virtual bool operator==(const DevelopmentCard&);
3738
};
3839

39-
40-
40+
/**
41+
* A development card used to move the robber and take a resource from another player.
42+
*/
4143
class KnightCard : public DevelopmentCard {
4244
private:
4345

4446
public:
45-
KnightCard(GameBoard& board);
46-
// virtual ~KnightCard();
47-
47+
KnightCard() {}
4848
virtual DevCardType getType() const;
49-
void playCard(Player *player, Coordinate target);
50-
5149
};
5250

53-
54-
51+
/**
52+
* A development card that gives a permanent victory point on usage.
53+
*/
5554
class VictoryPointCard : public DevelopmentCard {
5655
public:
57-
VictoryPointCard(GameBoard& board);
58-
// virtual ~VictoryPointCard();
59-
56+
VictoryPointCard() {}
6057
virtual DevCardType getType() const;
61-
6258
};
6359

64-
60+
/**
61+
* A development card used to retrieve two resources of any type from the bank.
62+
*/
6563
class YearOfPlentyCard : public DevelopmentCard {
6664
public:
67-
YearOfPlentyCard(GameBoard& board);
68-
// virtual ~YearOfPlentyCard();
69-
65+
YearOfPlentyCard() {}
7066
virtual DevCardType getType() const;
71-
void playCard(Player *player, int rType1, int rType2);
72-
7367
};
7468

75-
76-
77-
69+
/**
70+
* A development card used to take all resources of a particular type from all players.
71+
*/
7872
class MonopolyCard : public DevelopmentCard {
7973
public:
80-
MonopolyCard(GameBoard& board);
81-
// virtual ~MonopolyCard();
82-
74+
MonopolyCard() {}
8375
virtual DevCardType getType() const;
84-
void playCard(Player *player, int rType);
85-
8676
};
8777

88-
89-
78+
/**
79+
* A development card used to build two roads at no cost.
80+
*/
9081
class RoadBuildingCard : public DevelopmentCard {
9182
private:
9283

9384
public:
94-
RoadBuildingCard(GameBoard& board);
95-
// virtual ~RoadBuildingCard();
96-
85+
RoadBuildingCard() {};
9786
virtual DevCardType getType() const;
98-
void playCard(Player* player, Coordinate start1, Coordinate end1, Coordinate start2, Coordinate end2);
9987
};
10088

10189

include/GameBoard.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class GameBoard {
4848
bool isValidBoard() const;
4949

5050

51-
bool verifyRoadPlacement(Coordinate start, Coordinate end, Player& Owner) const;
5251
bool outOfBounds(const Coordinate& coord) const;
5352
bool roadExists(Coordinate start, Coordinate end) const;
5453
bool isRoadConnectionPoint(Coordinate point, Player& Owner) const;
@@ -85,28 +84,31 @@ class GameBoard {
8584

8685
int getMaxVictoryPoints();
8786
void setMaxVictoryPoints(int maxVicPts);
88-
8987
const std::shared_ptr<Road> getRoad(Coordinate start, Coordinate end) const;
9088
const std::vector<std::shared_ptr<Road>>& getRoads(Coordinate loc) const;
9189

9290
int FindLongestRoad(const Player & owner) const;
91+
void updateLongestRoadPlayer();
92+
void updateLargestArmyPlayer();
9393

9494
std::vector<Settlement*> GetNeighboringSettlements(Coordinate location) const;
9595
std::vector<CornerPiece*> GetNeighboringCorners(Coordinate location) const;
9696

97-
97+
int CountCornerPoints(Player& owner);
9898

9999
void PlaceSettlement(Coordinate location, Player& Owner);
100100
void UpgradeSettlement(Coordinate location);
101101
void UpgradeToWonder(Coordinate location);
102102

103103

104+
bool verifyRoadPlacement(Coordinate start, Coordinate end, Player& Owner) const;
104105
bool buyRoad(Coordinate start, Coordinate end, Player& Owner);
105106

106107
//void PlaceSettlement(Coordinate location, Player& Owner);
107108
void PlaceCity(Coordinate location, Player& Owner);
108109
void PlaceWonder(Coordinate location, Player& Owner);
109110
bool PlaceRoad(Coordinate start, Coordinate end, Player& Owner);
111+
bool canPlayBuildRoadCard(Coordinate start1, Coordinate end1, Coordinate start2, Coordinate end2, Player& Owner);
110112

111113
void accept(GameVisitor& visitor);
112114

@@ -121,6 +123,7 @@ class GameBoard {
121123

122124
void moveRobber(Coordinate newRobber);
123125
Coordinate getRobber() const;
126+
bool canRobberRob(Player& opponent, Coordinate location);
124127

125128
};
126129

include/GameController.h

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define GAME_CONTROLLER_H
33

44
#include "Util.h"
5+
#include <vector>
56

67
#include <array>
78

@@ -10,18 +11,22 @@ class ClickCoordinateEvent;
1011
class GameView;
1112
class Player;
1213

14+
15+
enum ControlState {BASESTATE, MODALSTATE, BUILDROAD, BUILDSETTLEMENT, ROBBER,
16+
VICTORYPOINT_DEVCARD, BUILDROAD_DEVCARD, KNIGHT_DEVCARD, YEAROFPLENTY_DEVCARD, MONOPOLY_DEVCARD};
17+
18+
1319
/**
14-
* Takes interpreted Catan events from the View and calls the appropriate functions on the model to changee the state
20+
* Takes interpreted Catan events from the View and calls the appropriate functions on the model to change the state
1521
* in response.
1622
*/
1723
class GameController {
1824
private:
1925
GameBoard& model;
2026
GameView& view;
2127

22-
bool placingRoads;
23-
bool placingCities;
24-
Coordinate lastCoordClick;
28+
std::vector<ControlState> stateStack;
29+
std::vector<Coordinate> clickHistory;
2530

2631
GameController(const GameController& o) : model(o.model), view(o.view) {} //deleted
2732
GameController& operator=(const GameController& o) { return *this; } //deleted
@@ -33,6 +38,26 @@ class GameController {
3338
bool handleBoardEvent(ScreenCoordinate);
3439
bool handleRoadButtonEvent(ScreenCoordinate);
3540
bool handleSettlementButtonEvent(ScreenCoordinate);
41+
bool handleRoadCardButtonEvent(ScreenCoordinate);
42+
bool handleKnightCardButtonEvent(ScreenCoordinate);
43+
bool handleYearOfPlentyCardButtonEvent(ScreenCoordinate);
44+
bool handleMonopolyCardButtonEvent(ScreenCoordinate);
45+
bool handleVictoryPointCardButtonEvent(ScreenCoordinate);
46+
bool handleCancelButtonEvent(ScreenCoordinate);
47+
48+
bool handleConfirmRoadCard(ScreenCoordinate);
49+
bool handleCancelDialogueEvent(ScreenCoordinate);
50+
51+
void pushState(ControlState);
52+
ControlState getState();
53+
ControlState popState();
54+
void storeClick(Coordinate clickCoordinate);
55+
Coordinate getLastClick();
56+
Coordinate getPastClick(int howLongAgo);
57+
void clearClickHistory();
58+
bool hasClickHistory();
59+
int getClickHistorySize();
60+
3661
bool handlePlayerClick(ScreenCoordinate, Player&);
3762
bool handleTradeOffer(ScreenCoordinate, Player& initiating, std::array<int, 5>, Player& receiving, std::array<int, 5>);
3863
};

include/GameDice.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
#define GAMEDICE_H
33

44

5-
6-
7-
85
class GameVisitor;
96

107
class GameDice {
@@ -25,4 +22,4 @@ class GameDice {
2522

2623
};
2724

28-
#endif
25+
#endif

0 commit comments

Comments
 (0)