Module: ShowContent

Included in:
NewSuperCodebreaker2021::Game
Defined in:
lib/show_content.rb

Constant Summary collapse

DIFFICULTY =
{
  easy: { attempts: 15, hints: 2 },
  medium: { attempts: 10, hints: 1 },
  hell: { attempts: 5, hints: 1 }
}.freeze

Instance Method Summary collapse

Instance Method Details

#show_stats(file) ⇒ Object


10
11
12
13
14
15
# File 'lib/show_content.rb', line 10

def show_stats(file)
  data = YAML.load_file(file) || []
  data.sort_by(&:hints_used).sort_by(&:attempts_used).sort_by { |game| -game.difficulty }
rescue Errno::ENOENT
  []
end