wordle 0.1.1 → 0.4.0

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: 66a3c589752b864d16c6902b5cfba0fce02dc626f2c03e090bdd291c31e48b1c
4
- data.tar.gz: 75a98dc37a95080e994d1003390e3d8f860153b532e8062971c4985f55952b1c
3
+ metadata.gz: 3a6fde063384b381fd26d3bf8dd318e23ed68a76f2389bfe9ae5a25f6868106a
4
+ data.tar.gz: dc16f5b1a5ad0e9e4d40f7cbb7bcb29fe9224ed9e39cd715e4fe42199cc6bd81
5
5
  SHA512:
6
- metadata.gz: 207367decbccc995880b2a88903454fa7f60bac8bb24fd45162c2e639fd9dde7ff21e83073e180f93244f9511c1f981f4f1a10f0366692eda4d8c6f0c7813b7b
7
- data.tar.gz: 3dd312657ed39ad8a570746422fb86c9fa85f1811c35c47ebeb56394beb1b274a25a28256f1cc240b32a843cb2eee768e91247dd9547d58ab44a88af66529502
6
+ metadata.gz: 63745922fe29a07bb57f3313328c5afb1ce1190cafec5b1d91a129075eaa7ee69de4799df60800711d76df2aeb364e5b7b46f94749ac6b1b72f8891c0e37aa8c
7
+ data.tar.gz: 78b0c4fd62495d09a623815f8aa6410c65db0ac6d63ac8bfc8851d8932afffd2b87883716daa93c95b7482c56a2e3ec86cf5f4b9d39f68ecb5b206bd67380dbb
data/CHANGELOG.md CHANGED
@@ -1,4 +1,19 @@
1
- ## [Unreleased]
1
+ ## [0.4.0] - 2022-01-14
2
+
3
+ - Fixes bug where too many letters would get marked as yellow. Resolves
4
+ [https://github.com/JonathanWThom/wordle/issues/3](https://github.com/JonathanWThom/wordle/issues/3).
5
+
6
+ ## [0.3.0] - 2022-01-10
7
+
8
+ - Adds a better world list. From the Wordle source itself : )
9
+
10
+ ## [0.2.1] - 2022-01-10
11
+
12
+ - Adds legend for colors
13
+
14
+ ## [0.2.0] - 2022-01-09
15
+
16
+ - Actually tells you what the word was if you don't win!
2
17
 
3
18
  ## [0.1.1] - 2022-01-09
4
19
 
data/Gemfile.lock CHANGED
@@ -1,19 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wordle (0.1.1)
4
+ wordle (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  ast (2.4.2)
10
+ debug (1.4.0)
11
+ irb (>= 1.3.6)
12
+ reline (>= 0.2.7)
10
13
  diff-lcs (1.5.0)
14
+ io-console (0.5.11)
15
+ irb (1.4.1)
16
+ reline (>= 0.3.0)
11
17
  parallel (1.21.0)
12
18
  parser (3.1.0.0)
13
19
  ast (~> 2.4.1)
14
20
  rainbow (3.0.0)
15
21
  rake (13.0.6)
16
22
  regexp_parser (2.2.0)
23
+ reline (0.3.1)
24
+ io-console (~> 0.5)
17
25
  rexml (3.2.5)
18
26
  rspec (3.10.0)
19
27
  rspec-core (~> 3.10.0)
@@ -53,6 +61,7 @@ PLATFORMS
53
61
  x86_64-linux
54
62
 
55
63
  DEPENDENCIES
64
+ debug (>= 1.0.0)
56
65
  rake (~> 13.0)
57
66
  rspec (~> 3.0)
58
67
  standard (~> 1.3)
data/README.md CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  Ruby implementation of [Wordle](https://www.powerlanguage.co.uk/wordle/).
4
4
 
5
+ <img width="794" alt="Screen Shot 2022-01-10 at 9 18 19 PM" src="https://user-images.githubusercontent.com/22665228/148885575-39805830-274e-40e6-be14-4c6bc6db37ec.png">
6
+
5
7
  ## Installation
6
8
 
7
- $ gem install wordle
9
+ `gem install wordle`
8
10
 
9
11
  ## Usage
10
12
 
@@ -18,7 +20,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
18
20
 
19
21
  ## Contributing
20
22
 
21
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/wordle. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/wordle/blob/main/CODE_OF_CONDUCT.md).
23
+ Bug reports and pull requests are welcome on GitHub at https://github.com/JonathanWThom/wordle. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/JonathanWThom/wordle/blob/main/CODE_OF_CONDUCT.md).
24
+
25
+ ## Acknowledgements
26
+
27
+ I cribbed my word list from the Wordle site itself. I have no association with the site or its creator, I'm just a fan!
22
28
 
23
29
  ## License
24
30
 
@@ -26,4 +32,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
26
32
 
27
33
  ## Code of Conduct
28
34
 
29
- Everyone interacting in the Wordle project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/wordle/blob/main/CODE_OF_CONDUCT.md).
35
+ Everyone interacting in the Wordle project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/JonathanWThom/wordle/blob/main/CODE_OF_CONDUCT.md).
data/lib/wordle/game.rb CHANGED
@@ -18,6 +18,7 @@ module Wordle
18
18
  winner = false
