Class: LeagueApi::Util
- Inherits:
-
Object
- Object
- LeagueApi::Util
- Defined in:
- lib/league_api/util.rb
Class Method Summary collapse
-
.get_game_stats(game) ⇒ Object
Pass in stats from game info and get an readable stat hash to iterate on.
- .get_item_list(stats) ⇒ Object
- .get_raw_item_list(stats) ⇒ Object
-
.organize_players(players) ⇒ Object
Takes fellow_player hash from game info and splits into team 1 and team 2 (prepend lookup team1).
- .requests ⇒ Object
Class Method Details
.get_game_stats(game) ⇒ Object
Pass in stats from game info and get an readable stat hash to iterate on
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/league_api/util.rb', line 11 def self.get_game_stats(game) s = {} #manually add every stat we want s["Gold Earned"] = game["goldEarned"] s["Minions Killed"] = game["minionsKilled"] s["Total Damage"] = game["totalDamageDealt"] s["Total Damage Taken"] = game["totalDamageTaken"] s["Killing Sprees"] = game["killingSprees"] s["Largest Killing Sprees"] = game["largestKillingSpree"] s["Neutral Minions Killed"] = game["neutralMinionsKilled"] s["Largest Multikill"] = game["largestMultiKill"] s["Physical Damage Dealt"] = game["physicalDamageDealtPlayer"] s["Magic Damage Dealt"] = game["magicDamageDealtPlayer"] s["Physical Damage To Champions"] = game["physicalDamageDealtToChampions"] s["Magic Damage To Champions"] = game["magicDamageDealtToChampions"] s["Total Damage To Champions"] = game["totalDamageDealtToChampions"] s["True Damage Dealt"] = game["trueDamageDealtPlayer"] s["True Damage To Champions"] = game["trueDamageDealtToChampions"] s["True Damage Taken"] = game["trueDamageTaken"] s["Physical Damage Taken"] = game["physicalDamageTaken"] s["Magic Damage Taken"] = game["magicDamageTaken"] s["Total Healing"] = game["totalHeal"] s["Turrets Killed"] = game["turretsKilled"] s["Minions Killed in Enemy Jungle"] = game["neutralMinionsKilledEnemyJungle"] s["Minions Killed in Your Jungle"] = game["neutralMinionsKilledYourJungle"] s["Gold Spent"] = game["goldSpent"] s["Vision Wards Purchased"] = game["visionWardsBought"] s["Wards Placed"] = game["wardPlaced"] #TODO: Needs a more accurate descriptions (milli seconds) s["Crowd Control Dealt"] = game["totalTimeCrowdControlDealt"] s end |
.get_item_list(stats) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/league_api/util.rb', line 64 def self.get_item_list(stats) raw_list = get_raw_item_list(stats) item_list = [] 7.times do |i| if raw_list[i].nil? item_list[i] = "None" if raw_list[i].nil? else item_list[i] = LeagueApi::Static.get_item_by_id(raw_list[i])["name"] if raw_list[i] end end item_list end |
.get_raw_item_list(stats) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/league_api/util.rb', line 54 def self.get_raw_item_list(stats) item_list = [] 7.times do |i| item_list[i] = stats["item#{i}"] end item_list end |
.organize_players(players) ⇒ Object
Takes fellow_player hash from game info and splits into team 1 and team 2 (prepend lookup team1)
6 7 8 |
# File 'lib/league_api/util.rb', line 6 def self.organize_players(players) players.sort! { |x,y| x["teamId"] <=> y["teamId"]} end |
.requests ⇒ Object
50 51 52 |
# File 'lib/league_api/util.rb', line 50 def self.requests %w( organize_players(player_list) get_game_stats(game_stats_hash) ) end |