Sha256: ffe45688554f36bb38f109515eda27600897943d386579904a320803050469a4

Contents?: true

Size: 821 Bytes

Versions: 26

Compression:

Stored size: 821 Bytes

Contents

module SavesPicks
  def save_picks(entry)
    bracket = entry.bracket
    picks = params[:picks]
    logger.debug("PICKS: #{picks}")
    picks.split(//).each_with_index do |pick, idx|
      round, game = bracket.round_and_game(idx+1)
      logger.debug("Round #{round} game #{game} pick #{pick} idx #{idx}")
      if pick != '0'
        pick = pick.to_i - 1
        team = bracket.matchup(round, game)[pick]
        logger.debug("      --> Team = #{team.name}")
        bracket.set_winner(round, game, team)
      else
        bracket.set_winner(round, game, Tournament::Bracket::UNKNOWN_TEAM) 
      end
    end
    logger.debug("SAVING ENTRY PARAMS: #{params[:entry].inspect}")
    entry.attributes = params[:entry]
    logger.debug("DONE SAVING ENTRY PARAMS")
    entry.completed = true if bracket.complete?
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
tournament-3.3.3 webgui/lib/saves_picks.rb
tournament-3.3.2 webgui/lib/saves_picks.rb
tournament-3.3.1 webgui/lib/saves_picks.rb
tournament-3.3.0 webgui/lib/saves_picks.rb
tournament-3.2.2 webgui/lib/saves_picks.rb
tournament-3.2.1 webgui/lib/saves_picks.rb
tournament-3.2.0 webgui/lib/saves_picks.rb
tournament-3.1.1 webgui/lib/saves_picks.rb
tournament-3.1.0 webgui/lib/saves_picks.rb
tournament-3.0.3 webgui/lib/saves_picks.rb
tournament-3.0.2 webgui/lib/saves_picks.rb
tournament-3.0.1 webgui/lib/saves_picks.rb
tournament-3.0.0 webgui/lib/saves_picks.rb
tournament-2.1.2 webgui/lib/saves_picks.rb
tournament-2.1.0 webgui/lib/saves_picks.rb
tournament-2.2.0 webgui/lib/saves_picks.rb
tournament-2.0.0 webgui/lib/saves_picks.rb
tournament-2.1.1 webgui/lib/saves_picks.rb
tournament-2.2.1 webgui/lib/saves_picks.rb
tournament-2.2.2 webgui/lib/saves_picks.rb