-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_movable_object.rb
74 lines (61 loc) · 1.24 KB
/
class_movable_object.rb
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
###
# Class MobileObject
#
# This is the root Class for all Game Objects, such as players, other characters, items, etc. Basically, anything that is not
# an Area or a Gate. Objects may or may not be able to move around. Objects may or may not be able to be acquired by other
# Objects and carried around.
#
class MobileObject < DMUDObject
attr_accessor :metadata, :location
# Initialization
def initialize(
name,
location,
description = ''
)
super()
# Instance Variables
@metadata = {
:name => name,
:description => description
}
@location = location
@movable = true
@carryable = true
end
# Incoming message processor for messages received by the MobileObject
def message( message )
end
# Move the MobileObject
def move( gate )
# Exit the Area via the Gate
self.location.exit( self, gate )
end
end
###
# Specialized GameOjbects
#
# NPC MobileObject
class NPC < MobileObject
# Initialization
def initialize
super
@carryable = false
end
end
# Monster Object MobileObject
class MOB < MobileObject
# Initialization
def initialize
super
@carryable = false
end
end
# Carryable Item
class Item < MobileObject
# Initialization
def initialize
super
@carryable = true
end
end