223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
# File 'lib/Badge.rb', line 223
def sets_count(steamid, use_nonmarketable = true)
steamid,token = verify_profileid_or_trade_link_or_steamid(steamid)
hash = raw_get_inventory(steamid)
sorted = {}
classxinstance = {}
hash["descriptions"].delete_if {|desc|
conc = desc["classid"] + "_" + desc["instanceid"]
classxinstance[conc] = desc
true
}
hash["assets"].each { |asset|
identity = asset["classid"] + "_" + asset["instanceid"]
assetdesc = classxinstance[identity]
if use_nonmarketable == false
if assetdesc["marketable"] == 0 || assetdesc["tags"][-1]["localized_tag_name"] != "Trading Card" || assetdesc["tags"][-2]["localized_tag_name"] == "Foil"
next
end
else
if assetdesc["tags"][-1]["localized_tag_name"] != "Trading Card" ||assetdesc["tags"][-2]["localized_tag_name"] == "Foil"
next
end
end
name = assetdesc["name"].sub(" (Trading Card)", "")
appid =assetdesc["market_fee_app"].to_s
if sorted.has_key?(appid) == true
if sorted[appid].has_key?(name) == true
sorted[appid][name] = sorted[appid][name] + 1
elsif sorted[appid].has_key?(name) == false
sorted[appid][name] = 1
end
elsif sorted.has_key?(appid) == false
sorted[appid] = {}
sorted[appid][name] = 1
end
}
bigdata = JSON.parse(File.read("#{@@libdir}blueprints/byappid.json",:external_encoding => 'utf-8',:internal_encoding => 'utf-8'))
counted = {}
sorted.each { |appid,cards|
begin
counted[appid.to_s] = bigdata[appid].merge(cards)
rescue
output "badges blueprint does not include #{appid}"
end
}
counted.each { |appid, cards|
cards.delete_if { |key,value|
key == 'title'
}
}
setsowned = {}
numberofsets = 0
total_non_foil = 0
counted.each { |appid,cards|
lowest = 9999
cards.each { |cardname, amount|
next if amount.class == String if amount < lowest then lowest = amount end
total_non_foil = total_non_foil + amount
}
setsowned[appid.to_s] = lowest
numberofsets = numberofsets + lowest
}
persona = ''
write_badges(counted,setsowned,numberofsets,total_non_foil, use_nonmarketable,persona,steamid)
if use_nonmarketable == false
return {'sets' => counted, 'appxsets' => setsowned, 'totalsets' => numberofsets, 'totalcards' => total_non_foil, 'marketable' => false}
else
return {'sets' => counted, 'appxsets' => setsowned, 'totalsets' => numberofsets, 'totalcards' => total_non_foil, 'marketable' => true}
end
end
|