-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitem.hpp
More file actions
79 lines (67 loc) · 2.15 KB
/
item.hpp
File metadata and controls
79 lines (67 loc) · 2.15 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef __ITEM_HPP__
#define __ITEM_HPP__
#include <string>
#include "type.hpp"
#include "character.hpp"
/* circ dep so forward declare */
class Scene; //for itemInventorySubMenu
class Action;
class InventorySubmenuData
{
public:
InventorySubmenuData(std::string type, std::string itemName);
inventorySubmenuType_t type;
virtual std::string getText() = 0;
/* int can store additional data to define what answer means, for example if answer is a player, int can be his ID */
/* this way an action can be decided on based on answer, like player with id is user */
virtual std::vector<std::pair<int, std::string>> getAnswers() = 0;
const std::string itemName = "nop";
};
class ConfirmInventorySubmenuData : public InventorySubmenuData
{
public:
ConfirmInventorySubmenuData(std::string itemName);
std::string getText();
std::vector<std::pair<int, std::string>> getAnswers();
};
class MapInventorySubmenuData : public InventorySubmenuData
{
public:
MapInventorySubmenuData(std::string itemName, std::unordered_map<sceneId_t, Scene*>* scenes);
std::string getText();
std::vector<std::pair<int, std::string>> getAnswers();
std::unordered_map<sceneId_t, Scene*>* scenes = NULL;
};
struct UseItemParams
{
Character* user = NULL;
Character* receiver = NULL;
Scene* targetLocation = NULL;
};
/*
when int associated with selected answer from submenu (CANCEL_INVENTORY_SUBMENU),
constructItemParamsFromInventoryMenuSelectionSpecific() will return NULL so handleInventoryInput() knows to close inventory sub menu without using item
¯\_(ツ)_/¯ CLIENT SHOULD NOT (accidentaly) USE THIS VALUE FOR HIS OWN SUBMENUDATA ANSWERS ¯\_(ツ)_/¯
*/
#define CANCEL_INVENTORY_SUBMENU -57324
class Item
{
public:
Item(std::string type);
~Item();
virtual Action* use(UseItemParams params) = 0;
const itemType_t type;
std::string description = "nop";
std::string getName();
void setInventorySubmenuData(InventorySubmenuData* inventorySubmenuData);
InventorySubmenuData* getInventorySubmenuData();
protected:
InventorySubmenuData* inventorySubmenuData = NULL;
};
class Jonko : public Item
{
public:
Jonko();
Action* use(UseItemParams params);
};
#endif