From 1d257373d33e350a7caebadbc30a60f3b9509d2a Mon Sep 17 00:00:00 2001 From: Algonem <159506811+Algonem@users.noreply.github.com> Date: Sun, 24 Mar 2024 17:12:42 -0500 Subject: [PATCH 1/2] Update accept-sell.lic --- accept-sell.lic | 93 ++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/accept-sell.lic b/accept-sell.lic index c0f163ba8b..47d51f717e 100644 --- a/accept-sell.lic +++ b/accept-sell.lic @@ -4,60 +4,65 @@ custom_require.call(%w[common common-money]) -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' } +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) + 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 +end \ No newline at end of file From 520064e2bb7516af953cede98049664af022fd1c Mon Sep 17 00:00:00 2001 From: Algonem <159506811+Algonem@users.noreply.github.com> Date: Mon, 25 Mar 2024 10:53:06 -0500 Subject: [PATCH 2/2] added space --- accept-sell.lic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accept-sell.lic b/accept-sell.lic index 47d51f717e..1135fe87e0 100644 --- a/accept-sell.lic +++ b/accept-sell.lic @@ -65,4 +65,4 @@ loop do # No offers currently available, pause and wait for an offer pause 2 end -end \ No newline at end of file +end