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
@@ -1,5 +1,5 @@
|
|
1
|
-
module Olib
|
2
|
-
def Olib.monsterbold(str)
|
3
|
-
"<pushBold/>#{str}<popBold/>"
|
4
|
-
end
|
1
|
+
module Olib
|
2
|
+
def Olib.monsterbold(str)
|
3
|
+
"<pushBold/>#{str}<popBold/>"
|
4
|
+
end
|
5
5
|
end
|
data/lib/Olib/utils/vbulletin.rb
CHANGED
@@ -1,101 +1,101 @@
|
|
1
|
-
class VBulletin
|
2
|
-
attr_accessor :post
|
3
|
-
def initialize
|
4
|
-
@post = String.new
|
5
|
-
self
|
6
|
-
end
|
7
|
-
def open_bold
|
8
|
-
@post.concat "[B]"
|
9
|
-
self
|
10
|
-
end
|
11
|
-
def open_underline
|
12
|
-
@post.concat '[U]'
|
13
|
-
self
|
14
|
-
end
|
15
|
-
def close_underline
|
16
|
-
@post.concat '[/U]'
|
17
|
-
self
|
18
|
-
end
|
19
|
-
def close_bold
|
20
|
-
@post.concat '[/B]'
|
21
|
-
self
|
22
|
-
end
|
23
|
-
def open_color(hexcode)
|
24
|
-
@post.concat "[COLOR=\"#{hexcode}\"]"
|
25
|
-
self
|
26
|
-
end
|
27
|
-
def open_table(width=500)
|
28
|
-
@post.contat "[TABLE=\"width: #{width}\""
|
29
|
-
self
|
30
|
-
end
|
31
|
-
def close_table
|
32
|
-
@post.concat "[/TABLE]"
|
33
|
-
self
|
34
|
-
end
|
35
|
-
def open_tr
|
36
|
-
@post.contact "[TR]"
|
37
|
-
self
|
38
|
-
end
|
39
|
-
def close_tr
|
40
|
-
@post.contact "[/TR]"
|
41
|
-
self
|
42
|
-
end
|
43
|
-
def open_cell
|
44
|
-
@post.concat "[TD]"
|
45
|
-
self
|
46
|
-
end
|
47
|
-
def close_cell
|
48
|
-
@post.concat '[/TD]'
|
49
|
-
self
|
50
|
-
end
|
51
|
-
def close_color
|
52
|
-
@post.concat '[/COLOR]'
|
53
|
-
self
|
54
|
-
end
|
55
|
-
def add(str)
|
56
|
-
@post.concat str
|
57
|
-
self
|
58
|
-
end
|
59
|
-
def add_line(str)
|
60
|
-
@post.concat "#{str}\n"
|
61
|
-
self
|
62
|
-
end
|
63
|
-
def open_size(sz)
|
64
|
-
@post.concat "[SIZE=#{sz}]"
|
65
|
-
self
|
66
|
-
end
|
67
|
-
def close_size
|
68
|
-
@post.concat "[/SIZE]"
|
69
|
-
self
|
70
|
-
end
|
71
|
-
def open_italics
|
72
|
-
@post.concat"[I]"
|
73
|
-
self
|
74
|
-
end
|
75
|
-
def close_italics
|
76
|
-
@post.concat "[/I]"
|
77
|
-
self
|
78
|
-
end
|
79
|
-
def open_indent
|
80
|
-
@post.concat "[INDENT]"
|
81
|
-
self
|
82
|
-
end
|
83
|
-
def close_indent
|
84
|
-
@post.concat "[/INDENT]"
|
85
|
-
self
|
86
|
-
end
|
87
|
-
def tab
|
88
|
-
@post.concat "\t"
|
89
|
-
self
|
90
|
-
end
|
91
|
-
def enter
|
92
|
-
@post.concat "\n"
|
93
|
-
self
|
94
|
-
end
|
95
|
-
def VBulletin.commafy(n)
|
96
|
-
n.to_s.chars.to_a.reverse.each_slice(3).map(&:join).join(",").reverse
|
97
|
-
end
|
98
|
-
def to_s
|
99
|
-
@post
|
100
|
-
end
|
1
|
+
class VBulletin
|
2
|
+
attr_accessor :post
|
3
|
+
def initialize
|
4
|
+
@post = String.new
|
5
|
+
self
|
6
|
+
end
|
7
|
+
def open_bold
|
8
|
+
@post.concat "[B]"
|
9
|
+
self
|
10
|
+
end
|
11
|
+
def open_underline
|
12
|
+
@post.concat '[U]'
|
13
|
+
self
|
14
|
+
end
|
15
|
+
def close_underline
|
16
|
+
@post.concat '[/U]'
|
17
|
+
self
|
18
|
+
end
|
19
|
+
def close_bold
|
20
|
+
@post.concat '[/B]'
|
21
|
+
self
|
22
|
+
end
|
23
|
+
def open_color(hexcode)
|
24
|
+
@post.concat "[COLOR=\"#{hexcode}\"]"
|
25
|
+
self
|
26
|
+
end
|
27
|
+
def open_table(width=500)
|
28
|
+
@post.contat "[TABLE=\"width: #{width}\""
|
29
|
+
self
|
30
|
+
end
|
31
|
+
def close_table
|
32
|
+
@post.concat "[/TABLE]"
|
33
|
+
self
|
34
|
+
end
|
35
|
+
def open_tr
|
36
|
+
@post.contact "[TR]"
|
37
|
+
self
|
38
|
+
end
|
39
|
+
def close_tr
|
40
|
+
@post.contact "[/TR]"
|
41
|
+
self
|
42
|
+
end
|
43
|
+
def open_cell
|
44
|
+
@post.concat "[TD]"
|
45
|
+
self
|
46
|
+
end
|
47
|
+
def close_cell
|
48
|
+
@post.concat '[/TD]'
|
49
|
+
self
|
50
|
+
end
|
51
|
+
def close_color
|
52
|
+
@post.concat '[/COLOR]'
|
53
|
+
self
|
54
|
+
end
|
55
|
+
def add(str)
|
56
|
+
@post.concat str
|
57
|
+
self
|
58
|
+
end
|
59
|
+
def add_line(str)
|
60
|
+
@post.concat "#{str}\n"
|
61
|
+
self
|
62
|
+
end
|
63
|
+
def open_size(sz)
|
64
|
+
@post.concat "[SIZE=#{sz}]"
|
65
|
+
self
|
66
|
+
end
|
67
|
+
def close_size
|
68
|
+
@post.concat "[/SIZE]"
|
69
|
+
self
|
70
|
+
end
|
71
|
+
def open_italics
|
72
|
+
@post.concat"[I]"
|
73
|
+
self
|
74
|
+
end
|
75
|
+
def close_italics
|
76
|
+
@post.concat "[/I]"
|
77
|
+
self
|
78
|
+
end
|
79
|
+
def open_indent
|
80
|
+
@post.concat "[INDENT]"
|
81
|
+
self
|
82
|
+
end
|
83
|
+
def close_indent
|
84
|
+
@post.concat "[/INDENT]"
|
85
|
+
self
|
86
|
+
end
|
87
|
+
def tab
|
88
|
+
@post.concat "\t"
|
89
|
+
self
|
90
|
+
end
|
91
|
+
def enter
|
92
|
+
@post.concat "\n"
|
93
|
+
self
|
94
|
+
end
|
95
|
+
def VBulletin.commafy(n)
|
96
|
+
n.to_s.chars.to_a.reverse.each_slice(3).map(&:join).join(",").reverse
|
97
|
+
end
|
98
|
+
def to_s
|
99
|
+
@post
|
100
|
+
end
|
101
101
|
end
|
data/lib/Olib/version.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Olib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondreian Shamsiel
|
@@ -20,10 +20,13 @@ files:
|
|
20
20
|
- Olib.gemspec
|
21
21
|
- README.md
|
22
22
|
- TODOS.md
|
23
|
+
- lib/Olib.rb
|
24
|
+
- lib/Olib/area.rb
|
23
25
|
- lib/Olib/bounty.rb
|
24
26
|
- lib/Olib/character/char.rb
|
25
27
|
- lib/Olib/character/group.rb
|
26
28
|
- lib/Olib/character/inventory.rb
|
29
|
+
- lib/Olib/character/mind.rb
|
27
30
|
- lib/Olib/combat/creature.rb
|
28
31
|
- lib/Olib/combat/creatures.rb
|
29
32
|
- lib/Olib/core/container.rb
|
@@ -32,6 +35,9 @@ files:
|
|
32
35
|
- lib/Olib/core/item.rb
|
33
36
|
- lib/Olib/core/utils.rb
|
34
37
|
- lib/Olib/dictionary/dictionary.rb
|
38
|
+
- lib/Olib/events/emitter.rb
|
39
|
+
- lib/Olib/go2.rb
|
40
|
+
- lib/Olib/npcs.rb
|
35
41
|
- lib/Olib/objects/box.rb
|
36
42
|
- lib/Olib/objects/clothing.rb
|
37
43
|
- lib/Olib/objects/herb.rb
|
@@ -43,13 +49,11 @@ files:
|
|
43
49
|
- lib/Olib/objects/unknown.rb
|
44
50
|
- lib/Olib/objects/wand.rb
|
45
51
|
- lib/Olib/shops.rb
|
46
|
-
- lib/Olib/transport.rb
|
47
52
|
- lib/Olib/utils/cli.rb
|
48
53
|
- lib/Olib/utils/help_menu.rb
|
49
54
|
- lib/Olib/utils/monsterbold.rb
|
50
|
-
- lib/Olib/utils/utils.rb
|
51
55
|
- lib/Olib/utils/vbulletin.rb
|
52
|
-
- lib/Olib.rb
|
56
|
+
- lib/Olib/version.rb
|
53
57
|
homepage: https://github.com/ondreian/Olib
|
54
58
|
licenses:
|
55
59
|
- MIT
|
@@ -60,17 +64,17 @@ require_paths:
|
|
60
64
|
- lib
|
61
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
62
66
|
requirements:
|
63
|
-
- -
|
67
|
+
- - ">="
|
64
68
|
- !ruby/object:Gem::Version
|
65
69
|
version: '0'
|
66
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
71
|
requirements:
|
68
|
-
- -
|
72
|
+
- - ">="
|
69
73
|
- !ruby/object:Gem::Version
|
70
74
|
version: '0'
|
71
75
|
requirements: []
|
72
76
|
rubyforge_project:
|
73
|
-
rubygems_version: 2.
|
77
|
+
rubygems_version: 2.4.8
|
74
78
|
signing_key:
|
75
79
|
specification_version: 4
|
76
80
|
summary: Useful Lich extensions for Gemstone IV
|
data/lib/Olib/transport.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
module Olib
|
2
|
-
|
3
|
-
class Transport
|
4
|
-
|
5
|
-
@@teleporter = {}
|
6
|
-
@@routines = {}
|
7
|
-
|
8
|
-
def Transport.__extend__
|
9
|
-
singleton = (class << self; self end)
|
10
|
-
[
|
11
|
-
'bank', 'gemshop', 'pawnshop', 'advguild', 'forge', 'inn', 'npchealer',
|
12
|
-
'chronomage', 'town', 'furrier', 'herbalist', 'locksmith', 'alchemist',
|
13
|
-
'fletcher', 'sunfist', 'movers', 'consignment', 'advguard','advguard2',
|
14
|
-
'clericshop', 'warriorguild'
|
15
|
-
].each do |target|
|
16
|
-
singleton.send :define_method, "go2_#{target}".to_sym do
|
17
|
-
|
18
|
-
Olib.Char.unhide if hidden?
|
19
|
-
unless Room.current.tags.include?(target)
|
20
|
-
start_script 'go2', [target, '_disable_confirm_']
|
21
|
-
wait_while { running? "go2" };
|
22
|
-
end
|
23
|
-
return self
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
Transport.__extend__
|
29
|
-
|
30
|
-
def Transport.rebase
|
31
|
-
@@origin = {}
|
32
|
-
@@origin[:roomid] = Room.current.id
|
33
|
-
@@origin[:hidden] = hiding?
|
34
|
-
@@origin[:location] = Room.current.location
|
35
|
-
Olib.debug "rebasing to #{@@origin}"
|
36
|
-
self
|
37
|
-
end
|
38
|
-
|
39
|
-
Transport.rebase
|
40
|
-
|
41
|
-
|
42
|
-
# Thanks Tillmen
|
43
|
-
def Transport.cost(to)
|
44
|
-
cost = 0
|
45
|
-
Map.findpath(Room.current.id, to).each { |id|
|
46
|
-
Room[id].tags.each { |tag|
|
47
|
-
if tag =~ /^silver-cost:#{id-1}:(.*)$/
|
48
|
-
cost_string = $1
|
49
|
-
if cost_string =~ /^[0-9]+$/
|
50
|
-
cost += cost_string.to_i
|
51
|
-
else
|
52
|
-
cost = StringProc.new(cost_string).call.to_i
|
53
|
-
end
|
54
|
-
end
|
55
|
-
}
|
56
|
-
}
|
57
|
-
cost
|
58
|
-
end
|
59
|
-
|
60
|
-
# use the teleporter variable to locate your teleporter and teleport
|
61
|
-
# naive of where you are
|
62
|
-
def Transport.fwi_teleport
|
63
|
-
unless Vars.teleporter
|
64
|
-
echo "Error: No teleport defined ;var set teleporter=<teleporter>"
|
65
|
-
exit
|
66
|
-
end
|
67
|
-
|
68
|
-
unless Inventory.teleporter
|
69
|
-
echo "Error: Your teleporter could not be found #{Vars.teleporter}"
|
70
|
-
exit
|
71
|
-
end
|
72
|
-
|
73
|
-
last = Room.current.id
|
74
|
-
teleporter = Inventory.teleporter
|
75
|
-
if teleporter.worn?
|
76
|
-
teleporter.turn
|
77
|
-
else
|
78
|
-
teleporter.take.turn.stash
|
79
|
-
end
|
80
|
-
|
81
|
-
if Room.current.id == last
|
82
|
-
echo "Error: You tried to teleport to FWI in a room that does not allow that"
|
83
|
-
end
|
84
|
-
|
85
|
-
self
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
def Transport.go2(roomid)
|
90
|
-
Olib.Char.unhide if hidden
|
91
|
-
unless Room.current.id == roomid
|
92
|
-
start_script 'go2', [roomid, '_disable_confirm_']
|
93
|
-
wait_while { running? "go2" };
|
94
|
-
end
|
95
|
-
return self
|
96
|
-
end
|
97
|
-
|
98
|
-
# TODO
|
99
|
-
# create a dictionary of house lockers and the logic to enter a locker
|
100
|
-
# insure locker is closed before scripting away from it
|
101
|
-
def Transport.go2_locker
|
102
|
-
echo "the go2_locker method currently does not function properly..."
|
103
|
-
self
|
104
|
-
end
|
105
|
-
|
106
|
-
def Transport.go2_origin
|
107
|
-
Transport.go2 @@origin[:roomid]
|
108
|
-
Olib.Char.hide if @@origin[:hidden]
|
109
|
-
return self
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
def Olib.Transport
|
115
|
-
Olib::Transport
|
116
|
-
end
|
117
|
-
end
|
data/lib/Olib/utils/utils.rb
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
module Olib
|
2
|
-
@@debug = false
|
3
|
-
@@xml = false
|
4
|
-
|
5
|
-
|
6
|
-
def Olib.toggle_debug
|
7
|
-
@@debug = @@debug ? false : true
|
8
|
-
end
|
9
|
-
|
10
|
-
def Olib.debug(msg)
|
11
|
-
return unless @@debug
|
12
|
-
echo "Olib.debug> #{msg}"
|
13
|
-
end
|
14
|
-
|
15
|
-
def Olib.timeout(sec) #:yield: +sec+
|
16
|
-
return yield(sec) if sec == nil or sec.zero?
|
17
|
-
|
18
|
-
begin
|
19
|
-
current_thread = Thread.current
|
20
|
-
x = Thread.start{
|
21
|
-
begin
|
22
|
-
yield(sec)
|
23
|
-
rescue => e
|
24
|
-
current_thread.raise e
|
25
|
-
end
|
26
|
-
}
|
27
|
-
y = Thread.start {
|
28
|
-
begin
|
29
|
-
sleep sec
|
30
|
-
rescue => e
|
31
|
-
x.raise e
|
32
|
-
else
|
33
|
-
x.kill
|
34
|
-
current_thread.raise Olib::Errors::TimedOut
|
35
|
-
end
|
36
|
-
}
|
37
|
-
x.value
|
38
|
-
ensure
|
39
|
-
if y
|
40
|
-
y.kill
|
41
|
-
y.join # make sure y is dead.
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
def Olib.script
|
48
|
-
Script.current
|
49
|
-
end
|
50
|
-
|
51
|
-
def Olib.turn_on_xml
|
52
|
-
if not @@xml
|
53
|
-
@@xml = true
|
54
|
-
Script.current.want_downstream_xml = @@xml
|
55
|
-
end
|
56
|
-
self
|
57
|
-
end
|
58
|
-
|
59
|
-
def Olib.turn_off_xml
|
60
|
-
if @@xml
|
61
|
-
@@xml = false
|
62
|
-
Script.current.want_downstream_xml = @@xml
|
63
|
-
end
|
64
|
-
self
|
65
|
-
end
|
66
|
-
|
67
|
-
def Olib.xml?
|
68
|
-
@@xml
|
69
|
-
end
|
70
|
-
|
71
|
-
def Olib.wrap(action)
|
72
|
-
|
73
|
-
begin
|
74
|
-
Olib.timeout(3) {
|
75
|
-
put action
|
76
|
-
while (line=get)
|
77
|
-
next if Dictionary.ignorable?(line)
|
78
|
-
# attempt at removing PC action that turned out to be more harmful than good
|
79
|
-
# next if not GameObj.pcs.nil? and line =~ /#{GameObj.pcs.join('|')}/
|
80
|
-
yield line
|
81
|
-
end
|
82
|
-
}
|
83
|
-
|
84
|
-
rescue Olib::Errors::TimedOut
|
85
|
-
Olib.debug "timeout... "
|
86
|
-
# Silent
|
87
|
-
rescue Olib::Errors::Mundane => e
|
88
|
-
|
89
|
-
rescue Olib::Errors::Prempt => e
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
def Olib.wrap_greedy(action)
|
96
|
-
|
97
|
-
begin
|
98
|
-
Olib.timeout(3) {
|
99
|
-
put action
|
100
|
-
while (line=get)
|
101
|
-
#next if not GameObj.pcs.nil? and line =~ /#{GameObj.pcs.join('|')}/
|
102
|
-
yield line
|
103
|
-
end
|
104
|
-
}
|
105
|
-
|
106
|
-
rescue Olib::Errors::TimedOut
|
107
|
-
Olib.debug "timeout... "
|
108
|
-
# Silent
|
109
|
-
rescue Olib::Errors::Mundane => e
|
110
|
-
|
111
|
-
rescue Olib::Errors::Prempt => e
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
def Olib.exit
|
118
|
-
raise Olib::Errors::Mundane
|
119
|
-
end
|
120
|
-
|
121
|
-
def Olib.wrap_stream(action, seconds=3)
|
122
|
-
begin
|
123
|
-
Olib.turn_on_xml
|
124
|
-
|
125
|
-
Olib.timeout(seconds) {
|
126
|
-
put action
|
127
|
-
while (line=get)
|
128
|
-
next if Olib::Dictionary.ignorable?(line)
|
129
|
-
# next if not GameObj.pcs.nil? and line =~ /#{GameObj.pcs.join('|')}/
|
130
|
-
yield line
|
131
|
-
end
|
132
|
-
}
|
133
|
-
|
134
|
-
rescue Olib::Errors::TimedOut
|
135
|
-
Olib.debug "timeout... "
|
136
|
-
# Silent
|
137
|
-
|
138
|
-
rescue Olib::Errors::Mundane => e
|
139
|
-
Olib.debug "mundane..."
|
140
|
-
|
141
|
-
rescue Olib::Errors::Prempt => e
|
142
|
-
Olib.debug "waiting prempted..."
|
143
|
-
|
144
|
-
ensure
|
145
|
-
Olib.turn_off_xml
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|