19
19
  attempts = 0
20
20
 
21
+ Legend.print
21
22
  puts "Guess a 5 letter word: "
22
23
 
23
24
  while attempts < 6 && !winner
@@ -41,9 +42,10 @@ module Wordle
41
42
  end
42
43
 
43
44
  if winner
44
- puts "winner!"
45
+ puts "Winner!"
45
46
  else
46
- puts "better luck next time!"
47
+ puts "Word was: #{@target_word}"
48
+ puts "Better luck next time!"
47
49
  end
48
50
  end
49
51
 
@@ -14,21 +14,28 @@ module Wordle
14
14
  end
15
15
 
16
16
  def colors
17
- target_letters = @target_word.split("")
18
- guess_letters = @guess.split("")
19
- colored_letters = ""
17
+ target_letters = @target_word.chars
18
+ guess_letters = @guess.chars
19
+ colored_letters = []
20
20
 
21
21
  guess_letters.each_with_index do |letter, i|
22
22
  if letter == target_letters[i]
23
- colored_letters += letter.green
24
- elsif target_letters.include?(letter)
25
- colored_letters += letter.yellow
26
- else
27
- colored_letters += letter.gray
23
+ colored_letters[i] = letter.green
24
+ target_letters[i] = nil
28
25
  end
29
26
  end
30
27
 
31
- colored_letters
28
+ guess_letters.each_with_index do |letter, i|
29
+ if colored_letters[i].nil?
30
+ colored_letters[i] = if target_letters.include?(letter)
31
+ letter.yellow
32
+ else
33
+ letter.gray
34
+ end
35
+ end
36
+ end
37
+
38
+ colored_letters.join("")
32
39
  end
33
40
  end
34
41
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Wordle
3
4
  class GuessValidator
4
5
  attr_reader :error
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Wordle
4
+ class Legend
5
+ def self.print
6
+ new.print
7
+ end
8
+
9
+ def print
10
+ puts green_example
11
+ puts yellow_example
12
+ puts gray_example
13
+ end
14
+
15
+ private
16
+
17
+ def green_example
18
+ "#{"w".green}eary - The letter w is in the word and in the correct spot."
19
+ end
20
+
21
+ def yellow_example
22
+ "p#{"i".yellow}lls - The letter i is in the word but in the wrong spot."
23
+ end
24
+
25
+ def gray_example
26
+ "vag#{"u".gray}e - The letter u is not in the word in any spot."
27
+ end
28
+ end
29
+ end
data/lib/wordle/list.rb CHANGED
@@ -17,12 +17,7 @@ module Wordle
17
17
  private
18
18
 
19
19
  def list
20
- # fall back to api if this fails?
21
- @_list ||= begin
22
- File.readlines("/usr/share/dict/words").select do |word|
23
- word.strip.length == @length
24
- end.map { |w| w.downcase.strip } # sanitize class to standarize this?
25
- end
20
+ @_list ||= Wordle::SOURCE
26
21
  end
27
22
  end
28
23
  end