-
Notifications
You must be signed in to change notification settings - Fork 0
/
craft_mgr.h
60 lines (45 loc) · 1.54 KB
/
craft_mgr.h
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
#ifndef craft_mgr_h
#define craft_mgr_h
#include <map>
#include <vector>
#include <string>
#include "items.h"
/********************************************************************/
class Craft {
public:
enum class CraftType {ITEM, OBJECT};
public:
Craft(const std::string& name, CraftType type);
~Craft() = default;
const std::string& name() const { return name_; }
void addCountedItem(const std::string& basic_item, int occurrences);
const std::vector<CountedItem>& getItems() const { return items_; }
CraftType type() const { return type_; }
int time() const { return time_in_seconds_; }
void setTime(int time_in_seconds) { time_in_seconds_ = time_in_seconds; }
int occurrence() const { return occurrence_; }
void setOccurrence(int occurrence) { occurrence_ = occurrence; }
private:
std::string name_;
CraftType type_;
int time_in_seconds_ = 0;
int occurrence_ = 0;
std::vector<CountedItem> items_;
};
class CraftMgr {
private:
CraftMgr() {}
~CraftMgr() {}
public:
static CraftMgr* instance();
static void kill();
void loadCrafts(const std::string& filename);
std::vector<Craft*> craftsForMachine(const std::string& machine);
Craft* findCraft(const std::string& craft_name, const std::string& machine) const;
static std::string getPixmapName(Craft* craft);
private:
static CraftMgr* singleton_;
std::map<std::string, std::vector<Craft*> > crafts_by_machine_;
};
/********************************************************************/
#endif // craft_mgr_h