-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem.go
115 lines (94 loc) · 1.9 KB
/
item.go
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package main
import "fmt"
type MudItem interface {
Owner() ItemPossessor
SetOwner(newOwner ItemPossessor)
Article() string
SetArticle(newArt string)
Name() string
SetName(newName string)
Keyword() string
SetKeyword(newKey string)
FullName() string
}
type ItemPossessor interface {
AddItem(item *Item)
RemoveItem(item *Item)
MoveItemTo(item *Item)
}
type ItemType uint8
const (
TYPE_GENERIC = iota
TYPE_WEAPON
TYPE_ARMOR
TYPE_COINS
)
type Item struct {
keyword string
article string
name string
owner ItemPossessor
value uint64
itemType ItemType
}
func (item *Item) Value() uint64 {
return item.value
}
func (item *Item) SetValue(newValue uint64) {
item.value = newValue
}
func (item *Item) ItemType() ItemType {
return item.itemType
}
func (item *Item) SetItemType(newType ItemType) {
item.itemType = newType
}
func (item *Item) Owner() ItemPossessor {
return item.owner
}
func (item *Item) SetOwner(newOwner ItemPossessor) {
item.owner = newOwner
}
func (item *Item) FullName() string {
if len(item.article) > 0 {
return fmt.Sprintf("%s %s", item.article, item.name)
}
return item.name
}
func (item *Item) Name() string {
return item.name
}
func (item *Item) SetName(newName string) {
item.name = newName
}
func (item *Item) Article() string {
return item.article
}
func (item *Item) SetArticle(newArt string) {
item.article = newArt
}
func (item *Item) Keyword() string {
return item.keyword
}
func (item *Item) SetKeyword(newKey string) {
item.keyword = newKey
}
/*
Portals: []*RoomLink{
{
Verb: "gate",
RoomId: "D",
},
}
*/
func CreateItemTableDBQuery() string {
return "CREATE TABLE IF NOT EXISTS Item(" +
"article VARCHAR(3)," +
"name VARCHAR(50) NOT NULL," +
"keyword VARCHAR(50) NOT NULL," +
"owner VARCHAR(60) NOT NULL," +
"value INT UNSIGNED NOT NULL," +
"item_type TINYINT UNSIGNED NOT NULL," +
"PRIMARY KEY (article, name)" +
")"
}