forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pilgrimage.lic
66 lines (54 loc) · 1.75 KB
/
pilgrimage.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#pilgrimage
=end
custom_require.call(%w(common common-items common-money common-travel drinfomon))
class Pilgrimage
include DRC
include DRCI
include DRCM
include DRCT
def initialize
hometown = get_settings.hometown
buy_badge(hometown)
visited = visited_shrines
unvisited = unvisited_shrines(visited, hometown)
unvisited.each { |shrine| visit(shrine) }
end
def buy_badge(hometown)
return if exists?('pilgrim\'s badge')
if DRStats.cleric?
ensure_copper_on_hand(37_500, hometown)
room = get_data('town')[hometown]['theurgy_supplies']['id']
walk_to(room)
move('go storeroom')
bput("buy #{description}", 'You decide')
bput("kiss my #{description}", 'making it your own', 'You kiss')
bput('wear my badge', 'You put on')
move('out')
else
echo '***YOU MUST BE A CLERIC TO BUY A PILGRIM\'S BADGE***'
exit
end
end
def visited_shrines
fput('look my badge')
pause
log = reget(100)
start_index = log.rindex { |x| x =~ /You have/i } + 1
log[start_index..-1]
end
def unvisited_shrines(visited, hometown)
hometown_shrines = get_data('shrines')['shrines'][hometown]
hometown_shrines.reject { |new_shrine| visited.any? { |badge_shrine| badge_shrine =~ /#{new_shrine['location']}/i } }
end
def visit(shrine)
walk_to(shrine['start_room'])
shrine['path_in'].each { |dir| move(dir) }
bput('remove my badge', 'You take off')
bput("push #{shrine['push']} with my badge", 'You press')
bput('wear my badge', 'You put on')
shrine['path_out'].each { |dir| move(dir) }
end
end
# Call this last to avoid the need for forward declarations
Pilgrimage.new