Skip to content

Commit fdd5b65

Browse files
committed
Merge branch 'master' of https://github.com/Databean/warsofcatan
2 parents 1d48bd4 + 2b998ce commit fdd5b65

File tree

8 files changed

+55
-47
lines changed

8 files changed

+55
-47
lines changed

include/GameDice.h

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
#ifndef GAMEDICE_H
22
#define GAMEDICE_H
33

4-
54
class GameVisitor;
65

6+
/**
7+
* The two dice used to determine the tiles that give resources.
8+
*/
79
class GameDice {
8-
private:
9-
int first;
10-
int second;
11-
12-
13-
public:
14-
int getFirst();
15-
int getSecond();
16-
bool shown;
17-
void setFirst(int newFirst);
18-
void setSecond(int newSecond);
19-
virtual void accept(GameVisitor& visitor);
20-
21-
22-
10+
private:
11+
int first;
12+
int second;
13+
public:
14+
int roll();
15+
int getFirst() const;
16+
int getSecond() const;
17+
virtual void accept(GameVisitor& visitor);
2318
};
2419

2520
#endif

resources/ComicNeue-Bold.ttf

31.4 KB
Binary file not shown.
-49.5 KB
Binary file not shown.
-44.5 KB
Binary file not shown.

src/GameBoard.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -940,21 +940,15 @@ Player& GameBoard::getPlayer(int index)
940940
* When a player begins their turn, this rolls the dice and takes the required action (paying resources or enabling robber movement)
941941
* @return A pair of the values of the dice.
942942
*/
943-
std::pair<int, int> GameBoard::startTurn()
944-
{
945-
int die1 = std::rand() % 6 + 1;
946-
int die2 = std::rand() % 6 + 1;
947-
int roll = die1+die2;
948-
949-
dice.setFirst(die1);
950-
dice.setSecond(die2);
951-
if (roll==7)
952-
enableRobber();
953-
954-
else
955-
payoutResources(roll);
956-
957-
return std::make_pair(die1, die2);
943+
std::pair<int, int> GameBoard::startTurn() {
944+
int roll = dice.roll();
945+
if (roll==7) {
946+
enableRobber();
947+
} else {
948+
payoutResources(roll);
949+
}
950+
951+
return std::make_pair(dice.getFirst(), dice.getSecond());
958952
}
959953

960954
/**

src/GameController.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ GameController::GameController(GameBoard& model, GameView& view) : model(model),
2323
view.addElement(makeViewButtonColor(std::bind(&GameController::handleRoadButtonEvent, this, _1), {{0, 0}, {0.1, 0.1}}, std::make_tuple(1.f, 0.f, 0.f)));
2424
view.addElement(makeViewButtonColor(std::bind(&GameController::handleSettlementButtonEvent, this, _1), {{0, 0.1}, {0.1, 0.2}}, std::make_tuple(0.f, 1.0f, 0.f)));
2525

26-
auto font = "resources/TypeWritersSubstitute-Black.ttf";
26+
auto font = "resources/ComicNeue-Bold.ttf";
2727
auto fontSize = 50;
2828

2929

src/GameDice.cpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
11
#include "GameDice.h"
22
#include "GameVisitor.h"
33

4-
int GameDice::getFirst(){
5-
return first;
6-
}
4+
#include <cstdlib>
75

8-
int GameDice::getSecond(){
9-
return second;
6+
using std::rand;
7+
8+
/**
9+
* Re-roll the dice.
10+
* @return The sum of the two dice.
11+
*/
12+
int GameDice::roll() {
13+
first = rand() % 6 + 1;
14+
second = rand() % 6 + 1;
15+
16+
return first + second;
1017
}
1118

12-
void GameDice::setFirst(int newFirst){
13-
first = newFirst;
19+
/**
20+
* The value of the first die.
21+
* @return The first die's value.
22+
*/
23+
int GameDice::getFirst() const {
24+
return first;
1425
}
1526

16-
void GameDice::setSecond(int newSecond){
17-
second = newSecond;
27+
/**
28+
* The value of the second die.
29+
* @return The second die's value.
30+
*/
31+
int GameDice::getSecond() const {
32+
return second;
1833
}
1934

35+
/**
36+
* Double-dispatch method for GameVisitor.
37+
* @param visitor The visitor.
38+
*/
2039
void GameDice::accept(GameVisitor& visitor) {
2140
visitor.visit(*this);
2241
}

src/GameView.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ void GameView::render() {
135135
highlightPoint(it);
136136
}
137137

138-
auto font = "resources/TypeWritersSubstitute-Black.ttf";
138+
auto font = "resources/ComicNeue-Bold.ttf";
139139
auto fontSize = 50;
140140

141141
glColor3d(1, 1, 1);
@@ -650,8 +650,8 @@ void DrawingGameVisitor::visit(DevelopmentCard& card) {
650650
*/
651651
TradingView::TradingView(Player& initiating, Player& receiving, std::function<bool(std::array<int, 5>, ScreenCoordinate)> trade, std::function<bool(ScreenCoordinate)> cancel, std::array<int, 5> initialOffer) :
652652
ViewElement({{0.1, 0.1},{0.9, 0.9}}), initiating(initiating), receiving(receiving),
653-
trade(std::bind(trade, std::ref(offer), std::placeholders::_1), {{0.7, 0.1}, {0.9, 0.2}}, "resources/TypeWritersSubstitute-Black.ttf", 50, "Trade"),
654-
cancel(cancel, {{0.1, 0.1}, {0.3, 0.2}}, "resources/TypeWritersSubstitute-Black.ttf", 50, "Cancel"),
653+
trade(std::bind(trade, std::ref(offer), std::placeholders::_1), {{0.7, 0.1}, {0.9, 0.2}}, "resources/ComicNeue-Bold.ttf", 50, "Trade"),
654+
cancel(cancel, {{0.1, 0.1}, {0.3, 0.2}}, "resources/ComicNeue-Bold.ttf", 50, "Cancel"),
655655
offer(initialOffer) {
656656

657657
}
@@ -696,7 +696,7 @@ void TradingView::render() {
696696
glVertex2f(topLeft.first, bottomRight.second);
697697
glEnd();
698698

699-
auto font = "resources/TypeWritersSubstitute-Black.ttf";
699+
auto font = "resources/ComicNeue-Bold.ttf";
700700
auto fontSize = 50;
701701

702702
std::string resources[] = {"Wood", "Brick", "Ore", "Wheat", "Wool"};
@@ -724,7 +724,7 @@ ConfirmationDialogue::ConfirmationDialogue(std::function<bool(ScreenCoordinate)>
724724
ScreenCoordinate cancelTopLeft = ScreenCoordinate(topLeft.first + (width*.6), topLeft.second + (height *.1));
725725
ScreenCoordinate cancelBottomRight = ScreenCoordinate(bottomRight.first - (width * .1), bottomRight.second - (height * .6));
726726

727-
auto font = "resources/TypeWritersSubstitute-Black.ttf";
727+
auto font = "resources/ComicNeue-Bold.ttf";
728728
auto fontSize = 50;
729729

730730
confirmButton = std::unique_ptr<ViewElement>(new ViewButtonText(confirm_action, {confirmTopLeft, confirmBottomRight}, font, fontSize, "Yes"));
@@ -751,7 +751,7 @@ void ConfirmationDialogue::render(){
751751
glVertex2f(topLeft.first, bottomRight.second);
752752
glEnd();
753753

754-
auto font = "resources/TypeWritersSubstitute-Black.ttf";
754+
auto font = "resources/ComicNeue-Bold.ttf";
755755
auto fontSize = 50;
756756
float width = bottomRight.first - topLeft.first;
757757
float height = bottomRight.second - topLeft.second;

0 commit comments

Comments
 (0)