|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <functional>
|
|
|
|
#include <map>
|
|
|
|
#include "olcPixelGameEngine.h"
|
|
|
|
#include "olcUTIL_DataFile.h"
|
|
|
|
|
|
|
|
class Crawler;
|
|
|
|
class ItemInfo;
|
|
|
|
|
|
|
|
class Item{
|
|
|
|
private:
|
|
|
|
int amt;
|
|
|
|
ItemInfo*it;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Inventory{
|
|
|
|
public:
|
|
|
|
void AddItem(std::string it,int amt=1);
|
|
|
|
void GetItemCount(std::string it);
|
|
|
|
void UseItem(std::string it,int amt=1);
|
|
|
|
void RemoveItem(std::string it,int amt=1);
|
|
|
|
private:
|
|
|
|
static std::map<std::string,Item>inventory;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ItemProps{
|
|
|
|
friend class ItemInfo;
|
|
|
|
utils::datafile*scriptProps;
|
|
|
|
utils::datafile*customProps;
|
|
|
|
public:
|
|
|
|
ItemProps(utils::datafile*scriptProps,utils::datafile*customProps);
|
|
|
|
int GetIntProp(std::string prop);
|
|
|
|
float GetFloatProp(std::string prop);
|
|
|
|
std::string GetStringProp(std::string prop);
|
|
|
|
};
|
|
|
|
|
|
|
|
class ItemInfo{
|
|
|
|
std::string name;
|
|
|
|
std::string description;
|
|
|
|
std::string category;
|
|
|
|
Decal*img;
|
|
|
|
//Returns true if the item can be used, false otherwise
|
|
|
|
std::string useFunc="";
|
|
|
|
//Custom properties for this specific item's script.
|
|
|
|
static utils::datafile NOPROPS;
|
|
|
|
std::string script;
|
|
|
|
ItemProps customProps;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static void InitializeScripts();
|
|
|
|
public:
|
|
|
|
static void InitializeItems();
|
|
|
|
ItemInfo();
|
|
|
|
/*
|
|
|
|
For the useFunc, return true if the item can be used, false otherwise.
|
|
|
|
*/
|
|
|
|
//ItemInfo(std::string name,std::string description,std::string category,Decal*img,utils::datafile&props,std::string useFunc);
|
|
|
|
};
|