Olib 0.1.0 → 0.1.1
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/Olib.rb +38 -44
- data/lib/Olib/actor/actor.rb +117 -0
- data/lib/Olib/area.rb +23 -3
- data/lib/Olib/bounty.rb +175 -130
- data/lib/Olib/character/char.rb +71 -1
- data/lib/Olib/character/disk.rb +19 -0
- data/lib/Olib/character/group.rb +185 -48
- data/lib/Olib/character/inventory.rb +15 -74
- data/lib/Olib/character/stance.rb +28 -0
- data/lib/Olib/combat/creature.rb +235 -201
- data/lib/Olib/combat/creatures.rb +60 -48
- data/lib/Olib/core/container.rb +115 -50
- data/lib/Olib/core/extender.rb +2 -1
- data/lib/Olib/core/item.rb +158 -90
- data/lib/Olib/core/use.rb +39 -0
- data/lib/Olib/dictionary/dictionary.rb +8 -6
- data/lib/Olib/go2.rb +23 -38
- data/lib/Olib/interface/queryable.rb +50 -0
- data/lib/Olib/objects/box.rb +2 -3
- data/lib/Olib/objects/clothing.rb +1 -3
- data/lib/Olib/objects/herb.rb +2 -4
- data/lib/Olib/objects/jewel.rb +26 -29
- data/lib/Olib/objects/jewelry.rb +8 -8
- data/lib/Olib/objects/scroll.rb +37 -67
- data/lib/Olib/objects/uncommon.rb +1 -3
- data/lib/Olib/objects/wand.rb +1 -3
- data/lib/Olib/pattern.rb +34 -0
- data/lib/Olib/storage/app_data.rb +31 -0
- data/lib/Olib/supervisor/supervisor.rb +205 -0
- data/lib/Olib/try/try.rb +58 -0
- data/lib/Olib/version.rb +1 -1
- metadata +10 -3
- data/lib/Olib/events/emitter.rb +0 -7
- data/lib/Olib/objects/unknown.rb +0 -4
@@ -0,0 +1,39 @@
|
|
1
|
+
class Use
|
2
|
+
|
3
|
+
attr_accessor :item
|
4
|
+
|
5
|
+
def initialize(item, &block)
|
6
|
+
@item = item
|
7
|
+
both(&block) if block
|
8
|
+
end
|
9
|
+
|
10
|
+
def run(&block)
|
11
|
+
Try.new do
|
12
|
+
yield @item
|
13
|
+
end
|
14
|
+
@item.container.add(@item)
|
15
|
+
end
|
16
|
+
|
17
|
+
def left(&block)
|
18
|
+
empty_left_hand
|
19
|
+
@item.take
|
20
|
+
Char.swap if Char.right.id == @item.id
|
21
|
+
run &block
|
22
|
+
fill_left_hand
|
23
|
+
end
|
24
|
+
|
25
|
+
def right(&block)
|
26
|
+
empty_right_hand
|
27
|
+
@item.take
|
28
|
+
run &block
|
29
|
+
fill_right_hand
|
30
|
+
end
|
31
|
+
|
32
|
+
def both(&block)
|
33
|
+
empty_hands
|
34
|
+
@item.take
|
35
|
+
run &block
|
36
|
+
fill_hands
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
|
-
|
1
|
+
require "ostruct"
|
2
2
|
|
3
|
-
|
3
|
+
module Olib
|
4
|
+
class Dictionary < OpenStruct
|
4
5
|
def Dictionary.heirloom
|
5
6
|
re = {}
|
6
7
|
re[:is] = /are the initials ([A-Z]{2})./
|
@@ -82,7 +83,9 @@ module Olib
|
|
82
83
|
re[:appraise][:gemshop] = /inspects it carefully before saying, "I'll give you ([0-9]+) for it if you want to sell/
|
83
84
|
re[:appraise][:player] = /You estimate that the ([a-zA-Z '-]+) is of ([a-zA-Z '-]+) quality and worth approximately ([0-9]+) silvers/
|
84
85
|
re[:appraise][:failure] = /As best you can tell, the ([a-zA-Z '-]+) is of average quality/
|
85
|
-
re[:singularize] =
|
86
|
+
re[:singularize] = Proc.new do |str|
|
87
|
+
str.gsub(/ies$/, 'y').gsub(/zes$/,'z').gsub(/s$/,'').gsub(/large |medium |containing |small |tiny |some /, '').strip
|
88
|
+
end
|
86
89
|
re
|
87
90
|
end
|
88
91
|
|
@@ -96,7 +99,7 @@ module Olib
|
|
96
99
|
re[:failure][:buy] = /(is|for|be) (?<cost>[0-9]+) (silvers|coins)/
|
97
100
|
re[:failure][:race] = /be (?<cost>[0-9]+) (silvers|coins) for someone like you/
|
98
101
|
re[:failure][:pshop] = /^Looking closely/
|
99
|
-
re[:success] = /^You pick up|^You remove|^You rummage|^You draw|^You grab|^You reach|^You already/
|
102
|
+
re[:success] = /^You carefully|^You unsheathe|^You shield|^You discreetly|^You gather|^You pick up|^You remove|^You rummage|^You draw|^You grab|^You reach|^You already|^You gather/
|
100
103
|
re
|
101
104
|
end
|
102
105
|
|
@@ -105,7 +108,7 @@ module Olib
|
|
105
108
|
re[:failure] = {}
|
106
109
|
re[:failure][:full] = /^won't fit in the|is full!|filling it./
|
107
110
|
re[:failure][:ne] = /^I could not find what you were referring to/
|
108
|
-
re[:success] = /^You put|^You tuck|^You sheathe|^You slip|^You roll up|^You tuck|^You add|^You place/
|
111
|
+
re[:success] = /^Your bundle|^You attempt to shield|^As you place|^You wipe off the blade|^You discreetly|^You toss|^You carefully|^You give|^You untie your|^You put|^You absent|^You tuck|^You sheathe|^You slip|^You roll up|^You tuck|^You add|^You place/
|
109
112
|
re
|
110
113
|
end
|
111
114
|
|
@@ -161,6 +164,5 @@ module Olib
|
|
161
164
|
def Dictionary.fusion
|
162
165
|
/(?<orbs>.*?) spherical depressions adorn the (.*?), approximately the size and shape of a small gem/
|
163
166
|
end
|
164
|
-
|
165
167
|
end
|
166
168
|
end
|
data/lib/Olib/go2.rb
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
class Integer
|
2
|
+
def go2
|
3
|
+
Go2.room self
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class String
|
8
|
+
def go2
|
9
|
+
Go2.room self
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
1
13
|
module Olib
|
2
14
|
##
|
3
15
|
## @brief ;go2 wrapper class
|
@@ -18,38 +30,26 @@ module Olib
|
|
18
30
|
##
|
19
31
|
## dynamically assign all of our Go2#methods
|
20
32
|
##
|
21
|
-
Go2.tags
|
22
|
-
.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
}
|
33
|
+
Go2.tags.each { |tag|
|
34
|
+
method = Olib.methodize tag
|
35
|
+
|
36
|
+
Go2.define_singleton_method(method.to_sym) do
|
37
|
+
Go2.room tag
|
38
|
+
end
|
39
|
+
}
|
35
40
|
|
36
41
|
def Go2.room(roomid)
|
37
|
-
|
38
|
-
|
42
|
+
unless Room.current.id == roomid || Room.current.tags.include?(roomid)
|
43
|
+
Char.unhide if hidden
|
39
44
|
start_script "go2", [roomid, "_disable_confirm_"]
|
40
45
|
wait_while { running? "go2" };
|
41
46
|
end
|
42
47
|
Go2
|
43
48
|
end
|
44
49
|
|
45
|
-
def Go2.go2(roomid)
|
46
|
-
respond "[deprecation warning] Go2.go2 => Go2.room"
|
47
|
-
Go2.room(roomid)
|
48
|
-
end
|
49
|
-
|
50
50
|
def Go2.origin
|
51
51
|
Go2.room @@origin[:roomid]
|
52
|
-
|
52
|
+
Char.hide if @@origin[:hidden]
|
53
53
|
Go2
|
54
54
|
end
|
55
55
|
|
@@ -111,7 +111,6 @@ module Olib
|
|
111
111
|
# use the teleporter variable to locate your teleporter and teleport
|
112
112
|
# naive of where you are
|
113
113
|
def Go2.fwi_teleport
|
114
|
-
respond "[deprecation warning] Go2.fwi_teleport => Go2.fwi"
|
115
114
|
Go2.fwi
|
116
115
|
end
|
117
116
|
|
@@ -122,16 +121,7 @@ module Olib
|
|
122
121
|
echo "the go2_locker method currently does not function properly..."
|
123
122
|
self
|
124
123
|
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
|
124
|
+
|
135
125
|
|
136
126
|
end
|
137
127
|
|
@@ -139,11 +129,6 @@ module Olib
|
|
139
129
|
Olib::Go2
|
140
130
|
end
|
141
131
|
|
142
|
-
class Transport < Go2
|
143
|
-
respond "[deprecation warning] Olib::Transport => Olib::Go2 on next major release"
|
144
|
-
# backwards compat
|
145
|
-
end
|
146
|
-
|
147
132
|
end
|
148
133
|
|
149
134
|
class Go2 < Olib::Go2
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Interface
|
2
|
+
class Queryable
|
3
|
+
def self.fetch
|
4
|
+
[]
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.each(&block)
|
8
|
+
fetch.each &block
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.map(&block)
|
12
|
+
fetch.map &block
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.find(&block)
|
16
|
+
fetch.find &block
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.sort(&block)
|
20
|
+
fetch.sort &block
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.select(&block)
|
24
|
+
fetch.select &block
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.reject(&block)
|
28
|
+
fetch.reject &block
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.where(**conds)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.first
|
35
|
+
fetch.first
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.sample(n = 1)
|
39
|
+
fetch.sample n
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.empty?
|
43
|
+
(fetch || []).empty?
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.size
|
47
|
+
fetch.size
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/Olib/objects/box.rb
CHANGED
data/lib/Olib/objects/herb.rb
CHANGED
data/lib/Olib/objects/jewel.rb
CHANGED
@@ -1,35 +1,32 @@
|
|
1
1
|
# Class to interact with gems
|
2
2
|
# overwriting Gem is a bad idea
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Client.notify "Error during gem appraisal"
|
22
|
-
end
|
3
|
+
class Jewel < Olib::Item
|
4
|
+
attr_accessor :quality, :value
|
5
|
+
|
6
|
+
def appraise
|
7
|
+
result = dothistimeout "appraise ##{@id}", 3, /#{Olib::Dictionary.gems[:appraise].values.join('|')}/
|
8
|
+
case result
|
9
|
+
when Olib::Dictionary.gems[:appraise][:gemshop]
|
10
|
+
# handle gemshop appraisal
|
11
|
+
@value = $1.to_i
|
12
|
+
when Olib::Dictionary.gems[:appraise][:player]
|
13
|
+
@value = $3.to_i
|
14
|
+
@quality = $2
|
15
|
+
when Olib::Dictionary.gems[:appraise][:failure]
|
16
|
+
waitrt?
|
17
|
+
self.appraise
|
18
|
+
else
|
19
|
+
respond result
|
20
|
+
Client.notify "Error during gem appraisal"
|
23
21
|
end
|
22
|
+
end
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
def sell
|
30
|
-
result = take
|
31
|
-
fput "sell ##{@id}" if result =~ Gemstone_Regex.get[:success]
|
32
|
-
end
|
24
|
+
def normalized_name
|
25
|
+
Olib::Dictionary.gems[:singularize].call(@name)
|
26
|
+
end
|
33
27
|
|
28
|
+
def sell
|
29
|
+
result = take
|
30
|
+
fput "sell ##{@id}" if result =~ Olib::Dictionary.get[:success]
|
34
31
|
end
|
35
|
-
end
|
32
|
+
end
|
data/lib/Olib/objects/jewelry.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
class Jewelry < Olib::Item
|
2
|
+
HEIRLOOM = /are the initials ([A-Z]{2})./
|
3
|
+
|
4
|
+
attr_accessor :heirloom
|
5
|
+
def heirloom?
|
6
|
+
result = Olib.do "look ##{@id}", /^You see nothing unusual/ | HEIRLOOM
|
7
|
+
@heirloom = result =~ HEIRLOOM ? true : false
|
8
|
+
@heirloom
|
9
9
|
end
|
10
10
|
end
|
data/lib/Olib/objects/scroll.rb
CHANGED
@@ -1,72 +1,42 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def Scroll.add_to_whitelist(*args)
|
24
|
-
@@whitelist + args
|
25
|
-
end
|
26
|
-
|
27
|
-
def Scroll.remove_from_whitelist(*args)
|
28
|
-
@@whitelist = @@whitelist - args
|
29
|
-
end
|
30
|
-
|
31
|
-
def initialize(item)
|
32
|
-
super item
|
33
|
-
@spells = []
|
34
|
-
return self
|
35
|
-
end
|
1
|
+
class Scroll < Olib::Item
|
2
|
+
@@whitelist = [
|
3
|
+
101, 102, 103, 107, 116, 120,
|
4
|
+
202, 211, 215, 219,
|
5
|
+
303, 307, 310, 313, 315,
|
6
|
+
401, 406, 414, 425, 430,
|
7
|
+
503, 507, 508, 509, 511, 513, 520,
|
8
|
+
601, 602, 606, 613, 617, 618, 625, 640,
|
9
|
+
712, 716,
|
10
|
+
905, 911, 913, 920,
|
11
|
+
1109, 1119, 1125, 1130,
|
12
|
+
1201, 1204,
|
13
|
+
1601, 1603, 1606, 1610, 1611, 1612, 1616,
|
14
|
+
1712, 1718
|
15
|
+
]
|
16
|
+
attr_accessor :spells, :worthy, :whitelist
|
17
|
+
|
18
|
+
def Scroll.whitelist
|
19
|
+
@@whitelist
|
20
|
+
end
|
36
21
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
@spells.each do |spell| @worthy = true if Scroll.whitelist.include? spell[:n] end
|
41
|
-
@worthy
|
42
|
-
end
|
22
|
+
def Scroll.add_to_whitelist(*args)
|
23
|
+
@@whitelist + args
|
24
|
+
end
|
43
25
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
fput "sell ##{@id}" if result
|
48
|
-
end
|
49
|
-
end
|
26
|
+
def Scroll.remove_from_whitelist(*args)
|
27
|
+
@@whitelist = @@whitelist - args
|
28
|
+
end
|
50
29
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
Timeout::timeout(0.1) do
|
57
|
-
while(get =~ /\(([0-9]+)\) ([a-zA-Z'\s]+)/)
|
58
|
-
spell = {}
|
59
|
-
spell[:n] = $1.to_i
|
60
|
-
spell[:name] = $2.to_s
|
61
|
-
@spells.push spell
|
62
|
-
end
|
63
|
-
end
|
64
|
-
rescue Timeout::Error
|
65
|
-
# Silent
|
66
|
-
end
|
67
|
-
end
|
68
|
-
self
|
69
|
-
end
|
30
|
+
def initialize(item)
|
31
|
+
super item
|
32
|
+
@spells = []
|
33
|
+
return self
|
34
|
+
end
|
70
35
|
|
36
|
+
def worthy?
|
37
|
+
@worthy = false
|
38
|
+
read unless @spells.length > 0
|
39
|
+
@spells.each do |spell| @worthy = true if Scroll.whitelist.include? spell[:n] end
|
40
|
+
@worthy
|
71
41
|
end
|
72
|
-
end
|
42
|
+
end
|