bdoap 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fabb7eadd3b5446aa42832f5ce1164777c8ed9669c1679a16d61138e9be9de7
4
- data.tar.gz: 20232aec55bb79082273f1dcdadcc04347d83948b9f3cd2977143672a247d19e
3
+ metadata.gz: a4336121be8b520924050e57400f46e24661e9c9dc4156def8b08802e6eec2e2
4
+ data.tar.gz: 5011af8aa6f7f7a044786ca134ca8d4cce0bb3ae076409de70cc69a1adf8d6f9
5
5
  SHA512:
6
- metadata.gz: d7ce743bbc6e663ae0967e4a4a1117611ed87d83c3a6b793a76b5c635aafc8270652e4fc489644f87bb70cc0d5b5a73865314c56a6d0a4150a42baa08e2ccdfd
7
- data.tar.gz: 1af804e8da23ec52a1551e1e0db2da5fc2b975a7da9ada2ef1ef0b51ed2df46f4fbf4251226aa0002e4e25c1d198e2ac8e78d873332c7238eb6fb072b567e979
6
+ metadata.gz: 0b055768a4bad1ebc9b244574d546dd859c4db6f7475d72afd7352d24b3aa9db5a311f6c74b6ce160ae86756ebbbc249df87c8d17b2294bba1a575bec8b6e96d
7
+ data.tar.gz: f5537518eebae1c5f62d63d9daaa0b2ee29d1570940a165e0c7dcee1b033ed728909f6f7f3940edc51d5dc00672363f8639adb8f8a64780ecc3ed9706716ffa5
@@ -24,6 +24,7 @@
24
24
  # SOFTWARE.
25
25
 
26
26
  require 'optparse'
27
+ require 'httparty'
27
28
 
28
29
  require_relative './utils/user_cli'
29
30
  require_relative './central_market/market_searcher'
@@ -35,8 +36,102 @@ module BDOAP
35
36
  class BDOAlchemyProfits
36
37
  include Utils
37
38
 
39
+ def start_enhance(search_string, enhance_starting_level, region, cli)
40
+ items_at_level = []
41
+ root_url = ENVData.get_root_url region
42
+ search_url = "#{root_url}#{ENVData::MARKET_SEARCH_LIST}"
43
+ sub_url = "#{root_url}#{ENVData::MARKET_SUB_LIST}"
44
+ category_opts = {
45
+ url: search_url,
46
+ query_string: "#{ENVData::RVT}&searchText=#{URI.encode_www_form_component search_string}",
47
+ update: ->(data) { data['list'] }
48
+ }
49
+
50
+ data = HTTParty.post(
51
+ URI(category_opts[:url].to_s),
52
+ headers: ENVData.get_central_market_headers(ENVData.get_incap_cookie(@region_subdomain)),
53
+ body: category_opts[:query_string],
54
+ content_type: 'application/x-www-form-urlencoded'
55
+ )
56
+
57
+ resolved = category_opts[:update].call(data) if data
58
+
59
+ return unless resolved
60
+
61
+ resolved.each do |item|
62
+ subdata = HTTParty.post(
63
+ URI(sub_url),
64
+ headers: ENVData.get_central_market_headers(ENVData.get_incap_cookie(@region_subdomain)),
65
+ body: "#{ENVData::RVT}&mainKey=#{item['mainKey']}&usingCleint=0",
66
+ content_type: 'application/x-www-form-urlencoded'
67
+ )
68
+
69
+ sleep rand
70
+
71
+ if subdata&.dig('detailList')
72
+ level_map = {
73
+ 0 => 0,
74
+ 1 => 1,
75
+ 2 => 2,
76
+ 3 => 3,
77
+ 4 => 4,
78
+ 5 => 5,
79
+ 6 => 6,
80
+ 7 => 7,
81
+ 8 => 8,
82
+ 9 => 9,
83
+ 10 => 10,
84
+ 11 => 11,
85
+ 12 => 12,
86
+ 13 => 13,
87
+ 14 => 14,
88
+ 15 => 15,
89
+ 16 => 16,
90
+ 17 => 17,
91
+ 18 => 18,
92
+ 19 => 19,
93
+ 20 => 20,
94
+ }
95
+
96
+ level_map_to_bdo = {
97
+ 0 => 0,
98
+ 1 => 1,
99
+ 2 => 2,
100
+ 3 => 3,
101
+ 4 => 4,
102
+ 5 => 5,
103
+ 6 => 6,
104
+ 7 => 7,
105
+ 8 => 8,
106
+ 9 => 9,
107
+ 10 => 10,
108
+ 11 => 11,
109
+ 12 => 12,
110
+ 13 => 13,
111
+ 14 => 14,
112
+ 15 => 15,
113
+ 16 => 'PRI',
114
+ 17 => 'DUO',
115
+ 18 => 'TRI',
116
+ 19 => 'TET',
117
+ 20 => 'PEN',
118
+ }
119
+
120
+ result = subdata['detailList'] .find { |e| e['subKey'].to_s == level_map[enhance_starting_level.to_i].to_s }
121
+ if result
122
+ constructed = " #{result['count']} #{cli.yellow result['name'].downcase} @ #{level_map_to_bdo[result['subKey']]}"
123
+ items_at_level.push constructed unless result['count'].to_i == 0
124
+ end
125
+ end
126
+ end
127
+
128
+ puts "\nthe results are in!\n"
129
+ items_at_level.each { |item| puts item }
130
+ puts
131
+ end
132
+
38
133
  # begin the configuration and search process
