Class: BDOAP::BDOAlchemyProfits
- Inherits:
-
Object
- Object
- BDOAP::BDOAlchemyProfits
- Includes:
- Utils
- Defined in:
- lib/bdo_alchemy_profits.rb
Overview
used to search for profitable alchemy recipes
Instance Method Summary collapse
-
#start_cli ⇒ Object
begin the configuration and search process.
Instance Method Details
#start_cli ⇒ Object
begin the configuration and search process
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 |
# File 'lib/bdo_alchemy_profits.rb', line 39 def start_cli begin = {} OptionParser.new do |opt| opt.on('--silent', '-s') { [:silent] = true } end.parse! # option setup cli = UserCLI.new category = cli.choose_category cli.end_cli if category == 'exit' region = cli.choose_region cli.end_cli if region == 'exit' lang = cli.choose_lang cli.end_cli if lang == 'exit' aggression = cli.choose_aggression cli.end_cli if aggression == 'exit' free_ingredients = cli.choose_free_ingredients show_out_of_stock = cli.choose_show_out_of_stock if aggression == 'hyperaggressive' puts cli.orange("\nWARN: hyperagressive mode is RISKY AND SLOW. this will evaluate every substitution for every recipe. hammers apis violently. you will get rate limited. you will get IP blocked. her royal holiness imperva incapsula WILL get you. select if you know what all that stuff means and you are ok with waiting 20 minutes.") end # start searching cli.vipiko("\n♫ let's see if #{cli.yellow category} alchemy items are profitable in #{cli.yellow region}!") market_searcher = MarketSearcher.new(region, cli, free_ingredients) market_item_list = market_searcher.get_alchemy_market_data category cli.vipiko("I'll look for #{cli.yellow(market_item_list.length.to_s)} item#{ market_item_list.empty? || market_item_list.length > 1 ? 's' : '' } in #{category == 'all' ? cli.yellow('all categories'): "the #{cli.yellow category} category"}!") bdo_codex_searcher = BDOCodexSearcher.new(region, lang, cli, aggression == 'hyperaggressive') item_codex_data = bdo_codex_searcher.get_item_codex_data market_item_list recipe_prices = market_searcher.get_all_recipe_prices item_codex_data, category mapped_prices = recipe_prices.reverse.sort_by { |recipe| recipe[:gain].to_i }.map { |recipe| recipe[:information] } out_of_stock = recipe_prices.dig(0, :out_of_stock) || [] out_of_stock_list = "" out_of_stock.each { |item| out_of_stock_list += "\n\t #{cli.yellow item}" } if mapped_prices.length > 0 cli.vipiko_overwrite "done!" puts "\n\n" puts mapped_prices else cli.vipiko_overwrite "none of those recipes look profitable right now...let's go gathering!\n\n" end puts " items that were out of stock: #{out_of_stock_list}" if show_out_of_stock && out_of_stock_list.length > 0 rescue Interrupt => e puts "\n\nstopping!" end end |