Skip to content
Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 171 additions & 0 deletions Map with monster/items.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#include "stats.h"




class Items
{
public:
int Item_id = -1;
vector<string> all_possible_items { "stick", "shield", "armour", "sword",};
vector<string> player_bag { "stick", "shield", "armour","stick"};
vector<string> equippedItems {};


void printBag()
{
cout << "your bag: \n" ;
for (int it = 0; it <= (player_bag.size()-1); it++)
{
cout << player_bag[it] << " , " ;
}
}

void printequiped()
{
if (equippedItems.size()==0)
{
cout << "You have no items equipped. enter skip to continue" << endl;
}
else
{
for (int it = 0; it <= (equippedItems.size()-1); it++)
{
cout << equippedItems[it] << " , " ;
}

cout << " \n"<< endl;
cout << "what do you want to remove \n" << endl;
}
}


int get_ID(string uitem)
{
for (int it = 0; it <= (all_possible_items.size()-1); it++)
{
if( all_possible_items[it]==uitem)
{
int num = it;
return num;
}
}
if (uitem == "skip")
{
int num= -2;
return num;
}
else
{
int num = -1;
return num;
}
}


int* add_item()
{
if(equippedItems.size() == 4 )
{
system("cls");
cout << "you have equiped max number of items remove some to equip a new item " << endl;
static int changes[6] = {0,0,0,0,0,0};return changes;

}
else
{
vector<string> temp {};
int count = 0;
for (int it = (player_bag.size()-1); it >=0 ; it--)
{
if (player_bag[it] == all_possible_items[Item_id] && count == 0)
{
equippedItems.push_back(player_bag[it]);
player_bag.pop_back();
count +=1;
}
else
{
temp.push_back(player_bag[it]);
player_bag.pop_back();
}
}

for (int it2 = (temp.size()-1) ; it2 >=0; it2--)
{
string tempp = temp.back();
temp.pop_back();
player_bag.push_back(tempp);
}

cout << "you have equipped " << all_possible_items[Item_id] << "\n" << endl;

if (Item_id == 0){static int changes[6] = {5,2,0,0,0,0};return changes;}
else if (Item_id == 1){static int changes[6] = {0,-2,5,0,0,-1};return changes;}
else if (Item_id == 2){static int changes[6] = {0,-3,3,0,7,0};return changes;}
else if (Item_id == 3){static int changes[6] = {10,-2,0,0,0,1};return changes;}
}
}


int* removeitem()
{
if (equippedItems.empty())
{
cout << "everthing has been removed \n" << endl;
}
else
{
vector<string> temp {};
int count = 0;

for (int it = (equippedItems.size()-1); it >=0 ; it--)
{
if (equippedItems[it] == all_possible_items[Item_id] && count == 0)
{
player_bag.push_back(equippedItems[it]);
equippedItems.pop_back();
count +=1;
}
else
{
temp.push_back(equippedItems[it]);
equippedItems.pop_back();
}
}

for (int it2 = (temp.size()-1) ; it2 >=0; it2--)
{
string tempp = temp.back();
temp.pop_back();
equippedItems.push_back(tempp);
}
cout << "you have unequipped " << all_possible_items[Item_id] << "\n" << endl;

if (Item_id == 0){static int changes[6] = {-5,-2,0,0,0,0};return changes;}
else if (Item_id == 1){static int changes[6] = {0,2,-5,0,0,1};return changes;}
else if (Item_id == 2){static int changes[6] = {0,3,-3,0,-7,0};return changes;}
else if (Item_id == 3){static int changes[6] = {-10,2,0,0,0,-1};return changes;}



}
}


void setNewItem()
{
int randNumber = rand() % all_possible_items.size();
player_bag.push_back(all_possible_items[randNumber]);
cout << "the chest has given you a " << all_possible_items[randNumber] << "\n" << endl;
printBag();


}


};
Loading