Skip to content

Commit 6278b97

Browse files
author
ankit21
committed
//\\
1 parent 8ac5f10 commit 6278b97

File tree

5 files changed

+67
-60
lines changed

5 files changed

+67
-60
lines changed

include/Player.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const int BRICK_INDEX = 3;
2727
const int WOOD_INDEX = 4;
2828

2929

30-
class DevelopmentCard;
30+
//class DevelopmentCard;
3131
//class Deck;
3232

3333

tests/testSerialization.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include "Serialization.h"
99
#include "GameBoard.h"
10-
#include "DevelopmentCard.h"
10+
//#include "DevelopmentCard.h"
1111
#include "Player.h"
1212

1313
#include "tinyxml2.h"
@@ -41,17 +41,17 @@ TEST(SerializationTest, testCardSerialization) {
4141
Player& testPlayer = testBoard.getPlayer(0);
4242

4343

44-
std::unique_ptr<DevelopmentCard> knight_card = unique_ptr<DevelopmentCard>(new KnightCard());
45-
std::unique_ptr<DevelopmentCard> victory_card = unique_ptr<DevelopmentCard>(new VictoryPointCard());
46-
std::unique_ptr<DevelopmentCard> plenty_card = unique_ptr<DevelopmentCard>(new YearOfPlentyCard());
47-
std::unique_ptr<DevelopmentCard> monopoly_card = unique_ptr<DevelopmentCard>(new MonopolyCard());
48-
std::unique_ptr<DevelopmentCard> road_card = std::unique_ptr<DevelopmentCard>(new RoadBuildingCard());
44+
// std::unique_ptr<DevelopmentCard> knight_card = unique_ptr<DevelopmentCard>(new KnightCard());
45+
// std::unique_ptr<DevelopmentCard> victory_card = unique_ptr<DevelopmentCard>(new VictoryPointCard());
46+
// std::unique_ptr<DevelopmentCard> plenty_card = unique_ptr<DevelopmentCard>(new YearOfPlentyCard());
47+
// std::unique_ptr<DevelopmentCard> monopoly_card = unique_ptr<DevelopmentCard>(new MonopolyCard());
48+
// std::unique_ptr<DevelopmentCard> road_card = std::unique_ptr<DevelopmentCard>(new RoadBuildingCard());
4949

50-
testPlayer.buyCard(knight_card);
51-
testPlayer.buyCard(victory_card);
52-
testPlayer.buyCard(plenty_card);
53-
testPlayer.buyCard(monopoly_card);
54-
testPlayer.buyCard(road_card);
50+
testPlayer.buyCard(KNIGHT);
51+
testPlayer.buyCard(VICTORYPOINT);
52+
testPlayer.buyCard(YEAROFPLENTY);
53+
testPlayer.buyCard(MONOPOLY);
54+
testPlayer.buyCard(ROADBUILDING);
5555

5656
stringstream stream;
5757
testBoard.save(stream);

tests/test_Deck.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
TEST(DeckTest, deck_draw)
1414
{
1515
Deck* testDeck= new Deck();
16-
DevelopmentCard* temp = testDeck->drawCard();
17-
ASSERT_NE(temp, nullptr);
16+
DevCardType temp = testDeck->drawCard();
17+
ASSERT_NE(temp, KNIGHT);
1818
testDeck->discard(temp);
19-
temp = NULL;
20-
delete testDeck;
19+
// temp = NULL;
20+
// delete testDeck;
2121
}
2222

2323
TEST(DeckTest, reshuffle_discard_pile)
2424
{
2525
Deck* testDeck= new Deck();
26-
DevelopmentCard* drawn = NULL;
26+
DevCardType drawn;
2727
for (int i = 0; i<300; i++)
2828
{
2929
drawn = testDeck->drawCard();
30-
ASSERT_NE(drawn, nullptr);
30+
ASSERT_NE(drawn, Knight);
3131
testDeck->discard(drawn);
32-
drawn = NULL;
32+
// drawn = NULL;
3333
}
3434
delete testDeck;
35-
}
35+
}

tests/test_DevelopmentCards.cpp

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77

88
#include "GameBoard.h"
99
#include "GamePiece.h"
10-
#include "DevelopmentCard.h"
10+
//#include "DevelopmentCard.h"
11+
#include "Player.h"
1112
#include "Util.h"
1213

