class Statistic

Public Class Methods

difficulty_name() click to toggle source
# File lib/services/statistic_service.rb, line 41
def difficulty_name
  game.difficulty_name
end
game() click to toggle source
# File lib/services/statistic_service.rb, line 49
def game
  CurrentGame.game
end
generate_stats() click to toggle source
# File lib/services/statistic_service.rb, line 5
def generate_stats
  {
    name: player_name,
    difficulty: difficulty_name,
    total_attempts: total_attempts,
    used_attempts: used_attempts,
    total_hints: total_hints,
    used_hints: used_hints,
    date: Time.now
  }
end
player_name() click to toggle source
# File lib/services/statistic_service.rb, line 45
def player_name
  game.player_name
end
sort_stats() click to toggle source
# File lib/services/statistic_service.rb, line 17
def sort_stats
  stats.sort_by { |player| [player[:total_attempts], player[:used_attempts], player[:used_hints]] }
end
stats() click to toggle source
# File lib/services/statistic_service.rb, line 21
def stats
  DbUtils.get(DB) || []
end
total_attempts() click to toggle source
# File lib/services/statistic_service.rb, line 25
def total_attempts
  DIFFICULTIES[game.difficulty_name.to_sym][:attempts]
end
total_hints() click to toggle source
# File lib/services/statistic_service.rb, line 33
def total_hints
  DIFFICULTIES[game.difficulty_name.to_sym][:hints]
end
used_attempts() click to toggle source
# File lib/services/statistic_service.rb, line 29
def used_attempts
  DIFFICULTIES[game.difficulty_name.to_sym][:attempts] - game.attempts
end
used_hints() click to toggle source
# File lib/services/statistic_service.rb, line 37
def used_hints
  DIFFICULTIES[game.difficulty_name.to_sym][:hints] - game.hints
end