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.
@@ -1,118 +1,113 @@
1
-
2
- module Olib
3
- class Char
4
- @@silvers = 0
5
- @@routines = {}
6
-
7
- def Char.hide
8
- while not hiding?
9
- waitrt?
10
- if @@routines[:hiding]
11
- @@routines[:hiding].call
12
- else
13
- fput 'hide'
14
- end
15
- end
16
- Char
17
- end
18
-
19
- def Char.visible?
20
- hiding? || invisible?
21
- end
22
-
23
- def Char.hiding_routine(procedure)
24
- @@routines[:hiding] = procedure
25
- Char
26
- end
27
-
28
- def Char.left
29
- GameObj.left_hand.nil? ? nil : Item.new(GameObj.left_hand)
30
- end
31
-
32
- def Char.right
33
- GameObj.right_hand.nil? ? nil : Item.new(GameObj.right_hand)
34
- end
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
-
111
- end
112
-
113
- # chainable
114
- def Olib.Char
115
- Olib::Char
116
- end
117
-
118
- end
1
+ class Char
2
+ @@silvers = 0
3
+ @@routines = {}
4
+
5
+ def Char.hide
6
+ while not hiding?
7
+ waitrt?
8
+ if @@routines[:hiding]
9
+ @@routines[:hiding].call
10
+ else
11
+ fput 'hide'
12
+ end
13
+ end
14
+ Char
15
+ end
16
+
17
+ def Char.fwi_teleporter
18
+ Vars.teleporter || Vars.mapdb_fwi_trinket
19
+ end
20
+
21
+ def Char.visible?
22
+ hiding? || invisible?
23
+ end
24
+
25
+ def Char.hiding_routine(procedure)
26
+ @@routines[:hiding] = procedure
27
+ Char
28
+ end
29
+
30
+ def Char.left
31
+ GameObj.left_hand.name == "Empty" ? nil : Olib::Item.new(GameObj.left_hand)
32
+ end
33
+
34
+ def Char.right
35
+ GameObj.right_hand.name == "Empty" ? nil : Olib::Item.new(GameObj.right_hand)
36
+ end
37
+
38
+ def Char.withdraw(amount)
39
+ Go2.bank
40
+ result = Olib.do "withdraw #{amount} silvers", /I'm sorry|hands you/
41
+ if result =~ /I'm sorry/
42
+ Go2.origin
43
+ echo "Unable to withdraw the amount requested for this script to run from your bank account"
44
+ exit
45
+ end
46
+ wealth
47
+ return self
48
+ end
49
+
50
+ def Char.deposit_all
51
+ Go2.bank
52
+ fput "unhide" if invisible? || hidden?
53
+ fput "deposit all"
54
+ @@silvers = 0
55
+ return self
56
+ end
57
+
58
+ def Char.deposit(amt)
59
+ wealth
60
+ if wealth >= amt
61
+ Go2.bank
62
+ fput "unhide" if invisible? || hidden?
63
+ fput "deposit #{amt}"
64
+ end
65
+ return self
66
+ end
67
+
68
+ # naive share
69
+ # does not check if you're actually in a group or not
70
+ def Char.share
71
+ wealth
72
+ fput "share #{@silvers}"
73
+ wealth
74
+ self
75
+ end
76
+
77
+ def Char.deplete_wealth(silvers)
78
+ @@silvers = @@silvers - silvers
79
+ end
80
+
81
+ def Char.smart_wealth
82
+ return @@silvers if @@silvers
83
+ Char.wealth
84
+ end
85
+
86
+ def Char.unhide
87
+ fput 'unhide' if Spell[916].active? or hidden?
88
+ self
89
+ end
90
+
91
+ def Char.hide
92
+ if Spell[916].known? && Spell[916].affordable?
93
+ Spell[916].cast
94
+ else
95
+ fput "hide" until hidden?
96
+ end
97
+ end
98
+
99
+ def Char.wealth
100
+ fput "info"
101
+ while(line=get)
102
+ 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\)\:/
103
+ if line =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+([0-9]+)/
104
+ @@silvers= $1.to_i
105
+ break
106
+ end
107
+ sleep 0.1
108
+ end
109
+ @@silvers
110
+ end
111
+
112
+
113
+ end
@@ -1,68 +1,69 @@
1
- # NEW: Stable
2
- module Olib
3
- class Group
4
- @@characters = {}
5
- @@checked = false
6
- @@characters[Char.name] = true # YOU CAN NEVER ESCAPE YOURSELF (so your own disk won't fuck up)
7
- @@leader = Char.name
8
-
9
- # ran at the initialization of a script
10
- def Group.check
11
- @@characters = {}
12
-
13
-
14
- fput "group"
15
- while line=get
16
- break if line =~ /You are not currently in a group/
17
- Group.define($1) if line =~ /([a-zA-Z]+) (is following you|is also a member of your group|is the leader of your group)/
18
- @@leader = $1 if line =~ /([a-zA-Z]+) is the leader of your group/
19
- break if line =~ /^Your group status is/
20
- end
21
- @@checked = true
22
- @@characters
23
- end
24
-
25
- def Group.leader
26
- @@leader
27
- end
28
-
29
- def Group.leader?
30
- Group.check unless @@checked
31
- @@leader == Char.name
32
- end
33
-
34
- def Group.whisper(msg)
35
- fput "whisper group #{msg}" unless Group.members.empty?
36
- end
37
-
38
- def Group.add(char)
39
- fput "group #{char}"
40
- Group.define(char)
41
- self
42
- end
43
-
44
- def Group.remove(char)
45
- fput "remove #{char}"
46
- @@characters.delete(char)
47
- self
48
- end
49
-
50
- def Group.nonmembers
51
- Group.check unless @@checked
52
- others = GameObj.pcs.map! {|char| char.noun } || []
53
- # find all the disks/hidden players too
54
- disk_owners = GameObj.loot.find_all { |obj| (obj.noun == 'disk') }.map{|disk| /([A-Z](?:[a-z]+))/.match(disk.name)[0].strip } || []
55
- [others, disk_owners].flatten.reject(&:nil?).uniq - @@characters.keys
56
- end
57
-
58
- def Group.members
59
- Group.check unless @@checked
60
- @@characters.keys
61
- end
62
-
63
- def Group.define(name)
64
- GameObj.pcs.detect do |pc| @@characters[name] = pc.dup if pc.noun == name end
65
- end
66
-
67
- end
1
+ module Olib
2
+ class Group
3
+ @@characters = {}
4
+ @@checked = false
5
+ @@characters[Char.name] = true # YOU CAN NEVER ESCAPE YOURSELF (so your own disk won't fuck up)
6
+ @@leader = Char.name
7
+
8
+ # ran at the initialization of a script
9
+ def Group.check
10
+ @@characters = {}
11
+
12
+
13
+ fput "group"
14
+ while line=get
15
+ break if line =~ /You are not currently in a group/
16
+ Group.define($1) if line =~ /([a-zA-Z]+) (is following you|is also a member of your group|is the leader of your group)/
17
+ @@leader = $1 if line =~ /([a-zA-Z]+) is the leader of your group/
18
+ break if line =~ /^Your group status is/
19
+ end
20
+ @@checked = true
21
+ @@characters
22
+ end
23
+
24
+ def Group.leader
25
+ @@leader
26
+ end
27
+
28
+ def Group.leader?
29
+ Group.check unless @@checked
30
+ @@leader == Char.name
31
+ end
32
+
33
+ def Group.whisper(msg)
34
+ fput "whisper group #{msg}" unless Group.members.empty?
35
+ end
36
+
37
+ def Group.add(char)
38
+ fput "group #{char}"
39
+ Group.define(char)
40
+ self
41
+ end
42
+
43
+ def Group.remove(char)
44
+ fput "remove #{char}"
45
+ @@characters.delete(char)
46
+ self
47
+ end
48
+
49
+ def Group.nonmembers
50
+ Group.check unless @@checked
51
+ others = GameObj.pcs.map! {|char| char.noun } || []
52
+ # find all the disks/hidden players too
53
+ disk_owners = GameObj.loot.find_all { |obj| (obj.noun == 'disk') }.map{|disk| /([A-Z](?:[a-z]+))/.match(disk.name)[0].strip } || []
54
+ [others, disk_owners].flatten.reject(&:nil?).uniq - @@characters.keys
55
+ end
56
+
57
+ def Group.members
58
+ Group.check unless @@checked
59
+ @@characters.keys
60
+ end
61
+
62
+ def Group.define(name)
63
+ GameObj.pcs.detect do |pc| @@characters[name] = pc.dup if pc.noun == name end
64
+ end
65
+ end
66
+ end
67
+
68
+ class Group < Olib::Group
68
69
  end
