git_game_show 0.2.1 → 0.2.2
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 -0
- data/lib/git_game_show/core/game_state.rb +120 -0
- data/lib/git_game_show/core/mini_game_loader.rb +55 -0
- data/lib/git_game_show/core/player_manager.rb +61 -0
- data/lib/git_game_show/core/question_manager.rb +120 -0
- data/lib/git_game_show/game_server.rb +47 -1603
- data/lib/git_game_show/message_type.rb +18 -0
- data/lib/git_game_show/network/message_handler.rb +241 -0
- data/lib/git_game_show/network/server.rb +52 -0
- data/lib/git_game_show/player_client.rb +14 -14
- data/lib/git_game_show/server_handler.rb +299 -0
- data/lib/git_game_show/ui/console.rb +66 -0
- data/lib/git_game_show/ui/message_area.rb +7 -0
- data/lib/git_game_show/ui/renderer.rb +232 -0
- data/lib/git_game_show/ui/sidebar.rb +116 -0
- data/lib/git_game_show/ui/welcome_screen.rb +40 -0
- data/lib/git_game_show/version.rb +1 -1
- data/lib/git_game_show.rb +40 -17
- metadata +15 -2
@@ -0,0 +1,66 @@
|
|
1
|
+
module GitGameShow
|
2
|
+
# Handles console input and command processing
|
3
|
+
class Console
|
4
|
+
def initialize(server_handler, renderer)
|
5
|
+
@server_handler = server_handler
|
6
|
+
@renderer = renderer
|
7
|
+
end
|
8
|
+
|
9
|
+
def setup_command_handler
|
10
|
+
# Log initial instructions
|
11
|
+
@renderer.log_message("Available commands: help, start, exit", :cyan)
|
12
|
+
@renderer.log_message("Type a command and press Enter", :cyan)
|
13
|
+
@renderer.log_message("Server is running. Waiting for players to join...", :green)
|
14
|
+
|
15
|
+
# Handle commands in a separate thread
|
16
|
+
Thread.new do
|
17
|
+
loop do
|
18
|
+
@renderer.draw_command_prompt
|
19
|
+
command = gets&.chomp&.downcase
|
20
|
+
next unless command
|
21
|
+
|
22
|
+
# Process commands
|
23
|
+
handle_command(command)
|
24
|
+
|
25
|
+
# Small delay to process any display changes
|
26
|
+
sleep 0.1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def handle_command(command)
|
34
|
+
case command
|
35
|
+
when 'start'
|
36
|
+
@server_handler.handle_start_command
|
37
|
+
when 'help'
|
38
|
+
show_help
|
39
|
+
when 'end'
|
40
|
+
@server_handler.handle_end_command
|
41
|
+
when 'reset'
|
42
|
+
@server_handler.handle_reset_command
|
43
|
+
when 'exit'
|
44
|
+
handle_exit_command
|
45
|
+
else
|
46
|
+
@renderer.log_message("Unknown command: #{command}. Type 'help' for available commands.", :red)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def show_help
|
51
|
+
@renderer.log_message("Available commands:", :cyan)
|
52
|
+
@renderer.log_message(" start - Start the game with current players", :cyan)
|
53
|
+
@renderer.log_message(" end - End current game and show final scores", :cyan)
|
54
|
+
@renderer.log_message(" reset - Manually reset players to waiting room (after game ends)", :cyan)
|
55
|
+
@renderer.log_message(" help - Show this help message", :cyan)
|
56
|
+
@renderer.log_message(" exit - Shut down the server and exit", :cyan)
|
57
|
+
end
|
58
|
+
|
59
|
+
def handle_exit_command
|
60
|
+
# Clean up before exiting
|
61
|
+
@renderer.log_message("Shutting down server...", :yellow)
|
62
|
+
@renderer.cleanup
|
63
|
+
EM.stop_event_loop
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,232 @@
|
|
1
|
+
module GitGameShow
|
2
|
+
# Main UI renderer for terminal display
|
3
|
+
class Renderer
|
4
|
+
def initialize
|
5
|
+
@message_log = []
|
6
|
+
@cursor = TTY::Cursor
|
7
|
+
|
8
|
+
# Get terminal dimensions
|
9
|
+
@terminal_width = `tput cols`.to_i rescue 80
|
10
|
+
@terminal_height = `tput lines`.to_i rescue 24
|
11
|
+
|
12
|
+
# Calculate layout
|
13
|
+
@main_width = (@terminal_width * 0.7).to_i
|
14
|
+
@sidebar_width = @terminal_width - @main_width - 3 # 3 for border
|
15
|
+
|
16
|
+
# The fixed line for command input (near bottom of screen)
|
17
|
+
@command_line = @terminal_height - 3
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup
|
21
|
+
# Clear screen and hide cursor
|
22
|
+
print @cursor.clear_screen
|
23
|
+
print @cursor.hide
|
24
|
+
|
25
|
+
# Draw initial UI
|
26
|
+
draw_ui_frame
|
27
|
+
end
|
28
|
+
|
29
|
+
def cleanup
|
30
|
+
print @cursor.show # Make sure cursor is visible
|
31
|
+
print @cursor.clear_screen
|
32
|
+
end
|
33
|
+
|
34
|
+
def draw_ui_frame
|
35
|
+
# Clear screen
|
36
|
+
print @cursor.clear_screen
|
37
|
+
|
38
|
+
# Draw horizontal divider line between main area and command area
|
39
|
+
print @cursor.move_to(0, @command_line - 1)
|
40
|
+
print "═" * (@terminal_width - @sidebar_width - 3) + "╧" + "═" * (@sidebar_width + 2)
|
41
|
+
|
42
|
+
# Draw vertical divider line between main area and sidebar
|
43
|
+
print @cursor.move_to(@main_width, 0)
|
44
|
+
print "│"
|
45
|
+
print @cursor.move_to(@main_width, 1)
|
46
|
+
print "│"
|
47
|
+
print @cursor.move_to(@main_width, 2)
|
48
|
+
print "╞═"
|
49
|
+
(3...@command_line-1).each do |line|
|
50
|
+
print @cursor.move_to(@main_width, line)
|
51
|
+
print "│"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def draw_welcome_banner
|
56
|
+
# Position cursor at top left
|
57
|
+
lines = [
|
58
|
+
" ██████╗ ".colorize(:red) + " ██████╗ ".colorize(:green) + " █████╗".colorize(:blue),
|
59
|
+
"██╔════╝ ".colorize(:red) + " ██╔════╝ ".colorize(:green) + " ██╔═══╝".colorize(:blue),
|
60
|
+
"██║ ███╗".colorize(:red) + " ██║ ███╗".colorize(:green) + " ███████╗".colorize(:blue),
|
61
|
+
"██║ ██║".colorize(:red) + " ██║ ██║".colorize(:green) + " ╚════██║".colorize(:blue),
|
62
|
+
"╚██████╔╝".colorize(:red) + " ╚██████╔╝".colorize(:green) + " ██████╔╝".colorize(:blue),
|
63
|
+
" ╚═════╝ ".colorize(:red) + " ╚═════╝ ".colorize(:green) + " ╚═════╝ ".colorize(:blue),
|
64
|
+
]
|
65
|
+
|
66
|
+
start_y = 1
|
67
|
+
lines.each_with_index do |line, i|
|
68
|
+
print @cursor.move_to((@main_width - 28) / 2, start_y + i)
|
69
|
+
print line
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def draw_join_link(join_link)
|
74
|
+
# Copy the join link to clipboard
|
75
|
+
Clipboard.copy(join_link)
|
76
|
+
|
77
|
+
link_box_width = [join_link.length + 6, @main_width - 10].min
|
78
|
+
start_x = (@main_width - link_box_width) / 2
|
79
|
+
start_y = 8
|
80
|
+
|
81
|
+
print @cursor.move_to(start_x, start_y)
|
82
|
+
print "╭" + "─" * (link_box_width - 2) + "╮"
|
83
|
+
|
84
|
+
print @cursor.move_to(start_x, start_y + 1)
|
85
|
+
print "│" + " Join Link (Copied to Clipboard) ".center(link_box_width - 2).colorize(:green) + "│"
|
86
|
+
|
87
|
+
print @cursor.move_to(start_x, start_y + 2)
|
88
|
+
print "│" + join_link.center(link_box_width - 2).colorize(:yellow) + "│"
|
89
|
+
|
90
|
+
print @cursor.move_to(start_x, start_y + 3)
|
91
|
+
print "╰" + "─" * (link_box_width - 2) + "╯"
|
92
|
+
|
93
|
+
# Also log that the link was copied
|
94
|
+
log_message("Join link copied to clipboard", :green)
|
95
|
+
end
|
96
|
+
|
97
|
+
def log_message(message, color = :white)
|
98
|
+
# Add message to log
|
99
|
+
@message_log << {text: message, color: color}
|
100
|
+
|
101
|
+
# Keep only last few messages
|
102
|
+
@message_log = @message_log.last(15) if @message_log.size > 15
|
103
|
+
|
104
|
+
# Redraw message area
|
105
|
+
draw_message_area
|
106
|
+
|
107
|
+
# Return cursor to command prompt
|
108
|
+
draw_command_prompt
|
109
|
+
end
|
110
|
+
|
111
|
+
def draw_message_area
|
112
|
+
# Calculate message area dimensions
|
113
|
+
message_area_start = 18
|
114
|
+
message_area_height = @command_line - message_area_start - 2
|
115
|
+
|
116
|
+
# Clear message area
|
117
|
+
(message_area_start..(@command_line-2)).each do |line|
|
118
|
+
print @cursor.move_to(1, line)
|
119
|
+
print " " * (@main_width - 2)
|
120
|
+
end
|
121
|
+
|
122
|
+
# Draw most recent messages
|
123
|
+
display_messages = @message_log.last(message_area_height)
|
124
|
+
display_messages.each_with_index do |msg, index|
|
125
|
+
print @cursor.move_to(1, message_area_start + index)
|
126
|
+
# Truncate message to fit within main width to prevent overflow
|
127
|
+
truncated_text = msg[:text][0...(@main_width - 3)]
|
128
|
+
print truncated_text.colorize(msg[:color])
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def draw_command_prompt
|
133
|
+
# Clear command line and two lines below to prevent commit info bleeding
|
134
|
+
print @cursor.move_to(0, @command_line)
|
135
|
+
print " " * @terminal_width
|
136
|
+
print @cursor.move_to(0, @command_line + 1)
|
137
|
+
print " " * @terminal_width
|
138
|
+
print @cursor.move_to(0, @command_line + 2)
|
139
|
+
print " " * @terminal_width
|
140
|
+
|
141
|
+
# Draw command prompt
|
142
|
+
print @cursor.move_to(0, @command_line)
|
143
|
+
print "Command> ".colorize(:green)
|
144
|
+
|
145
|
+
# Position cursor after prompt
|
146
|
+
print @cursor.move_to(9, @command_line)
|
147
|
+
print @cursor.show
|
148
|
+
end
|
149
|
+
|
150
|
+
def draw_game_over(winner, scores)
|
151
|
+
# Safety check for winner
|
152
|
+
if !winner || !winner[0] || !winner[1]
|
153
|
+
log_message("Error: Invalid winner data", :red)
|
154
|
+
return
|
155
|
+
end
|
156
|
+
|
157
|
+
# Create a safe copy of scores to work with
|
158
|
+
safe_scores = {}
|
159
|
+
begin
|
160
|
+
if scores && !scores.empty?
|
161
|
+
scores.each do |player, score|
|
162
|
+
next unless player && player.to_s != ""
|
163
|
+
safe_scores[player.to_s] = score.to_i
|
164
|
+
end
|
165
|
+
end
|
166
|
+
rescue => e
|
167
|
+
log_message("Error copying scores: #{e.message}", :red)
|
168
|
+
end
|
169
|
+
|
170
|
+
# Use log messages for display
|
171
|
+
divider = "=" * (@main_width - 5)
|
172
|
+
log_message(divider, :yellow)
|
173
|
+
log_message("🏆 GAME OVER - FINAL SCORES 🏆", :yellow)
|
174
|
+
|
175
|
+
# Announce winner
|
176
|
+
winner_name = winner[0].to_s
|
177
|
+
winner_name = winner_name.length > 20 ? "#{winner_name[0...17]}..." : winner_name
|
178
|
+
winner_score = winner[1].to_i
|
179
|
+
log_message("Winner: #{winner_name} with #{winner_score} points!", :green)
|
180
|
+
|
181
|
+
# Show leaderboard
|
182
|
+
log_message("Leaderboard:", :cyan)
|
183
|
+
|
184
|
+
# Sort scores safely
|
185
|
+
sorted_scores = []
|
186
|
+
begin
|
187
|
+
sorted_scores = safe_scores.sort_by { |_, score| -(score || 0) }.to_a
|
188
|
+
rescue => e
|
189
|
+
log_message("Error sorting scores for display: #{e.message}", :red)
|
190
|
+
sorted_scores = safe_scores.to_a
|
191
|
+
end
|
192
|
+
|
193
|
+
max_to_show = 10
|
194
|
+
entries_to_show = [sorted_scores.size, max_to_show].min
|
195
|
+
|
196
|
+
sorted_scores.take(entries_to_show).each_with_index do |score_entry, index|
|
197
|
+
# Extra safety check for each entry
|
198
|
+
next unless score_entry && score_entry.is_a?(Array) && score_entry.size >= 2
|
199
|
+
|
200
|
+
name = score_entry[0]
|
201
|
+
score = score_entry[1]
|
202
|
+
|
203
|
+
# Safely handle name and score
|
204
|
+
player_name = name.to_s
|
205
|
+
player_score = score.to_i
|
206
|
+
|
207
|
+
# Truncate name if needed
|
208
|
+
display_name = player_name.length > 15 ? "#{player_name[0...12]}..." : player_name
|
209
|
+
|
210
|
+
# Format based on position
|
211
|
+
case index
|
212
|
+
when 0
|
213
|
+
log_message("🥇 #{display_name}: #{player_score} points", :yellow)
|
214
|
+
when 1
|
215
|
+
log_message("🥈 #{display_name}: #{player_score} points", :light_blue)
|
216
|
+
when 2
|
217
|
+
log_message("🥉 #{display_name}: #{player_score} points", :light_magenta)
|
218
|
+
else
|
219
|
+
log_message("#{(index + 1).to_s}. #{display_name}: #{player_score} points", :white)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
# If there are more players than shown, add a note
|
224
|
+
if sorted_scores.size > max_to_show
|
225
|
+
log_message("... and #{sorted_scores.size - max_to_show} more", :light_black)
|
226
|
+
end
|
227
|
+
|
228
|
+
log_message(divider, :yellow)
|
229
|
+
log_message("Ready for a new game! Type 'start' when players have joined.", :green)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module GitGameShow
|
2
|
+
# Manages the sidebar display
|
3
|
+
class Sidebar
|
4
|
+
def initialize(renderer)
|
5
|
+
@renderer = renderer
|
6
|
+
@cursor = TTY::Cursor
|
7
|
+
|
8
|
+
# Get terminal dimensions
|
9
|
+
@terminal_width = `tput cols`.to_i rescue 80
|
10
|
+
@terminal_height = `tput lines`.to_i rescue 24
|
11
|
+
|
12
|
+
# Calculate layout
|
13
|
+
@main_width = (@terminal_width * 0.7).to_i
|
14
|
+
@sidebar_width = @terminal_width - @main_width - 3 # 3 for border
|
15
|
+
|
16
|
+
# The fixed line for command input (near bottom of screen)
|
17
|
+
@command_line = @terminal_height - 3
|
18
|
+
end
|
19
|
+
|
20
|
+
def draw_header
|
21
|
+
# Draw sidebar header
|
22
|
+
print @cursor.move_to(@main_width + 2, 1)
|
23
|
+
print "Players".colorize(:cyan)
|
24
|
+
|
25
|
+
print @cursor.move_to(@main_width + 2, 2)
|
26
|
+
print "═" * (@sidebar_width - 2)
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_player_list(players, scores)
|
30
|
+
draw_header
|
31
|
+
|
32
|
+
# Clear player area
|
33
|
+
(3..(@command_line-3)).each do |line|
|
34
|
+
print @cursor.move_to(@main_width + 2, line)
|
35
|
+
print " " * (@sidebar_width - 2)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Show player count
|
39
|
+
print @cursor.move_to(@main_width + 2, 3)
|
40
|
+
print "Total: #{players.size} player(s)".colorize(:yellow)
|
41
|
+
|
42
|
+
# Calculate available space for the player list
|
43
|
+
max_visible_players = @command_line - 8 # Allow space for headers, counts and scrolling indicators
|
44
|
+
|
45
|
+
# List players with scrolling if needed
|
46
|
+
if players.empty?
|
47
|
+
print @cursor.move_to(@main_width + 2, 5)
|
48
|
+
print "Waiting for players...".colorize(:light_black)
|
49
|
+
else
|
50
|
+
# Sort players by score (highest first)
|
51
|
+
sorted_players = players.sort_by { |name| -(scores[name] || 0) }
|
52
|
+
|
53
|
+
# Show scrolling indicator if needed
|
54
|
+
if players.size > max_visible_players
|
55
|
+
print @cursor.move_to(@main_width + 2, 4)
|
56
|
+
print "Showing #{max_visible_players} of #{players.size}:".colorize(:yellow)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Determine which players to display (show top N players by score)
|
60
|
+
visible_players = sorted_players.take(max_visible_players)
|
61
|
+
|
62
|
+
# Display visible players with their scores
|
63
|
+
visible_players.each_with_index do |name, index|
|
64
|
+
print @cursor.move_to(@main_width + 2, 5 + index)
|
65
|
+
|
66
|
+
# Get score (default to 0 if not found)
|
67
|
+
score = scores[name] || 0
|
68
|
+
score_str = score.to_s
|
69
|
+
|
70
|
+
# Calculate available space for name and right-justified score
|
71
|
+
usable_width = @sidebar_width - 6
|
72
|
+
prefix_width = 3 # Account for emoji or number + dot + space
|
73
|
+
|
74
|
+
# Apply medal emoji for top 3 players when in game
|
75
|
+
prefix = ""
|
76
|
+
if scores.any?
|
77
|
+
prefix = case index
|
78
|
+
when 0 then "🥇 "
|
79
|
+
when 1 then "🥈 "
|
80
|
+
when 2 then "🥉 "
|
81
|
+
else "#{index + 1}. "
|
82
|
+
end
|
83
|
+
else
|
84
|
+
prefix = "#{index + 1}. "
|
85
|
+
end
|
86
|
+
|
87
|
+
# Calculate how much space we have for the name
|
88
|
+
max_name_length = usable_width - score_str.length - 1 # 1 space before score
|
89
|
+
|
90
|
+
# Truncate long names
|
91
|
+
truncated_name = name.length > max_name_length ?
|
92
|
+
"#{name[0...(max_name_length-3)]}..." :
|
93
|
+
name
|
94
|
+
|
95
|
+
# Print player name
|
96
|
+
print @cursor.move_to(@main_width + 2, 5 + index)
|
97
|
+
print "#{prefix}#{truncated_name}".colorize(:light_blue)
|
98
|
+
|
99
|
+
# Print right-justified score
|
100
|
+
score_position = @main_width + usable_width
|
101
|
+
print @cursor.move_to(score_position, 5 + index)
|
102
|
+
print score_str.colorize(:light_blue)
|
103
|
+
end
|
104
|
+
|
105
|
+
# If there are more players than can be shown, add an indicator
|
106
|
+
if players.size > max_visible_players
|
107
|
+
print @cursor.move_to(@main_width + 2, 5 + max_visible_players)
|
108
|
+
print "... and #{players.size - max_visible_players} more".colorize(:light_black)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Return cursor to command prompt
|
113
|
+
@renderer.draw_command_prompt
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module GitGameShow
|
2
|
+
# Handles the welcome screen display
|
3
|
+
class WelcomeScreen
|
4
|
+
def self.display_ggs
|
5
|
+
# Clear screen
|
6
|
+
system('clear') || system('cls')
|
7
|
+
|
8
|
+
puts ""
|
9
|
+
lines = [
|
10
|
+
" ██████╗ ".colorize(:red) + " ██████╗ ".colorize(:green) + " █████╗".colorize(:blue),
|
11
|
+
"██╔════╝ ".colorize(:red) + " ██╔════╝ ".colorize(:green) + " ██╔═══╝".colorize(:blue),
|
12
|
+
"██║ ███╗".colorize(:red) + " ██║ ███╗".colorize(:green) + " ███████╗".colorize(:blue),
|
13
|
+
"██║ ██║".colorize(:red) + " ██║ ██║".colorize(:green) + " ╚════██║".colorize(:blue),
|
14
|
+
"╚██████╔╝".colorize(:red) + " ╚██████╔╝".colorize(:green) + " ██████╔╝".colorize(:blue),
|
15
|
+
" ╚═════╝ ".colorize(:red) + " ╚═════╝ ".colorize(:green) + " ╚═════╝ ".colorize(:blue),
|
16
|
+
]
|
17
|
+
lines.each { |line| puts line.center(120) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.display_game_logo
|
21
|
+
# Clear screen
|
22
|
+
system('clear') || system('cls')
|
23
|
+
|
24
|
+
puts ""
|
25
|
+
puts (" ██████╗ ██╗████████╗".colorize(:red) + " ██████╗ █████╗ ███╗ ███╗███████╗".colorize(:green)).center(110)
|
26
|
+
puts ("██╔════╝ ██║╚══██╔══╝".colorize(:red) + " ██╔════╝ ██╔══██╗████╗ ████║██╔════╝".colorize(:green)).center(110)
|
27
|
+
puts ("██║ ███╗██║ ██║ ".colorize(:red) + " ██║ ███╗███████║██╔████╔██║█████╗ ".colorize(:green)).center(110)
|
28
|
+
puts ("██║ ██║██║ ██║ ".colorize(:red) + " ██║ ██║██╔══██║██║╚██╔╝██║██╔══╝ ".colorize(:green)).center(110)
|
29
|
+
puts ("╚██████╔╝██║ ██║ ".colorize(:red) + " ╚██████╔╝██║ ██║██║ ╚═╝ ██║███████╗".colorize(:green)).center(110)
|
30
|
+
puts (" ╚═════╝ ╚═╝ ╚═╝ ".colorize(:red) + " ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝".colorize(:green)).center(110)
|
31
|
+
|
32
|
+
puts (" █████╗ ██╗ ██╗ ██████╗ ██╗ ██╗".colorize(:blue)).center(95)
|
33
|
+
puts ("██╔═══╝ ██║ ██║██╔═══██╗██║ ██║".colorize(:blue)).center(95)
|
34
|
+
puts ("███████╗███████║██║ ██║██║ █╗ ██║".colorize(:blue)).center(95)
|
35
|
+
puts ("╚════██║██╔══██║██║ ██║██║███╗██║".colorize(:blue)).center(95)
|
36
|
+
puts ("██████╔╝██║ ██║╚██████╔╝╚███╔███╔╝".colorize(:blue)).center(95)
|
37
|
+
puts ("╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ".colorize(:blue)).center(95)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/git_game_show.rb
CHANGED
@@ -27,24 +27,47 @@ module GitGameShow
|
|
27
27
|
transition_delay: 10 # seconds between rounds
|
28
28
|
}.freeze
|
29
29
|
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
ROUND_RESULT = 'round_result'
|
39
|
-
SCOREBOARD = 'scoreboard'
|
40
|
-
GAME_END = 'game_end'
|
41
|
-
GAME_RESET = 'game_reset' # New message type for resetting the game
|
42
|
-
CHAT = 'chat'
|
43
|
-
end
|
30
|
+
# File structure is now:
|
31
|
+
# 1. Load core message types first
|
32
|
+
# 2. Load version file
|
33
|
+
# 3. Load core files
|
34
|
+
# 4. Load UI components
|
35
|
+
# 5. Load network components
|
36
|
+
# 6. Load main coordination files (server_handler, game_server)
|
37
|
+
# 7. Load mini-games
|
44
38
|
end
|
45
39
|
|
46
|
-
# Load
|
47
|
-
|
40
|
+
# Load message types
|
41
|
+
require_relative 'git_game_show/message_type'
|
42
|
+
|
43
|
+
# Load version file
|
44
|
+
require_relative 'git_game_show/version'
|
45
|
+
|
46
|
+
# Load core components
|
47
|
+
require_relative 'git_game_show/core/game_state'
|
48
|
+
require_relative 'git_game_show/core/player_manager'
|
49
|
+
require_relative 'git_game_show/core/mini_game_loader'
|
50
|
+
require_relative 'git_game_show/core/question_manager'
|
51
|
+
|
52
|
+
# Load UI components
|
53
|
+
require_relative 'git_game_show/ui/renderer'
|
54
|
+
require_relative 'git_game_show/ui/sidebar'
|
55
|
+
require_relative 'git_game_show/ui/console'
|
56
|
+
require_relative 'git_game_show/ui/welcome_screen'
|
57
|
+
|
58
|
+
# Load network components
|
59
|
+
require_relative 'git_game_show/network/server'
|
60
|
+
require_relative 'git_game_show/network/message_handler'
|
61
|
+
|
62
|
+
# Load coordination files
|
63
|
+
require_relative 'git_game_show/server_handler'
|
64
|
+
require_relative 'git_game_show/game_server'
|
65
|
+
|
66
|
+
# Load other required files
|
67
|
+
require_relative 'git_game_show/cli'
|
68
|
+
require_relative 'git_game_show/mini_game'
|
69
|
+
require_relative 'git_game_show/player_client'
|
70
|
+
require_relative 'git_game_show/updater' if File.exist?(File.join(__dir__, 'git_game_show', 'updater.rb'))
|
48
71
|
|
49
72
|
# Load all mini-games
|
50
|
-
Dir[File.join(__dir__, '..', 'mini_games', '*.rb')].sort.each { |file| require file }
|
73
|
+
Dir[File.join(__dir__, '..', 'mini_games', '*.rb')].sort.each { |file| require file }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_game_show
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Paulson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -207,9 +207,22 @@ files:
|
|
207
207
|
- bin/git-game-show
|
208
208
|
- lib/git_game_show.rb
|
209
209
|
- lib/git_game_show/cli.rb
|
210
|
+
- lib/git_game_show/core/game_state.rb
|
211
|
+
- lib/git_game_show/core/mini_game_loader.rb
|
212
|
+
- lib/git_game_show/core/player_manager.rb
|
213
|
+
- lib/git_game_show/core/question_manager.rb
|
210
214
|
- lib/git_game_show/game_server.rb
|
215
|
+
- lib/git_game_show/message_type.rb
|
211
216
|
- lib/git_game_show/mini_game.rb
|
217
|
+
- lib/git_game_show/network/message_handler.rb
|
218
|
+
- lib/git_game_show/network/server.rb
|
212
219
|
- lib/git_game_show/player_client.rb
|
220
|
+
- lib/git_game_show/server_handler.rb
|
221
|
+
- lib/git_game_show/ui/console.rb
|
222
|
+
- lib/git_game_show/ui/message_area.rb
|
223
|
+
- lib/git_game_show/ui/renderer.rb
|
224
|
+
- lib/git_game_show/ui/sidebar.rb
|
225
|
+
- lib/git_game_show/ui/welcome_screen.rb
|
213
226
|
- lib/git_game_show/updater.rb
|
214
227
|
- lib/git_game_show/version.rb
|
215
228
|
- mini_games/author_quiz.rb
|