Skip to content

Commit 8b764d6

Browse files
committed
Merge pull request #20 from Databean/documentation
Document ALL the things!
2 parents 9ba73b9 + 676db45 commit 8b764d6

31 files changed

+834
-250
lines changed

include/City.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#include "CornerPiece.h"
55

6+
/**
7+
* Upgraded from a Settlement. Exists on the board, and receives two resources from adjacent tiles when their number is rolled.
8+
*/
69
class City : public CornerPiece {
710
private:
811

include/CornerPiece.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include "GamePiece.h"
55
#include "Player.h"
66

7+
/**
8+
* A piece that exists on one of the corners of a resource hexagon. Currently is either a Settlement or City, both of which
9+
* receive resources from adjacent resource tiles.
10+
*/
711
class CornerPiece : public GamePiece {
812
private:
913
Player& owner;

include/Deck.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#include <algorithm>
1414
#include "DevelopmentCard.h"
1515

16+
/**
17+
* A collection of Settlers of Catan cards, initialized with the cards available in the standard game
18+
* in the original amounts.
19+
*/
1620
class Deck {
1721

1822
private:

include/DevelopmentCard.h

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
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

2628
private:
@@ -38,8 +40,9 @@ class DevelopmentCard {
3840
virtual bool operator==(const DevelopmentCard&);
3941
};
4042

41-
42-
43+
/**
44+
* A development card used to move the robber and take a resource from another player.
45+
*/
4346
class KnightCard : public DevelopmentCard {
4447
private:
4548

@@ -52,8 +55,9 @@ class KnightCard : public DevelopmentCard {
5255

5356
};
5457

55-
56-
58+
/**
59+
* A development card that gives a permanent victory point on usage.
60+
*/
5761
class VictoryPointCard : public DevelopmentCard {
5862
public:
5963
VictoryPointCard(Player* player);
@@ -64,7 +68,9 @@ class VictoryPointCard : public DevelopmentCard {
6468

6569
};
6670

67-
71+
/**
72+
* A development card used to retrieve two resources of any type from the bank.
73+
*/
6874
class YearOfPlentyCard : public DevelopmentCard {
6975
public:
7076
YearOfPlentyCard(Player* player);
@@ -75,9 +81,9 @@ class YearOfPlentyCard : public DevelopmentCard {
7581

7682
};
7783

78-
79-
80-
84+
/**
85+
* A development card used to take all resources of a particular type from all players.
86+
*/
8187
class MonopolyCard : public DevelopmentCard {
8288
public:
8389
MonopolyCard(Player* player);
@@ -88,8 +94,9 @@ class MonopolyCard : public DevelopmentCard {
8894

8995
};
9096

91-
92-
97+
/**
98+
* A development card used to build two roads at no cost.
99+
*/
93100
class RoadBuildingCard : public DevelopmentCard {
94101
private:
95102

include/GameBoard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
class GameVisitor;
2222

23+
/**
24+
* A game of Settlers of Catan, including resource tiles, settlements, cities, roads, and players.
25+
*/
2326
class GameBoard {
2427
private:
2528
std::map<Coordinate, std::unique_ptr<CornerPiece>> corners;

include/GameController.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ class GameBoard;
77
class ClickCoordinateEvent;
88
class GameView;
99

10+
/**
11+
* Takes interpreted Catan events from the View and calls the appropriate functions on the model to changee the state
12+
* in response.
13+
*/
1014
class GameController {
1115
private:
1216
GameBoard& model;

include/GamePiece.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ enum resourceType { WHEAT, SHEEP, STONE, BRICK, WOOD, DESERT };
1010

1111
class GameBoard;
1212

13+
/**
14+
* Something that occupies a position in triangular coordinates on the board. Currently is either a
15+
* CornerPiece(Settlement or City) or a ResourceTile.
16+
*/
1317
class GamePiece {
1418
private:
1519
GameBoard& board;
@@ -33,6 +37,10 @@ class GamePiece {
3337

3438
};
3539

40+
/**
41+
* One of the hexagons that has a particular resource and a dice number on the board. When the dice
42+
* roll its number, resources are paid out to adjacent cities.
43+
*/
3644
class ResourceTile : public GamePiece {
3745
public:
3846
ResourceTile(GameBoard& board);

include/GameView.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class GameController;
1616
class ViewElement;
1717
class GameView;
1818

19+
/**
20+
* An element that is drawn on screen and can receive inputs from the user. These all occupy a rectangular area on screen
21+
* and can choose to handle clicks from the user that are inside their area.
22+
*/
1923
class ViewElement {
2024
private:
2125
std::pair<ScreenCoordinate, ScreenCoordinate> rect;
@@ -34,6 +38,9 @@ class ViewElement {
3438
virtual void render() = 0;
3539
};
3640

41+
/**
42+
* The class in charge of drawing the view to the screen, using OpenGL calls.
43+
*/
3744
class GameView {
3845
private:
3946
GameBoard& model;
@@ -52,6 +59,9 @@ class GameView {
5259
void addElement(std::unique_ptr<ViewElement>);
5360
};
5461

62+
/**
63+
* A visitor of the GameBoard hierarchy that draws the entire model.
64+
*/
5565
class DrawingGameVisitor : public GameVisitor {
5666
private:
5767
GameView& view;
@@ -71,6 +81,9 @@ class DrawingGameVisitor : public GameVisitor {
7181
virtual void visit(DevelopmentCard&);
7282
};
7383

84+
/**
85+
* A view element that is invisible and calls a callback function when it is clicked.
86+
*/
7487
template<class Fn>
7588
class ViewButton : public ViewElement {
7689
private:
@@ -89,11 +102,21 @@ class ViewButton : public ViewElement {
89102
virtual void render() {}
90103
};
91104

105+
/**
106+
* Constructs a ViewButton using the same parameters as the ViewButton. Exists because template inference exists only
107+
* for functions, not classes.
108+
* @param fn The callback function to be called with the ScreenCoordinate clicked and returning a boolean on if it was handled.
109+
* @param rect The location on screen that the invisible button receives clicks from.
110+
* @return An owning unique pointer to the constructed view button.
111+
*/
92112
template<class Fn>
93113
std::unique_ptr<ViewElement> makeViewButton(Fn fn, std::pair<ScreenCoordinate, ScreenCoordinate> rect) {
94114
return std::unique_ptr<ViewElement>(new ViewButton<Fn>(fn, rect));
95115
}
96116

117+
/**
118+
* A view element drawn as a solid color that has a callback function that is called when it is clicked.
119+
*/
97120
template<class Fn>
98121
class ViewButtonColor : public ViewButton<Fn> {
99122
private:
@@ -119,6 +142,14 @@ class ViewButtonColor : public ViewButton<Fn> {
119142
}
120143
};
121144

145+
/**
146+
* Constructs a ViewButtonColor using the same parameters as the ViewButtonColor. Exists because template inference exists only
147+
* for functions, not classes.
148+
* @param fn The callback function to be called with the ScreenCoordinate clicked and returning a boolean on if it was handled.
149+
* @param rect The location on screen to draw to and receive clicks from.
150+
* @param color The color to draw the button. RGB floats from 0 to 1 for intensity.
151+
* @return An owning unique pointer to the constructed view button.
152+
*/
122153
template<class Fn>
123154
std::unique_ptr<ViewElement> makeViewButtonColor(Fn fn, std::pair<ScreenCoordinate, ScreenCoordinate> rect, std::tuple<float, float, float> color) {
124155
return std::unique_ptr<ViewElement>(new ViewButtonColor<Fn>(fn, rect, color));

include/GameVisitor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ class City;
99
class Player;
1010
class DevelopmentCard;
1111

12+
/**
13+
* A class to be extended with callbacks to handle the different classes in the model.
14+
*/
1215
class GameVisitor {
1316
private:
1417
//Block copy constructor and assignment operator

include/Player.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ class Deck;
3030
class GameBoard;
3131

3232

33-
33+
/**
34+
* One of the players interacting with the Settlers of Catan game. Contains her name, victory points,
35+
* development cards, and resources.
36+
*/
3437
class Player {
3538
private:
3639
std::string name;

0 commit comments

Comments
 (0)