Skip to content

Commit

Permalink
Merge pull request #6784 from Algonem/Accept-sell-repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
MahtraDR authored Mar 25, 2024
2 parents 6c703c1 + 520064e commit a6550ec
Showing 1 changed file with 47 additions and 42 deletions.
89 changes: 47 additions & 42 deletions accept-sell.lic
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,65 @@

custom_require.call(%w[common common-money])

if DRC.right_hand || DRC.left_hand
echo('Empty your hands!')
exit
end
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' }
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)
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')
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?
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)
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
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("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

0 comments on commit a6550ec

Please sign in to comment.