glimmer_wordle 1.0.0 → 1.1.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/README.md +4 -4
- data/VERSION +1 -1
- data/app/wordle/view/app_view.rb +208 -42
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 450dbdcb851754bb9e443dce3511a31fe46d275ecc4db7edcbd1b4eca30322f0
|
|
4
|
+
data.tar.gz: 5f8e3c63f36d914e2b15ab21eb386c2b7bbb4bbd897172dcf19b454d0a901dd4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 961b5ec85887d1fe92a444dfc292985ef60ac4ebcd04916702c8bc66c4afe861bce3c958380ce3179913789fecd961507f73cdcecdfe663b06dad228f16c280e
|
|
7
|
+
data.tar.gz: 35055490ab7a0ceb7e5c6001cd814478fc181f648a7fa6ed2ab815e04182859d3695c0ee327cdf8266998eb741e9c8db0fda1cd5cbc66f6da387e9037c7180b5
|
data/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# <img src='https://raw.githubusercontent.com/AndyObtiva/glimmer_wordle/master/icons/linux/Glimmer Wordle.png' height=85 /> Wordle
|
|
2
|
-
##
|
|
1
|
+
# <img src='https://raw.githubusercontent.com/AndyObtiva/glimmer_wordle/master/icons/linux/Glimmer Wordle.png' height=85 /> Glimmer Wordle 1.1.0
|
|
2
|
+
## Play Wordle Endlessly with No Limit!
|
|
3
3
|
[](http://badge.fury.io/rb/glimmer_wordle)
|
|
4
4
|
|
|
5
5
|
[Wordle](https://en.wikipedia.org/wiki/Wordle) word game desktop GUI app written [test-first](https://github.com/AndyObtiva/wordle/blob/master/spec/app/model/five_letter_word_spec.rb) using [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Framework) as inspiration by [Kevin Newton's blog post](https://kddnewton.com/2022/01/29/solving-wordle-in-ruby.html).
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
### Download
|
|
16
16
|
|
|
17
|
-
[<img src='https://raw.githubusercontent.com/AndyObtiva/glimmer_wordle/master/icons/linux/Glimmer Wordle.png' height=40 /> Download Glimmer Wordle DMG for Mac ARM64 Monterey and Older](https://www.dropbox.com/s/
|
|
17
|
+
[<img src='https://raw.githubusercontent.com/AndyObtiva/glimmer_wordle/master/icons/linux/Glimmer Wordle.png' height=40 /> Download Glimmer Wordle 1.1.0 DMG for Mac ARM64 Monterey and Older](https://www.dropbox.com/s/j2j5cyor90jr7rj/Glimmer%20Wordle-ARM64-1.1.0.dmg?dl=1)
|
|
18
18
|
|
|
19
|
-
[<img src='https://raw.githubusercontent.com/AndyObtiva/glimmer_wordle/master/icons/linux/Glimmer Wordle.png' height=40 /> Download Glimmer Wordle DMG for Mac x86_64 Catalina and Older](https://www.dropbox.com/s/
|
|
19
|
+
[<img src='https://raw.githubusercontent.com/AndyObtiva/glimmer_wordle/master/icons/linux/Glimmer Wordle.png' height=40 /> Download Glimmer Wordle 1.1.0 DMG for Mac x86_64 Catalina and Older](https://www.dropbox.com/s/t6tjuzp4dhmuls9/Glimmer%20Wordle-1.1.0.dmg?dl=1)
|
|
20
20
|
|
|
21
21
|
### Install Ruby Gem
|
|
22
22
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.1.0
|
data/app/wordle/view/app_view.rb
CHANGED
|
@@ -4,9 +4,9 @@ class Wordle
|
|
|
4
4
|
include Glimmer::UI::CustomShell
|
|
5
5
|
|
|
6
6
|
COLOR_TO_BACKGROUND_COLOR_MAP = {
|
|
7
|
-
green:
|
|
8
|
-
yellow:
|
|
9
|
-
gray:
|
|
7
|
+
green: rgb(106, 170, 100),
|
|
8
|
+
yellow: rgb(201, 180, 88),
|
|
9
|
+
gray: rgb(120, 124, 126),
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
COLOR_TO_TEXT_COLOR_MAP = {
|
|
@@ -15,10 +15,20 @@ class Wordle
|
|
|
15
15
|
gray: :white,
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
ALPHABET_LAYOUTS = {
|
|
19
|
+
alphabetical: [
|
|
20
|
+
%w[A B C D E F G H I J],
|
|
21
|
+
%w[K L M N O P Q R S],
|
|
22
|
+
%w[T U V W X Y Z],
|
|
23
|
+
],
|
|
24
|
+
querty: [
|
|
25
|
+
%w[Q W E R T Y U I O P],
|
|
26
|
+
%w[A S D F G H J K L],
|
|
27
|
+
%w[Z X C V B N M],
|
|
28
|
+
],
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
CONFIG_FILE = File.join(Dir.home, '.glimmer_wordle')
|
|
22
32
|
|
|
23
33
|
before_body do
|
|
24
34
|
@display = display {
|
|
@@ -31,6 +41,10 @@ class Wordle
|
|
|
31
41
|
on_swt_keydown do |key_event|
|
|
32
42
|
if key_event.keyCode == 8
|
|
33
43
|
do_backspace
|
|
44
|
+
elsif key_event.keyCode == swt(:arrow_left)
|
|
45
|
+
do_left
|
|
46
|
+
elsif key_event.keyCode == swt(:arrow_right)
|
|
47
|
+
do_right
|
|
34
48
|
elsif key_event.keyCode == swt(:cr)
|
|
35
49
|
if @five_letter_word.status == :in_progress
|
|
36
50
|
do_guess
|
|
@@ -43,6 +57,8 @@ class Wordle
|
|
|
43
57
|
end
|
|
44
58
|
}
|
|
45
59
|
@five_letter_word = Model::FiveLetterWord.new
|
|
60
|
+
config = load_config
|
|
61
|
+
@alphabet_layout = config[:alphabet_layout] || :alphabetical
|
|
46
62
|
end
|
|
47
63
|
|
|
48
64
|
## Add widget content inside custom shell body
|
|
@@ -65,7 +81,7 @@ class Wordle
|
|
|
65
81
|
|
|
66
82
|
app_menu_bar
|
|
67
83
|
|
|
68
|
-
|
|
84
|
+
alphabet_container
|
|
69
85
|
|
|
70
86
|
label {
|
|
71
87
|
layout_data :center, :center, true, false
|
|
@@ -100,11 +116,47 @@ class Wordle
|
|
|
100
116
|
}
|
|
101
117
|
}
|
|
102
118
|
|
|
119
|
+
menu {
|
|
120
|
+
text '&View'
|
|
121
|
+
|
|
122
|
+
menu {
|
|
123
|
+
text 'Alphabet &Layout'
|
|
124
|
+
|
|
125
|
+
menu_item(:radio) {
|
|
126
|
+
text '&Alphabetical'
|
|
127
|
+
selection @alphabet_layout == :alphabetical
|
|
128
|
+
|
|
129
|
+
on_widget_selected {
|
|
130
|
+
self.alphabet_layout = :alphabetical
|
|
131
|
+
rebuild_alphabet_container
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
menu_item(:radio) {
|
|
136
|
+
text '&Querty'
|
|
137
|
+
selection @alphabet_layout == :querty
|
|
138
|
+
|
|
139
|
+
on_widget_selected {
|
|
140
|
+
self.alphabet_layout = :querty
|
|
141
|
+
rebuild_alphabet_container
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
103
147
|
menu {
|
|
104
148
|
text '&Help'
|
|
105
149
|
|
|
106
150
|
menu_item {
|
|
107
|
-
text '&
|
|
151
|
+
text '&Instructions'
|
|
152
|
+
|
|
153
|
+
on_widget_selected {
|
|
154
|
+
display_instructions_dialog
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
menu_item {
|
|
159
|
+
text '&About'
|
|
108
160
|
|
|
109
161
|
on_widget_selected {
|
|
110
162
|
display_about_dialog
|
|
@@ -114,6 +166,33 @@ class Wordle
|
|
|
114
166
|
}
|
|
115
167
|
end
|
|
116
168
|
|
|
169
|
+
def display_instructions_dialog
|
|
170
|
+
message_box(body_root) {
|
|
171
|
+
text 'Instructions'
|
|
172
|
+
message <<~MULTI_LINE_STRING
|
|
173
|
+
Glimmer Wordle Instructions
|
|
174
|
+
|
|
175
|
+
Make 6 guesses for a 5-letter word.
|
|
176
|
+
|
|
177
|
+
If you enter a letter that is part of the word,
|
|
178
|
+
and at the right location in the word,
|
|
179
|
+
the letter will become green.
|
|
180
|
+
|
|
181
|
+
If you enter a letter that is part of the word,
|
|
182
|
+
but at the wrong location in the word,
|
|
183
|
+
the letter will become yellow.
|
|
184
|
+
|
|
185
|
+
If you enter a letter that is not part of the word,
|
|
186
|
+
the letter will become red.
|
|
187
|
+
|
|
188
|
+
If you win or lose, you get to see the answer,
|
|
189
|
+
and share the result emojis.
|
|
190
|
+
|
|
191
|
+
Happy Glimmer Wordle!
|
|
192
|
+
MULTI_LINE_STRING
|
|
193
|
+
}.open
|
|
194
|
+
end
|
|
195
|
+
|
|
117
196
|
def display_about_dialog
|
|
118
197
|
message_box(body_root) {
|
|
119
198
|
text 'About'
|
|
@@ -121,22 +200,38 @@ class Wordle
|
|
|
121
200
|
}.open
|
|
122
201
|
end
|
|
123
202
|
|
|
203
|
+
def alphabet_container
|
|
204
|
+
@alphabet_container = composite {
|
|
205
|
+
layout_data(:center, :center, true, false)
|
|
206
|
+
|
|
207
|
+
grid_layout {
|
|
208
|
+
margin_width 0
|
|
209
|
+
margin_height 0
|
|
210
|
+
vertical_spacing 0
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
background :white
|
|
214
|
+
|
|
215
|
+
alphabets
|
|
216
|
+
}
|
|
217
|
+
end
|
|
218
|
+
|
|
124
219
|
def alphabets
|
|
125
|
-
alphabet_row(
|
|
220
|
+
alphabet_row(ALPHABET_LAYOUTS[@alphabet_layout][0]) {
|
|
126
221
|
layout_data(:center, :center, true, false) {
|
|
127
222
|
width_hint 318
|
|
128
223
|
height_hint 50
|
|
129
224
|
}
|
|
130
225
|
}
|
|
131
226
|
|
|
132
|
-
alphabet_row(
|
|
227
|
+
alphabet_row(ALPHABET_LAYOUTS[@alphabet_layout][1]) {
|
|
133
228
|
layout_data(:center, :center, true, false) {
|
|
134
229
|
width_hint 288
|
|
135
230
|
height_hint 50
|
|
136
231
|
}
|
|
137
232
|
}
|
|
138
233
|
|
|
139
|
-
alphabet_row(
|
|
234
|
+
alphabet_row(ALPHABET_LAYOUTS[@alphabet_layout][2]) {
|
|
140
235
|
layout_data(:center, :center, true, false) {
|
|
141
236
|
width_hint 222
|
|
142
237
|
height_hint 50
|
|
@@ -169,6 +264,10 @@ class Wordle
|
|
|
169
264
|
}
|
|
170
265
|
end
|
|
171
266
|
|
|
267
|
+
def alphabet_layout_alphabets
|
|
268
|
+
ALPHABET_LAYOUTS[@alphabet_layout].reduce(:+)
|
|
269
|
+
end
|
|
270
|
+
|
|
172
271
|
def word_guesser
|
|
173
272
|
@canvasses ||= []
|
|
174
273
|
margin_x = 5
|
|
@@ -214,13 +313,11 @@ class Wordle
|
|
|
214
313
|
|
|
215
314
|
def do_backspace
|
|
216
315
|
@letter = @letters.find {|letter| letter.string == ''}
|
|
217
|
-
index = @letter ? @letters.index(@letter) - 1 : 4
|
|
316
|
+
index = @letter ? [@letters.index(@letter) - 1, 0].max : 4
|
|
218
317
|
@letter = @letters[index]
|
|
219
318
|
@letter.string = ''
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
@borders[index - 1].foreground = :title_background
|
|
223
|
-
end
|
|
319
|
+
@borders.each { |caret| caret.foreground = :gray}
|
|
320
|
+
@borders[index].foreground = :title_background
|
|
224
321
|
end
|
|
225
322
|
|
|
226
323
|
def do_guess
|
|
@@ -261,26 +358,47 @@ class Wordle
|
|
|
261
358
|
body_root.pack(true)
|
|
262
359
|
end
|
|
263
360
|
|
|
361
|
+
def highlighted_letter_index
|
|
362
|
+
@borders.each_with_index.find {|border, i| border.foreground.first == color(:title_background).swt_color }.last
|
|
363
|
+
end
|
|
364
|
+
|
|
264
365
|
def do_type(character)
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
366
|
+
index = highlighted_letter_index
|
|
367
|
+
@letter = @letters[index]
|
|
368
|
+
@letter.string = character.upcase
|
|
369
|
+
if @letters.any? {|letter| letter.string == ''}
|
|
268
370
|
@borders.each { |caret| caret.foreground = :gray}
|
|
269
371
|
@borders[index == 4 ? 4 : index + 1].foreground = :title_background
|
|
270
|
-
@letter.string = character.upcase
|
|
271
372
|
end
|
|
272
373
|
end
|
|
273
374
|
|
|
375
|
+
def do_left
|
|
376
|
+
index = [highlighted_letter_index - 1, 0].max
|
|
377
|
+
@borders.each { |caret| caret.foreground = :gray}
|
|
378
|
+
@borders[index].foreground = :title_background
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
def do_right
|
|
382
|
+
index = [highlighted_letter_index + 1, @letters.count - 1].min
|
|
383
|
+
@borders.each { |caret| caret.foreground = :gray}
|
|
384
|
+
@borders[index].foreground = :title_background
|
|
385
|
+
end
|
|
386
|
+
|
|
274
387
|
def do_restart
|
|
275
|
-
|
|
388
|
+
@share_text_dialog&.close
|
|
389
|
+
alphabet_layout_alphabets.each_with_index do |alphabet_character, i|
|
|
276
390
|
@alphabet_borders[i].foreground = :gray
|
|
277
391
|
@alphabet_rectangles[i].background = :white
|
|
278
392
|
@alphabet_letters[i].foreground = :black
|
|
279
393
|
end
|
|
280
|
-
@restart_button
|
|
394
|
+
@restart_button&.dispose
|
|
281
395
|
@canvasses.dup.each(&:dispose)
|
|
282
396
|
@canvasses.clear
|
|
283
|
-
|
|
397
|
+
@guess_button&.dispose
|
|
398
|
+
body_root.content {
|
|
399
|
+
word_guesser
|
|
400
|
+
guess_button
|
|
401
|
+
}
|
|
284
402
|
body_root.layout(true, true)
|
|
285
403
|
body_root.pack(true)
|
|
286
404
|
@five_letter_word.refresh
|
|
@@ -297,7 +415,7 @@ class Wordle
|
|
|
297
415
|
end
|
|
298
416
|
|
|
299
417
|
def update_alphabet_background_colors
|
|
300
|
-
|
|
418
|
+
alphabet_layout_alphabets.each_with_index do |alphabet_character, i|
|
|
301
419
|
result_color = @five_letter_word.colored_alphabets[alphabet_character.downcase]
|
|
302
420
|
if result_color
|
|
303
421
|
background_color = COLOR_TO_BACKGROUND_COLOR_MAP[result_color]
|
|
@@ -321,27 +439,16 @@ class Wordle
|
|
|
321
439
|
end
|
|
322
440
|
|
|
323
441
|
def display_share_text_dialog
|
|
324
|
-
result =
|
|
325
|
-
|
|
326
|
-
row.each do |result_color|
|
|
327
|
-
case result_color
|
|
328
|
-
when :green
|
|
329
|
-
result << "🟩"
|
|
330
|
-
when :yellow
|
|
331
|
-
result << "🟨"
|
|
332
|
-
when :gray
|
|
333
|
-
result << "⬜"
|
|
334
|
-
end
|
|
335
|
-
end
|
|
336
|
-
result << "\n"
|
|
337
|
-
end
|
|
338
|
-
|
|
442
|
+
result = "#{@five_letter_word.answer.upcase}\n\n#{emoji_result}"
|
|
443
|
+
|
|
339
444
|
Clipboard.copy(result)
|
|
340
445
|
|
|
341
|
-
dialog(body_root) {
|
|
446
|
+
@share_text_dialog = dialog(body_root) {
|
|
342
447
|
grid_layout
|
|
343
448
|
text 'Share Result'
|
|
344
449
|
|
|
450
|
+
app_menu_bar
|
|
451
|
+
|
|
345
452
|
label {
|
|
346
453
|
layout_data :center, :center, true, false
|
|
347
454
|
text 'Result is copied to clipboard!'
|
|
@@ -354,7 +461,66 @@ class Wordle
|
|
|
354
461
|
alignment :center
|
|
355
462
|
text result
|
|
356
463
|
}
|
|
357
|
-
}
|
|
464
|
+
}
|
|
465
|
+
@share_text_dialog.open
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
def dispose_alphabet_container_children
|
|
469
|
+
@alphabet_rectangles.clear
|
|
470
|
+
@alphabet_borders.clear
|
|
471
|
+
@alphabet_letters.clear
|
|
472
|
+
@alphabet_container.children.each(&:dispose)
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
def rebuild_alphabet_container
|
|
476
|
+
dispose_alphabet_container_children
|
|
477
|
+
@alphabet_container.content {
|
|
478
|
+
alphabets
|
|
479
|
+
}
|
|
480
|
+
@alphabet_container.layout(true, true)
|
|
481
|
+
@alphabet_container.pack(true)
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
def alphabet_layout=(value)
|
|
485
|
+
@alphabet_layout = value
|
|
486
|
+
save_config
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
def new_config
|
|
490
|
+
{
|
|
491
|
+
alphabet_layout: @alphabet_layout
|
|
492
|
+
}
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
def save_config
|
|
496
|
+
File.write(CONFIG_FILE, YAML.dump(new_config))
|
|
497
|
+
rescue => e
|
|
498
|
+
puts e.full_message
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
def load_config
|
|
502
|
+
File.exist?(CONFIG_FILE) ? YAML.load(File.read(CONFIG_FILE)) : {}
|
|
503
|
+
rescue => e
|
|
504
|
+
puts e.full_message
|
|
505
|
+
{}
|
|
506
|
+
end
|
|
507
|
+
|
|
508
|
+
def emoji_result
|
|
509
|
+
result = ''
|
|
510
|
+
@five_letter_word.guess_results.each do |row|
|
|
511
|
+
row.each do |result_color|
|
|
512
|
+
case result_color
|
|
513
|
+
when :green
|
|
514
|
+
result << "🟩"
|
|
515
|
+
when :yellow
|
|
516
|
+
result << "🟨"
|
|
517
|
+
when :gray
|
|
518
|
+
result << "⬜"
|
|
519
|
+
end
|
|
520
|
+
end
|
|
521
|
+
result << "\n"
|
|
522
|
+
end
|
|
523
|
+
result
|
|
358
524
|
end
|
|
359
525
|
end
|
|
360
526
|
end
|
metadata
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: glimmer_wordle
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Maleh
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-02-
|
|
11
|
+
date: 2022-02-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 4.22.2.
|
|
18
|
+
version: 4.22.2.6
|
|
19
19
|
name: glimmer-dsl-swt
|
|
20
20
|
prerelease: false
|
|
21
21
|
type: :runtime
|
|
@@ -23,7 +23,7 @@ dependencies:
|
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 4.22.2.
|
|
26
|
+
version: 4.22.2.6
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
@@ -95,7 +95,7 @@ dependencies:
|
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '0'
|
|
97
97
|
description: Glimmer Wordle - Word Game Desktop GUI App Written in Glimmer DSL for
|
|
98
|
-
SWT (requires JRuby)
|
|
98
|
+
SWT (requires JRuby) - Play Wordle Endlessly with No Limit!
|
|
99
99
|
email: andy.am@gmail.com
|
|
100
100
|
executables:
|
|
101
101
|
- glimmer_wordle
|