Olib 0.0.5 → 0.0.6
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 +1 -1
- data/lib/Olib.rb +16 -12
- data/lib/Olib/bounty.rb +119 -42
- data/lib/Olib/character/char.rb +77 -1
- data/lib/Olib/core/container.rb +8 -4
- data/lib/Olib/core/errors.rb +16 -7
- data/lib/Olib/core/item.rb +39 -5
- data/lib/Olib/dictionary/dictionary.rb +1 -1
- data/lib/Olib/objects/box.rb +1 -1
- data/lib/Olib/objects/clothing.rb +1 -1
- data/lib/Olib/objects/herb.rb +1 -1
- data/lib/Olib/objects/jar.rb +1 -1
- data/lib/Olib/objects/jewel.rb +1 -1
- data/lib/Olib/objects/jewelry.rb +1 -1
- data/lib/Olib/objects/scroll.rb +59 -59
- data/lib/Olib/objects/uncommon.rb +1 -1
- data/lib/Olib/objects/unknown.rb +1 -1
- data/lib/Olib/objects/wand.rb +1 -1
- data/lib/Olib/shops.rb +8 -6
- data/lib/Olib/transport.rb +6 -68
- data/lib/Olib/utils/cli.rb +63 -56
- data/lib/Olib/utils/monsterbold.rb +5 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df424880c2b863a92f1f370b6721dda0e54d63b4
|
4
|
+
data.tar.gz: 0b2911f4abf059ca84605d829cf4456d3d189ee7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6ad45ab88fee2b97934a2035e35b9f8ff37f324e54b943da41df31e5372bebaf508862d8a5cb6cb3b9030a6704d7c4e187bc88dcd5faacfbe3f4f18471c8a17
|
7
|
+
data.tar.gz: bd38704ae30455a17d6284ec88e7c1b7692cfa3f4edaa39af250e97500d7dea915575044c69e044f0d7db4284ef6884d151719d83ab230ff8d9bacf5332e483a
|
data/Olib.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'Olib'
|
6
|
-
s.version = '0.0.
|
6
|
+
s.version = '0.0.6'
|
7
7
|
s.date = '2014-09-12'
|
8
8
|
s.summary = "Useful Lich extensions for Gemstone IV"
|
9
9
|
s.description = "Useful Lich extensions for Gemstone IV including hostile creature management, group management, syntactically pleasing movement, locker management, etc"
|
data/lib/Olib.rb
CHANGED
@@ -3,17 +3,6 @@ require 'json'
|
|
3
3
|
|
4
4
|
module Olib
|
5
5
|
|
6
|
-
|
7
|
-
# load core first
|
8
|
-
Dir[File.dirname(__FILE__) + '/Olib/core/**/*.rb'].each {|file|
|
9
|
-
require file
|
10
|
-
}
|
11
|
-
|
12
|
-
# load things that depend on core extensions
|
13
|
-
Dir[File.dirname(__FILE__) + '/Olib/**/*.rb'].each {|file|
|
14
|
-
require file
|
15
|
-
}
|
16
|
-
|
17
6
|
def Olib.update_notifier
|
18
7
|
begin
|
19
8
|
request = Net::HTTP::Get.new('/api/v1/gems/Olib.json', initheader = {'Content-Type' =>'application/json'})
|
@@ -24,7 +13,7 @@ module Olib
|
|
24
13
|
else
|
25
14
|
# check version
|
26
15
|
if Gem.loaded_specs["Olib"].version < Gem::Version.new(JSON.parse(response.body)['version'])
|
27
|
-
|
16
|
+
puts "<pushBold/>You need to update the Olib gem with a `gem install Olib`<popBold/>"
|
28
17
|
end
|
29
18
|
end
|
30
19
|
rescue
|
@@ -33,6 +22,16 @@ module Olib
|
|
33
22
|
end
|
34
23
|
end
|
35
24
|
|
25
|
+
# load core first
|
26
|
+
Dir[File.dirname(__FILE__) + '/Olib/core/**/*.rb'].each {|file|
|
27
|
+
require file
|
28
|
+
}
|
29
|
+
|
30
|
+
# load things that depend on core extensions
|
31
|
+
Dir[File.dirname(__FILE__) + '/Olib/**/*.rb'].each {|file|
|
32
|
+
require file
|
33
|
+
}
|
34
|
+
|
36
35
|
# invoke update notifier immediately
|
37
36
|
Olib.update_notifier
|
38
37
|
|
@@ -40,6 +39,11 @@ module Olib
|
|
40
39
|
dothistimeout action, 5, re
|
41
40
|
end
|
42
41
|
|
42
|
+
def Olib.run(script, *args)
|
43
|
+
start_script script, args
|
44
|
+
wait_while { running? script }
|
45
|
+
end
|
46
|
+
|
43
47
|
Vars.Olib ||= Hash.new
|
44
48
|
|
45
49
|
|
data/lib/Olib/bounty.rb
CHANGED
@@ -1,52 +1,129 @@
|
|
1
1
|
module Olib
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def Bounty.types
|
25
|
-
@@re.keys
|
26
|
-
end
|
2
|
+
class Bounty
|
3
|
+
@@procedures = {}
|
4
|
+
|
5
|
+
@@re = {}
|
6
|
+
@@re[:herb] = /requires (?:a|an|some) (?<herb>[a-zA-Z '-]+) found (?:in|on|around) (?<area>[a-zA-Z '-]+). These samples must be in pristine condition. You have been tasked to retrieve (?<number>[\d]+)/
|
7
|
+
@@re[:escort] = /Go to the (.*?) and WAIT for (?:him|her|them) to meet you there. You must guarantee (?:his|her|their) safety to (?<destiniation>[a-zA-Z '-]+) as soon as/
|
8
|
+
@@re[:gem] = /has received orders from multiple customers requesting (?:a|an|some) (?<gem>[a-zA-Z '-]+). You have been tasked to retrieve (?<number>[0-9]+)/
|
9
|
+
@@re[:heirloom] = /You have been tasked to recover ([a-zA-Z '-]+) that an unfortunate citizen lost after being attacked by (a|an|some) (?<creature>[a-zA-Z '-]+) (in|on|around|near|by) (?<area>[a-zA-Z '-]+)./
|
10
|
+
@@re[:heirloom_found] = /^You have located the heirloom and should bring it back to/
|
11
|
+
@@re[:turn_in] = /You have succeeded in your task and can return to the Adventurer's Guild to receive your reward/
|
12
|
+
@@re[:guard_turn_in] = /^You succeeded in your task and should report back to/
|
13
|
+
@@re[:guard_bounty] = /Go report to ([a-zA-Z ]+) to find out more/
|
14
|
+
@@re[:cull] = /^You have been tasked to suppress (?<creature>^((?!bandit).)*$) activity (?:in|on) (?:the )? (?<area>.*?)(?: near| between| under|\.) ([a-zA-Z' ]+). You need to kill (?<number>[0-9]+)/
|
15
|
+
@@re[:bandits] = /^You have been tasked to suppress bandit activity (?:in |on )(?:the )(?<area>.*?)(?: near| between| under) ([a-zA-Z' ]+). You need to kill (?<number>[0-9]+)/
|
16
|
+
@@re[:dangerous] = /You have been tasked to hunt down and kill a particularly dangerous (?<creature>.*) that has established a territory (?:in|on) (?:the )?(?<area>.*?)(?: near| between| under|\.)/
|
17
|
+
@@re[:get_skin_bounty] = /The local furrier/
|
18
|
+
@@re[:get_herb_bounty] = /local herbalist|local healer|local alchemist/
|
19
|
+
@@re[:get_gem_bounty] = /The local gem dealer, (?<npc>[a-zA-Z ]+), has an order to fill and wants our help/
|
20
|
+
@@re[:creature_problem] = /It appears they have a creature problem they\'d like you to solve/
|
21
|
+
@@re[:rescue] = /A local divinist has had visions of the child fleeing from (?:a|an) (?<creature>.*) (?:in|on) (?:the )?(?<area>.*?)(?: near| between| under|\.)/
|
22
|
+
@@re[:failed_bounty] = /You have failed in your task/
|
23
|
+
@@re[:no_bounty] = /You are not currently assigned a task/
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
t= type if checkbounty =~ exp
|
25
|
+
# convenience list to get all types of bounties
|
26
|
+
def Bounty.types
|
27
|
+
@@re.keys
|
32
28
|
end
|
33
|
-
return t
|
34
|
-
end
|
35
29
|
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
def Bounty.town
|
31
|
+
checkbounty.match(@@re[ Bounty.type ])[:town]
|
32
|
+
end
|
39
33
|
|
40
|
-
|
41
|
-
|
42
|
-
|
34
|
+
def Bounty.area
|
35
|
+
checkbounty.match(@@re[ Bounty.type ])[:area]
|
36
|
+
end
|
43
37
|
|
44
|
-
|
45
|
-
|
38
|
+
def Bounty.destination
|
39
|
+
checkbounty.match(@@re[ Bounty.type ])[:destiniation]
|
40
|
+
end
|
41
|
+
|
42
|
+
def Bounty.gem
|
43
|
+
checkbounty.match(@@re[ Bounty.type ])[:gem]
|
44
|
+
end
|
46
45
|
|
47
|
-
|
46
|
+
def Bounty.creature
|
47
|
+
checkbounty.match(@@re[ Bounty.type ])[:creature]
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
+
def Bounty.herb
|
51
|
+
checkbounty.match(@@re[ Bounty.type ])[:herb]
|
52
|
+
end
|
53
|
+
|
54
|
+
def Bounty.n
|
55
|
+
checkbounty.match(@@re[ Bounty.type ])[:number].to_i
|
56
|
+
end
|
57
|
+
|
58
|
+
def Bounty.type
|
59
|
+
t = nil
|
60
|
+
@@re.each do |type, exp|
|
61
|
+
t= type if checkbounty =~ exp
|
62
|
+
end
|
63
|
+
return t
|
64
|
+
end
|
65
|
+
|
66
|
+
def Bounty.current
|
67
|
+
Bounty.type
|
68
|
+
end
|
50
69
|
|
51
|
-
|
70
|
+
def Bounty.ask_for_bounty
|
71
|
+
fput "ask ##{Bounty.npc.id} for bounty"
|
72
|
+
end
|
73
|
+
|
74
|
+
def Bounty.to_s
|
75
|
+
@@procedures.to_s
|
76
|
+
end
|
77
|
+
|
78
|
+
def Bounty.define_procedure(namespace, &block)
|
79
|
+
@@procedures[namespace] = block
|
80
|
+
end
|
81
|
+
|
82
|
+
def Bounty.procedures
|
83
|
+
@@procedures
|
84
|
+
end
|
85
|
+
|
86
|
+
def Bounty.cooldown?
|
87
|
+
Spell[9003].active?
|
88
|
+
end
|
89
|
+
|
90
|
+
def Bounty.throw_missing_procedure
|
91
|
+
msg = "\n"
|
92
|
+
msg.concat "\nBounty.exec called for #{Bounty.current} without a defined procedure\n\n"
|
93
|
+
msg.concat "define a procedure with:\n"
|
94
|
+
msg.concat " \n"
|
95
|
+
msg.concat " Bounty.define_procedure(:#{Bounty.current}) {\n"
|
96
|
+
msg.concat " # do something\n"
|
97
|
+
msg.concat " }\n"
|
98
|
+
msg.concat " \n"
|
99
|
+
msg.concat "or rescue this error (Olib::Errors::Fatal) gracefully\n"
|
100
|
+
msg.concat " \n"
|
101
|
+
raise Errors::Fatal.new msg
|
102
|
+
end
|
103
|
+
|
104
|
+
def Bounty.exec(procedure=nil)
|
105
|
+
|
106
|
+
if procedure
|
107
|
+
if @@procedures[procedure]
|
108
|
+
@@procedures[procedure].call
|
109
|
+
return Bounty
|
110
|
+
else
|
111
|
+
Bounty.throw_missing_procedure
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
if @@procedures[Bounty.current]
|
116
|
+
@@procedures[Bounty.current].call
|
117
|
+
return Bounty
|
118
|
+
else
|
119
|
+
Bounty.throw_missing_procedure
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
def Bounty.npc
|
125
|
+
GameObj.npcs.select { |npc| npc.name =~ /guard|taskmaster|gemcutter|jeweler|healer/i }.first
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
52
129
|
end
|
data/lib/Olib/character/char.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
module Olib
|
3
|
-
|
3
|
+
class Char
|
4
|
+
@@silvers = 0
|
4
5
|
@@routines = {}
|
5
6
|
|
6
7
|
def Char.hide
|
@@ -32,6 +33,81 @@ module Olib
|
|
32
33
|
GameObj.right_hand.nil? ? nil : Item.new(GameObj.right_hand)
|
33
34
|
end
|
34
35
|
|
36
|
+
def Char.withdraw(amount)
|
37
|
+
Transport.go2_bank
|
38
|
+
result = Olib.do "withdraw #{amount} silvers", /I'm sorry|hands you/
|
39
|
+
if result =~ /I'm sorry/
|
40
|
+
Transport.go2_origin
|
41
|
+
echo "Unable to withdraw the amount requested for this script to run from your bank account"
|
42
|
+
exit
|
43
|
+
end
|
44
|
+
wealth
|
45
|
+
return self
|
46
|
+
end
|
47
|
+
|
48
|
+
def Char.deposit_all
|
49
|
+
Transport.go2_bank
|
50
|
+
fput "unhide" if invisible? || hidden?
|
51
|
+
fput "deposit all"
|
52
|
+
@@silvers = 0
|
53
|
+
return self
|
54
|
+
end
|
55
|
+
|
56
|
+
def Char.deposit(amt)
|
57
|
+
wealth
|
58
|
+
if wealth >= amt
|
59
|
+
Transport.go2_bank
|
60
|
+
fput "unhide" if invisible? || hidden?
|
61
|
+
fput "deposit #{amt}"
|
62
|
+
end
|
63
|
+
return self
|
64
|
+
end
|
65
|
+
|
66
|
+
# naive share
|
67
|
+
# does not check if you're actually in a group or not
|
68
|
+
def Char.share
|
69
|
+
wealth
|
70
|
+
fput "share #{@silvers}"
|
71
|
+
wealth
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
75
|
+
def Char.deplete_wealth(silvers)
|
76
|
+
@@silvers = @@silvers - silvers
|
77
|
+
end
|
78
|
+
|
79
|
+
def Char.smart_wealth
|
80
|
+
return @@silvers if @@silvers
|
81
|
+
Char.wealth
|
82
|
+
end
|
83
|
+
|
84
|
+
def Char.unhide
|
85
|
+
fput 'unhide' if Spell[916].active? or hidden?
|
86
|
+
self
|
87
|
+
end
|
88
|
+
|
89
|
+
def Char.hide
|
90
|
+
if Spell[916].known? && Spell[916].affordable?
|
91
|
+
Spell[916].cast
|
92
|
+
else
|
93
|
+
fput "hide" until hidden?
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def Char.wealth
|
98
|
+
fput "info"
|
99
|
+
while(line=get)
|
100
|
+
next if line =~ /^\s*Name\:|^\s*Gender\:|^\s*Normal \(Bonus\)|^\s*Strength \(STR\)\:|^\s*Constitution \(CON\)\:|^\s*Dexterity \(DEX\)\:|^\s*Agility \(AGI\)\:|^\s*Discipline \(DIS\)\:|^\s*Aura \(AUR\)\:|^\s*Logic \(LOG\)\:|^\s*Intuition \(INT\)\:|^\s*Wisdom \(WIS\)\:|^\s*Influence \(INF\)\:/
|
101
|
+
if line =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+([0-9]+)/
|
102
|
+
@@silvers= $1.to_i
|
103
|
+
break
|
104
|
+
end
|
105
|
+
sleep 0.1
|
106
|
+
end
|
107
|
+
@@silvers
|
108
|
+
end
|
109
|
+
|
110
|
+
|
35
111
|
end
|
36
112
|
|
37
113
|
# chainable
|
data/lib/Olib/core/container.rb
CHANGED
@@ -48,11 +48,15 @@ module Olib
|
|
48
48
|
GameObj[@ref.id].contents.map{ |item| Item.new(item) }
|
49
49
|
end
|
50
50
|
|
51
|
-
def where(conditions)
|
51
|
+
def where(conditions)
|
52
52
|
contents.select { |item|
|
53
|
-
conditions.keys.map { |key|
|
54
|
-
|
55
|
-
|
53
|
+
!conditions.keys.map { |key|
|
54
|
+
if conditions[key].class == Array
|
55
|
+
item.props[key].class == Array && !conditions[key].map { |ele| item.props[key].include? ele }.include?(false)
|
56
|
+
else
|
57
|
+
item.props[key] == conditions[key]
|
58
|
+
end
|
59
|
+
}.include?(false)
|
56
60
|
}
|
57
61
|
end
|
58
62
|
|
data/lib/Olib/core/errors.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
module Olib
|
2
2
|
module Errors
|
3
|
+
@@padding = 20
|
4
|
+
|
5
|
+
def Errors.padding(n)
|
6
|
+
@@padding = n
|
7
|
+
end
|
8
|
+
|
9
|
+
def Errors.indent(str)
|
10
|
+
str.split("\n").map { |line| [''] * @@padding * " " + line }.join("\n")
|
11
|
+
end
|
3
12
|
|
4
13
|
# used internally to handle early thread execution and error bubbling
|
5
14
|
class Mundane < Exception
|
@@ -21,7 +30,7 @@ module Olib
|
|
21
30
|
message.concat "\n\nAn Olib::Errors::Fatal was raised but not rescued in an Olib method"
|
22
31
|
message.concat "\nyou should rescue this error if it isn't fatal and you don't want your script to break"
|
23
32
|
end
|
24
|
-
super
|
33
|
+
super Errors.indent message
|
25
34
|
end
|
26
35
|
end
|
27
36
|
|
@@ -34,7 +43,7 @@ module Olib
|
|
34
43
|
message.concat "\n\nYou tried to add stuff to a container that was full"
|
35
44
|
message.concat "\nyou should rescue this error if it isn't fatal and you don't want your script to break"
|
36
45
|
end
|
37
|
-
super
|
46
|
+
super Errors.indent message
|
38
47
|
end
|
39
48
|
end
|
40
49
|
|
@@ -45,7 +54,7 @@ module Olib
|
|
45
54
|
message.concat "\n\nYou tried to do something that costs more money that your character had on them"
|
46
55
|
message.concat "\nyou should rescue this error if it isn't fatal and you don't want your script to break"
|
47
56
|
end
|
48
|
-
super
|
57
|
+
super Errors.indent message
|
49
58
|
end
|
50
59
|
end
|
51
60
|
|
@@ -54,7 +63,7 @@ module Olib
|
|
54
63
|
message = String.new
|
55
64
|
message.concat "\n\nYour hands were full!"
|
56
65
|
message.concat "\nyou should rescue this error if you don't want your script to break"
|
57
|
-
super
|
66
|
+
super Errors.indent message
|
58
67
|
end
|
59
68
|
end
|
60
69
|
|
@@ -63,7 +72,7 @@ module Olib
|
|
63
72
|
message = String.new
|
64
73
|
message.concat "\n\nYou were too heavy to do something!"
|
65
74
|
message.concat "\nyou should rescue this error if you don't want your script to break"
|
66
|
-
super
|
75
|
+
super Errors.indent message
|
67
76
|
end
|
68
77
|
end
|
69
78
|
|
@@ -74,9 +83,9 @@ module Olib
|
|
74
83
|
message.concat "\n\nYou tried to interact with something that no longer exists"
|
75
84
|
message.concat "\nyou should rescue this error if it isn't fatal and you don't want your script to break"
|
76
85
|
end
|
77
|
-
super
|
86
|
+
super Errors.indent message
|
78
87
|
end
|
79
88
|
end
|
80
89
|
|
81
90
|
end
|
82
|
-
end
|
91
|
+
end
|
data/lib/Olib/core/item.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
require 'Olib/core/extender'
|
2
2
|
|
3
3
|
module Olib
|
4
|
-
#
|
4
|
+
# this is the structure for a base Object
|
5
|
+
# wraps an instance of GameObj and adds the ability for tags, queries
|
5
6
|
class Item < Olib::Gameobj_Extender
|
6
7
|
attr_accessor :props
|
7
|
-
|
8
|
-
|
8
|
+
# When created, it should be passed an instance of GameObj
|
9
|
+
#
|
10
|
+
# Example:
|
11
|
+
# Olib::Item.new(GameObj.right_hand)
|
12
|
+
def initialize(obj)
|
9
13
|
@props = Hash.new
|
10
14
|
|
11
15
|
@props[:name] = obj.name
|
@@ -37,6 +41,11 @@ module Olib
|
|
37
41
|
@props.to_s
|
38
42
|
end
|
39
43
|
|
44
|
+
# determine if Item is something
|
45
|
+
#
|
46
|
+
# example:
|
47
|
+
# item.is?("jar")
|
48
|
+
#
|
40
49
|
def is?(tag)
|
41
50
|
@props[:tags].include?(tag)
|
42
51
|
end
|
@@ -65,6 +74,7 @@ module Olib
|
|
65
74
|
end
|
66
75
|
|
67
76
|
def buy
|
77
|
+
Char.deplete_wealth cost
|
68
78
|
fput action 'buy'
|
69
79
|
self
|
70
80
|
end
|
@@ -77,10 +87,20 @@ module Olib
|
|
77
87
|
!has?(key)
|
78
88
|
end
|
79
89
|
|
90
|
+
def exists?
|
91
|
+
GameObj[@id].nil?
|
92
|
+
end
|
93
|
+
|
80
94
|
def pullable?
|
81
95
|
is? 'pullable'
|
82
96
|
end
|
83
97
|
|
98
|
+
def affordable?
|
99
|
+
take
|
100
|
+
return true if pullable?
|
101
|
+
cost <= Char.smart_wealth
|
102
|
+
end
|
103
|
+
|
84
104
|
def buyable?
|
85
105
|
is? 'buyable'
|
86
106
|
end
|
@@ -96,7 +116,10 @@ module Olib
|
|
96
116
|
else
|
97
117
|
Olib.wrap(action "buy"){ |line|
|
98
118
|
raise Olib::Errors::InsufficientFunds if line =~ /The merchant frowns/
|
99
|
-
|
119
|
+
if line =~ /You hand over/
|
120
|
+
Char.deplete_wealth cost
|
121
|
+
raise Olib::Errors::Mundane
|
122
|
+
end
|
100
123
|
}
|
101
124
|
end
|
102
125
|
self
|
@@ -222,7 +245,12 @@ module Olib
|
|
222
245
|
|
223
246
|
def give(target, onfailure=nil)
|
224
247
|
Olib.wrap_stream("give ##{@id} to #{target}", 30) { |line|
|
225
|
-
|
248
|
+
raise Olib::Errors::Mundane if line=~ /This looks perfect/
|
249
|
+
|
250
|
+
if line =~ /glances at you and moves out of your reach./
|
251
|
+
raise Olib::Errors::Fatal.new "You appear to have an invalid NPC definition"
|
252
|
+
end
|
253
|
+
|
226
254
|
}
|
227
255
|
|
228
256
|
self
|
@@ -311,6 +339,12 @@ module Olib
|
|
311
339
|
self
|
312
340
|
end
|
313
341
|
|
342
|
+
def drop
|
343
|
+
Script.log("#{Time.now} > dropped #{to_s}")
|
344
|
+
fput action "drop"
|
345
|
+
self
|
346
|
+
end
|
347
|
+
|
314
348
|
def _inspect
|
315
349
|
|
316
350
|
return self if has? 'inspect'
|
@@ -96,7 +96,7 @@ module Olib
|
|
96
96
|
re[:failure] = {}
|
97
97
|
re[:failure][:full] = /^won't fit in the|is full!|filling it./
|
98
98
|
re[:failure][:ne] = /^I could not find what you were referring to/
|
99
|
-
re[:success] = /^You put|^You tuck|^You sheathe|^You slip|^You roll up|^You tuck|^You add/
|
99
|
+
re[:success] = /^You put|^You tuck|^You sheathe|^You slip|^You roll up|^You tuck|^You add|^You place/
|
100
100
|
re
|
101
101
|
end
|
102
102
|
|
data/lib/Olib/objects/box.rb
CHANGED
data/lib/Olib/objects/herb.rb
CHANGED
data/lib/Olib/objects/jar.rb
CHANGED
data/lib/Olib/objects/jewel.rb
CHANGED
data/lib/Olib/objects/jewelry.rb
CHANGED
data/lib/Olib/objects/scroll.rb
CHANGED
@@ -1,72 +1,72 @@
|
|
1
1
|
module Olib
|
2
|
-
class Scroll <
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
2
|
+
class Scroll < Item
|
3
|
+
@@whitelist = [
|
4
|
+
101, 102, 103, 107, 116, 120,
|
5
|
+
202, 211, 215, 219,
|
6
|
+
303, 307, 310, 313, 315,
|
7
|
+
401, 406, 414, 425, 430,
|
8
|
+
503, 507, 508, 509, 511, 513, 520,
|
9
|
+
601, 602, 606, 613, 617, 618, 625, 640,
|
10
|
+
712,
|
11
|
+
905, 911, 913, 920,
|
12
|
+
1109, 1119, 1125, 1130,
|
13
|
+
1201, 1204,
|
14
|
+
1601, 1603, 1606, 1610, 1611, 1612, 1616,
|
15
|
+
1712, 1718
|
16
|
+
]
|
17
|
+
attr_accessor :spells, :worthy, :whitelist
|
18
|
+
|
19
|
+
def Scroll.whitelist
|
20
|
+
@@whitelist
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
def Scroll.add_to_whitelist(*args)
|
24
|
+
@@whitelist + args
|
25
|
+
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
def Scroll.remove_from_whitelist(*args)
|
28
|
+
@@whitelist = @@whitelist - args
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
def initialize(item)
|
32
|
+
super item
|
33
|
+
@spells = []
|
34
|
+
return self
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
def worthy?
|
38
|
+
@worthy = false
|
39
|
+
read unless @spells.length > 0
|
40
|
+
@spells.each do |spell| @worthy = true if Scroll.whitelist.include? spell[:n] end
|
41
|
+
@worthy
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
def sell
|
45
|
+
unless self.worthy?
|
46
|
+
result = dothistimeout "get ##{@id}", 1, /^You remove/
|
47
|
+
fput "sell ##{@id}" if result
|
48
|
+
end
|
48
49
|
end
|
49
|
-
end
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
51
|
+
def read
|
52
|
+
dothistimeout "read ##{@id}", 5, /It takes you a moment to focus/
|
53
|
+
result = matchtimeout(5, 'On the')
|
54
|
+
if result
|
55
|
+
begin
|
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
|
63
66
|
end
|
64
|
-
rescue Timeout::Error
|
65
|
-
# Silent
|
66
67
|
end
|
68
|
+
self
|
67
69
|
end
|
68
|
-
self
|
69
|
-
end
|
70
70
|
|
71
|
-
end
|
71
|
+
end
|
72
72
|
end
|
data/lib/Olib/objects/unknown.rb
CHANGED
data/lib/Olib/objects/wand.rb
CHANGED
data/lib/Olib/shops.rb
CHANGED
@@ -15,6 +15,7 @@ module Olib
|
|
15
15
|
]
|
16
16
|
.flatten
|
17
17
|
.compact
|
18
|
+
.select { |container| !(container.name =~ /^([A-z][a-z]+ disk$)/)}
|
18
19
|
.map { |container| Shop::Container.new(container) }
|
19
20
|
|
20
21
|
@@containers
|
@@ -135,13 +136,14 @@ module Olib
|
|
135
136
|
|
136
137
|
def Playershop.where(conditions)
|
137
138
|
Playershop.items.select { |item|
|
138
|
-
conditions.keys.map { |key|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
!conditions.keys.map { |key|
|
140
|
+
if conditions[key].class == Array
|
141
|
+
item.props[key].class == Array && !conditions[key].map { |ele| item.props[key].include? ele }.include?(false)
|
142
|
+
else
|
143
|
+
item.props[key] == conditions[key]
|
144
|
+
end
|
145
|
+
}.include?(false)
|
143
146
|
}
|
144
|
-
|
145
147
|
end
|
146
148
|
|
147
149
|
def Playershop.find_by_tags(*tags)
|
data/lib/Olib/transport.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module Olib
|
2
2
|
|
3
3
|
class Transport
|
4
|
-
|
5
|
-
@@silvers = 0
|
4
|
+
|
6
5
|
@@teleporter = {}
|
7
6
|
@@routines = {}
|
8
7
|
|
@@ -16,7 +15,7 @@ module Olib
|
|
16
15
|
].each do |target|
|
17
16
|
singleton.send :define_method, "go2_#{target}".to_sym do
|
18
17
|
|
19
|
-
unhide if hidden?
|
18
|
+
Olib.Char.unhide if hidden?
|
20
19
|
unless Room.current.tags.include?(target)
|
21
20
|
start_script 'go2', [target, '_disable_confirm_']
|
22
21
|
wait_while { running? "go2" };
|
@@ -33,6 +32,7 @@ module Olib
|
|
33
32
|
@@origin[:roomid] = Room.current.id
|
34
33
|
@@origin[:hidden] = hiding?
|
35
34
|
@@origin[:location] = Room.current.location
|
35
|
+
Olib.debug "rebasing to #{@@origin}"
|
36
36
|
self
|
37
37
|
end
|
38
38
|
|
@@ -85,68 +85,9 @@ module Olib
|
|
85
85
|
self
|
86
86
|
end
|
87
87
|
|
88
|
-
def Transport.wealth
|
89
|
-
fput "info"
|
90
|
-
while(line=get)
|
91
|
-
next if line =~ /^\s*Name\:|^\s*Gender\:|^\s*Normal \(Bonus\)|^\s*Strength \(STR\)\:|^\s*Constitution \(CON\)\:|^\s*Dexterity \(DEX\)\:|^\s*Agility \(AGI\)\:|^\s*Discipline \(DIS\)\:|^\s*Aura \(AUR\)\:|^\s*Logic \(LOG\)\:|^\s*Intuition \(INT\)\:|^\s*Wisdom \(WIS\)\:|^\s*Influence \(INF\)\:/
|
92
|
-
if line =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+([0-9]+)/
|
93
|
-
@@silvers= $1.to_i
|
94
|
-
break
|
95
|
-
end
|
96
|
-
sleep 0.1
|
97
|
-
end
|
98
|
-
@@silvers
|
99
|
-
end
|
100
|
-
|
101
|
-
def Transport.deplete(silvers)
|
102
|
-
@@silvers = @@silvers - silvers
|
103
|
-
end
|
104
|
-
|
105
|
-
def Transport.smart_wealth
|
106
|
-
return @@silvers if @@silvers
|
107
|
-
@@wealth
|
108
|
-
end
|
109
|
-
|
110
|
-
def Transport.unhide
|
111
|
-
fput 'unhide' if Spell[916].active? or hidden?
|
112
|
-
self
|
113
|
-
end
|
114
|
-
|
115
|
-
def Transport.withdraw(amount)
|
116
|
-
go2_bank
|
117
|
-
result = Olib.do "withdraw #{amount} silvers", /I'm sorry|hands you/
|
118
|
-
if result =~ /I'm sorry/
|
119
|
-
go2_origin
|
120
|
-
echo "Unable to withdraw the amount requested for this script to run from your bank account"
|
121
|
-
exit
|
122
|
-
end
|
123
|
-
return self
|
124
|
-
end
|
125
|
-
|
126
|
-
def Transport.deposit_all
|
127
|
-
self.go2_bank
|
128
|
-
fput "unhide" if invisible? || hidden?
|
129
|
-
fput "deposit all"
|
130
|
-
return self
|
131
|
-
end
|
132
|
-
|
133
|
-
def Transport.deposit(amt)
|
134
|
-
self.go2_bank
|
135
|
-
fput "unhide" if invisible? || hidden?
|
136
|
-
fput "deposit #{amt}"
|
137
|
-
return self
|
138
|
-
end
|
139
|
-
|
140
|
-
# naive share
|
141
|
-
# does not check if you're actually in a group or not
|
142
|
-
def Transport.share
|
143
|
-
wealth
|
144
|
-
fput "share #{@silvers}"
|
145
|
-
self
|
146
|
-
end
|
147
88
|
|
148
89
|
def Transport.go2(roomid)
|
149
|
-
unhide if hidden
|
90
|
+
Olib.Char.unhide if hidden
|
150
91
|
unless Room.current.id == roomid
|
151
92
|
start_script 'go2', [roomid, '_disable_confirm_']
|
152
93
|
wait_while { running? "go2" };
|
@@ -163,11 +104,8 @@ module Olib
|
|
163
104
|
end
|
164
105
|
|
165
106
|
def Transport.go2_origin
|
166
|
-
|
167
|
-
|
168
|
-
wait_while { running? "go2" };
|
169
|
-
end
|
170
|
-
hide if @@origin[:hidden]
|
107
|
+
Transport.go2 @@origin[:roomid]
|
108
|
+
Olib.Char.hide if @@origin[:hidden]
|
171
109
|
return self
|
172
110
|
end
|
173
111
|
|
data/lib/Olib/utils/cli.rb
CHANGED
@@ -1,74 +1,81 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
list.each.with_index {|ele, i|
|
14
|
-
if ele.start_with?('--')
|
15
|
-
opts[:flags][ symbolize(ele) ] = ''
|
16
|
-
else
|
17
|
-
# cast to Number if is number
|
18
|
-
ele = ele.to_i if ele =~ /^([\d\.]+$)/
|
19
|
-
# look back to previous flag and set it to it's value
|
20
|
-
opts[:flags][ symbolize(list[i-1]) ] = ele
|
1
|
+
module Olib
|
2
|
+
class ScriptVars
|
3
|
+
attr_accessor :opts
|
4
|
+
def initialize
|
5
|
+
opts = {}
|
6
|
+
opts[:flags] = {}
|
7
|
+
return opts if Script.current.vars.empty?
|
8
|
+
list = Script.current.vars.map(&:downcase).last(Script.current.vars.length-1)
|
9
|
+
|
10
|
+
unless list.first.start_with?('--')
|
11
|
+
opts[:cmd] = list.shift
|
21
12
|
end
|
22
|
-
}
|
23
|
-
|
24
|
-
@opts = opts
|
25
|
-
self
|
26
|
-
end
|
27
13
|
|
28
|
-
|
29
|
-
|
30
|
-
|
14
|
+
# iterate over list for flag values
|
15
|
+
flags = list.compact.join(' ').split('--')
|
16
|
+
flags.shift
|
17
|
+
flags.each { |flag|
|
18
|
+
segments = flag.split(' ')
|
19
|
+
name = symbolize(segments.shift)
|
20
|
+
opts[:flags][name] = true
|
21
|
+
if !segments.empty?
|
22
|
+
value = segments.join(' ').strip
|
23
|
+
if value =~ /[\d]+/
|
24
|
+
value = value.to_i
|
25
|
+
end
|
26
|
+
opts[:flags][name] = value
|
27
|
+
end
|
28
|
+
}
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
@opts = opts
|
31
|
+
self
|
32
|
+
end
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
def cmd
|
35
|
+
@opts[:cmd]
|
36
|
+
end
|
39
37
|
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
def empty?(flag)
|
39
|
+
opts[:flags][flag].class == TrueClass || opts[:flags][flag].class == NilClass
|
40
|
+
end
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
def cmd?(action)
|
43
|
+
cmd == action
|
44
|
+
end
|
47
45
|
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
def symbolize(flag)
|
47
|
+
flag.gsub('--', '').gsub('-', '_').to_sym
|
48
|
+
end
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
def help?
|
51
|
+
cmd =~ /help/
|
52
|
+
end
|
55
53
|
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
def flags
|
55
|
+
opts[:flags].keys
|
56
|
+
end
|
59
57
|
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
def to_s
|
59
|
+
@opts.to_s
|
60
|
+
end
|
63
61
|
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
def flag
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
def flag?(f)
|
67
|
+
opts[:flags][ symbolize(f) ]
|
68
|
+
end
|
67
69
|
|
70
|
+
def method_missing(arg1, arg2=nil)
|
71
|
+
@opts[:flags][arg1]
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
68
75
|
end
|
69
76
|
|
70
77
|
module Olib
|
71
78
|
def Olib.CLI
|
72
|
-
ScriptVars.new
|
79
|
+
Olib::ScriptVars.new
|
73
80
|
end
|
74
81
|
end
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondreian Shamsiel
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- lib/Olib/transport.rb
|
47
47
|
- lib/Olib/utils/cli.rb
|
48
48
|
- lib/Olib/utils/help_menu.rb
|
49
|
+
- lib/Olib/utils/monsterbold.rb
|
49
50
|
- lib/Olib/utils/utils.rb
|
50
51
|
- lib/Olib/utils/vbulletin.rb
|
51
52
|
- lib/Olib.rb
|