-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeck.cpp
More file actions
79 lines (77 loc) · 1.37 KB
/
Deck.cpp
File metadata and controls
79 lines (77 loc) · 1.37 KB
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
#include "Deck.h"
Deck::Deck(int x, int y)
{
this->inicio=NULL;
this->x = x;
this->y = y;
this->contador = 0;
}
void Deck::agregarCartas(Carta* nueva){
if(inicio==NULL)
{
inicio = nueva;
contador++;
}else{
Carta* temp = inicio;
while(temp->siguiente!=NULL)
temp = temp->siguiente;
temp->siguiente = nueva;
contador++;
}
}
void Deck::imprimir(SDL_Surface* screen){
if(inicio!=NULL){
Carta* temp = inicio;
while(temp!=NULL){
SDL_Rect offset;
offset.x = x;
offset.y = y;
if(temp->cara==true){
SDL_BlitSurface( temp->imagen, NULL, screen, &offset );
}
else
SDL_BlitSurface( temp->bak, NULL, screen, &offset );
temp = temp->siguiente;
}
}
}
void Deck::eleminar(){
Carta* temp = inicio;
if(contador == 2){
inicio->siguiente = NULL;
contador--;
}else if(contador == 1){
inicio = NULL;
contador--;
}else{
while(temp->siguiente->siguiente!=NULL)
temp = temp ->siguiente;
temp ->siguiente = NULL;
contador--;
}
}
Carta* Deck::recuperar(){
Carta* temp = inicio;
while(temp->siguiente!=NULL)
temp = temp->siguiente;
return temp;
}
void Deck::enviar(Deck* destination){
Carta *temp = recuperar();
if(temp->cara==true)
temp->cara = false;
else if(temp->cara==false)
temp->cara = true;
destination->agregarCartas(temp);
eleminar();
}
void Deck::vaciar(Deck* destination){
int c = contador;
for(int i = 0; i < c; i++){
enviar(destination);
}
}
Deck::~Deck()
{
//dtor
}