new_super_codebreaker_2021 0.4.6 → 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: 81df7f5993ddc2b124bf20ac2632b1c6908a785076afacb407e2a3dcf14b7c11
4
- data.tar.gz: a9246bff8d86887c221547198b93f8716297989de63ea77a5baa6e2a5c3ff87c
3
+ metadata.gz: eefe6fdf6726a78b7b59a4bab743e3d4fc78c2305553993ab94bd35cf87b6def
4
+ data.tar.gz: 4a935daec1b031b0d34c9296b7c275a7871788154fdd1be5bb875f56925e0142
5
5
  SHA512:
6
- metadata.gz: c8c12e16606143f316f87d56e5b92fe5a76ea1fffbe4f4e7c5ea5ca07dd16905dc8d0f35347bfc81c5ad3e4eddee3f435486e1ccfe77682ccd54ca47e9642f5e
7
- data.tar.gz: eb64b063703142840276857ebf202e97ed4c2c1e31743c7636cc0f0f0759b69ec71626b0a00b77a8afd7e0ab166940c4a3680238d96f1501bbe838919fe0bafa
6
+ metadata.gz: 4fdff73737550e1859efa5c0e28dc33bdd4e710538ede1c9e1745612d1770a3197c823370e3c2911770abcb53add586db25d6dd74d42c2c6e03b5889ace019f0
7
+ data.tar.gz: e42f57e0cf33aaaf0e779d72ac57a5770372959fab44c8fa02e7e9a6ffb130cfb053bb80a4da04e6e723912624e87aced1751bf7ea61b099d5f12e173ba12625
@@ -1,17 +1,10 @@
1
- require_relative '../loader'
2
-
3
1
  module NewSuperCodebreaker2021
4
2
  class Game
5
3
  include DBMethods
6
4
  include ShowContent
7
5
  include Validate
8
6
 
9
- attr_reader :code
10
-
11
- def initialize
12
- @code = generate_code
13
- @code_copy = @code.dup
14
- end
7
+ attr_accessor :code
15
8
 
16
9
  GUESS_COMMANDS = %i[hint rules exit].freeze
17
10
  START_COMMANDS = %i[start rules stats exit].freeze
@@ -19,6 +12,11 @@ module NewSuperCodebreaker2021
19
12
  AFTER_GAME_COMMANDS = %i[start save exit].freeze
20
13
  YES_NO_COMMANDS = %i[yes no].freeze
21
14
 
15
+ def initialize
16
+ @code = generate_code
17
+ @code_copy = @code.dup
18
+ end
19
+
22
20
  def chose_command(command)
23
21
  check_input(command, START_COMMANDS)
24
22
  end
@@ -83,14 +81,23 @@ module NewSuperCodebreaker2021
83
81
  amount_numbers_in_user_code = Hash.new(0)
84
82
  code_copy.each { |number| amount_numbers_in_secret_code[number] += 1 }
85
83
  user_code.each do |element|
86
- if code_copy.include?(element) && amount_numbers_in_user_code[element] < amount_numbers_in_secret_code[element]
87
- matches.push('-')
88
- amount_numbers_in_user_code[element] += 1
89
- end
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
90
89
  end
91
90
  matches
92
91
  end
93
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
+
94
101
  def generate_code
95
102
  Array.new(4) { rand(1..6) }
96
103
  end
@@ -1,3 +1,3 @@
1
1
  module NewSuperCodebreaker2021
2
- VERSION = '0.4.6'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
@@ -1,8 +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
- require_relative 'new_super_codebreaker_2021/new_super_codebreaker_2021'
7
7
  require_relative 'new_super_codebreaker_2021/game'
8
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.6
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nazar Dakhno
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-13 00:00:00.000000000 Z
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
@@ -115,18 +101,10 @@ executables: []
115
101
  extensions: []
116
102
  extra_rdoc_files: []
117
103
  files:
118
- - CHANGELOG.md
119
- - CODE_OF_CONDUCT.md
120
- - Gemfile
121
- - Gemfile.lock
122
104
  - README.md
