Module: D2AD

Defined in:
lib/d2ad.rb

Class Method Summary collapse

Class Method Details

.abilities(api_key, match_id) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/d2ad.rb', line 12

def self.abilities(api_key, match_id)
  begin
    lib_dir = File.expand_path(File.dirname(__FILE__))
    abilities = JSON.parse(File.read("#{lib_dir}/d2ad/abilities.json"))
    match_details = JSON.parse(DotaAPI.query(api_key, 'GetMatchDetails', { match_id: match_id }))

    match_details['result']['players'].each do |p|
      puts "\naccount_id: #{p['account_id']}"
      p['ability_upgrades'].each do |u|
        abilities['abilities'].each do |a|
          puts "  #{u['level'].to_s.rjust(2)}: #{a['name']}" if u['ability'].to_s == a['id']
        end
      end
    end
  rescue Exception => e
    puts e.inspect
  end

  nil
end

.matches(api_key, account_id, matches_requested = 5) ⇒ Object



6
7
8
9
10
# File 'lib/d2ad.rb', line 6

def self.matches(api_key, , matches_requested=5)
  data = JSON.parse(DotaAPI.query(api_key, 'GetMatchHistory', { account_id: , matches_requested: matches_requested }))
  data['result']['matches'].each { |m| puts "#{DateTime.strptime(m['start_time'].to_s, '%s').to_s} #{m['match_id']}" }
  nil
end