Skip to content

Commit 73cd25c

Browse files
author
ankitbhutani
committed
//DevCards, deck
1 parent 390ca20 commit 73cd25c

File tree

4 files changed

+296
-0
lines changed

4 files changed

+296
-0
lines changed

include/Deck.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Deck.h
3+
*
4+
* Created on: Feb 23, 2014
5+
* Author: ankitbhutani
6+
*/
7+
8+
#ifndef DECK_H_
9+
#define DECK_H_
10+
11+
#include <vector>
12+
#include <algorithm>
13+
#include "DevelopmentCard.h"
14+
15+
class Deck {
16+
17+
private:
18+
std::vector<DevelopmentCard*> deck;
19+
20+
public:
21+
Deck();
22+
virtual ~Deck();
23+
24+
int getSize();
25+
DevelopmentCard* drawCard();
26+
};
27+
28+
#endif /* DECK_H_ */

include/DevelopmentCard.h

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
//
2+
// DevelopmentCard.h
3+
// Catan parts
4+
//
5+
// Created by Ankit Bhutani on 2/22/14.
6+
// Copyright (c) 2014 Ankit Bhutani. All rights reserved.
7+
//
8+
9+
#ifndef Catan_parts_DevelopmentCard_h
10+
#define Catan_parts_DevelopmentCard_h
11+
12+
13+
#include "Util.h"
14+
#include "Player.h"
15+
16+
17+
enum DevCardType { KNIGHT, VICTORYPOINT, YEAROFPLENTY, MONOPOLY, ROADBUILDING };
18+
19+
20+
21+
class DevelopmentCard {
22+
23+
private:
24+
Player* owner;
25+
DevCardType type;
26+
public:
27+
DevelopmentCard(Player* player);
28+
// virtual ~DevelopmentCard();
29+
30+
virtual DevCardType getType() = 0;
31+
virtual void playCard() = 0;
32+
33+
};
34+
35+
36+
37+
class KnightCard : public DevelopmentCard {
38+
private:
39+
40+
public:
41+
KnightCard(Player* player);
42+
// virtual ~KnightCard();
43+
44+
DevCardType getType();
45+
void playCard();
46+
47+
};
48+
49+
50+
51+
class VictoryPointCard : public DevelopmentCard {
52+
public:
53+
VictoryPointCard(Player* player);
54+
// virtual ~VictoryPointCard();
55+
56+
DevCardType getType();
57+
void playCard();
58+
59+
};
60+
61+
62+
class YearOfPlentyCard : public DevelopmentCard {
63+
public:
64+
YearOfPlentyCard(Player* player);
65+
// virtual ~YearOfPlentyCard();
66+
67+
DevCardType getType();
68+
void playCard();
69+
70+
};
71+
72+
73+
74+
75+
class MonopolyCard : public DevelopmentCard {
76+
public:
77+
MonopolyCard(Player* player);
78+
// virtual ~MonopolyCard();
79+
80+
DevCardType getType();
81+
void playCard();
82+
83+
};
84+
85+
86+
87+
class RoadBuildingCard : public DevelopmentCard {
88+
private:
89+
90+
public:
91+
RoadBuildingCard(Player* player);
92+
// virtual ~RoadBuildingCard();
93+
94+
DevCardType getType();
95+
void playCard();
96+
};
97+
98+
99+
100+
101+
#endif

src/Deck.cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Deck.cpp
3+
*
4+
* Created on: Feb 23, 2014
5+
* Author: ankitbhutani
6+
*/
7+
8+
#include <iostream>
9+
#include "Deck.h"
10+
11+
Deck::Deck() {
12+
// TODO Auto-generated constructor stub
13+
for(int i = 0; i < 15; i++)
14+
{
15+
DevelopmentCard* card = new KnightCard(NULL);
16+
this->deck.push_back(card);
17+
}
18+
for(int i = 0; i < 4; i++)
19+
{
20+
DevelopmentCard* card = new VictoryPointCard(NULL);
21+
this->deck.push_back(card);
22+
}
23+
for(int i = 0; i < 2; i++)
24+
{
25+
DevelopmentCard* card = new YearOfPlentyCard(NULL);
26+
this->deck.push_back(card);
27+
}
28+
for(int i = 0; i < 2; i++)
29+
{
30+
DevelopmentCard* card = new MonopolyCard(NULL);
31+
this->deck.push_back(card);
32+
}
33+
for(int i = 0; i < 2; i++)
34+
{
35+
DevelopmentCard* card = new RoadBuildingCard(NULL);
36+
this->deck.push_back(card);
37+
}
38+
39+
}
40+
41+
Deck::~Deck() {
42+
// TODO Auto-generated destructor stub
43+
44+
while(!this->deck.empty())
45+
{
46+
delete this->deck.back();
47+
this->deck.pop_back();
48+
std::cout<<":";
49+
}
50+
}
51+
52+
53+
int Deck::getSize()
54+
{
55+
return this->deck.size();
56+
}
57+
58+
59+
DevelopmentCard* Deck::drawCard()
60+
{
61+
if(this->getSize() == 0)
62+
return NULL;
63+
DevelopmentCard* card = this->deck.back();
64+
this->deck.pop_back();
65+
return card;
66+
}

src/DevelopmentCard.cpp

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
//
2+
// DevelopmentCard.cpp
3+
// Catan parts
4+
//
5+
// Created by Ankit Bhutani on 2/22/14.
6+
// Copyright (c) 2014 Ankit Bhutani. All rights reserved.
7+
//
8+
9+
#include "DevelopmentCard.h"
10+
#include "Util.h"
11+
12+
13+
//Base Class
14+
DevelopmentCard::DevelopmentCard(Player* player):owner(player)
15+
{
16+
17+
}
18+
19+
20+
21+
22+
KnightCard::KnightCard(Player* player):DevelopmentCard(player)
23+
{
24+
25+
}
26+
27+
DevCardType KnightCard::getType(){
28+
return KNIGHT;
29+
}
30+
31+
void KnightCard::playCard()
32+
{
33+
//Call function to play card
34+
}
35+
36+
37+
VictoryPointCard::VictoryPointCard(Player* player):DevelopmentCard(player)
38+
{
39+
40+
}
41+
42+
DevCardType VictoryPointCard::getType(){
43+
return VICTORYPOINT;
44+
}
45+
46+
void VictoryPointCard::playCard()
47+
{
48+
//Call function to change knight positsion
49+
}
50+
51+
52+
YearOfPlentyCard::YearOfPlentyCard(Player* player):DevelopmentCard(player)
53+
{
54+
55+
}
56+
57+
DevCardType YearOfPlentyCard::getType(){
58+
return YEAROFPLENTY;
59+
}
60+
61+
void YearOfPlentyCard::playCard()
62+
{
63+
//Call function to change knight positsion
64+
}
65+
66+
67+
68+
MonopolyCard::MonopolyCard(Player* player):DevelopmentCard(player)
69+
{
70+
71+
}
72+
73+
DevCardType MonopolyCard::getType(){
74+
return MONOPOLY;
75+
}
76+
77+
void MonopolyCard::playCard()
78+
{
79+
//Call function to change knight positsion
80+
}
81+
82+
83+
84+
RoadBuildingCard::RoadBuildingCard(Player* player):DevelopmentCard(player){};
85+
86+
DevCardType RoadBuildingCard::getType()
87+
{
88+
return ROADBUILDING;
89+
}
90+
91+
void RoadBuildingCard::playCard()
92+
{
93+
//Call function to build a road twice
94+
}
95+
96+
97+
98+
99+
100+
101+

0 commit comments

Comments
 (0)