39
- def start_cli
134
+ def start_cli(search_string = nil, enhance_starting_level = nil, enhancing = false)
40
135
  begin
41
136
  options = {}
42
137
 
@@ -47,10 +142,20 @@ module BDOAP
47
142
  # option setup
48
143
  cli = UserCLI.new options
49
144
 
50
- category = cli.choose_category
51
- cli.end_cli if category == 'exit'
145
+ unless enhancing
146
+ category = cli.choose_category
147
+ cli.end_cli if category == 'exit'
148
+ end
149
+
52
150
  region = cli.choose_region
53
151
  cli.end_cli if region == 'exit'
152
+
153
+ # start enhancing
154
+ if enhancing && search_string && enhance_starting_level
155
+ start_enhance(search_string, enhance_starting_level, region, cli)
156
+ return
157
+ end
158
+
54
159
  lang = cli.choose_lang
55
160
  cli.end_cli if lang == 'exit'
56
161
  aggression = cli.choose_aggression
@@ -10,6 +10,7 @@ module MarketSearchTools
10
10
  offensive: 1,
11
11
  defensive: 2,
12
12
  functional: 3,
13
+ food: 4,
13
14
  potion: 5,
14
15
  other: 8,
15
16
  all: [1, 2, 3, 5, 8]
@@ -87,6 +88,13 @@ module MarketSearchTools
87
88
  "#{ENVData::RVT}&mainCategory=#{CONSUMABLE_CATEGORY}&subCategory=#{CONSUMABLE_SUBCATEGORIES[:offensive]}",
88
89
  update: ->(data) { data['marketList'] }
89
90
  },
91
+ {
92
+ name: 'food',
93
+ url: url,
94
+ query_string:
95
+ "#{ENVData::RVT}&mainCategory=#{CONSUMABLE_CATEGORY}&subCategory=#{CONSUMABLE_SUBCATEGORIES[:food]}",
96
+ update: ->(data) { data['marketList'] }
97
+ },
90
98
  {
91
99
  name: 'defensive',
92
100
  url: url,
@@ -132,7 +140,14 @@ module MarketSearchTools
132
140
  query_string: "#{ENVData::RVT}&searchText=purified+lightstone+of",
133
141
  # update: ->(data) { { otherResponse: data['marketList'] } },
134
142
  update: ->(data) { data['list'] }
135
- }
143
+ },
144
+ # {
145
+ # name: 'stuffed animals',
146
+ # url: search_url,
147
+ # query_string: "#{ENVData::RVT}&searchText=stuffed",
148
+ # # update: ->(data) { { otherResponse: data['marketList'] } },
149
+ # update: ->(data) { data['list'] }
150
+ # }
136
151
  ]
137
152
  end
138
153
  end
@@ -24,6 +24,7 @@ class MarketSearcher
24
24
  @market_sub_url = "#{@root_url}#{ENVData::MARKET_SUB_LIST}"
25
25
  @market_sell_buy_url = "#{@root_url}#{ENVData::MARKET_SELL_BUY_INFO}"
26
26
  @cli = cli
27
+ # cache used to store all ingredients for which the price has already been checked
27
28
  @ingredient_cache = {}
28
29
  @free_ingredients = free_ingredients
29
30
  @out_of_stock_items = []
@@ -320,7 +321,7 @@ class MarketSearcher
320
321
  average_procs = 1
321
322
 
322
323
  if [25, 35].include? item[:main_category]
