forked from AlexMPC/ALL-Project-2-master-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmenu.cpp
More file actions
96 lines (91 loc) · 3.22 KB
/
menu.cpp
File metadata and controls
96 lines (91 loc) · 3.22 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
#include <iostream>
#include <string>
#include "libsqlite.hpp"
#include "shop.h"
#include "weaponset.h"
#include "global.h"
using namespace std;
int shop(){
sqlite::sqlite db( "dungeonCrawler.db" ); // open database
auto cur = db.get_statement();
cur->set_sql("SELECT gold FROM users WHERE idUser=?;");
cur->prepare();
cur->bind(1,globalUserID); //global user id is used to find the users id
cur->step();
int goldamount = cur->get_int(0); //Sets the gold amount of the user
bool checkMenu = false;
while(true){
bool checkItem = true;
cout<<"*-----------------------------------*"<<endl;
cout<<"| Welcome to the Cave |"<<endl;
cout<<"*-----------------------------------*"<<endl;
cout<<"*-----------------------------------*"<<endl;
cout<<"| 1 - Weapons |"<<endl;
cout<<"| 2 - Potions or Level jump |"<<endl;
cout<<"| 3 - Go Back |"<<endl;
cout<<"*-----------------------------------*"<<endl;
char item;
cin>>item;
if(item =='1' || item=='2'){
checkMenu = false;
if (item=='1'){
Weapons var; //define the object to print all weapons and assign them to a user
var.idUser = 7; // dont forget to assign this to the globalvariable HERE
var.printWeapons(db); //antonio part of the code
bool checkgetWeapon = false;
while(checkgetWeapon != true){
int weaponChoice;
cin >> weaponChoice;
if (weaponChoice>0 && weaponChoice<5){
checkgetWeapon = true;
var.assignWeapon(weaponChoice, db);
}
else{
cout<<"You should type a number between 1 and 4"<<endl;
}
}
}
else if (item=='2'){
if (goldamount>=10) //Makes sure that you have above 10 gold to enter the armour, duration and level jump shop
{
shopMain(); //anir part of the code
}
else
{
cout << "You can't afford anything" << endl;
}
}
}
if(item == '3'){
checkMenu= false;
}
if(item=='3'){
break;
}
}
return 0;
}
int menu()
{
bool checkMenu = false;
while(checkMenu != true)
{
cout<<"*-------------------*"<<endl;
cout<<"| 1- Start the game |"<<endl;
cout<<"| 2- Shop |"<<endl;
cout<<"*-------------------*"<<endl;
char menuChoice;
cin>> menuChoice;
if (menuChoice=='1' || menuChoice =='2')
{
if (menuChoice == '2')
{
shop();
}
if (menuChoice == '1'){
checkMenu = true;
return 1;
}
}
}
}