jbrocky

Untitled

Mar 10th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.84 KB | None | 0 0
  1. =begin
  2.   Documentation: https://elanthipedia.play.net/sell-pouches
  3. =end
  4.  
  5. custom_require.call(%w(common common-items))
  6.  
  7. class SellPouches
  8. include DRC
  9. include DRCI
  10.  
  11.   def initialize
  12.     arg_definitions = [
  13.       [
  14.         { name: 'trader', regex: /\d+/, variable: true, description: 'Container the pouches to be sold are located.' },
  15.         { name: 'container', regex: /\d+/, variable: true, description: 'Name of the Trader doing the selling.' },
  16.         { name: 'dispose', regex: /\d+/, variable: true, optional: true, description: 'Place to put the pouches when returned. (Can be your own container).' }
  17.       ]
  18.     ]
  19.  
  20.     args = parse_args(arg_definitions)
  21.  
  22.     EquipmentManager.new.empty_hands
  23.  
  24.     @pouch_adj = get_settings.gem_pouch_adjective
  25.     @trader = args.trader
  26.     @container = args.container
  27.     @dispose = args.dispose || 'bucket'
  28.  
  29.     @pouches = rummage('C pouch', @container)
  30.  
  31.     sell
  32.   end
  33.  
  34.   def sell
  35.     @pouches.each do |pouch|
  36.       case DRC.bput("get #{@pouch_adj} pouch in my #{@container}", 'You get', 'What were')
  37.       when 'You get'
  38.         result = bput("give my #{@pouch_adj} pouch to #{@trader}", 'You offer', 'What is it')
  39.         if result =~ /What is it/i
  40.           echo "Exiting, Trader is invalid."
  41.           exit
  42.         end
  43.         waitfor ('offers you')
  44.         pause 1.5
  45.         bput('accept tip', 'You accept', 'But you have no tip')
  46.         case DRC.bput("accept", 'You accept', 'You have no offers')
  47.         when "You accept"
  48.           result = bput("put my pouch in #{@dispose}", 'You put', 'I could not')
  49.           bput('drop my pouch', 'You drop') if result =~ /I could not/i
  50.         end
  51.       when 'What were'
  52.         bput('accept tip', 'You accept', 'But you have no tip')
  53.         return
  54.       end
  55.     end
  56.     bput('accept tip', 'You accept', 'But you have no tip')
  57.   end
  58. end
Advertisement
Add Comment
Please, Sign In to add comment