-
Notifications
You must be signed in to change notification settings - Fork 0
/
levelinfo.cpp
125 lines (101 loc) · 2.2 KB
/
levelinfo.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "levelinfo.h"
LevelInfo::LevelInfo(QObject *parent) : QObject(parent)
{
_test = "nothing";
for (int i=0;i<MAX_PLACES;i++){
thingOnPlace.append(i);
}
int size = thingOnPlace.size();
int tempIndex,tempValue;
for(int i=0;i<size;i++){
tempIndex = rand()%size;
tempValue = thingOnPlace.at(tempIndex);
thingOnPlace[tempIndex] = thingOnPlace.at(i);
thingOnPlace[i] = tempValue;
}
for (int i=0;i<MAX_PLACES;i++){
visible.append(true);
}
}
LevelInfo::~LevelInfo()
{
}
void LevelInfo::setTest(QString &str)
{
_test = str;
}
QString LevelInfo::getImageName(int i)
{
if (thingOnPlace.size() <= i) return "nothing";
string str = (Consts::stuff[thingOnPlace[i]]);
QString qS;
for (int i=0;i<str.size();i++)
qS.append(str.at(i));
return qS;
}
int LevelInfo::getX(QString room,int i)
{
return Consts::roomsCoords[room.toStdString()][i].x;
}
int LevelInfo::getY(QString room, int i)
{
return Consts::roomsCoords[room.toStdString()][i].y;
}
int LevelInfo::getDoorX(int lvl, int i)
{
return Consts::doorsCoords[lvl][i].x;
}
int LevelInfo::getDoorY(int lvl, int i)
{
return Consts::doorsCoords[lvl][i].y;
}
bool LevelInfo::isVisible(int i)
{
return visible[i];
}
void LevelInfo::changeVisible(int i)
{
visible[i] = !visible[i];
}
bool LevelInfo::isBagCatched()
{
return bag.isCatched();
}
void LevelInfo::catchBag()
{
bag.setIsCatched(true);
}
void LevelInfo::addToBag(int i)
{
if(bag.isCatched())
bag.add(Consts::stuff[thingOnPlace[i]]);
}
void LevelInfo::recreate()
{
LevelInfo s;
thingOnPlace = s.thingOnPlace;
visible = s.visible;
}
QString LevelInfo::whatIsInBag(int i)
{
string str = bag.whatIsIn.at(i);
QString qS;
for (int i=0;i<str.size();i++)
qS.append(str.at(i));
qS.insert(0,"bag_");
return qS;
}
void LevelInfo::removeFromBag(int i)
{
int where = -1;
for (int j=0;j< Consts::stuff.size();j++){
if (Consts::stuff[thingOnPlace[j]] == bag.whatIsIn.at(i))
where = j;
}
changeVisible(where);
bag.remove(i);
}
bool LevelInfo::isBagFull()
{
return ((bag.isFull() == -1) ? true : false);
}