codebreakergem 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae8b8f97ebd4ef14b7786e7f53698d843eedb948d43c2e809239247a1b103274
4
- data.tar.gz: 13786f33799c7ad15d64755db84f26634fb4caef88c318755907243570cc1017
3
+ metadata.gz: b346baa5b1b863238227b096668b9341a6e408e33d60aa3158a029bed0b11294
4
+ data.tar.gz: c8909b1b3654ace2d824bb60fa703719390483e4c3a1bcf0b893bd5b96105754
5
5
  SHA512:
6
- metadata.gz: 43a495a0d703bc01ef254044d8654bf0a6429276f25bef2ae8f1a974bf278aea8ad79bbf5f328f45438fc0c46af1d5f79cd98fd5427111f5092061f20d0d1d63
7
- data.tar.gz: 2f441a4471d45b4ea41673ceb4aa8aede3060eae159467ce86de1f700e56069c50a9e026e3ff1ab5b04f42845cc9cb3aadcf0541000bf2753a25bca511b279d4
6
+ metadata.gz: 6abf7854f2ff1d0fa794b769a1cb8da307491ce1248442cbbb8c3bea13587341009219c0d7e300578ca4904c28004243952fe5b389cac6d3a678b972b61e4a46
7
+ data.tar.gz: a962ee328b653a189c9d04eef19591517d327cef41f21c2aaf5d15e98c2341c35f5cf98b7c995ae197ff3b9f7259bbf2c61943710a9c813e3816e6541fd39183
data/lib/classes/game.rb CHANGED
@@ -9,6 +9,12 @@ module Codebreakergem
9
9
  INCORRECT_PLACE_SYMBOL = '-'
10
10
  FILE = File.expand_path(__dir__ + '/../data/data.yml')
11
11
 
12
+ PERMITTED_CLASSES = [Codebreakergem::User,
13
+ Codebreakergem::Game,
14
+ Codebreakergem::Easy,
15
+ Codebreakergem::Hell,
16
+ Codebreakergem::Medium].freeze
17
+
12
18
  attr_reader :secret_code, :user
13
19
  attr_accessor :difficulty, :statistics
14
20
 
@@ -56,7 +62,8 @@ module Codebreakergem
56
62
  attempts_total: source_difficulty.attempts,
57
63
  attempts_used: attempts_used,
58
64
  hints_total: source_difficulty.hints,
59
- hints_used: hints_used }
65
+ hints_used: hints_used,
66
+ game_time: Time.now.strftime('%Y.%m.%d - %H:%M:%S') }
60
67
  end
61
68
 
62
69
  def generate_code
@@ -21,11 +21,18 @@ module Codebreakergem
21
21
  result
22
22
  end
23
23
 
24
+ def stats_as_hash
25
+ stats = FileWorker.read_from_file(Game::FILE)
26
+ return stats.sort_by { |item| [item[:order], item[:attempts_used], item[:hints_used]] } if stats.is_a? Array
27
+
28
+ stats
29
+ end
30
+
24
31
  private
25
32
 
26
33
  def stats_constructor(index, item)
27
34
  "#{index}\t #{item[:name]}\t #{item[:difficulty]}\t #{item[:attempts_total]}\t " \
28
- "#{item[:attempts_used]}\t #{item[:hints_total]}\t #{item[:hints_used]}\n"
35
+ "#{item[:attempts_used]}\t #{item[:hints_total]}\t #{item[:hints_used]}\t #{item[:game_time]}\n"
29
36
  end
30
37
  end
31
38
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Codebreakergem
4
- VERSION = '0.1.15'
4
+ VERSION = '0.1.16'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codebreakergem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sasha
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-20 00:00:00.000000000 Z
11
+ date: 2020-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler