-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathitem.cpp
More file actions
72 lines (60 loc) · 1.1 KB
/
item.cpp
File metadata and controls
72 lines (60 loc) · 1.1 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
#include <sstream>
#include "item.h"
#include "database.h"
#include "common.h"
using namespace std;
Item::Item(string n, string d, string o, ITEM_TYPE t) : name(n), desc(d), owner(o), type(t)
{
name = n;
desc = d;
owner = o;
type = t;
itemId = -1;
}
void Item::save()
{
//Have a list of the data, new lines should make it easier to read and load later
if(itemId == -1) {
itemId = db->lastid;
string temp = "item\n name:"+getName()+"\n"+"desc:"+getDesc()+"\n"+"owner:"+getOwner()+"\n"+"type:"+to_string(getType());
db->write(to_string(itemId),temp);
db->increment_lastid();
db->addItem(this);
}
}
string Item::getName() const
{
return name;
}
string Item::getDesc() const
{
return desc;
}
string Item::getOwner() const
{
return owner;
}
ITEM_TYPE Item::getType()
{
return type;
}
void Item::setItemId(int id)
{
itemId = id;
}
void Item::setName(string n)
{
name = n;
}
void Item::setDesc(string d)
{
desc = d;
}
void Item::setOwner(string o)
{
owner = o;
}
void Item::setType(ITEM_TYPE t)
{
type = t;
}