twisty 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/twisty/engine.rb +8 -4
- data/lib/twisty/item.rb +5 -6
- data/lib/twisty/room.rb +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f1c781f539f60e786f679974578998bf0e1b69eff21b8980804c0ba150f58c3
|
4
|
+
data.tar.gz: 69602ce2bcf7579e85da60bc16c312f64da7818eb339f0a92be5febce647371e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30207c2da3be170aa87713345ca975b8b366dc8aaa07609aed96f39a14a0603e4cad29c3e50f63f623364eb8ba835c4b712721004a5a445c67c91af544cd17f1
|
7
|
+
data.tar.gz: 9b47d15f50b238caf7844ceda7bc324574d559820398752ee4e78853506d45837869d6fccacd9091b5507fcef049e740908d37e1879a025e0858365bf9f82ffb
|
data/lib/twisty/engine.rb
CHANGED
@@ -51,7 +51,9 @@ class Engine
|
|
51
51
|
|
52
52
|
# TODO: Make private "defining" method
|
53
53
|
|
54
|
-
rtype [Symbol, String, String, Hash] =>
|
54
|
+
rtype [Symbol, String, String, Hash] => Item
|
55
|
+
#(+Item+)
|
56
|
+
#
|
55
57
|
#Creates a new instance of Item in Engine.items indexed by id. Use this
|
56
58
|
#instead of Item.new().
|
57
59
|
#
|
@@ -79,10 +81,12 @@ class Engine
|
|
79
81
|
raise GameError.new "Item #{id} has already been defined"
|
80
82
|
end
|
81
83
|
|
82
|
-
return
|
84
|
+
return @items[id]
|
83
85
|
end
|
84
86
|
|
85
|
-
rtype [Symbol, String, String] =>
|
87
|
+
rtype [Symbol, String, String] => Room
|
88
|
+
#(+Room+)
|
89
|
+
#
|
86
90
|
#Creates a new instance of Room in Engine.rooms indexed by id. Use this
|
87
91
|
#instead of Room.new().
|
88
92
|
#
|
@@ -104,7 +108,7 @@ class Engine
|
|
104
108
|
@current_room = id
|
105
109
|
end
|
106
110
|
|
107
|
-
return
|
111
|
+
return @rooms[id]
|
108
112
|
end
|
109
113
|
|
110
114
|
rtype [Symbol, Symbol, String] => nil
|
data/lib/twisty/item.rb
CHANGED
@@ -49,13 +49,15 @@ class Item < Entity
|
|
49
49
|
@contents = []
|
50
50
|
end
|
51
51
|
|
52
|
-
rtype [Symbol] =>
|
52
|
+
rtype [Symbol] => Item
|
53
|
+
#(+Item+)
|
54
|
+
#
|
53
55
|
#Creates another Item identical to this instance
|
54
56
|
#
|
55
57
|
#other:: (+Symbol+) Index of the new instance of Item
|
56
58
|
def clone(other)
|
57
|
-
engine.define_item(other, @name, @desc,
|
58
|
-
|
59
|
+
return engine.define_item(other, @name, @desc,
|
60
|
+
:fixed => @fixed, :storage => @storage)
|
59
61
|
end
|
60
62
|
rtype [] => Boolean
|
61
63
|
#(+Boolean+)
|
@@ -64,7 +66,6 @@ class Item < Entity
|
|
64
66
|
#on a per-instance basis using on_take(&block). If this returns false
|
65
67
|
#take will fail
|
66
68
|
def take_event
|
67
|
-
puts "Taken"
|
68
69
|
return true
|
69
70
|
end
|
70
71
|
|
@@ -75,7 +76,6 @@ class Item < Entity
|
|
75
76
|
#on a per-instance basis using on_drop(&block). If this returns false
|
76
77
|
#drop will fail.
|
77
78
|
def drop_event
|
78
|
-
puts "Dropped"
|
79
79
|
return true
|
80
80
|
end
|
81
81
|
|
@@ -88,7 +88,6 @@ class Item < Entity
|
|
88
88
|
#
|
89
89
|
#item:: (+Symbol+) Key in Engine.items of the item being added
|
90
90
|
def put_content_event(item)
|
91
|
-
puts "Placed"
|
92
91
|
return true
|
93
92
|
end
|
94
93
|
|
data/lib/twisty/room.rb
CHANGED
@@ -44,13 +44,14 @@ class Room < Entity
|
|
44
44
|
@items = []
|
45
45
|
end
|
46
46
|
|
47
|
-
rtype [Symbol] =>
|
47
|
+
rtype [Symbol] => Room
|
48
|
+
#(+Room+)
|
49
|
+
#
|
48
50
|
#Creates another Item identical to this instance
|
49
51
|
#
|
50
52
|
#other:: (+Symbol+) Index of the new instance of Item
|
51
53
|
def clone(other)
|
52
|
-
engine.define_room(other, @name, @desc)
|
53
|
-
return nil
|
54
|
+
return engine.define_room(other, @name, @desc)
|
54
55
|
end
|
55
56
|
|
56
57
|
rtype [] => Boolean
|