323
- unless /oil of|draught|\[mix\]|\[party\]|immortal:|perfume|indignation|flame of|essence of dawn/im.match item[:name].downcase
324
+ unless /oil of|draught|\[mix\]|\[party\]|immortal:|perfume|indignation|flame of|essence of dawn|mystical cleaning oil|whale tendon|leather glaze/im.match item[:name].downcase
324
325
  average_procs = 2.5
325
326
  end
326
327
 
@@ -2,7 +2,20 @@
2
2
 
3
3
  require 'date'
4
4
 
5
- $request_verification_token = '__RequestVerificationToken=aVYGQPovG8EI6bRIagh8tbHJUhZlM-nH3UKVQaV9R9N0vODzmWcB747BHEsHaphwANvzsaNi5TCPlB-72-e1LadqAlL-bdkDkTqVh4gMnu81' # rubocop:disable Layout/LineLength
5
+ require_relative '../../environment'
6
+
7
+ if ENV['rvt_dom'].length == 0
8
+ puts "empty DOM environment variable! set ENV['rvt_dom'] in environment.rb."
9
+ end
10
+
11
+ if ENV['rvt_cookie'].length == 0
12
+ puts "empty cookie environment variable! set ENV['rvt_cookie'] in environment.rb."
13
+ end
14
+
15
+ if ENV['rvt_dom'].length == 0 || ENV['rvt_cookie'].length == 0
16
+ puts ''
17
+ exit
18
+ end
6
19
 
7
20
  module Utils
8
21
  # constants to use when user is configuring the tool
@@ -19,12 +32,14 @@ module Utils
19
32
  'alchemy stone': "searches 'imperfect alchemy stone of'",
20
33
  reagent: "searches 'reagent'",
21
34
  'black stone': 'category 30, subcategory 1',
35
+ 'food': 'category 35, subcategory 4',
22
36
  'misc': 'category 25, subcategory 8',
23
37
  'other tools': 'category 40, subcategory 10',
24
38
  'manos': "searches 'manos'",
25
39
  'purified lightstone': "searches 'purified lightstone of' (requires guru 1 alchemy)",
26
40
  'combined crystals': 'category 50, subcategory 4',
27
41
  'essences of dawn': "searches 'essence of dawn'",
42
+ # 'stuffed animals': "searches 'stuffed'",
28
43
  # 'magic crystal': "searches 'magic crystal'",
29
44
  exit: 'stops the search',
30
45
  }.freeze
@@ -42,7 +57,7 @@ module Utils
42
57
  jp: 'trade.jp.playblackdesert.com',
43
58
  th: 'trade.th.playblackdesert.com',
44
59
  tw: 'trade.tw.playblackdesert.com',
45
- sa: 'blackdesert-tradeweb.playredfox.com',
60
+ sa: 'trade.sa.playblackdesert.com',
46
61
  exit: 'stops the search',
47
62
  }.freeze
48
63
 
@@ -76,10 +91,6 @@ module Utils
76
91
  no: false,
77
92
  yes: true,
78
93
  }.freeze
79
-
80
- def self.set_rvt(rvt)
81
- $request_verification_token = rvt
82
- end
83
94
  end
84
95
 
85
96
  # constants that will be used in by search / scraping scripts
@@ -89,8 +100,8 @@ module Utils
89
100
  ERROR_LOG = './error.log'
90
101
  # note that the following two tokens are different!! the first one is from a request cookie
91
102
  # the second is from the dom of the actual BDO central market interface
92
- COOKIE = '__RequestVerificationToken=aVYGQPovG8EI6bRIagh8tbHJUhZlM-nH3UKVQaV9R9N0vODzmWcB747BHEsHaphwANvzsaNi5TCPlB-72-e1LadqAlL-bdkDkTqVh4gMnu81' # rubocop:disable Layout/LineLength
93
- RVT = '__RequestVerificationToken=yWbqJmiU4wcp2IRQGkbDfqMFs2fjCYx4UqVxg4umK8CvdbLhweMLZ1es-4SFWD8J1UfoqwbaQyo_YuzAkSzHWY8Wjyx4ttwZBvtu_pd--9U1' # rubocop:disable Layout/LineLength
103
+ COOKIE = ENV['rvt_cookie']
104
+ RVT = ENV['rvt_dom']
94
105
  WORLD_MARKET_LIST = '/GetWorldMarketList'
95
106
  MARKET_SUB_LIST = '/GetWorldMarketSubList'
96
107
  MARKET_SEARCH_LIST = '/GetWorldMarketSearchList'
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BDOAP
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bdoap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - jpegzilla