codebreaker_marian 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba65afe215a165444024a41a46ac4298b251d06c5652120b0d36642a6e654b99
4
- data.tar.gz: 70ab4ed45981fe98d68043c994069849fc9eebadb317b9d392d048386f342a39
3
+ metadata.gz: 75dc6ed79579580e68659d494b6e5c42b8c4ae2d7ec328bda9ef1035406e44a1
4
+ data.tar.gz: a5b515ef3f3c579cf1b10df2b7fa07b6ecfd71f1582dbc443b5456259a5ed2e0
5
5
  SHA512:
6
- metadata.gz: aa816afc23eaf7f52cda9cd2761b13cb09ac693f9c4d03ff3d49afb107093cb2a78d8854ce43ed8e5f43ab2698e2cda82b750ec17d3653154fe7dd056a8c0695
7
- data.tar.gz: 643b7c44a5f80e14133b6e754dd68b92e4185c3733c8097ce743525d6393d3c71612d761fb50e943ee2a073c52199619888985c16df0264b67b1d07169292145
6
+ metadata.gz: aabcf54bbff14ea59314954b1a106ebe1cbe74d6d6421a1bbeead5d54705743bf0955406a58091ebb3d925c223fc21e9c16d0992fd75c6f1c2b2fddce4d00f83
7
+ data.tar.gz: 9a28736a8e2e38f3d2976c2f64db4881b1dd34dbddb87a17cd25f684aa543948bcdbd246b30d63db169d83cbb05182282b4ff4e0e79262f8ad5e9214ddfc0441
@@ -6,9 +6,6 @@ AllCops:
6
6
  Metrics/LineLength:
7
7
  Max: 120
8
8
 
9
- Metrics/ClassLength:
10
- Max: 125
11
-
12
9
  Metrics/BlockLength:
13
10
  ExcludedMethods: ['describe', 'context']
