Skip to content

Commit

Permalink
handle first objectives correctly (#223)
Browse files Browse the repository at this point in the history
* handle first objectives correctly

* remove needless nil
  • Loading branch information
danReynolds committed Apr 29, 2018
1 parent 32aa153 commit b2efa02
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
3 changes: 1 addition & 2 deletions app/models/match.rb
Expand Up @@ -13,8 +13,7 @@ class Match < ActiveRecord::Base
has_many :summoner_performances
has_many :summoners, through: :summoner_performances

validates_presence_of :game_id, :queue_id, :season_id, :region_id, :winning_team_id,
:team1_id, :team2_id, :game_duration
validates_presence_of :game_id, :queue_id, :season_id, :region_id, :team1_id, :team2_id, :game_duration

REMAKE_DURATION = 4.minutes.seconds.to_int
end
36 changes: 31 additions & 5 deletions lib/match_helper.rb
Expand Up @@ -71,18 +71,44 @@ def create_match(match_data)
riftherald_kills: team2_params['riftHeraldKills']
)

first_blood_team = if team1_params['firstBlood']
team1
elsif team2_params['firstBlood']
team2
end
first_tower_team = if team1_params['firstTower']
team1
elsif team2_params['firstTower']
team2
end
first_inhibitor_team = if team1_params['firstInhibitor']
team1
elsif team2_params['firstInhibitor']
team2
end
first_baron_team = if team1_params['firstBaron']
team1
elsif team2_params['firstBaron']
team2
end
first_rift_herald = if team1_params['firstRiftHerald']
team1
elsif team2_params['firstRiftHerald']
team2
end

match = Match.create!(
game_id: match_data['gameId'],
queue_id: match_data['queueId'],
season_id: match_data['seasonId'],
region_id: match_data['platformId'],
game_duration: match_data['gameDuration'],
winning_team: team1_params['win'] == 'Win' ? team1 : team2,
first_blood_team: team1_params['firstBlood'] ? team1 : team2,
first_tower_team: team1_params['firstTower'] ? team1 : team2,
first_inhibitor_team: team1_params['firstInhibitor'] ? team1 : team2,
first_baron_team: team1_params['firstBaron'] ? team1 : team2,
first_rift_herald_team: team1_params['firstRiftHerald'] ? team1 : team2,
first_blood_team: first_blood_team,
first_tower_team: first_tower_team,
first_inhibitor_team: first_inhibitor_team,
first_baron_team: first_baron_team,
first_rift_herald_team: first_rift_herald,
team1: team1,
team2: team2
)
Expand Down

0 comments on commit b2efa02

Please sign in to comment.