class Codebreaker::Statistics

Public Class Methods

decorated_top_players(game_plays) click to toggle source
# File lib/codebreaker/statistics.rb, line 13
def decorated_top_players(game_plays)
  game_plays.map.with_index do |game, index|
    { rating: index + 1, name: game.player.name, difficulty: game.difficulty[:name],
      attempts_total: game.attempts_total, attempts_used: game.attempts_used,
      hints_total: game.hints_total, hints_used: game.hints_used, date: game.player.created_at }
  end
end
sorted_winners(winners) click to toggle source
# File lib/codebreaker/statistics.rb, line 6
def sorted_winners(winners)
  winners.sort_by do |winner|
    [winner.difficulty[:attempts], winner.difficulty[:hints],
     winner.attempts_used, winner.hints_used]
  end
end