-
Notifications
You must be signed in to change notification settings - Fork 0
/
level3.cpp
61 lines (55 loc) · 1.14 KB
/
level3.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
#include "level3.h"
#include <iostream>
using namespace std;
Level3::Level3() : checkRandom(true), randomIndex(0) {
}
string Level3::getBlock() {
if (checkRandom == false) {
string blockName = store[randomIndex];
randomIndex = randomIndex + 1;
if (randomIndex == store.size()) {
randomIndex = 0;
}
return blockName;
} else {
int tmp = rand() % 9 + 1;
if (tmp == 1) {
return "I";
} else if (tmp == 2) {
return "J";
} else if (tmp == 3) {
return "L";
} else if (tmp == 4) {
return "O";
} else if (tmp == 5) {
return "T";
} else if (tmp == 6 || tmp == 8) {
return "S";
} else {
return "Z";
}
}
}
Level3::~Level3() {
store.clear();
}
int Level3::getLevel() {
return 3;
}
void Level3::changeState(string file) {
if (checkRandom == true) {
checkRandom = false;
store.clear();
filename = file;
ifstream infile{ filename };
string blockName;
while ( true ) {
infile >> blockName;
if ( infile.fail() ) break;
store.emplace_back(blockName);
}
randomIndex = 0;
} else {
checkRandom = true;
}
}