-
Notifications
You must be signed in to change notification settings - Fork 0
/
freecell.cpp
76 lines (68 loc) · 2.3 KB
/
freecell.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
#include "freecell.h"
#include <QTime>
#include <QIcon>
#include "pile.h"
#include <QList>
#include "card.h"
freecell::freecell(QWidget *parent):games(parent)
{
// setParent(parent);
}
void freecell::setUp(){
shuffle(deck,1);
piles.append(new Pile(FOUNDATION,QPoint(30,190), parentWidget()));
piles.append(new Pile(FOUNDATION,QPoint(120,190), parentWidget()));
piles.append(new Pile(FOUNDATION,QPoint(210,190), parentWidget()));
piles.append(new Pile(FOUNDATION,QPoint(300,190), parentWidget()));
piles.append(new Pile(FOUNDATION,QPoint(400,190), parentWidget()));
piles.append(new Pile(FOUNDATION,QPoint(490,190), parentWidget()));
piles.append(new Pile(FOUNDATION,QPoint(580,190), parentWidget()));
piles.append(new Pile(FOUNDATION,QPoint(670,190), parentWidget()));
piles.append(new Pile(SPACE,QPoint(30,40), parentWidget()));
piles.append(new Pile(SPACE,QPoint(120,40), parentWidget()));
piles.append(new Pile(SPACE,QPoint(210,40), parentWidget()));
piles.append(new Pile(SPACE,QPoint(300,40), parentWidget()));
piles.append(new Pile(STOCK,QPoint(410,40), parentWidget()));
piles.append(new Pile(STOCK,QPoint(500,40), parentWidget()));
piles.append(new Pile(STOCK,QPoint(590,40), parentWidget()));
piles.append(new Pile(STOCK,QPoint(680,40), parentWidget()));
placeCards1();
}
void freecell::placeCards1(){
for(int i = 0; i<6;i++ ){
piles.value(0)->put(deck[i]);
piles.value(1)->put(deck[i + 6]);
piles.value(2)->put(deck[i + 6*2]);
piles.value(3)->put(deck[i + 6*3]);
piles.value(4)->put(deck[i + 6*4]);
piles.value(5)->put(deck[i + 6*5]);
piles.value(6)->put(deck[i + 6*6]);
piles.value(7)->put(deck[i + 6*7]);
}
piles.value(0)->put(deck[48]);
piles.value(1)->put(deck[49]);
piles.value(2)->put(deck[50]);
piles.value(3)->put(deck[51]);
for(int i = 0; i<52;i++ ){
deck[i]->setImage();
deck[i]->show();
}
}
void freecell::redeal(){
for(int i = 0; i<piles.size(); i++){
piles.value(i)->~Pile();
}
piles.clear();
history.clear();
setUp();
}
void freecell::clear(){
for(int i = 0; i<piles.size(); i++){
piles.value(i)->~Pile();
}
/* for(int i = 0; i<104; i++){
deck[i] = NULL;
}*/
piles.clear();
history.clear();
}