Class: Statistic
- Inherits:
-
Object
- Object
- Statistic
- Defined in:
- lib/services/statistic_service.rb
Class Method Summary collapse
- .difficulty_name ⇒ Object
- .game ⇒ Object
- .generate_stats ⇒ Object
- .player_name ⇒ Object
- .sort_stats ⇒ Object
- .stats ⇒ Object
- .total_attempts ⇒ Object
- .total_hints ⇒ Object
- .used_attempts ⇒ Object
- .used_hints ⇒ Object
Class Method Details
.difficulty_name ⇒ Object
41 42 43 |
# File 'lib/services/statistic_service.rb', line 41 def difficulty_name game.difficulty_name end |
.game ⇒ Object
49 50 51 |
# File 'lib/services/statistic_service.rb', line 49 def game CurrentGame.game end |
.generate_stats ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# 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 ⇒ Object
45 46 47 |
# File 'lib/services/statistic_service.rb', line 45 def player_name game.player_name end |
.sort_stats ⇒ Object
17 18 19 |
# 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 ⇒ Object
21 22 23 |
# File 'lib/services/statistic_service.rb', line 21 def stats DbUtils.get(DB) || [] end |
.total_attempts ⇒ Object
25 26 27 |
# File 'lib/services/statistic_service.rb', line 25 def total_attempts DIFFICULTIES[game.difficulty_name.to_sym][:attempts] end |
.total_hints ⇒ Object
33 34 35 |
# File 'lib/services/statistic_service.rb', line 33 def total_hints DIFFICULTIES[game.difficulty_name.to_sym][:hints] end |
.used_attempts ⇒ Object
29 30 31 |
# File 'lib/services/statistic_service.rb', line 29 def used_attempts DIFFICULTIES[game.difficulty_name.to_sym][:attempts] - game.attempts end |
.used_hints ⇒ Object
37 38 39 |
# File 'lib/services/statistic_service.rb', line 37 def used_hints DIFFICULTIES[game.difficulty_name.to_sym][:hints] - game.hints end |