forked from rpherbig/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dusk-labyrinth.lic
106 lines (95 loc) · 2.94 KB
/
dusk-labyrinth.lic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#dusk-labyrinth
=end
custom_require.call %w[common common-items events]
class DuskLab
include DRC
include DRCI
def initialize
arg_definitions = [
[{ name: 'loot_bag', display: 'container noun', regex: /\w+/i, description: 'Bag for your loot!' },
{ name: 'redeem_scrip', display: 'redeem', regex: /^redeem/i, optional: true, description: 'Redeem scrip when finished?' }]
]
args = parse_args(arg_definitions)
Flags.add('five-minute-warning', 'You only have about 5 minutes left in the labyrinth!')
Flags.add('done', 'A surly Dwarf stomps in and glowers at you in the dim gloom')
Flags.add('no-monkey', 'A small monkey scurries (?<rat_dir>\w+)!')
Flags.add('monkey', 'You notice a small monkey scurrying around the area')
Flags.add('caught', 'You pick them both up, claiming your new pet')
@prev_dir = nil
@dir_to_prev_dir = {
'northeast' => 'southwest',
'southwest' => 'northeast',
'northwest' => 'southeast',
'southeast' => 'northwest',
'north' => 'south',
'south' => 'north',
'east' => 'west',
'west' => 'east',
'up' => 'down', # up and down dont appear in the maze, but are used for testing
'down' => 'up'
}
stow_hands
main(args) until done?
redeem if args.redeem_scrip
end
def redeem
while bput('get my bloodscrip', 'You get', 'What were') == 'You get'
bput('redeem my bloodscrip', 'You quickly pocket')
end
end
def main(args)
# search
@pause_timer = Time.now
pause 1 until Flags['no-monkey'] || Flags['monkey'] || Flags['caught']
if Flags['no-monkey'] && Flags['five-minute-warning']
search
Flags.reset('no-monkey')
elsif Flags['no-monkey']
Flags.reset('no-monkey')
elsif Flags['monkey']
search
Flags.reset('monkey')
elsif Flags['five-minute-warning'] || Flags['caught']
search
end
stow_loot(args.loot_bag)
wander unless done?
end
def next_move(exits)
if exits.count > 1 && !@prev_dir.nil?
exits.delete(@dir_to_prev_dir[@prev_dir.to_s])
end
exits.sample
end
def wander
waitrt?
next_dir = next_move(XMLData.room_exits)
@dir_to_prev_dir.each_key { |dir| break if move(dir) } unless move(next_dir)
@prev_dir = next_dir
end
def stow_loot(loot_bag)
if loot_bag
fput("stow left in my #{loot_bag}") if DRC.left_hand
fput("stow right in my #{loot_bag}") if DRC.right_hand
else
stow_hands
end
end
def search
bput('search', 'You search around', "You've recently searched this area", 'As you begin to search')
waitrt?
fix_standing
end
def done?
XMLData.room_title == '[[Duskruin, Darkened Antichamber]]' || Flags['done']
end
end
before_dying do
Flags.delete('five-minute-warning')
Flags.delete('done')
Flags.delete('no-monkey')
Flags.delete('monkey')
Flags.delete('caught')
end
DuskLab.new