Olib 0.0.8 → 0.0.9
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/Olib.gemspec +17 -16
- data/README.md +23 -21
- data/TODOS.md +3 -3
- data/lib/Olib.rb +88 -50
- data/lib/Olib/area.rb +51 -0
- data/lib/Olib/bounty.rb +171 -128
- data/lib/Olib/character/char.rb +113 -118
- data/lib/Olib/character/group.rb +68 -67
- data/lib/Olib/character/inventory.rb +79 -79
- data/lib/Olib/character/mind.rb +70 -0
- data/lib/Olib/combat/creature.rb +255 -249
- data/lib/Olib/combat/creatures.rb +61 -56
- data/lib/Olib/core/container.rb +200 -148
- data/lib/Olib/core/errors.rb +91 -91
- data/lib/Olib/core/extender.rb +27 -19
- data/lib/Olib/core/item.rb +549 -549
- data/lib/Olib/core/utils.rb +220 -220
- data/lib/Olib/dictionary/dictionary.rb +165 -157
- data/lib/Olib/events/emitter.rb +7 -0
- data/lib/Olib/go2.rb +151 -0
- data/lib/Olib/npcs.rb +5 -0
- data/lib/Olib/objects/box.rb +3 -3
- data/lib/Olib/objects/clothing.rb +3 -3
- data/lib/Olib/objects/herb.rb +3 -3
- data/lib/Olib/objects/jar.rb +100 -100
- data/lib/Olib/objects/jewel.rb +34 -34
- data/lib/Olib/objects/jewelry.rb +9 -9
- data/lib/Olib/objects/scroll.rb +71 -71
- data/lib/Olib/objects/uncommon.rb +3 -3
- data/lib/Olib/objects/unknown.rb +3 -3
- data/lib/Olib/objects/wand.rb +3 -3
- data/lib/Olib/shops.rb +176 -176
- data/lib/Olib/utils/cli.rb +80 -80
- data/lib/Olib/utils/help_menu.rb +166 -166
- data/lib/Olib/utils/monsterbold.rb +4 -4
- data/lib/Olib/utils/vbulletin.rb +100 -100
- data/lib/Olib/version.rb +3 -0
- metadata +11 -7
- data/lib/Olib/transport.rb +0 -117
- data/lib/Olib/utils/utils.rb +0 -148
data/lib/Olib/go2.rb
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
module Olib
|
2
|
+
##
|
3
|
+
## @brief ;go2 wrapper class
|
4
|
+
##
|
5
|
+
class Go2
|
6
|
+
@@teleporter = {}
|
7
|
+
@@routines = {}
|
8
|
+
##
|
9
|
+
## @brief returns the filtered relevant Map db tags
|
10
|
+
##
|
11
|
+
## @return Array
|
12
|
+
##
|
13
|
+
def Go2.tags
|
14
|
+
Map.tags
|
15
|
+
.select { |tag| !tag.include? "=" }
|
16
|
+
end
|
17
|
+
|
18
|
+
##
|
19
|
+
## dynamically assign all of our Go2#methods
|
20
|
+
##
|
21
|
+
Go2.tags
|
22
|
+
.each { |tag|
|
23
|
+
method = Olib.methodize tag
|
24
|
+
go2_dep = "go2_#{method}"
|
25
|
+
|
26
|
+
Go2.define_singleton_method(method.to_sym) do
|
27
|
+
Go2.room tag
|
28
|
+
end
|
29
|
+
|
30
|
+
Go2.define_singleton_method(go2_dep.to_sym) do
|
31
|
+
respond "[deprecation warning] Go2.#{go2_dep} => Go2.#{method}"
|
32
|
+
Go2.room tag
|
33
|
+
end
|
34
|
+
}
|
35
|
+
|
36
|
+
def Go2.room(roomid)
|
37
|
+
Olib.Char.unhide if hidden
|
38
|
+
unless Room.current.id == roomid
|
39
|
+
start_script "go2", [roomid, "_disable_confirm_"]
|
40
|
+
wait_while { running? "go2" };
|
41
|
+
end
|
42
|
+
Go2
|
43
|
+
end
|
44
|
+
|
45
|
+
def Go2.go2(roomid)
|
46
|
+
respond "[deprecation warning] Go2.go2 => Go2.room"
|
47
|
+
Go2.room(roomid)
|
48
|
+
end
|
49
|
+
|
50
|
+
def Go2.origin
|
51
|
+
Go2.room @@origin[:roomid]
|
52
|
+
Olib.Char.hide if @@origin[:hidden]
|
53
|
+
Go2
|
54
|
+
end
|
55
|
+
|
56
|
+
def Go2.fwi
|
57
|
+
unless Char.fwi_teleporter
|
58
|
+
echo "Error: No teleport defined ;var set teleporter=<teleporter>"
|
59
|
+
exit
|
60
|
+
end
|
61
|
+
|
62
|
+
unless Inventory.fwi_teleporter
|
63
|
+
echo "Error: Your teleporter could not be found #{Go2.teleporter}"
|
64
|
+
exit
|
65
|
+
end
|
66
|
+
|
67
|
+
last = Room.current.id
|
68
|
+
teleporter = Inventory.fwi_teleporter
|
69
|
+
if teleporter.worn?
|
70
|
+
teleporter.turn
|
71
|
+
else
|
72
|
+
teleporter.take.turn.stash
|
73
|
+
end
|
74
|
+
|
75
|
+
if Room.current.id == last
|
76
|
+
echo "Error: You tried to teleport to FWI in a room that does not allow that"
|
77
|
+
end
|
78
|
+
|
79
|
+
Go2
|
80
|
+
end
|
81
|
+
|
82
|
+
def Go2.rebase
|
83
|
+
@@origin = {}
|
84
|
+
@@origin[:roomid] = Room.current.id
|
85
|
+
@@origin[:hidden] = hiding?
|
86
|
+
@@origin[:location] = Room.current.location
|
87
|
+
Olib.debug "rebasing to #{@@origin}"
|
88
|
+
Go2
|
89
|
+
end
|
90
|
+
|
91
|
+
Go2.rebase
|
92
|
+
|
93
|
+
# Thanks Tillmen
|
94
|
+
def Go2.cost(to)
|
95
|
+
cost = 0
|
96
|
+
Map.findpath(Room.current.id, to).each { |id|
|
97
|
+
Room[id].tags.each { |tag|
|
98
|
+
if tag =~ /^silver-cost:#{id-1}:(.*)$/
|
99
|
+
cost_string = $1
|
100
|
+
if cost_string =~ /^[0-9]+$/
|
101
|
+
cost += cost_string.to_i
|
102
|
+
else
|
103
|
+
cost = StringProc.new(cost_string).call.to_i
|
104
|
+
end
|
105
|
+
end
|
106
|
+
}
|
107
|
+
}
|
108
|
+
cost
|
109
|
+
end
|
110
|
+
|
111
|
+
# use the teleporter variable to locate your teleporter and teleport
|
112
|
+
# naive of where you are
|
113
|
+
def Go2.fwi_teleport
|
114
|
+
respond "[deprecation warning] Go2.fwi_teleport => Go2.fwi"
|
115
|
+
Go2.fwi
|
116
|
+
end
|
117
|
+
|
118
|
+
# TODO
|
119
|
+
# create a dictionary of house lockers and the logic to enter a locker
|
120
|
+
# insure locker is closed before scripting away from it
|
121
|
+
def Go2.locker
|
122
|
+
echo "the go2_locker method currently does not function properly..."
|
123
|
+
self
|
124
|
+
end
|
125
|
+
##
|
126
|
+
## @brief returns to the rebased room
|
127
|
+
## @deprecated
|
128
|
+
##
|
129
|
+
## @return Go2
|
130
|
+
##
|
131
|
+
def Go2.go2_origin
|
132
|
+
respond "[deprecation warning] Go2.go2_origin => Go2.origin"
|
133
|
+
Go2.fwi
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
def Olib.Go2
|
139
|
+
Olib::Go2
|
140
|
+
end
|
141
|
+
|
142
|
+
class Transport < Go2
|
143
|
+
respond "[deprecation warning] Olib::Transport => Olib::Go2 on next major release"
|
144
|
+
# backwards compat
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
class Go2 < Olib::Go2
|
150
|
+
# expose on the global scope
|
151
|
+
end
|
data/lib/Olib/npcs.rb
ADDED
data/lib/Olib/objects/box.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module Olib
|
2
|
-
class Box < Item
|
3
|
-
end
|
1
|
+
module Olib
|
2
|
+
class Box < Item
|
3
|
+
end
|
4
4
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Olib
|
2
|
-
class Clothing < Item
|
3
|
-
end
|
1
|
+
module Olib
|
2
|
+
class Clothing < Item
|
3
|
+
end
|
4
4
|
end
|
data/lib/Olib/objects/herb.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module Olib
|
2
|
-
class Herb < Item
|
3
|
-
end
|
1
|
+
module Olib
|
2
|
+
class Herb < Item
|
3
|
+
end
|
4
4
|
end
|
data/lib/Olib/objects/jar.rb
CHANGED
@@ -1,101 +1,101 @@
|
|
1
|
-
module Olib
|
2
|
-
class Jar < Item
|
3
|
-
attr_accessor :gem, :count, :full, :empty, :pullable, :initial_count, :stacked
|
4
|
-
|
5
|
-
def initialize(item)
|
6
|
-
super(item)
|
7
|
-
@count = 0 # for empty jars
|
8
|
-
@full = false
|
9
|
-
@empty = false
|
10
|
-
_extract
|
11
|
-
self
|
12
|
-
end
|
13
|
-
|
14
|
-
def _extract
|
15
|
-
jem = @after_name.gsub('containing', '').strip
|
16
|
-
if jem != ''
|
17
|
-
@gem = Gemstone_Regex.gems[:singularize].call(jem)
|
18
|
-
look_result = self.look
|
19
|
-
if look_result =~ /^Inside .*? you see ([0-9]+) portion/
|
20
|
-
@count = $1.to_i
|
21
|
-
@initial_count = @count
|
22
|
-
@full = look_result.include?('It is full') ? true : false
|
23
|
-
else
|
24
|
-
respond "[0lib] Oddity detected in extracting Jar data"
|
25
|
-
end
|
26
|
-
else
|
27
|
-
@empty = true
|
28
|
-
end
|
29
|
-
self
|
30
|
-
end
|
31
|
-
|
32
|
-
def shake
|
33
|
-
result = Library.do "shake ##{@id}", /^You give your #{@noun} a hard shake|before you realize that it is empty/
|
34
|
-
@empty = true if result =~ /realize that it is empty/
|
35
|
-
return Gem_O.new(GameObj.left_hand) if GameObj.right_hand.id == @id
|
36
|
-
return Gem_O.new(GameObj.right_hand) if GameObj.left_hand.id == @id
|
37
|
-
end
|
38
|
-
|
39
|
-
def full?
|
40
|
-
@full
|
41
|
-
end
|
42
|
-
|
43
|
-
def empty?
|
44
|
-
@empty
|
45
|
-
end
|
46
|
-
|
47
|
-
def stash
|
48
|
-
take unless GameObj.right_hand.id == @id or GameObj.left_hand == @id
|
49
|
-
Library.do "shop sell 1", /^You place your/
|
50
|
-
end
|
51
|
-
|
52
|
-
def acquire
|
53
|
-
if pullable?
|
54
|
-
result = Library.do "pull ##{@id}", /^You pull/
|
55
|
-
@stacked = true if result =~ /([0-9]+) left/
|
56
|
-
else
|
57
|
-
result = Library.do "buy ##{@id}", /You hand over/
|
58
|
-
unless result =~ /^You hand over/
|
59
|
-
Client.end "[FATAL] Logic flaw, not enough coins to acquire #{@name}"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
self
|
63
|
-
end
|
64
|
-
|
65
|
-
def look
|
66
|
-
Library.do "look in ##{@id}", /^Inside .*? you see [0-9]+ portion|The .*? is empty./
|
67
|
-
end
|
68
|
-
|
69
|
-
def pullable?
|
70
|
-
unless @pullable
|
71
|
-
Library.do "get ##{@id}", /^Looking closely/
|
72
|
-
result = Library.timeoutfor "You can PULL", "You'll have to buy it if you want it"
|
73
|
-
if result =~ /^You can PULL/ then @pullable = true else @pullable = false end
|
74
|
-
end
|
75
|
-
@pullable
|
76
|
-
end
|
77
|
-
|
78
|
-
def inc
|
79
|
-
@count = @count+1
|
80
|
-
return self
|
81
|
-
end
|
82
|
-
|
83
|
-
def fill
|
84
|
-
@full = true
|
85
|
-
return self
|
86
|
-
end
|
87
|
-
|
88
|
-
def add(g)
|
89
|
-
result = Library.do "_drag ##{g.id} ##{@id}", /^You add|^You put|is full|does not appear to be a suitable container for|^You can't do that/
|
90
|
-
result = Library.do "put ##{g.id} in my #{@noun}", /^You add|^You put|is full|does not appear to be a suitable container for/ if result =~ /^You can't do that/
|
91
|
-
case result
|
92
|
-
when /^You add .* filling it/ then inc.fill
|
93
|
-
when /^You add|^You put/ then inc
|
94
|
-
when /does not appear to be a suitable container for/ then return false
|
95
|
-
when /is full/ then fill; return false
|
96
|
-
else return false
|
97
|
-
end
|
98
|
-
return true
|
99
|
-
end
|
100
|
-
end
|
1
|
+
module Olib
|
2
|
+
class Jar < Item
|
3
|
+
attr_accessor :gem, :count, :full, :empty, :pullable, :initial_count, :stacked
|
4
|
+
|
5
|
+
def initialize(item)
|
6
|
+
super(item)
|
7
|
+
@count = 0 # for empty jars
|
8
|
+
@full = false
|
9
|
+
@empty = false
|
10
|
+
_extract
|
11
|
+
self
|
12
|
+
end
|
13
|
+
|
14
|
+
def _extract
|
15
|
+
jem = @after_name.gsub('containing', '').strip
|
16
|
+
if jem != ''
|
17
|
+
@gem = Gemstone_Regex.gems[:singularize].call(jem)
|
18
|
+
look_result = self.look
|
19
|
+
if look_result =~ /^Inside .*? you see ([0-9]+) portion/
|
20
|
+
@count = $1.to_i
|
21
|
+
@initial_count = @count
|
22
|
+
@full = look_result.include?('It is full') ? true : false
|
23
|
+
else
|
24
|
+
respond "[0lib] Oddity detected in extracting Jar data"
|
25
|
+
end
|
26
|
+
else
|
27
|
+
@empty = true
|
28
|
+
end
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
def shake
|
33
|
+
result = Library.do "shake ##{@id}", /^You give your #{@noun} a hard shake|before you realize that it is empty/
|
34
|
+
@empty = true if result =~ /realize that it is empty/
|
35
|
+
return Gem_O.new(GameObj.left_hand) if GameObj.right_hand.id == @id
|
36
|
+
return Gem_O.new(GameObj.right_hand) if GameObj.left_hand.id == @id
|
37
|
+
end
|
38
|
+
|
39
|
+
def full?
|
40
|
+
@full
|
41
|
+
end
|
42
|
+
|
43
|
+
def empty?
|
44
|
+
@empty
|
45
|
+
end
|
46
|
+
|
47
|
+
def stash
|
48
|
+
take unless GameObj.right_hand.id == @id or GameObj.left_hand == @id
|
49
|
+
Library.do "shop sell 1", /^You place your/
|
50
|
+
end
|
51
|
+
|
52
|
+
def acquire
|
53
|
+
if pullable?
|
54
|
+
result = Library.do "pull ##{@id}", /^You pull/
|
55
|
+
@stacked = true if result =~ /([0-9]+) left/
|
56
|
+
else
|
57
|
+
result = Library.do "buy ##{@id}", /You hand over/
|
58
|
+
unless result =~ /^You hand over/
|
59
|
+
Client.end "[FATAL] Logic flaw, not enough coins to acquire #{@name}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
self
|
63
|
+
end
|
64
|
+
|
65
|
+
def look
|
66
|
+
Library.do "look in ##{@id}", /^Inside .*? you see [0-9]+ portion|The .*? is empty./
|
67
|
+
end
|
68
|
+
|
69
|
+
def pullable?
|
70
|
+
unless @pullable
|
71
|
+
Library.do "get ##{@id}", /^Looking closely/
|
72
|
+
result = Library.timeoutfor "You can PULL", "You'll have to buy it if you want it"
|
73
|
+
if result =~ /^You can PULL/ then @pullable = true else @pullable = false end
|
74
|
+
end
|
75
|
+
@pullable
|
76
|
+
end
|
77
|
+
|
78
|
+
def inc
|
79
|
+
@count = @count+1
|
80
|
+
return self
|
81
|
+
end
|
82
|
+
|
83
|
+
def fill
|
84
|
+
@full = true
|
85
|
+
return self
|
86
|
+
end
|
87
|
+
|
88
|
+
def add(g)
|
89
|
+
result = Library.do "_drag ##{g.id} ##{@id}", /^You add|^You put|is full|does not appear to be a suitable container for|^You can't do that/
|
90
|
+
result = Library.do "put ##{g.id} in my #{@noun}", /^You add|^You put|is full|does not appear to be a suitable container for/ if result =~ /^You can't do that/
|
91
|
+
case result
|
92
|
+
when /^You add .* filling it/ then inc.fill
|
93
|
+
when /^You add|^You put/ then inc
|
94
|
+
when /does not appear to be a suitable container for/ then return false
|
95
|
+
when /is full/ then fill; return false
|
96
|
+
else return false
|
97
|
+
end
|
98
|
+
return true
|
99
|
+
end
|
100
|
+
end
|
101
101
|
end
|
data/lib/Olib/objects/jewel.rb
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
# Class to interact with gems
|
2
|
-
# overwriting Gem is a bad idea
|
3
|
-
module Olib
|
4
|
-
class Jewel < Item
|
5
|
-
attr_accessor :quality, :value
|
6
|
-
|
7
|
-
def appraise
|
8
|
-
result = dothistimeout "appraise ##{@id}", 3, /#{Gemstone_Regex.gems[:appraise].values.join('|')}/
|
9
|
-
case result
|
10
|
-
when Gemstone_Regex.gems[:appraise][:gemshop]
|
11
|
-
# handle gemshop appraisal
|
12
|
-
@value = $1
|
13
|
-
when Gemstone_Regex.gems[:appraise][:player]
|
14
|
-
@value = $3
|
15
|
-
@quality = $2
|
16
|
-
when Gemstone_Regex.gems[:appraise][:failure]
|
17
|
-
waitrt?
|
18
|
-
self.appraise
|
19
|
-
else
|
20
|
-
respond result
|
21
|
-
Client.notify "Error during gem appraisal"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def normalized_name
|
26
|
-
Gemstone_Regex.gems[:singularize].call(@name)
|
27
|
-
end
|
28
|
-
|
29
|
-
def sell
|
30
|
-
result = take
|
31
|
-
fput "sell ##{@id}" if result =~ Gemstone_Regex.get[:success]
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
1
|
+
# Class to interact with gems
|
2
|
+
# overwriting Gem is a bad idea
|
3
|
+
module Olib
|
4
|
+
class Jewel < Item
|
5
|
+
attr_accessor :quality, :value
|
6
|
+
|
7
|
+
def appraise
|
8
|
+
result = dothistimeout "appraise ##{@id}", 3, /#{Gemstone_Regex.gems[:appraise].values.join('|')}/
|
9
|
+
case result
|
10
|
+
when Gemstone_Regex.gems[:appraise][:gemshop]
|
11
|
+
# handle gemshop appraisal
|
12
|
+
@value = $1
|
13
|
+
when Gemstone_Regex.gems[:appraise][:player]
|
14
|
+
@value = $3
|
15
|
+
@quality = $2
|
16
|
+
when Gemstone_Regex.gems[:appraise][:failure]
|
17
|
+
waitrt?
|
18
|
+
self.appraise
|
19
|
+
else
|
20
|
+
respond result
|
21
|
+
Client.notify "Error during gem appraisal"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def normalized_name
|
26
|
+
Gemstone_Regex.gems[:singularize].call(@name)
|
27
|
+
end
|
28
|
+
|
29
|
+
def sell
|
30
|
+
result = take
|
31
|
+
fput "sell ##{@id}" if result =~ Gemstone_Regex.get[:success]
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
35
|
end
|