13-
void testBuyingCard(Player& test_player, std::unique_ptr<DevelopmentCard> card, bool correct_result){
14+
void testBuyingCard(Player& test_player, DevCardType card, bool correct_result){
1415
int prevOre = test_player.getOre();
1516
int prevWheat = test_player.getWheat();
1617
int prevWool = test_player.getWool();
@@ -37,17 +38,17 @@ TEST(DevCardTest, buying_card){
3738
testPlayer.addWheat(5);
3839
testPlayer.addWool(5);
3940

40-
testBuyingCard(testPlayer, std::unique_ptr<DevelopmentCard>(new KnightCard()), true);
41-
testBuyingCard(testPlayer, std::unique_ptr<DevelopmentCard>(new VictoryPointCard()), true);
42-
testBuyingCard(testPlayer, std::unique_ptr<DevelopmentCard>(new YearOfPlentyCard()), true);
43-
testBuyingCard(testPlayer, std::unique_ptr<DevelopmentCard>(new MonopolyCard()), true);
44-
testBuyingCard(testPlayer, std::unique_ptr<DevelopmentCard>(new RoadBuildingCard()), true);
41+
testBuyingCard(testPlayer, KNIGHT, true);
42+
testBuyingCard(testPlayer, VICTORYPOINT, true);
43+
testBuyingCard(testPlayer, YEAROFPLENTY, true);
44+
testBuyingCard(testPlayer, MONOPOLY, true);
45+
testBuyingCard(testPlayer, ROADBUILDING, true);
4546

46-
testBuyingCard(testPlayer, std::unique_ptr<DevelopmentCard>(new KnightCard()), false);
47-
testBuyingCard(testPlayer, std::unique_ptr<DevelopmentCard>(new VictoryPointCard()), false);
48-
testBuyingCard(testPlayer, std::unique_ptr<DevelopmentCard>(new YearOfPlentyCard()), false);
49-
testBuyingCard(testPlayer, std::unique_ptr<DevelopmentCard>(new MonopolyCard()), false);
50-
testBuyingCard(testPlayer, std::unique_ptr<DevelopmentCard>(new RoadBuildingCard()), false);
47+
testBuyingCard(testPlayer, KNIGHT, false);
48+
testBuyingCard(testPlayer, VICTORYPOINT, false);
49+
testBuyingCard(testPlayer, YEAROFPLENTY, false);
50+
testBuyingCard(testPlayer, MONOPOLY, false);
51+
testBuyingCard(testPlayer, ROADBUILDING, false);
5152
}
5253

5354
void testRoadBuildingCard(Player& test_player, bool correct_result, GameBoard& test_board, Coordinate start1, Coordinate end1, Coordinate start2, Coordinate end2){
@@ -79,7 +80,8 @@ TEST(DevCardTest, RoadBuildingCard){
7980
Player& test_player = *test_board.getPlayers()[0];
8081

8182
test_board.PlaceSettlement(Coordinate(0,0), test_player);
82-
std::unique_ptr<DevelopmentCard> test_card = std::unique_ptr<DevelopmentCard>(new RoadBuildingCard());
83+
// std::unique_ptr<DevelopmentCard> test_card = std::unique_ptr<DevelopmentCard>(new RoadBuildingCard());
84+
DevCardType test_card = ROADBUILDING;
8385

8486
test_player.addOre(4);
8587
test_player.addWheat(4);
@@ -117,8 +119,8 @@ TEST(DevCardTest, VictoryPointCard){
117119
GameBoard test_board({"tester1"});
118120
Player& test_player = *test_board.getPlayers()[0];
119121

120-
std::unique_ptr<DevelopmentCard> test_card = std::unique_ptr<DevelopmentCard>(new VictoryPointCard());
121-
122+
// std::unique_ptr<DevelopmentCard> test_card = std::unique_ptr<DevelopmentCard>(new VictoryPointCard());
123+
DevCardType test_card = VICTORYPOINT;
122124
test_player.addOre(2);
123125
test_player.addWheat(2);
124126
test_player.addWool(2);
@@ -157,7 +159,9 @@ TEST(DevCardTest, MonopolyCard){
157159
Player& test_player2 = test_board.getPlayer(1);
158160
Player& test_player3 = test_board.getPlayer(2);
159161

160-
std::unique_ptr<DevelopmentCard> test_card = std::unique_ptr<DevelopmentCard>(new MonopolyCard());
162+
// std::unique_ptr<DevelopmentCard> test_card = std::unique_ptr<DevelopmentCard>(new MonopolyCard());
163+
DevCardType test_card = MONOPOLY;
164+
161165

162166
test_player1.addOre(3);
163167
test_player1.addWheat(3);
@@ -205,7 +209,9 @@ TEST(DevCardTest, YearOfPlentyCard){
205209
GameBoard test_board({"tester1"});
206210
Player& test_player = test_board.getPlayer(0);
207211

208-
std::unique_ptr<DevelopmentCard> test_card = std::unique_ptr<YearOfPlentyCard>(new YearOfPlentyCard());
212+
// std::unique_ptr<DevelopmentCard> test_card = std::unique_ptr<YearOfPlentyCard>(new YearOfPlentyCard());
213+
DevCardType test_card = YEAROFPLENTY;
214+
209215

210216
test_player.addOre(2);
211217
test_player.addWheat(2);
@@ -260,7 +266,8 @@ TEST(DevCardTest, KnightCard){
260266
Player& test_player2 = test_board.getPlayer(1);
261267
Player& test_player3 = test_board.getPlayer(2);
262268

263-
std::unique_ptr<DevelopmentCard> test_card = std::unique_ptr<DevelopmentCard>(new KnightCard());
269+
// std::unique_ptr<DevelopmentCard> test_card = std::unique_ptr<DevelopmentCard>(new KnightCard());
270+
DevCardType test_card = KNIGHT;
264271

265272
test_player1.addOre(4);
266273
test_player1.addWheat(4);

tests/test_Player.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,12 @@ TEST(PlayerTest, UpdateVictoryPoints_VictoryCards){
285285
ASSERT_EQ(test_player.getVictoryPoints(), 0);
286286
ASSERT_EQ(test_player.getVictoryPointsWithoutCards(), 0);
287287

288-
std::unique_ptr<DevelopmentCard> test_VictoryCard = std::unique_ptr<DevelopmentCard>(new VictoryPointCard());
288+
// std::unique_ptr<DevelopmentCard> test_VictoryCard = std::unique_ptr<DevelopmentCard>(new VictoryPointCard());
289289
test_player.addOre(1);
290290
test_player.addWheat(1);
291291
test_player.addWool(1);
292292

293-
test_player.buyCard(test_VictoryCard);
293+
test_player.buyCard(VICTORYPOINT);
294294
ASSERT_EQ(test_player.getVictoryPoints(), 1);
295295
ASSERT_EQ(test_player.getVictoryPointsWithoutCards(), 0);
296296
}
@@ -306,10 +306,10 @@ TEST(PlayerTest, UpdateVictoryPoints_LargestArmy){
306306
test_player.addWheat(3);
307307
test_player.addWool(3);
308308

309-
std::unique_ptr<DevelopmentCard> test_KnightCard = std::unique_ptr<DevelopmentCard>(new KnightCard());
310-
test_player.buyCard(test_KnightCard);
311-
test_player.buyCard(test_KnightCard);
312-
test_player.buyCard(test_KnightCard);
309+
// std::unique_ptr<DevelopmentCard> test_KnightCard = std::unique_ptr<DevelopmentCard>(new KnightCard());
310+
test_player.buyCard(KNIGHT);
311+
test_player.buyCard(KNIGHT);
312+
test_player.buyCard(KNIGHT);
313313

314314
test_board.PlaceSettlement(Coordinate(0,0), opponent);
315315

@@ -345,18 +345,18 @@ TEST(PlayerTest, UpdateVictoryPoints_all){
345345

346346
ASSERT_EQ(test_player.getVictoryPoints(), 4);
347347

348-
std::unique_ptr<DevelopmentCard> test_VictoryCard = std::unique_ptr<DevelopmentCard>(new VictoryPointCard());
348+
// std::unique_ptr<DevelopmentCard> test_VictoryCard = std::unique_ptr<DevelopmentCard>(new VictoryPointCard());
349349
test_player.addOre(4);
350350
test_player.addWheat(4);
351351
test_player.addWool(4);
352352

353-
test_player.buyCard(test_VictoryCard);
353+
test_player.buyCard(VICTORY);
354354
ASSERT_EQ(test_player.getVictoryPoints(), 5);
355355

356-
std::unique_ptr<DevelopmentCard> test_KnightCard = std::unique_ptr<DevelopmentCard>(new KnightCard());
357-
test_player.buyCard(test_KnightCard);
358-
test_player.buyCard(test_KnightCard);
359-
test_player.buyCard(test_KnightCard);
356+
// std::unique_ptr<DevelopmentCard> test_KnightCard = std::unique_ptr<DevelopmentCard>(new KnightCard());
357+
test_player.buyCard(KNIGHT);
358+
test_player.buyCard(KNIGHT);
359+
test_player.buyCard(KNIGHT);
360360

361361
test_board.PlaceSettlement(Coordinate(0,5), opponent);
362362

@@ -378,8 +378,8 @@ TEST(PlayerTest, Monopoly_card_1){
378378

379379
tp1.addMultiple(0,0,1,1,1);
380380

381-
std::unique_ptr<DevelopmentCard> test_MonopolyCard = std::unique_ptr<DevelopmentCard>(new MonopolyCard());
382-
tp1.buyCard(test_MonopolyCard);
381+
// std::unique_ptr<DevelopmentCard> test_MonopolyCard = std::unique_ptr<DevelopmentCard>(new MonopolyCard());
382+
tp1.buyCard(MONOPOLY);
383383

384384

385385
tp1.addMultiple(5,5,5,5,5);
@@ -401,8 +401,8 @@ TEST(PlayerTest, Monopoly_card_2){
401401

402402
tp1.addMultiple(0,0,1,1,1);
403403

404-
std::unique_ptr<DevelopmentCard> test_MonopolyCard = std::unique_ptr<DevelopmentCard>(new MonopolyCard());
405-
tp1.buyCard(test_MonopolyCard);
404+
// std::unique_ptr<DevelopmentCard> test_MonopolyCard = std::unique_ptr<DevelopmentCard>(new MonopolyCard());
405+
tp1.buyCard(MONOPOLY);
406406

407407
tp1.addMultiple(0,0,0,1,1);
408408
tp2.addMultiple(1,1,0,0,0);
@@ -423,8 +423,8 @@ TEST(PlayerTest, Monopoly_card_false){
423423
Player& tp1 = board.getPlayer(0);
424424
Player& tp2 = board.getPlayer(1);
425425

426-
std::unique_ptr<DevelopmentCard> test_MonopolyCard = std::unique_ptr<DevelopmentCard>(new MonopolyCard());
427-
tp1.buyCard(test_MonopolyCard);
426+
// std::unique_ptr<DevelopmentCard> test_MonopolyCard = std::unique_ptr<DevelopmentCard>(new MonopolyCard());
427+
tp1.buyCard(MONOPOLY);
428428

429429
tp1.addMultiple(0,0,0,1,1);
430430
tp2.addMultiple(1,1,0,0,0);
@@ -461,8 +461,8 @@ TEST(PlayerTest, Year_Of_Plenty_card){
461461

462462
tp1.addMultiple(0,0,1,1,1);
463463

464-
std::unique_ptr<DevelopmentCard> test_YearOfPlentyCard = std::unique_ptr<DevelopmentCard>(new YearOfPlentyCard());
465-
tp1.buyCard(test_YearOfPlentyCard);
464+
// std::unique_ptr<DevelopmentCard> test_YearOfPlentyCard = std::unique_ptr<DevelopmentCard>(new YearOfPlentyCard());
465+
tp1.buyCard(YEAROFPLENTY);
466466

467467
tp1.addMultiple(0,0,0,1,1);
468468

@@ -479,8 +479,8 @@ TEST(PlayerTest, Year_Of_Plenty_card_false){
479479

480480
Player& tp1 = board.getPlayer(0);
481481

482-
std::unique_ptr<DevelopmentCard> test_YearOfPlentyCard = std::unique_ptr<DevelopmentCard>(new YearOfPlentyCard());
483-
tp1.buyCard(test_YearOfPlentyCard);
482+
// std::unique_ptr<DevelopmentCard> test_YearOfPlentyCard = std::unique_ptr<DevelopmentCard>(new YearOfPlentyCard());
483+
tp1.buyCard(YEAROFPLENTY);
484484

485485
tp1.addMultiple(0,0,0,1,1);
486486

0 commit comments

Comments
 (0)