-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject.h
64 lines (51 loc) · 1.66 KB
/
object.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
61
62
63
64
#ifndef OBJECT_H
#define OBJECT_H
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include "drawable.h"
class Renderer;
class Object : public std::enable_shared_from_this<Object>
{
public:
typedef std::shared_ptr<Object> ObjectPtr;
virtual ~Object() {};
virtual std::string Examine() = 0;
virtual std::string Open() = 0;
virtual std::string UseWith(ObjectPtr obj) = 0;
// Should the following be here or only in the class where these things are possible ?
virtual std::string SetLock(bool lock);
virtual std::string AddItem(ObjectPtr object);
virtual ObjectPtr GetObjectByName(const std::string& name) = 0;
const std::string& GetName() const { return m_name; }
const std::string& GetDescription() const { return m_description; }
protected:
Object(const std::string& name, const std::string& description);
std::string m_name;
std::string m_description;
};
class Hammer : public Object
{
public:
Hammer() :
Object("a hammer", "This is an old hammer. Probably not worth 1 gp.") {}
std::string Examine();
std::string Open();
std::string UseWith(ObjectPtr obj);
virtual ObjectPtr GetObjectByName(const std::string& name);
};
class Chest : public Object
{
public:
Chest();
std::string Examine();
std::string Open();
std::string UseWith(ObjectPtr obj);
std::string AddItem(ObjectPtr object);
virtual ObjectPtr GetObjectByName(const std::string& name);
private:
std::vector<ObjectPtr> m_container;
bool m_locked;
};
#endif // OBJECT_H