Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <iostream>
#include <string>
#include <time.h> // Used for random generation being based off time
#include <random> // Used for random generation of board
#include "character.cpp"
using namespace std;
int i;
int plyrchoice;
int price, hp, dmg, def, stm;
int main()
{
struct items
{
string name;
int price;
int hp;
int dmg;
int def;
int stm;
};
items itemList[5];
itemList[0] = {"bottle o' orange", 50, 5, -5, 5, 1};
itemList[1] = {"bottle o' yahzoo", 150, 0, 10, 10, 2};
itemList[2] = {"dead fly", 10, 0, 0, 5, 0};
itemList[3] = {"chocolate coin", 10, 0, 0, 5, 0};
itemList[4] = {"dog fur", 10, 0, 0, 5, 0};
itemList[5] = {"silky string", 10, 0, 0, 5, 0};
items shopInv[3];
int count = 0;
int checker[100];
int randomNum[3];
while (count < 3)
{
int num = rand() % 100;
// check if num has already been generated
if (checker[num] == 0)
{
// now mark it as visited
checker[num] = 1;
randomNum[count++] = num; // store the generated number in an array.
}
}
for (int i = 0; i < 3; i++)
{
shopInv[i] = itemList[randomNum[i]];
}
int gold = 1000;
cout << "Would you like to buy my wares?. THEYRE AT A REALLY GOOD PRICE!!"
<< "\n";
cout << "We have:"
<< "\n";
for (int i = 0; i < 3; i = i + 1)
{
cout << i + 1 << ". " << itemList[i].name << " gold: " << itemList[i].price << endl;
} // prints all items in the shop
cin >> plyrchoice;
// check player has enough gold
if (itemList[plyrchoice - 1].price > gold)
{
cout << "you dont have enough gold broke boy" << endl;
main();
return 0;
};
hp = itemList[i].hp;
dmg = itemList[i].dmg;
def = itemList[i].def;
stm = itemList[i].stm;
return 0;
}
// rip the shop