-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMazo.cpp
101 lines (90 loc) · 2.44 KB
/
Mazo.cpp
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
#include "Mazo.h"
#include <cstdlib>
using namespace std;
Mazo::Mazo(){
this->mazo = new Lista<Carta*>();
}
Mazo::~Mazo(){
delete this->mazo;
}
void Mazo::agregarCarta(TipoCartas tipo){
for(int i = 0; i < this->mazo->getSize(); i++){
if(this->mazo->getLData(i)->getTipo() == tipo){
this->mazo->add(new Carta(tipo));
}
}
this->mazo->add(new Carta(tipo));
}
void Mazo::removerCarta(TipoCartas tipo){
for(int i = 0; i < this->mazo->getSize(); i++){
if(this->mazo->getLData(i)->getTipo() == tipo){
this->mazo->remove(i);
}
}
}
Carta* Mazo::obtenerCarta(TipoCartas tipo){
try{
for(int i = 0; i < this->mazo->getSize(); i++){
if(this->mazo->getLData(i)->getTipo() == tipo){
return this->mazo->getLData(i);
}
}
throw tipo;
} catch (TipoCartas e) {
std::cout << "CardNotFoundException ("<< this->tipoDeCartaGlobal(e) <<")" << std::endl;
exit(1);
}
}
bool Mazo::estaVacio(){
return this->mazo->getSize() == 0;
}
int Mazo::obtenerCantidadCartas(TipoCartas tipo){
for(int i = 0; i < this->mazo->getSize(); i++){
if(this->mazo->getLData(i)->getTipo() == tipo){
return this->mazo->getLData(i)->getCantidad();
}
}
return 0;
}
Lista<Carta*>* Mazo::obtenerMazo(){
return this->mazo;
}
void Mazo::usarCarta(TipoCartas tipo){
switch(tipo){
case BLINDAJE:
this->removerCarta(BLINDAJE);
break;
case RADAR:
this->removerCarta(RADAR);
break;
case PARTIR_TESORO:
this->removerCarta(PARTIR_TESORO);
break;
case AGENTES_DURMIENTES:
this->removerCarta(AGENTES_DURMIENTES);
break;
case PALA_PARA_TUNEL:
this->removerCarta(PALA_PARA_TUNEL);
break;
case BOMBA_DE_RACIMO:
this->removerCarta(BOMBA_DE_RACIMO);
break;
}
}
string Mazo::tipoDeCartaGlobal(TipoCartas tipo){
switch(tipo){
case BLINDAJE:
return "Blindaje";
case RADAR:
return "Radar";
case PARTIR_TESORO:
return "Partir tesoro";
case AGENTES_DURMIENTES:
return "Agentes durmientes";
case PALA_PARA_TUNEL:
return "Pala para tunel";
case BOMBA_DE_RACIMO:
return "Bomba de racimo";
}
return "";
}