forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrossing-repair.lic
More file actions
103 lines (84 loc) · 3.49 KB
/
crossing-repair.lic
File metadata and controls
103 lines (84 loc) · 3.49 KB
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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#crossing-repair
=end
custom_require.call(%w[common common-money common-travel drinfomon equipmanager])
class CrossingRepair
include DRC
include DRCM
include DRCT
def initialize
setup
@repair_info.each do |repairer, items|
echo "Repairing at #{repairer}" if UserVars.crossing_repair_debug
repair_at(repairer['name'], repairer['id'], items)
end
@repair_info.to_a.reverse.each do |repairer, _items|
while tickets_left?(repairer)
end
end
end
def repair(repairer, item, repeat = false)
return unless repairer
return unless item
release_invisibility
if repeat
fput('swap') unless right_hand
command = "give #{repairer}"
else
return unless @equipment_manager.get_item?(item)
command = "give my #{item.short_name} to #{repairer}"
end
case bput(command, "There isn't a scratch on that", "I don't work on those here", "I don't repair those here", 'Just give it to me again', "You don't need to specify the object", "I will not repair something that isn't broken", "Please don't lose this ticket!", "You hand.*#{repairer}", "Lucky for you! That isn't damaged!", 'You will need more coin if I am to be repairing that!')
when "There isn't a scratch on that", "I will not repair something that isn't broken", "Lucky for you! That isn't damaged!", 'You will need more coin if I am to be repairing that!', "I don't repair those here"
@equipment_manager.empty_hands
when "I don't work on those here"
echo "*** ITEM HAS IMPROPER is_leather FLAG: #{item.short_name} ***"
@equipment_manager.empty_hands
when "You don't need to specify the object", 'Just give it to me again'
repair(repairer, item, true)
when "Please don't lose this ticket!", "You hand.*#{repairer}"
bput('stow my ticket', 'You put')
end
end
def tickets_left?(repairer)
if bput("get my #{repairer['name']} ticket", 'What were you referring', 'You get') == 'What were you referring'
return false
end
walk_to(repairer['id'])
turn_in_ticket(repairer['name'])
@equipment_manager.empty_hands
true
end
def turn_in_ticket(repairer, failed = false)
if failed
fput('swap') unless right_hand
command = "give #{repairer}"
else
command = "give my ticket to #{repairer}"
end
case bput(command, 'You hand', 'takes your ticket', "You don't need to specify the object", 'almost done', "Well that isn't gonna be done")
when "You don't need to specify the object"
turn_in_ticket(repairer, true)
when 'almost done', "Well that isn't gonna be done"
pause 30
turn_in_ticket(repairer)
end
end
def repair_at(repairer, target_room, items)
return if items.nil? || items.empty?
return unless walk_to target_room
items.each { |item| repair(repairer, item) }
end
def setup
@equipment_manager = EquipmentManager.new
@equipment_manager.wear_equipment_set?('standard')
settings = get_settings
@repair_withdrawal_amount = settings.repair_withdrawal_amount
hometown = get_data('town')[settings.hometown]
ensure_copper_on_hand(@repair_withdrawal_amount, settings.hometown)
# Merge, do not overwrite
@repair_info = { hometown['leather_repair'] => @equipment_manager.items.select(&:leather) }
.merge(hometown['metal_repair'] => @equipment_manager.items.reject(&:leather)) { |_key, old, new| old + new }
end
end
CrossingRepair.new