wordle 0.1.0 → 0.3.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 +4 -4
- data/CHANGELOG.md +12 -2
- data/Gemfile.lock +2 -1
- data/README.md +7 -18
- data/lib/wordle/game.rb +4 -2
- data/lib/wordle/guess_analyzer.rb +6 -6
- data/lib/wordle/guess_validator.rb +1 -0
- data/lib/wordle/legend.rb +29 -0
- data/lib/wordle/list.rb +1 -6
- data/lib/wordle/source.rb +12978 -0
- data/lib/wordle/version.rb +1 -1
- data/lib/wordle.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff0c43c46f9e5e2e25088128a3cd8e2f634bda564b98a0b36473c0d9fb1a25b7
|
4
|
+
data.tar.gz: bbcaf825639fd41c6388b501388cc108048d1c4464e59a3cad7eaa2451586679
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 366f914646b492bd8c00f4a4334db6ebb494b447cd54c34ea0d6c47310be1ab7ed3af5662c05daf5bcf8056dbb0899db2848599525ed17859eb40e6b111d500b
|
7
|
+
data.tar.gz: 1a21fa7349041d534f29588cb45b9ca41e4e0deef0d6812de0e1384a80613a94667b925b3c32cacf9d6d99bc587807b0419f416a9b6ebe16cb43142d1de13cce
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
|
-
## [
|
1
|
+
## [0.3.0] - 2022-01-10
|
2
2
|
|
3
|
-
|
3
|
+
- Adds a better world list. From the Wordle source itself : )
|
4
|
+
|
5
|
+
## [0.2.1] - 2022-01-10
|
6
|
+
|
7
|
+
- Adds legend for colors
|
8
|
+
|
9
|
+
## [0.2.0] - 2022-01-09
|
10
|
+
|
11
|
+
- Actually tells you what the word was if you don't win!
|
12
|
+
|
13
|
+
## [0.1.1] - 2022-01-09
|
4
14
|
|
5
15
|
- Initial release
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,28 +1,17 @@
|
|
1
1
|
# Wordle
|
2
2
|
|
3
|
-
|
3
|
+
Ruby implementation of [Wordle](https://www.powerlanguage.co.uk/wordle/).
|
4
4
|
|
5
|
-
|
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
6
|
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'wordle'
|
13
|
-
```
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
8
|
+
## Installation
|
20
9
|
|
21
|
-
|
10
|
+
`gem install wordle`
|
22
11
|
|
23
12
|
## Usage
|
24
13
|
|
25
|
-
|
14
|
+
Just run `wordle` from the command line.
|
26
15
|
|
27
16
|
## Development
|
28
17
|
|
@@ -32,7 +21,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
21
|
|
33
22
|
## Contributing
|
34
23
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
24
|
+
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).
|
36
25
|
|
37
26
|
## License
|
38
27
|
|
@@ -40,4 +29,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
29
|
|
41
30
|
## Code of Conduct
|
42
31
|
|
43
|
-
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/
|
32
|
+
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 "
|
45
|
+
puts "Winner!"
|
45
46
|
else
|
46
|
-
puts "
|
47
|
+
puts "Word was: #{@target_word}"
|
48
|
+
puts "Better luck next time!"
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
@@ -14,17 +14,17 @@ module Wordle
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def colors
|
17
|
-
target_letters = @target_word.
|
18
|
-
guess_letters = @guess.
|
17
|
+
target_letters = @target_word.chars
|
18
|
+
guess_letters = @guess.chars
|
19
19
|
colored_letters = ""
|
20
20
|
|
21
21
|
guess_letters.each_with_index do |letter, i|
|
22
|
-
if letter == target_letters[i]
|
23
|
-
|
22
|
+
colored_letters += if letter == target_letters[i]
|
23
|
+
letter.green
|
24
24
|
elsif target_letters.include?(letter)
|
25
|
-
|
25
|
+
letter.yellow
|
26
26
|
else
|
27
|
-
|
27
|
+
letter.gray
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -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
|
-
|
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
|