@@ -1,80 +1,80 @@
1
- module Olib
2
- module Inventory
3
- Vars.Olib[:Inventory] ||= Hash.new
4
-
5
- @@checked = false
6
-
7
-
8
- def Inventory.containers
9
- Inventory.check
10
- GameObj.containers
11
- end
12
-
13
- def Inventory.to_s
14
- Inventory.items.map(&:to_s)
15
- end
16
-
17
- def Inventory.checked?
18
- @@checked
19
- end
20
-
21
- def Inventory.[](query)
22
- GameObj.inv.select { |item|
23
- item.name == query || item.id == query
24
- }
25
- end
26
-
27
- def Inventory.teleporter
28
- # check for worn teleporter
29
- candidates= GameObj.inv.select { |item|
30
- item.name == Vars.teleporter
31
- }
32
-
33
- unless candidates.empty?
34
- return Item.new(candidates.first)
35
- end
36
-
37
- # check in containers
38
- Inventory.items.select { |item|
39
- item.is? "teleporter"
40
- }.first
41
- end
42
-
43
- def Inventory.items
44
- Inventory.containers.map { |id, contents| contents.map {|item|
45
- Item.new(item).define("container", id)
46
- }
47
- }.flatten
48
- end
49
-
50
- def Inventory.check
51
- return self if Inventory.checked?
52
- GameObj.inv.select{ |item|
53
- !item.name.include?('tattoo')
54
- }.each {|item|
55
- if item.contents.nil?
56
- Olib.wrap("look in ##{item.id}") { |line|
57
- respond line =~ /Shadow engulf/
58
-
59
- raise Olib::Errors::Mundane if line =~ /There is nothing in there.|Total|^In the (.*).$|prompt|^Shadows engulf/
60
-
61
- if line =~ /That is closed./
62
- Olib.wrap("open ##{item.id}") { |line|
63
- if line =~ /You open/
64
- multifput "look in ##{item.id}", "close ##{item.id}"
65
- end
66
- }
67
- end
68
- }
69
- end
70
- }
71
- @@checked = true
72
- return self
73
- end
74
-
75
- end
76
-
77
- def Olib.Inventory
78
- Olib::Inventory
79
- end
1
+ module Olib
2
+ module Inventory
3
+ Vars.Olib[:Inventory] ||= Hash.new
4
+
5
+ @@checked = false
6
+
7
+
8
+ def Inventory.containers
9
+ Inventory.check
10
+ GameObj.containers
11
+ end
12
+
13
+ def Inventory.to_s
14
+ Inventory.items.map(&:to_s)
15
+ end
16
+
17
+ def Inventory.checked?
18
+ @@checked
19
+ end
20
+
21
+ def Inventory.[](query)
22
+ GameObj.inv.select { |item|
23
+ item.name == query || item.id == query
24
+ }
25
+ end
26
+
27
+ def Inventory.fwi_teleporter
28
+ # check for worn teleporter
29
+ candidates= GameObj.inv.select { |item|
30
+ item.name == Char.fwi_teleporter
31
+ }
32
+
33
+ unless candidates.empty?
34
+ return Item.new(candidates.first)
35
+ end
36
+
37
+ # check in containers
38
+ Inventory.items.select { |item|
39
+ item.is? "teleporter"
40
+ }.first
41
+ end
42
+
43
+ def Inventory.items
44
+ Inventory.containers.map { |id, contents| contents.map {|item|
45
+ Item.new(item).define("container", id)
46
+ }
47
+ }.flatten
48
+ end
49
+
50
+ def Inventory.check
51
+ return self if Inventory.checked?
52
+ GameObj.inv.select{ |item|
53
+ !item.name.include?('tattoo')
54
+ }.each {|item|
55
+ if item.contents.nil?
56
+ Olib.wrap("look in ##{item.id}") { |line|
57
+ respond line =~ /Shadow engulf/
58
+
59
+ raise Olib::Errors::Mundane if line =~ /There is nothing in there.|Total|^In the (.*).$|prompt|^Shadows engulf/
60
+
61
+ if line =~ /That is closed./
62
+ Olib.wrap("open ##{item.id}") { |line|
63
+ if line =~ /You open/
64
+ multifput "look in ##{item.id}", "close ##{item.id}"
65
+ end
66
+ }
67
+ end
68
+ }
69
+ end
70
+ }
71
+ @@checked = true
72
+ return self
73
+ end
74
+
75
+ end
76
+
77
+ def Olib.Inventory
78
+ Olib::Inventory
79
+ end
80
80
  end