forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
accept-sell.lic
68 lines (60 loc) · 2.15 KB
/
accept-sell.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#accept-sell
=end
custom_require.call(%w[common common-money])
loop do
if DRC.right_hand || DRC.left_hand
echo('Empty your hands!')
exit
end
arg_definitions = [
[
{ name: 'skip', regex: /skip/i, optional: true, description: 'Don\'t appraise, just sell and hand off' },
{ name: 'buy', regex: /buy/i, optional: true, description: 'Pay for the pouch out of your own money' },
{ name: 'dump', regex: /dump/i, optional: true, description: 'dump item after sale' }
]
]
args = parse_args(arg_definitions)
case DRC.bput('accept', 'You have no offers to accept', "You accept \\w+'s offer and are now holding")
when /You accept (\w+)/
item_type = GameObj.right_hand.noun
giver = Regexp.last_match(1)
unless args.skip
until /(\d+) (\w+)/ =~ DRC.bput("app my #{DRC.right_hand}", 'total of about \d+ \w+\.', 'to examine its contents')
pause
waitrt?
fput('tie my pouch')
end
app = Regexp.last_match(1).to_i
currency = Regexp.last_match(2)
pause
waitrt?
end
if args.buy
price = (app * 1.5).to_i
fput("stow #{DRC.right_hand}")
fput("tip #{giver} #{price} #{currency}")
else
/(\d+) (\w+)/ =~ DRC.bput("sell my #{DRC.right_hand}", 'then hands you \d+ \w+')
sell = Regexp.last_match(1).to_i
currency ||= Regexp.last_match(2)
unless args.skip
profit = DRCM.minimize_coins(sell - app)
percentage = ((sell.to_f / app - 1).round(2) * 100).to_i
fput("whisper #{giver} This #{item_type} sold for #{percentage}% above appraisal, a profit of #{profit[0..1].join(' and ')} #{currency}")
end
fput("tip #{giver} #{sell} #{currency}")
if args.dump
fput("put #{DRC.right_hand} in bucket")
else
case DRC.bput("give #{DRC.right_hand} to #{giver}", 'has declined the offer', 'has accepted your offer')
when 'has declined the offer'
fput("put #{DRC.right_hand} in bucket")
end
end
end
else
# No offers currently available, pause and wait for an offer
pause 2
end
end