Sha256: 120c6ccb80ee3ee8e72c143fdeb3f34ac043c9f69059853d855105e8da53cbed
Contents?: true
Size: 758 Bytes
Versions: 2
Compression:
Stored size: 758 Bytes
Contents
require_relative '../utils/db_utils' require_relative '../config/constants' class Statistic attr_reader :game def self.generate_stats(game) { name: game.player_name, difficulty: game.difficulty_name, attempts_total: DIFFICULTIES[game.difficulty_name.to_sym][:attempts], attempts_used: DIFFICULTIES[game.difficulty_name.to_sym][:attempts] - game.attempts, hints_total: DIFFICULTIES[game.difficulty_name.to_sym][:hints], hints_used: DIFFICULTIES[game.difficulty_name.to_sym][:hints] - game.hints, date: Time.now } end def self.sort_stats stats.sort_by { |player| [player[:attempts_total], player[:attempts_used], player[:hints_used]] } end def self.stats DbUtils.get(DB) || [] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
codebreaker_paratskiy-0.2.2 | lib/services/statistic_service.rb |
codebreaker_paratskiy-0.2.1 | lib/services/statistic_service.rb |