14
11
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- codebreaker_marian (0.1.8)
4
+ codebreaker_marian (0.1.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -3,9 +3,7 @@
3
3
  require 'i18n'
4
4
  require 'yaml'
5
5
  require_relative 'lib/codebreaker_marian/entities/game'
6
- require_relative 'lib/codebreaker_marian/entities/game'
7
6
  require_relative 'lib/codebreaker_marian/entities/data_storage'
8
7
  require_relative 'lib/codebreaker_marian/entities/processor'
9
- require_relative 'lib/codebreaker_marian/entities/menu'
10
8
  require_relative 'lib/codebreaker_marian/entities/statistics'
11
9
  require_relative 'lib/codebreaker_marian/version'
@@ -35,6 +35,7 @@ module Codebreaker
35
35
 
36
36
  def start_process(command)
37
37
  @process.secret_code_proc(code.join, command)
38
+ decrease_attempts!
38
39
  end
39
40
 
40
41
  def win?(guess)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Codebreaker
4
- VERSION = '0.1.8'
4
+ VERSION = '0.1.9'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codebreaker_marian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marian Rebeha
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-30 00:00:00.000000000 Z
11
+ date: 2020-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -177,11 +177,9 @@ files:
177
177
  - lib/codebreaker_marian.rb
178
178
  - lib/codebreaker_marian/entities/data_storage.rb
179
179
  - lib/codebreaker_marian/entities/game.rb
180
- - lib/codebreaker_marian/entities/menu.rb
181
180
  - lib/codebreaker_marian/entities/processor.rb
182
181
  - lib/codebreaker_marian/entities/renderer.rb
183
182
  - lib/codebreaker_marian/entities/statistics.rb
184
- - lib/codebreaker_marian/modules/validator.rb
185
183
  - lib/codebreaker_marian/version.rb
186
184
  homepage: https://github.com/marikrebega/RubyGarage_2_Codebreaker_gem
187
185
  licenses: []
@@ -1,169 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Codebreaker
4
- module Entities
5
- class Menu
6
- #include Modules::Validator
7
- #attr_reader :storage, :renderer, :game, :guess
8
- =begin
9
- COMMANDS = {
10
- start: 'start',
11
- exit: 'exit',
12
- rules: 'rules',
13
- stats: 'stats'
14
- }.freeze
15
- CHOOSE_COMMANDS = {
16
- yes: 'yes'
17
- }.freeze
18
- HINT_COMMAND = 'hint'
19
- =end
20
- MIN_SIZE_VALUE = 3
21
- MAX_SIZE_VALUE = 20
22
- =begin
23
- def initialize
24
- @storage = DataStorage.new
25
- @renderer = Renderer.new
26
- @game = Game.new
27
- @statistics = Statistics.new
28
- end
29
- =end
30
- def tests
31
- puts '11111111111111111111111111111111111111111'
32
- end
33
- =begin
34
- def game_menu
35
- renderer.start_message
36
-
37
- choice_menu_process(ask(:choice_options, commands: COMMANDS.keys.join(' | ')))
38
- end
39
-
40
- private
41
-
42
- def rules
43
- renderer.rules
44
- game_menu
45
- end
46
-
47
- def start
48
- @name = registrate_user
49
- level_choice
50
- game_process
51
- end
52
-
53
- def stats
54
- scores = storage.load
55
- render_stats(@statistics.stats(scores)) if scores
56
- game_menu
57
- end
58
-
59
- def ask(phrase_key = nil, options = {})
60
- renderer.message(phrase_key, options) if phrase_key
61
- gets.chomp
62
- end
63
-
64
- def save_result
65
- storage.save_game_result(game.to_h(@name)) if ask(:save_result_message) == CHOOSE_COMMANDS[:yes]
66
- end
67
-
68
- def registrate_user
69
- loop do
70
- name = ask(:registration)
71
-
72
- return name if name_valid?(name)
73
-
74
- renderer.registration_name_length_error
75
- end
76
- end
77
-
78
- def name_valid?(name)
79
- !check_emptyness(name) && check_length(name, MIN_SIZE_VALUE, MAX_SIZE_VALUE)
80
- end
81
-
82
- def level_choice
83
- loop do
84
- level = ask(:hard_level, levels: Game::DIFFICULTIES.keys.join(' | '))
85
-
86
- return generate_game(Game::DIFFICULTIES[level.to_sym]) if Game::DIFFICULTIES[level.to_sym]
87
- return game_menu if level == COMMANDS[:exit]
88
-
89
- renderer.command_error
90
- end
91
- end
92
-
93
- def generate_game(difficulty)
94
- game.generate(difficulty)
95
- renderer.message(:difficulty, hints: difficulty[:hints], attempts: difficulty[:attempts])
96
- end
97
-
98
- def game_process
99
- while game.attempts.positive?
100
- @guess = ask
101
- return handle_win if game.win?(guess)
102
-
103
- choice_code_process
104
- end
105
- handle_lose
106
- end
107
-
108
- def choice_code_process
109
- case guess
110
- when HINT_COMMAND then hint_process
111
- when COMMANDS[:exit] then game_menu
112
- else handle_command
113
- end
114
- end
115
-
116
- def handle_command
117
- return renderer.command_error unless check_command_range(guess)
118
-
119
- p game.start_process(guess)
120
- renderer.round_message
121
- game.decrease_attempts!
122
- end
123
-
124
- def handle_win
125
- renderer.win_game_message
126
- save_result
127
- game_menu
128
- end
129
-
130
- def handle_lose
131
- renderer.lost_game_message(game.code)
132
- game_menu
133
- end
134
-
135
- def hint_process
136
- return renderer.no_hints_message? if game.hints_spent?
137
-
138
- renderer.print_hint_number(game.take_a_hint!)
139
- end
140
-
141
- def exit_from_game
142
- renderer.goodbye_message
143
- exit
144
- end
145
-
146
- def choice_menu_process(command_name)
147
- case command_name
148
- when COMMANDS[:start] then start
149
- when COMMANDS[:exit] then exit_from_game
150
- when COMMANDS[:rules] then rules
151
- when COMMANDS[:stats] then stats
152
- else
153
- renderer.command_error
154
- game_menu
155
- end
156
- end
157
-
158
- def render_stats(list)
159
- index = 0
160
- while index < list.size
161
- puts "#{index + 1}: "
162
- list[index].each { |param, value| puts "#{param}:#{value}" }
163
- index += 1
164
- end
165
- end
166
- =end
167
- end
168
- end
169
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Codebreaker
4
- module Modules
5
- module Validator
6
- VALUE_FORMAT = /^[1-6]{4}$/.freeze
7
-
8
- def check_emptyness(value)
9
- value.empty?
10
- end
11
-
12
- def check_length(value, min_size, max_size)
13
- value.size.between?(min_size, max_size)
14
- end
15
-
16
- def check_command_range(command)
17
- command =~ VALUE_FORMAT
18
- end
19
- end
20
- end
21
- end