forked from AlexMPC/ALL-Project-2-master-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathchest.cpp
More file actions
115 lines (89 loc) · 2.64 KB
/
chest.cpp
File metadata and controls
115 lines (89 loc) · 2.64 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
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
#include <iostream>
#include <vector>
#include "libsqlite.hpp"
#include "chest.h"
#include "global.h"
Chest::Chest(int x, int y, int HP) {
xPos = x;
yPos = y;
currentHealth = HP;
}
int smallHealthUpgrade(sqlite::sqlite &db){
auto cur2 = db.get_statement();
cur2->set_sql("UPDATE users SET maxHealth=maxHealth+5 WHERE idUser =?");
cur2->prepare();
cur2->bind(1,2); //change by global variable here
cur2->step();
return 0;
std::cout << "You found a small health upgrade! Health increased by 5.";
}
int healthUpgrade(sqlite::sqlite &db){
auto cur2 = db.get_statement();
cur2->set_sql("UPDATE users SET maxHealth=maxHealth+10 WHERE idUser =?");
cur2->prepare();
cur2->bind(1,2); //change by global variable here
cur2->step();
return 0;
std::cout << "You found a health upgrade! Health increased by 10.";
}
int gold20(sqlite::sqlite &db){
auto cur2 = db.get_statement();
cur2->set_sql("UPDATE users SET gold=gold+20 WHERE idUser =?");
cur2->prepare();
cur2->bind(1,2); //change by global variable here
cur2->step();
return 0;
std::cout << "You found 20 gold";
}
int gold40(sqlite::sqlite &db){
auto cur2 = db.get_statement();
cur2->set_sql("UPDATE users SET gold=gold+40 WHERE idUser =?");
cur2->prepare();
cur2->bind(1,2); //change by global variable here
cur2->step();
return 0;
std::cout << "You found 40 gold";
}
int gold70(sqlite::sqlite &db){
auto cur2 = db.get_statement();
cur2->set_sql("UPDATE users SET gold=gold+70 WHERE idUser =?");
cur2->prepare();
cur2->bind(1,2); //change by global variable here
cur2->step();
return 0;
std::cout << "You found 70 gold";
}
int gold100(sqlite::sqlite &db){
auto cur2 = db.get_statement();
cur2->set_sql("UPDATE users SET gold=gold+100 WHERE idUser =?");
cur2->prepare();
cur2->bind(1,2); //change by global variable here
cur2->step();
return 0;
std::cout << "You found 100 gold";
}
int Chest::openTheChest(){
sqlite::sqlite db("dungeonCrawler.db"); //opens database connection
auto cur = db.get_statement();
int numOfPowerups = 6;
srand(time(0));
int randPowerup = rand() % numOfPowerups + 1;
cur-> set_sql("SELECT * FROM powerups WHERE num=?");
cur-> prepare();
cur->bind(1,randPowerup);
cur->step();
string powerupName = cur->get_text(1);
if (randPowerup == 1){
}
if (randPowerup == 2){
}
if (randPowerup == 3){
}
if (randPowerup == 4){
}
if (randPowerup == 5){
}
if (randPowerup == 6){
}
return 0;
}