forked from rpherbig/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
forestry-buddy.lic
114 lines (94 loc) · 3.25 KB
/
forestry-buddy.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
107
108
109
110
111
112
113
114
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#forestry-buddy
=end
custom_require.call(%w[common common-items common-money common-travel drinfomon])
class ForestryBuddy
include DRC
include DRCI
include DRCM
include DRCT
def initialize
setup
ensure_copper_on_hand(10_000, @settings)
if @use_packet
buy_deed_packet unless exists?('packet')
buy_deed_packet unless exists?('second packet')
first = bput('look first packet', 'You count \d+').scan(/\d+/).first.to_i
second = bput('look second packet', 'You count \d+').scan(/\d+/).first.to_i
if second < first
fput('get my second packet')
fput('stow my packet')
end
end
wait_for_script_to_complete('buff', ['forestry'])
@areas.each { |area_name| chop_rooms(@area_list[area_name]) }
end
def buy_deed_packet
if @deeds_room && @deeds_number
order_item(@deeds_room, @deeds_number)
else
echo 'Your hometown is missing data for purchasing deeds!'
exit
end
fput('stow my packet')
end
def setup
@settings = get_settings
@area_list = get_data('lumber').lumber_buddy_rooms
@areas = @settings.forests_to_chop
@skip_populated = @settings.lumber_skip_populated
@chop_every_room = @settings.lumber_buddy_chop_every_room
@tree_list = @settings.lumber_buddy_tree_list
@lumber_implement = @settings.lumber_implement
@use_packet = @settings.lumber_use_packet
@hometown = @settings.hometown
deeds_data = get_data('crafting').deeds[@hometown]
@deeds_room = deeds_data['room']
@deeds_number = deeds_data['medium_number']
echo("#{@areas}:#{@tree_list}") if UserVars.lumber_debug
end
def check_repair
fput("get #{@lumber_implement}")
result = bput("app my #{@lumber_implement}", 'practically in mint', 'pristine condition', 'in good condition', 'Roundtime')
waitrt?
fput("stow #{@lumber_implement}")
return unless /roundtime/i =~ result
repair = get_data('town')[@hometown]['metal_repair']
walk_to(repair['id'])
fput("get #{@lumber_implement}")
fput("give #{repair['name']}")
fput("give #{repair['name']}")
pause 10 until bput('look at my ticket', 'should be ready by now', 'Looking at the') == 'should be ready by now'
fput("give #{repair['name']}")
fput("stow #{@lumber_implement}")
end
def chop_rooms(rooms)
rooms.each do |room|
wait_for_script_to_complete('safe-room') if bleeding?
check_repair if chop?(room)
end
end
def chop?(room)
waitrt?
walk_to(room)
unless DRRoom.pcs.empty?
return false if @skip_populated
fput('wave')
end
unless @chop_every_room
bput('watch forest', 'Roundtime')
results = reget(20, 'can be harvested')
echo(results) if UserVars.lumber_debug
return false if results.nil?
return false unless results
.each_with_object([]) { |line, array| array << line.match(/You are certain that (.*) trees can be/i)[1] }
.reject(&:nil?)
.map(&:downcase)
.any? { |tree| @tree_list.map(&:downcase).include?(tree) }
end
waitrt?
wait_for_script_to_complete('chop-wood')
true
end
end
ForestryBuddy.new