123
- - Rakefile
124
- - bin/console
125
- - bin/setup
126
- - lib/loader.rb
105
+ - lib/new_super_codebreaker_2021.rb
127
106
  - lib/new_super_codebreaker_2021/db_methods.rb
128
107
  - lib/new_super_codebreaker_2021/game.rb
129
- - lib/new_super_codebreaker_2021/new_super_codebreaker_2021.rb
130
108
  - lib/new_super_codebreaker_2021/show_content.rb
131
109
  - lib/new_super_codebreaker_2021/user.rb
132
110
  - lib/new_super_codebreaker_2021/validate.rb
data/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2021-08-17
4
-
5
- - Initial release
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at dakhnonazar@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in new_super_codebreaker_2021.gemspec
6
- gemspec
data/Gemfile.lock DELETED
@@ -1,76 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- new_super_codebreaker_2021 (0.4.5)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.2)
10
- colorize (0.8.1)
11
- diff-lcs (1.4.4)
12
- docile (1.4.0)
13
- fasterer (0.9.0)
14
- colorize (~> 0.7)
15
- ruby_parser (>= 3.14.1)
16
- ffaker (2.19.0)
17
- parallel (1.20.1)
18
- parser (3.0.2.0)
19
- ast (~> 2.4.1)
20
- rainbow (3.0.0)
21
- rake (13.0.6)
22
- regexp_parser (2.1.1)
23
- rexml (3.2.5)
24
- rspec (3.10.0)
25
- rspec-core (~> 3.10.0)
26
- rspec-expectations (~> 3.10.0)
27
- rspec-mocks (~> 3.10.0)
28
- rspec-core (3.10.1)
29
- rspec-support (~> 3.10.0)
30
- rspec-expectations (3.10.1)
31
- diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.10.0)
33
- rspec-mocks (3.10.2)
34
- diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.10.0)
36
- rspec-support (3.10.2)
37
- rubocop (1.19.1)
38
- parallel (~> 1.10)
39
- parser (>= 3.0.0.0)
40
- rainbow (>= 2.2.2, < 4.0)
41
- regexp_parser (>= 1.8, < 3.0)
42
- rexml
43
- rubocop-ast (>= 1.9.1, < 2.0)
44
- ruby-progressbar (~> 1.7)
45
- unicode-display_width (>= 1.4.0, < 3.0)
46
- rubocop-ast (1.10.0)
47
- parser (>= 3.0.1.1)
48
- ruby-progressbar (1.11.0)
49
- ruby_parser (3.17.0)
50
- sexp_processor (~> 4.15, >= 4.15.1)
51
- sexp_processor (4.15.3)
52
- simplecov (0.21.2)
53
- docile (~> 1.1)
54
- simplecov-html (~> 0.11)
55
- simplecov_json_formatter (~> 0.1)
56
- simplecov-html (0.12.3)
57
- simplecov_json_formatter (0.1.3)
58
- terminal-table (3.0.1)
59
- unicode-display_width (>= 1.1.1, < 3)
60
- unicode-display_width (2.0.0)
61
-
62
- PLATFORMS
63
- x86_64-linux
64
-
65
- DEPENDENCIES
66
- fasterer (~> 0.9.0)
67
- ffaker (~> 2.19.0)
68
- new_super_codebreaker_2021!
69
- rake (~> 13.0)
70
- rspec (~> 3.10.0)
71
- rubocop (~> 1.7)
72
- simplecov (~> 0.21.2)
73
- terminal-table (~> 3.0.1)
74
-
75
- BUNDLED WITH
76
- 2.2.26
data/Rakefile DELETED
@@ -1,9 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rubocop/rake_task'
3
-
4
- begin
5
- require 'rspec/core/rake_task'
6
- RSpec::Core::RakeTask.new(:spec)
7
- rescue LoadError
8
- # Ignored
9
- end
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'new_super_codebreaker_2021'
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require 'irb'
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,3 +0,0 @@
1
- module NewSuperCodebreaker2021
2
- class Error < StandardError; end
3
- end