git_game_show 0.1.4 → 0.1.5
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/lib/git_game_show/cli.rb +116 -84
- data/lib/git_game_show/game_server.rb +609 -232
- data/lib/git_game_show/player_client.rb +127 -113
- data/lib/git_game_show/updater.rb +8 -8
- data/lib/git_game_show/version.rb +1 -1
- data/mini_games/date_ordering_quiz.rb +78 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f8afebed41ed43c7d886a48c4de43fb6243d29a7b7e8be0655d4e5b1676208d
|
4
|
+
data.tar.gz: 7fdc45f5fe5526980daf719a228edfb058aa5648db0120902835036c383e7352
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 620bc18628354eb9b5910a6cf87eb8d998c82b8325d05fd64ebabfc752e8fa9b8897c32ead3823b41fda8c3f7c0d84d9633eae458345eb0a3581664a2d6e1aed
|
7
|
+
data.tar.gz: dd3c6f2276b3780fcdc9a228d9a7b51979ede0bc4b5dbaa851949727b184c2ea139a2cca11f46e70394bd6da141f552a642beaecf1f38cbeb8a978d682938f6f
|
data/lib/git_game_show/cli.rb
CHANGED
@@ -20,7 +20,7 @@ module GitGameShow
|
|
20
20
|
GitGameShow::Updater.check_for_updates if defined?(GitGameShow::Updater)
|
21
21
|
|
22
22
|
prompt = TTY::Prompt.new
|
23
|
-
choice = prompt.select("
|
23
|
+
choice = prompt.select("", [
|
24
24
|
{name: "Host a new game", value: :host},
|
25
25
|
{name: "Join a game", value: :join},
|
26
26
|
{name: "Check for updates", value: :update},
|
@@ -105,20 +105,20 @@ module GitGameShow
|
|
105
105
|
# Ask user which IP to use
|
106
106
|
prompt = TTY::Prompt.new
|
107
107
|
ip_choices = []
|
108
|
-
ip_choices << {name: "Local
|
109
|
-
ip_choices << {name: "
|
110
|
-
ip_choices << {name: "
|
108
|
+
ip_choices << {name: "Local IP (#{local_ip})", value: {:type => :local, :ip => local_ip}} if !local_ip.empty?
|
109
|
+
ip_choices << {name: "External IP (#{external_ip})", value: {:type => :external, :ip => external_ip}} if external_ip
|
110
|
+
ip_choices << {name: "Automatic tunneling", value: {:type => :tunnel}}
|
111
111
|
ip_choices << {name: "Custom IP or hostname", value: {:type => :custom}}
|
112
112
|
|
113
113
|
# Format question with explanation
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
114
|
+
display_info_box(:info, "Network Setup", [
|
115
|
+
" • Local IP: Only for players on the same network",
|
116
|
+
" • External IP: For internet players",
|
117
|
+
" - requires router port forwarding",
|
118
|
+
" • Automatic tunneling: For internet players",
|
119
|
+
" - requires free account & authorization through ngrok",
|
120
|
+
" • Custom IP: For advanced users with specific network setup"
|
121
|
+
])
|
122
122
|
|
123
123
|
ip_choice = prompt.select("How should players connect to your game?", ip_choices)
|
124
124
|
|
@@ -132,13 +132,15 @@ module GitGameShow
|
|
132
132
|
when :tunnel
|
133
133
|
# Clear the screen and show informative message about ngrok
|
134
134
|
display_ggs
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
135
|
+
display_info_box(:info, "Ngrok Tunnel Setup", [
|
136
|
+
" The automatic tunneling option uses ngrok, a secure tunneling service.",
|
137
|
+
" This will allow players to connect from anywhere without port forwarding.",
|
138
|
+
" ",
|
139
|
+
" If you do not already have ngrok set up:",
|
140
|
+
" • The ngrok client will be downloaded and started automatically",
|
141
|
+
" • Instructions will be provided to set up a required free account on ngrok",
|
142
|
+
" • The tunnel will be established and the game will start"
|
143
|
+
])
|
142
144
|
|
143
145
|
# Check if ngrok is available
|
144
146
|
begin
|
@@ -269,17 +271,15 @@ module GitGameShow
|
|
269
271
|
|
270
272
|
if auth_needed
|
271
273
|
display_ggs
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
puts " 2. Get your authtoken from https://dashboard.ngrok.com/get-started/your-authtoken"
|
282
|
-
puts " 3. Enter your authtoken below"
|
274
|
+
display_info_box(:info, 'Ngrok Authorization Required', [
|
275
|
+
" Starting with ngrok v3, you need to create a free account and authorize ",
|
276
|
+
" to use TCP tunnels. This is a one-time setup. ",
|
277
|
+
" ",
|
278
|
+
" Steps to authorize ngrok: ",
|
279
|
+
" 1. Create a free account at https://ngrok.com/signup ",
|
280
|
+
" 2. Get an authtoken https://dashboard.ngrok.com/get-started/your-authtoken ",
|
281
|
+
" 3. Enter your authtoken below "
|
282
|
+
])
|
283
283
|
puts ""
|
284
284
|
|
285
285
|
prompt = TTY::Prompt.new
|
@@ -364,21 +364,20 @@ module GitGameShow
|
|
364
364
|
|
365
365
|
display_ggs
|
366
366
|
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
puts "Public URL: #{public_url}"
|
367
|
+
# We need to handle the colorized content within the green box
|
368
|
+
content = [
|
369
|
+
" Your game is now accessible over the internet",
|
370
|
+
" The ngrok tunnel is running in the background:",
|
371
|
+
" ",
|
372
|
+
" ngrok ip: #{ip.ljust(57)}".colorize(:light_blue),
|
373
|
+
" ngrok port: #{external_port.to_s.ljust(57)}".colorize(:light_blue),
|
374
|
+
" ngrok public URL: #{public_url.ljust(57)}".colorize(:light_blue),
|
375
|
+
" ",
|
376
|
+
" DO NOT close the terminal window until your game is finished",
|
377
|
+
" The tunnel will automatically close when you exit the game"
|
378
|
+
]
|
379
|
+
|
380
|
+
display_info_box(:success, 'Ngrok tunnel established successfully!', content)
|
382
381
|
puts ""
|
383
382
|
puts "Press Enter to continue..."
|
384
383
|
gets
|
@@ -392,20 +391,17 @@ module GitGameShow
|
|
392
391
|
|
393
392
|
unless tunnel_url
|
394
393
|
display_ggs
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
puts " 3. Run this command: ngrok config add-authtoken <YOUR_TOKEN>"
|
407
|
-
puts " 4. Then restart the game and try tunneling again"
|
408
|
-
puts ""
|
394
|
+
display_info_box(:error, 'Tunnel setup failed!', [
|
395
|
+
" ngrok tunnel could not be established",
|
396
|
+
" Most common reason: Missing or invalid ngrok authentication token",
|
397
|
+
" Falling back to local IP (players will only be able to join locally)",
|
398
|
+
" ",
|
399
|
+
" Common solutions:",
|
400
|
+
" 1. Create a free account at https://ngrok.com/signup",
|
401
|
+
" 2. Get an authtoken https://dashboard.ngrok.com/get-started/your-authtoken",
|
402
|
+
" 3. Run this command: ngrok config add-authtoken <YOUR_TOKEN>",
|
403
|
+
" 4. Then restart the game and try tunneling again"
|
404
|
+
])
|
409
405
|
puts "Press Enter to continue with local IP..."
|
410
406
|
gets
|
411
407
|
|
@@ -413,14 +409,11 @@ module GitGameShow
|
|
413
409
|
end
|
414
410
|
rescue => e
|
415
411
|
display_ggs
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
puts "┃ • Falling back to local IP (players will only be able to join locally) ┃"
|
422
|
-
puts "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"
|
423
|
-
puts ""
|
412
|
+
display_info_box(:error, 'Error setting up ngrok tunnel!', [
|
413
|
+
" An error occurred while trying to set up the ngrok tunnel",
|
414
|
+
" This is likely an authentication issue with ngrok",
|
415
|
+
" Falling back to local IP (players will only be able to join locally)"
|
416
|
+
])
|
424
417
|
puts "Error details: #{e.message}"
|
425
418
|
puts ""
|
426
419
|
puts "Press Enter to continue with local IP..."
|
@@ -525,31 +518,34 @@ module GitGameShow
|
|
525
518
|
"╚██████╔╝".colorize(:red) + " ╚██████╔╝".colorize(:green) + " ██████╔╝".colorize(:blue),
|
526
519
|
" ╚═════╝ ".colorize(:red) + " ╚═════╝ ".colorize(:green) + " ╚═════╝ ".colorize(:blue),
|
527
520
|
]
|
528
|
-
lines.each { |line| puts line }
|
521
|
+
lines.each { |line| puts line.center(120) }
|
529
522
|
end
|
530
523
|
|
531
524
|
def display_game_logo
|
532
525
|
clear_screen
|
533
|
-
puts " ██████╗ ██╗████████╗".colorize(:red) + " ██████╗ █████╗ ███╗ ███╗███████╗".colorize(:green)
|
534
|
-
puts "██╔════╝ ██║╚══██╔══╝".colorize(:red) + " ██╔════╝ ██╔══██╗████╗ ████║██╔════╝".colorize(:green)
|
535
|
-
puts "██║ ███╗██║ ██║ ".colorize(:red) + " ██║ ███╗███████║██╔████╔██║█████╗ ".colorize(:green)
|
536
|
-
puts "██║ ██║██║ ██║ ".colorize(:red) + " ██║ ██║██╔══██║██║╚██╔╝██║██╔══╝ ".colorize(:green)
|
537
|
-
puts "╚██████╔╝██║ ██║ ".colorize(:red) + " ╚██████╔╝██║ ██║██║ ╚═╝ ██║███████╗".colorize(:green)
|
538
|
-
puts " ╚═════╝ ╚═╝ ╚═╝ ".colorize(:red) + " ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝".colorize(:green)
|
539
|
-
|
540
|
-
puts " █████╗ ██╗ ██╗ ██████╗ ██╗ ██╗".colorize(:blue)
|
541
|
-
puts "██╔═══╝ ██║ ██║██╔═══██╗██║ ██║".colorize(:blue)
|
542
|
-
puts "███████╗███████║██║ ██║██║ █╗ ██║".colorize(:blue)
|
543
|
-
puts "╚════██║██╔══██║██║ ██║██║███╗██║".colorize(:blue)
|
544
|
-
puts "██████╔╝██║ ██║╚██████╔╝╚███╔███╔╝".colorize(:blue)
|
545
|
-
puts "╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ".colorize(:blue)
|
526
|
+
puts (" ██████╗ ██╗████████╗".colorize(:red) + " ██████╗ █████╗ ███╗ ███╗███████╗".colorize(:green)).center(110)
|
527
|
+
puts ("██╔════╝ ██║╚══██╔══╝".colorize(:red) + " ██╔════╝ ██╔══██╗████╗ ████║██╔════╝".colorize(:green)).center(110)
|
528
|
+
puts ("██║ ███╗██║ ██║ ".colorize(:red) + " ██║ ███╗███████║██╔████╔██║█████╗ ".colorize(:green)).center(110)
|
529
|
+
puts ("██║ ██║██║ ██║ ".colorize(:red) + " ██║ ██║██╔══██║██║╚██╔╝██║██╔══╝ ".colorize(:green)).center(110)
|
530
|
+
puts ("╚██████╔╝██║ ██║ ".colorize(:red) + " ╚██████╔╝██║ ██║██║ ╚═╝ ██║███████╗".colorize(:green)).center(110)
|
531
|
+
puts (" ╚═════╝ ╚═╝ ╚═╝ ".colorize(:red) + " ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝".colorize(:green)).center(110)
|
532
|
+
|
533
|
+
puts (" █████╗ ██╗ ██╗ ██████╗ ██╗ ██╗".colorize(:blue)).center(95)
|
534
|
+
puts ("██╔═══╝ ██║ ██║██╔═══██╗██║ ██║".colorize(:blue)).center(95)
|
535
|
+
puts ("███████╗███████║██║ ██║██║ █╗ ██║".colorize(:blue)).center(95)
|
536
|
+
puts ("╚════██║██╔══██║██║ ██║██║███╗██║".colorize(:blue)).center(95)
|
537
|
+
puts ("██████╔╝██║ ██║╚██████╔╝╚███╔███╔╝".colorize(:blue)).center(95)
|
538
|
+
puts ("╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ".colorize(:blue)).center(95)
|
546
539
|
end
|
547
540
|
|
548
541
|
def display_welcome_screen
|
549
542
|
display_game_logo
|
550
|
-
|
551
|
-
|
552
|
-
|
543
|
+
puts ""
|
544
|
+
display_info_box(:info, "Welcome to Git Game Show! version " + GitGameShow::VERSION, [
|
545
|
+
" Test your team's knowledge with fun mini games based on git commit history.",
|
546
|
+
"",
|
547
|
+
" Choose to host a new game or join an existing one."
|
548
|
+
])
|
553
549
|
end
|
554
550
|
|
555
551
|
def prompt_for_host_options
|
@@ -593,5 +589,41 @@ module GitGameShow
|
|
593
589
|
|
594
590
|
"#{adjectives.sample}-#{nouns.sample}-#{rand(100..999)}"
|
595
591
|
end
|
592
|
+
|
593
|
+
def display_info_box(kind, heading, content, width = 80)
|
594
|
+
# Set color based on the kind of box
|
595
|
+
color = case kind.to_sym
|
596
|
+
when :info
|
597
|
+
:light_blue
|
598
|
+
when :success
|
599
|
+
:green
|
600
|
+
when :error
|
601
|
+
:red
|
602
|
+
else
|
603
|
+
:light_blue
|
604
|
+
end
|
605
|
+
|
606
|
+
# Calculate border width - using 78 as in existing boxes
|
607
|
+
content_width = width - 2
|
608
|
+
|
609
|
+
# Create the box with borders and heading in the specified color
|
610
|
+
puts ("╭" + "─" * content_width + "╮").colorize(color)
|
611
|
+
puts "│#{heading.center(content_width)}│".colorize(color)
|
612
|
+
puts ("├" + "─" * content_width + "┤").colorize(color)
|
613
|
+
|
614
|
+
# Split content by lines and format each line
|
615
|
+
if content.is_a?(String)
|
616
|
+
content.each_line do |line|
|
617
|
+
puts "│".colorize(color) + "#{line.chomp}".ljust(content_width) + "│".colorize(color)
|
618
|
+
end
|
619
|
+
elsif content.is_a?(Array)
|
620
|
+
content.each do |line|
|
621
|
+
puts "│".colorize(color) + "#{line}".ljust(content_width) + "│".colorize(color)
|
622
|
+
end
|
623
|
+
end
|
624
|
+
|
625
|
+
puts ("╰" + "─" * content_width + "╯").colorize(color)
|
626
|
+
puts ""
|
627
|
+
end
|
596
628
|
end
|
597
629
|
end
|