new_super_codebreaker_2021 0.4.9 → 0.5.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eefe6fdf6726a78b7b59a4bab743e3d4fc78c2305553993ab94bd35cf87b6def
|
4
|
+
data.tar.gz: 4a935daec1b031b0d34c9296b7c275a7871788154fdd1be5bb875f56925e0142
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fdff73737550e1859efa5c0e28dc33bdd4e710538ede1c9e1745612d1770a3197c823370e3c2911770abcb53add586db25d6dd74d42c2c6e03b5889ace019f0
|
7
|
+
data.tar.gz: e42f57e0cf33aaaf0e779d72ac57a5770372959fab44c8fa02e7e9a6ffb130cfb053bb80a4da04e6e723912624e87aced1751bf7ea61b099d5f12e173ba12625
|
@@ -4,12 +4,7 @@ module NewSuperCodebreaker2021
|
|
4
4
|
include ShowContent
|
5
5
|
include Validate
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@code = generate_code
|
11
|
-
@code_copy = @code.dup
|
12
|
-
end
|
7
|
+
attr_accessor :code
|
13
8
|
|
14
9
|
GUESS_COMMANDS = %i[hint rules exit].freeze
|
15
10
|
START_COMMANDS = %i[start rules stats exit].freeze
|
@@ -17,6 +12,11 @@ module NewSuperCodebreaker2021
|
|
17
12
|
AFTER_GAME_COMMANDS = %i[start save exit].freeze
|
18
13
|
YES_NO_COMMANDS = %i[yes no].freeze
|
19
14
|
|
15
|
+
def initialize
|
16
|
+
@code = generate_code
|
17
|
+
@code_copy = @code.dup
|
18
|
+
end
|
19
|
+
|
20
20
|
def chose_command(command)
|
21
21
|
check_input(command, START_COMMANDS)
|
22
22
|
end
|
@@ -81,14 +81,23 @@ module NewSuperCodebreaker2021
|
|
81
81
|
amount_numbers_in_user_code = Hash.new(0)
|
82
82
|
code_copy.each { |number| amount_numbers_in_secret_code[number] += 1 }
|
83
83
|
user_code.each do |element|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
next unless include_element?(code_copy, element) &&
|
85
|
+
less_amount_of_element?(amount_numbers_in_user_code, amount_numbers_in_secret_code, element)
|
86
|
+
|
87
|
+
matches.push('-')
|
88
|
+
amount_numbers_in_user_code[element] += 1
|
88
89
|
end
|
89
90
|
matches
|
90
91
|
end
|
91
92
|
|
93
|
+
def include_element?(given_array, element)
|
94
|
+
given_array.include? element
|
95
|
+
end
|
96
|
+
|
97
|
+
def less_amount_of_element?(first_hash, second_hash, element)
|
98
|
+
first_hash[element] < second_hash[element]
|
99
|
+
end
|
100
|
+
|
92
101
|
def generate_code
|
93
102
|
Array.new(4) { rand(1..6) }
|
94
103
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
|
2
3
|
require_relative 'new_super_codebreaker_2021/user'
|
3
4
|
require_relative 'new_super_codebreaker_2021/show_content'
|
4
5
|
require_relative 'new_super_codebreaker_2021/db_methods'
|
5
6
|
require_relative 'new_super_codebreaker_2021/validate'
|
6
7
|
require_relative 'new_super_codebreaker_2021/game'
|
7
|
-
require_relative 'new_super_codebreaker_2021/version'
|
8
|
+
require_relative 'new_super_codebreaker_2021/version'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: new_super_codebreaker_2021
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nazar Dakhno
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fasterer
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.21.2
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: terminal-table
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 3.0.1
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 3.0.1
|
111
97
|
description: Game where you need to guess the secret code
|
112
98
|
email:
|
113
99
|
- dakhnonazar@gmail.com
|