-
Notifications
You must be signed in to change notification settings - Fork 0
/
ammunationshop.cpp
72 lines (69 loc) · 2.94 KB
/
ammunationshop.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
//ammuniation function
#include <iostream>
#include <string>
#include <vector>
#include "Jovian.h"
using namespace std;
void ammunationshop(vector<string> &inventory_p, vector<int> &inventory_pvalue)
{
if (inventory_p.size() == 3)
{
cout << "Opps! You inventory is full! Use what you got to hunt some monsters down first!" << endl;
}
else
{
//array of the ammunations
string power[10] = {"Ak-47", "Pan", "Copper_Dagger", "Machine-gun", "Specter",
"S98_shotgun", "Pistol", "Kar-98_Sniper", "Grenade", "SMG-9"};
//array of the ammunation value
int sp_increase[10] = {53, 20, 54, 45, 28, 38, 22, 35, 65, 40};
srand (time(0));
//generating 3 random numbers
int random_option1 = rand() % 10; //random number between 0 and 9.
int random_option2 = rand() % 10;
int random_option3 = rand() % 10;
//giving 3 random ammunations
cout << "Input " << 1 << " to pick " << power[random_option1] << endl;
cout << "Input " << 2 << " to pick " << power[random_option2] << endl;
cout << "Input " << 3 << " to pick " << power[random_option3] << endl;
int input;
cout << "Choose from 1, 2 or 3 -> ";
cin >> input;
//invalid input criteria
while (input > 3 || input < 1)
{
cout << "Invalid input" << endl;
cin >> input;
}
if (input <= 3)
{
switch (input)
{
case 1: //adding the first option to the inventory
cout << "You have chosen the first option." << endl;
cout << "You get " << power[random_option1] << " with attack power of " << sp_increase[random_option1] << endl; //Showing what the user gets
inventory_p.push_back(power[random_option1]); //adding the ammunation to the inventory
inventory_pvalue.push_back(sp_increase[random_option1]); // adding to the ammunation's power to the inventory
cout << power[random_option1] << " is added to you inventory." << endl; //confirmation that the item is added to the inventory
cout << endl;
break;
case 2: //same as above but for second option
cout << "You have chosen the second option." << endl;
cout << "You get " << power[random_option2] << " with attack power of " << sp_increase[random_option2] << endl;
inventory_p.push_back(power[random_option2]);
inventory_pvalue.push_back(sp_increase[random_option2]);
cout << power[random_option2] << " is added to you inventory." << endl;
cout << endl;
break;
case 3: //same as above but for third option
cout << "You have chosen the third option." << endl;
cout << "You get " << power[random_option3] << " with attack power of " << sp_increase[random_option3] << endl;
inventory_p.push_back(power[random_option3]);
inventory_pvalue.push_back(sp_increase[random_option3]);
cout << power[random_option3] << " is added to you inventory." << endl;
cout << endl;
break;
}
}
}
}