-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolitaire.cpp
More file actions
63 lines (56 loc) · 1.88 KB
/
solitaire.cpp
File metadata and controls
63 lines (56 loc) · 1.88 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
#include <iostream>
#include <vector>
#include <fstream>
#include <cstring>
#include "cards.h"
#pragma once
using namespace std;
int main()
{
uint8_t deck[24], tab[7][13], fnd[4][13];
uint8_t dsz, tsz[7], fsz[4], covered[7];
card global_card_list[52];
dsz = 0;
memset(tsz, 0, sizeof(tsz));
memset(fsz, 0, sizeof(fsz));
memset(deck, -1, sizeof(deck));
memset(tab, -1, sizeof(tab));
memset(fnd, -1, sizeof(fnd));
memset(covered, -1, sizeof(covered));
ifstream inpfile("shuffle.txt", ios::in);
for (int i=0; i<9; ++i) {
string buff;
getline(inpfile, buff);
char crd = '/';
int cov = -1;
for (auto c : buff) {
if (crd != '/' && (c == 'S' || c == 'H' || c == 'D' || c == 'C')) {
if (i&8) {
// Deck
// cout << (int) getNum(crd, c) << " ";
insertDeck(getNum(crd, c), global_card_list, deck, dsz);
}
else if ((i+1)&8) {
// Foundation
int cnum = getNum(crd, c);
for (int cc = 13*(cnum/13); cc <= cnum; ++cc)
insertFoundation(cc, global_card_list, fnd, fsz);
}
else {
// Tableau
// cout << (int) getNum(crd, c) << endl;
insertTab(getNum(crd, c), i, global_card_list, tab, tsz);
covered[i] = cov++;
}
crd = '/';
}
else if (crd == '/' && ((c >= '2' && c <= '9') || (c == 'K' || c == 'Q' || c == 'J' || c == 'A'))) {
crd = c;
}
}
// cout << endl;
}
inpfile.close();
print_all(global_card_list, deck, tab, fnd, covered, dsz, tsz, fsz);
return 0;
}