Commit ffcf2449 authored by Aaron Sturtevant's avatar Aaron Sturtevant
Browse files

Merge branch 'master' of gitlab.cs.wallawalla.edu:sturaa/cptr142_group_project

parents 7a13f3ef cde9f904
//filename: item.cpp
//filename: Inventory.cpp
//Contains the implementation of the more complicated functions from the item class, which represents the items the player is carrying in the form of several dynamic arrays.
#include <iostream> //for output
#include <vector>
#include "item.h"
#include "Item.h"
#include "Inventory.h"
using namespace std;
//Constructs a new Item class.
Item::Item(){
Inventory::Inventory(){
equipped = 0;
}
//Accepts a string and three ints from the Monster class, and adds it into the 'array' of inventory.
void Item::gainItem(string lootName, int lootFight, int lootFlee , int lootTalk){
itemName.push_back(lootName);
itemFight.push_back(lootFight);
itemFlee.push_back(lootFlee);
itemTalk.push_back(lootTalk);
}
//outputs the inventory array
void Item::listInventory(){
for(int i = 0; i < itemName.size(); i++){
cout << itemName.at(i) << ": Fight: " << itemFight.at(i) << " Flee: "<< itemFlee.at(i) << " Talk: " << itemTalk.at(i) << endl;
void Inventory::listInventory(){
for(int i = 0; i < inventory.size(); i++){
cout << inventory.at(i).getName() << ": Fight: " << inventory.at(i).getFight() << " Talk: " << inventory.at(i).getTalk() << endl;
}
}
......
//filename: item.h
//Contains the implementation of the more complicated functions from the item class, which represents the items the player is carrying in the form of several dynamic arrays.
//filename: inventory.h
//Contains the implementation of the more complicated functions from the inventory class, which represents the items the player is carrying in the form of a dynamic array.
//Item accepts new items from the Monster class upon the player 'beating' the room, and allows the player to change which item they have equipped through the Player class.
#ifndef ITEM_H
#define ITEM_H
#ifndef INVENTORY_H
#define INVENTORY_H
#include <iostream> //for output
#include <vector>
#include <string>
#include "Item.h"
using namespace std;
class Item{
class Inventory{
private:
vector<string> itemName; //holds the names of the items in inventory
vector<int> itemFight; //holds the fight attributes of the items in inventory
vector<int> itemFlee; //holds the flee attributes of the items in inventory
vector<int> itemTalk; // holds the talk attributes of the items in inventory
vector<Item> inventory;
int equipped; // holds the index of the item currently equipped
public:
//Constructs a new Item class.
Item();
Inventory();
//Accepts a string and three ints from the Monster class, and adds it into the 'array' of inventory.
void gainItem(string lootName, int lootFight, int lootFlee , int lootTalk);
void gainItem(string lootName, int lootFight, int lootTalk){
Item newItem(lootName, lootFight, lootTalk);
inventory.push_back(newItem);
}
//returns the fight attribute of the equipped item
int getEquippedFight(){
return itemFight.at(equipped);
}
//returns the flee attribute of the equipped item
int getEquippedFlee(){
return itemFlee.at(equipped);
return inventory.at(equipped).getFight();
}
//returns the talk attribute of the equipped item
int getEquippedTalk(){
return itemTalk.at(equipped);
return inventory.at(equipped).getTalk();
}
//sets the equipped item to the index given by the player.
......@@ -51,12 +45,6 @@ class Item{
//Outputs your inventory line-by-line.
void listInventory();
//removes item from inventory. May not implement.
//loseItem(string lootName, int lootFight, int lootFlee, int lootTalk);
};
<<<<<<< HEAD
=======
>>>>>>> b98efe0e5646456c884e1f718a3cc4e946974b18
#endif // ITEM_H
\ No newline at end of file
#endif // INVENTORY_H
\ No newline at end of file
//filename: item.h
//Contains the item class, which represents the separate items the player will find and use throughout the dunGen. Accessed through Inventory.
#ifndef ITEM_H
#define ITEM_H
#include <string>
using namespace std;
class Item{
private:
string itemName;
int itemFight;
int itemTalk;
public:
Item(string lootName, int lootFight, int lootTalk){
itemName = lootName;
itemFight = lootFight;
itemTalk = lootTalk;
}
string getName(){
return itemName;
}
int getFight(){
return itemFight;
}
int getTalk(){
return itemTalk;
}
};
#endif // ITEM_H
\ No newline at end of file
#include <iostream> //for output
#include <vector>
#include "item.h"
#include "Inventory.h"
#include "Item.h"
using namespace std;
int main(){
Item pocketses;
pocketses.gainItem("Globe of Encoded Concurrency", 0, 2, 42);
pocketses.gainItem("Philter of Tranquility", 0, 42, 2);
Inventory pocketses;
pocketses.gainItem("Globe of Encoded Concurrency", 42, 2);
pocketses.gainItem("Philter of Tranquility", 0, 42);
pocketses.listInventory();
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment