Skip to content

Commit ba25cf5

Browse files
committed
Documented things!
1 parent ec567cd commit ba25cf5

File tree

2 files changed

+64
-4
lines changed

2 files changed

+64
-4
lines changed

src/GameController.cpp

+28-1
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,18 @@ GameController::~GameController() {
5858

5959
}
6060

61+
/**
62+
* Pushes the given state onto the control stack
63+
*/
6164
void GameController::pushState(ControlState newState){
6265
if (newState != BASESTATE){
6366
stateStack.push_back(newState);
6467
}
6568
}
6669

70+
/**
71+
* Pops the latest state from the control stack
72+
*/
6773
ControlState GameController::popState(){
6874
ControlState currState = getState();
6975
if(currState == BASESTATE){
@@ -73,36 +79,57 @@ ControlState GameController::popState(){
7379
return currState;
7480
}
7581

82+
/**
83+
* returns the current state of the controller
84+
*/
7685
ControlState GameController::getState(){
7786
return stateStack.back();
7887
}
7988

89+
/**
90+
* Stores a Coordinate in the clikc history
91+
*/
8092
void GameController::storeClick(Coordinate clickCoordinate){
8193
view.addPointOfInterest(coordToScreen(clickCoordinate));
8294
clickHistory.push_back(clickCoordinate);
8395
}
8496

97+
/**
98+
* Returns the last click stored in the history
99+
*/
85100
Coordinate GameController::getLastClick(){
86101
return getPastClick(0);
87102
}
88103

104+
/**
105+
* Gets a click from param clicks ago
106+
* @ param an integer
107+
*/
89108
Coordinate GameController::getPastClick(int howLongAgo){
90109
if (howLongAgo < clickHistory.size()){
91110
return clickHistory[clickHistory.size() - 1 - howLongAgo];
92111
}
93112
return Coordinate(-100,-100);
94113
}
95114

115+
/**
116+
* Clears the history of clicks
117+
*/
96118
void GameController::clearClickHistory(){
97119
view.clearPointsOfInterest();
98120
clickHistory.clear();
99121
}
100122

123+
/**
124+
* checks if there is a history of past clicks
125+
*/
101126
bool GameController::hasClickHistory(){
102127
return !clickHistory.empty();
103128
}
104129

105-
130+
/**
131+
* Returns the number of past clicks recorded
132+
*/
106133
int GameController::getClickHistorySize(){
107134
return clickHistory.size();
108135
}

src/Player.cpp

+36-3
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,10 @@ void Player::setGenralModifier()
411411
}
412412
}
413413

414-
414+
/**
415+
* Plays a victory point card if it exists. This means, the Player will 'consume' the card to gain a baseVictoryPoint
416+
* @ return true if the card was played, false otherwise
417+
*/
415418
bool Player::playVictoryCard(){
416419
if(developmentCards[VICTORYPOINT] > 0){
417420
developmentCards[VICTORYPOINT]--;
@@ -421,6 +424,11 @@ bool Player::playVictoryCard(){
421424
return false;
422425
}
423426

427+
/**
428+
* Plays a knight card if it exists. This means the player will move the Knight and gain 1 random resource from a player around the robber's new position
429+
* @ param Coordinate of the robber's new position and Player& of the opponent to rob
430+
* @return true if the card was used, false otherwise
431+
*/
424432
bool Player::playKnight(Coordinate location, Player& opponent){
425433
if(developmentCards[KNIGHT] > 0 && board.canRobberRob(opponent, location)){
426434
board.moveRobber(location);
@@ -436,6 +444,12 @@ bool Player::playKnight(Coordinate location, Player& opponent){
436444
}
437445
return false;
438446
}
447+
448+
/**
449+
* Plays a year of plenty card if it exists. This means the player will gain 2 of 1 resource of their choice
450+
* @ param the resource the player will recieve
451+
* @ returns true if the card was played, false otherwise
452+
*/
439453
bool Player::playYearOfPlenty(int resourceType){
440454
if(resourceType >= 5)
441455
return false;
@@ -447,6 +461,12 @@ bool Player::playYearOfPlenty(int resourceType){
447461
}
448462
return false;
449463
}
464+
465+
/**
466+
* Plays a monopoly card if it exists. This means the player will steal all of 1 resource type from all the other players
467+
* @ param the resource type the player wants to steal
468+
* @ return true if the card was played, false otherwise
469+
*/
450470
bool Player::playMonopoly(int resourceType){
451471
if (resourceType >= 5)
452472
return false;
@@ -460,6 +480,12 @@ bool Player::playMonopoly(int resourceType){
460480
}
461481
return false;
462482
}
483+
484+
/**
485+
* Plays a road building card if it exists. This means the player will place two roads of their choosing for free
486+
* @ param the start and end Coordinates of the two roads the Player wants to place
487+
* @ return true if the card was played
488+
*/
463489
bool Player::playRoadBuilding(Coordinate start1, Coordinate end1, Coordinate start2, Coordinate end2){
464490
if(developmentCards[ROADBUILDING] > 0){
465491
if(board.canPlayBuildRoadCard(start1, end1, start2, end2, *this)){
@@ -478,13 +504,16 @@ bool Player::playRoadBuilding(Coordinate start1, Coordinate end1, Coordinate sta
478504
return false;
479505
}
480506

481-
507+
/**
508+
* A cheat class that gives the player 5 of every development card, meant for debugging
509+
*/
482510
void Player::giveDevCardBoon(){
483511
for(int i = 0; i < 5; i++){
484512
developmentCards[i]+=5;
485513
}
486514
}
487515

516+
488517
int Player::getDevelopmentCards(int card_type) const{
489518
return developmentCards[card_type];
490519
}
@@ -505,7 +534,11 @@ int Player::getRoadBuildingCards() const{
505534
return developmentCards[ROADBUILDING];
506535
}
507536

508-
537+
/**
538+
* The player gives all their resources of a specific resource type. Meant to compliment the Monopoly card
539+
* @ param the resource type to give
540+
* @ return the number of resources given
541+
*/
509542
int Player::giveAllResources(int resourceType){
510543
int resource_count = resources[resourceType];
511544
resources[resourceType] = 0;

0 commit comments

Comments
 (0)