Module: RiotKit::Helpers::Riot::MatchHelpers

Included in:
Services::Riot::MatchDetail, Services::Riot::MatchHistory, Services::Riot::MatchIds
Defined in:
lib/riot_kit/helpers/riot/match_helpers.rb

Constant Summary collapse

FILTERS =
%w[ranked flex normal draft quickplay clash].freeze
QUEUE_ID =
{
  ranked: 420,
  flex: 440,
  normal: 430,
  draft: 400,
  quickplay: 490,
  clash: 700
}.freeze
QUEUE_LABEL =
{
  420 => 'Ranked Solo/Duo',
  440 => 'Ranked Flex',
  430 => 'Normal Blind',
  400 => 'Normal Draft',
  490 => 'Quickplay',
  700 => 'Clash'
}.freeze

Instance Method Summary collapse

Instance Method Details

#cs_per_minute(cs_count, duration_seconds) ⇒ Object



35
36
37
38
39
# File 'lib/riot_kit/helpers/riot/match_helpers.rb', line 35

def cs_per_minute(cs_count, duration_seconds)
  return 0.0 if duration_seconds <= 0

  cs_count.fdiv(duration_seconds.fdiv(60)).round(2)
end

#cs_total_for(participant) ⇒ Object



31
32
33
# File 'lib/riot_kit/helpers/riot/match_helpers.rb', line 31

def cs_total_for(participant)
  participant[:totalMinionsKilled].to_i + participant[:neutralMinionsKilled].to_i
end

#item_ids_for(participant) ⇒ Object



41
42
43
# File 'lib/riot_kit/helpers/riot/match_helpers.rb', line 41

def item_ids_for(participant)
  (0..6).map { |index| participant[:"item#{index}"] }.compact.reject { |item_id| item_id.to_i.zero? }
end

#queue_label_for(queue_id) ⇒ Object



27
28
29
# File 'lib/riot_kit/helpers/riot/match_helpers.rb', line 27

def queue_label_for(queue_id)
  QUEUE_LABEL[queue_id] || 'Unknown'
end