Skip to content

Commit b961a64

Browse files
Kyle GrageKyle Grage
authored andcommitted
Adding wonder class and method stubs
1 parent 9e52af2 commit b961a64

File tree

4 files changed

+114
-14
lines changed

4 files changed

+114
-14
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/Wonder.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 {
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+
#endif /* WONDER_H_ */

src/City.cpp

Lines changed: 1 addition & 2 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) {
@@ -49,7 +48,7 @@ int City::getResourceModifier() {
4948
* @return The victory points the player gets from the city.
5049
*/
5150
int City::getVictoryPoints() {
52-
return 2; //TODO: implement robber check here
51+
return 2;
5352
}
5453

5554
/**

src/Wonder.cpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Wonder.cpp
3+
*
4+
* Created on: Apr 10, 2014
5+
* Author: Kyle Grage
6+
*/
7+
8+
#include "Wonder.h"
9+
10+
#include "City.h"
11+
#include "Settlement.h"
12+
#include "GameVisitor.h"
13+
14+
/**
15+
* Construct a city.
16+
* @param board The GameBoard the city is a part of.
17+
* @param location The location of the city
18+
* @param owner The owner of the city
19+
*/
20+
Wonder::Wonder(GameBoard& board, Coordinate location, Player& owner) : CornerPiece(board, location, owner) {
21+
22+
}
23+
24+
/**
25+
* Destroy the city object.
26+
*/
27+
Wonder::~Wonder() {
28+
29+
}
30+
31+
/**
32+
*
33+
* @param visitor The visiting member.
34+
*/
35+
void Wonder::accept(GameVisitor& visitor) {
36+
visitor.visit(*this);
37+
}
38+
39+
/**
40+
* Test for equality with another game piece.
41+
* @param p The piece to test with
42+
* @return True if this object is equal to the other, false if not.
43+
*/
44+
bool Wonder::operator==(const GamePiece& p) const {
45+
return false; //TODO: Actually compare.
46+
}
47+
48+
/**
49+
* The number of resources this city gets from an adjacent tile when it pays out.
50+
* @return The number of resources acquired from one adjacent tile.
51+
*/
52+
int Wonder::getResourceModifier() {
53+
return 10;
54+
}
55+
56+
/**
57+
* The victory points the city is worth.
58+
* @return The victory points the player gets from the city.
59+
*/
60+
int Wonder::getVictoryPoints() {
61+
return 10;
62+
}
63+
64+
/**
65+
* Construct a Wonder from an existing CornerPiece (e.g. when upgrading a Settlement to a Wonder).
66+
* @param sett The CornerPiece to take initialization data from.
67+
*/
68+
Wonder::Wonder(CornerPiece& sett) : CornerPiece(sett.getBoard(), sett.getLocation(), sett.getOwner()) {
69+
70+
}
71+

0 commit comments

Comments
 (0)