-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeck.cc
117 lines (107 loc) · 3.3 KB
/
deck.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "deck.h"
#include <string>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <memory>
#include <utility>
#include <fstream>
#include "airelem.h"
#include "earthelem.h"
#include "fireelem.h"
#include "potionsell.h"
#include "apprentice.h"
#include "novice.h"
#include "massum.h"
#include "bonegolem.h"
#include "banish.h"
#include "unsummon.h"
#include "recharge.h"
#include "disenchant.h"
#include "raisedead.h"
#include "blizzard.h"
#include "GiantStre.h"
#include "enrage.h"
#include "haste.h"
#include "MagicFati.h"
#include "Silence.h"
#include "darkritual.h"
#include "auraofpower.h"
#include "standstill.h"
#include "spell.h"
#include "ritual.h"
#include "auraofpower.h"
using namespace std;
class Card;
Deck:: Deck (const string filename,Player *owner): owner{owner}{
ifstream f{filename};
string card;
while (getline(f,card)) {
addCard(card);
}
}
Deck:: ~Deck(){
}
int Deck::decksize() {
return content.size();
}
shared_ptr<Card> Deck:: popDeck() {
shared_ptr<Card> temp = content.back();
content.pop_back();
return temp;
}
void Deck:: shuffle(){
srand(time(NULL)); //
for(unsigned int i = 0; i < content.size(); ++i){
unsigned int r = rand() % content.size();
swap(content[i],content[r]);
}
}
void Deck:: addCard(const string s) {
if(s == "Air Elemental"){
content.emplace_back(make_shared<AirElem>(owner)); // new AirElem
}else if(s == "Earth Elemental"){
content.emplace_back(make_shared<EarthElem>(owner));
}else if(s == "Bone Golem"){
content.emplace_back(make_shared<BoneGol>(owner));
}else if(s == "Fire Elemental"){
content.emplace_back(make_shared<FireElem>(owner));
}else if(s == "Potion Seller"){
content.emplace_back(make_shared<PotionSell>(owner));
}else if(s == "Novice Pyromancer"){
content.emplace_back(make_shared<NovicePyro>(owner));
}else if(s == "Apprentice Summoner"){
content.emplace_back(make_shared<AppSum>(owner));
}else if(s == "Master Summoner"){
content.emplace_back(make_shared<MasSum>(owner));
}else if(s == "Banish"){
content.emplace_back(make_shared<Banish>(owner));
}else if(s == "Unsummon"){
content.emplace_back(make_shared<Unsummon>(owner));
}else if(s == "Recharge"){
content.emplace_back(make_shared<Recharge>(owner));
}else if(s == "Disenchant"){
content.emplace_back(make_shared<Disenchant>(owner));
}else if(s == "Raise Dead"){
content.emplace_back(make_shared<Raisedead>(owner));
}else if(s == "Blizzard"){
content.emplace_back(make_shared<Blizzard>(owner));
}else if(s == "Giant Strength"){
content.emplace_back(make_shared<GiantStre>(owner));
}else if(s == "Enrage"){
content.emplace_back(make_shared<Enrage>(owner));
}else if(s == "Haste"){
content.emplace_back(make_shared<Haste>(owner));
}else if(s == "Magic Fatigue"){
content.emplace_back(make_shared<MagicFati>(owner));
}else if(s == "Silence"){
content.emplace_back(make_shared<Silence>(owner));
}else if(s == "Dark Ritual"){
content.emplace_back(make_shared<DarkRitual>(owner));
}else if(s == "Aura of Power"){
content.emplace_back(make_shared<AuraOfPower>(owner));
}else if(s == "Standstill"){
content.emplace_back(make_shared<StandStill>(owner));
}
}