Skip to content

Commit 97d3b7e

Browse files
feat: Right/Wrong sound effects
1 parent 6ffe2ef commit 97d3b7e

10 files changed

Lines changed: 73 additions & 50 deletions

File tree

config/jeopardy.php

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,48 +31,22 @@
3131

3232
'game_settings' => [
3333
'daily_double_min_value' => 300,
34-
'lightning_round_time_limit' => 30,
35-
'points_multiplier' => 1,
36-
],
37-
38-
'sound_effects' => [
39-
'daily_double' => 'sounds/daily-double.mp3',
4034
],
4135

4236
'categories' => [
43-
'Taylor\'s Version' => [
44-
'clues' => [
45-
100 => [
46-
'question' => 'Swift\'s emotional 2012 album title describes what developers see when tests fail',
47-
'answer' => 'What is "Red"?',
48-
],
49-
300 => [
50-
'question' => 'Taylor Otwell\'s take on server management and deployment, this SaaS platform lets you provision and manage servers without the command line hassle',
51-
'answer' => 'What is Laravel Forge?',
52-
],
53-
500 => [
54-
'question' => 'Taylor\'s 2014 hit about relationships gone wrong also describes what PHP displays when you echo an uninitialized variable',
55-
'answer' => 'What is "Blank Space"?',
56-
],
57-
1000 => [
58-
'question' => 'Before creating Laravel, Taylor Otwell programmed in this 1960s business language',
59-
'answer' => 'What is COBOL?',
60-
],
61-
],
62-
],
6337
'404: Category Not Found' => [
6438
'clues' => [
6539
100 => [
66-
'question' => 'This HTTP status code is returned when the client should authenticate itself',
67-
'answer' => 'What is 401 (Unauthorized)?',
40+
'question' => 'This Laravel tool provides an interactive shell for testing code',
41+
'answer' => 'What is Tinker?',
6842
],
6943
300 => [
70-
'question' => 'This package provides a beautiful debugging interface to inspect errors',
71-
'answer' => 'What is Debugbar for Laravel?',
44+
'question' => 'This Laravel blade directive is used to display unescaped HTML content',
45+
'answer' => 'What is "{!! !!}"?',
7246
],
7347
500 => [
74-
'question' => 'This error occurs when PHP runs out of allocated memory',
75-
'answer' => 'What is "Fatal error: Allowed Memory Size of X Bytes Exhausted"?',
48+
'question' => 'This HTTP header is commonly missing when CORS errors occur',
49+
'answer' => 'What is "Access-Control-Allow-Origin"?',
7650
],
7751
1000 => [
7852
'question' => 'This HTTP status code means "I\'m a teapot" and was an April Fool\'s joke',
@@ -95,7 +69,7 @@
9569
'answer' => 'What is Washington, DC?',
9670
],
9771
1000 => [
98-
'question' => 'This entrepreneur had the vision for the first Laracon.', // Hint: He is also knwn as the "Godfather of Laravel"
72+
'question' => 'This entrepreneur had the vision for the first Laracon.', // Hint: He is also known as the "Godfather of Laravel"
9973
'answer' => 'Who is Ian Landsman?',
10074
],
10175
],
@@ -140,6 +114,26 @@
140114
],
141115
],
142116
],
117+
'Taylor\'s Version' => [
118+
'clues' => [
119+
100 => [
120+
'question' => 'Swift\'s emotional 2012 album title describes what developers see when tests fail',
121+
'answer' => 'What is "Red"?',
122+
],
123+
300 => [
124+
'question' => 'Taylor Otwell\'s take on server management and deployment, this SaaS platform lets you provision and manage servers without the command line hassle',
125+
'answer' => 'What is Laravel Forge?',
126+
],
127+
500 => [
128+
'question' => 'Taylor\'s 2014 hit about relationships gone wrong also describes what PHP displays when you echo an uninitialized variable',
129+
'answer' => 'What is "Blank Space"?',
130+
],
131+
1000 => [
132+
'question' => 'Before creating Laravel, Taylor Otwell programmed in this 1960s business language',
133+
'answer' => 'What is COBOL?',
134+
],
135+
],
136+
],
143137
'Eloquently Speaking' => [
144138
'clues' => [
145139
100 => [
@@ -170,7 +164,7 @@
170164
['question' => 'What is the default Laravel testing framework?', 'answer' => 'Pest or PHPUnit'],
171165
['question' => 'What is Laravel\'s real-time event broadcasting tool?', 'answer' => 'Echo'],
172166
['question' => 'What is Laravel\'s blade directive for CSRF protection?', 'answer' => '@csrf'],
173-
['question' => 'Who is the found of Laravel News?', 'answer' => 'Eric Barnes'],
167+
['question' => 'Who is the founder of Laravel News?', 'answer' => 'Eric Barnes'],
174168

175169
// Laravel Commands
176170
['question' => 'What is the command to list all routes?', 'answer' => 'php artisan route:list'],
@@ -187,7 +181,7 @@
187181
['question' => 'What is the HTTP status code for forbidden?', 'answer' => '403'],
188182

189183
// Frontend/CSS
190-
['question' => 'What is the CSS framework used in this project?', 'answer' => 'Tailwind'],
184+
['question' => 'What is the CSS framework used in this project?', 'answer' => 'Tailwind CSS'],
191185
['question' => 'What is the JavaScript framework used for reactivity in Livewire?', 'answer' => 'Alpine.js'],
192186
['question' => 'What is the Tailwind CSS utility for spacing between flex items?', 'answer' => 'gap'],
193187
['question' => 'What is Tailwind\'s dark mode prefix?', 'answer' => 'dark:'],
@@ -207,7 +201,7 @@
207201
['question' => 'What database typically uses port 6379?', 'answer' => 'Redis'],
208202

209203
// Additional Laravel-specific questions
210-
['question' => 'What method skips X rows in an Eloquent query?', 'answer' => 'offset()'],
204+
['question' => 'What method skips X rows in an Eloquent query?', 'answer' => 'offset() or skip()'],
211205
['question' => 'What artisan command rolls back the last migration batch?', 'answer' => 'migrate:rollback'],
212206
['question' => 'What facade provides access to the cache?', 'answer' => 'Cache'],
213207
['question' => 'What middleware verifies CSRF tokens on POST requests?', 'answer' => 'VerifyCsrfToken'],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "module",
44
"scripts": {
55
"build": "vite build",
6-
"dev": "vite"
6+
"dev": "vite --host"
77
},
88
"dependencies": {
99
"@tailwindcss/vite": "^4.1.11",

public/sounds/answer-correct.wav

279 KB
Binary file not shown.

public/sounds/answer-incorrect.wav

260 KB
Binary file not shown.

public/sounds/buzzer.mp3

Whitespace-only changes.

public/sounds/correct.mp3

Whitespace-only changes.

public/sounds/incorrect.mp3

Whitespace-only changes.

resources/js/buzzer.js

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,23 @@ export function initBuzzerListener(gameId) {
1010
.listen('.buzzer.pressed', (e) => {
1111
console.log('Buzzer pressed event received:', e);
1212
playBuzzerSound(e.teamName);
13-
});
13+
})
14+
.listen('ScoreUpdated', (e) => {
15+
let soundFile = e.correct ? 'answer-correct' : 'answer-incorrect';
16+
17+
const audio = document.getElementById(soundFile);
18+
if (audio) {
19+
audio.currentTime = 0; // Reset to start
20+
audio.play().catch(error => {
21+
console.error('Error playing buzzer sound:', error);
22+
23+
// Show user-friendly error message
24+
if (error.name === 'NotAllowedError') {
25+
showAudioPermissionMessage();
26+
}
27+
});
28+
}
29+
})
1430

1531
// Also listen on the general buzzers channel
1632
window.Echo.channel('buzzers')
@@ -42,7 +58,7 @@ function playBuzzerSound(teamName) {
4258
audio.currentTime = 0; // Reset to start
4359
audio.play().catch(error => {
4460
console.error('Error playing buzzer sound:', error);
45-
61+
4662
// Show user-friendly error message
4763
if (error.name === 'NotAllowedError') {
4864
showAudioPermissionMessage();
@@ -58,7 +74,7 @@ function showAudioPermissionMessage() {
5874
if (existingMessage) {
5975
existingMessage.remove();
6076
}
61-
77+
6278
// Create message element
6379
const message = document.createElement('div');
6480
message.id = 'audio-permission-message';
@@ -81,7 +97,7 @@ function showAudioPermissionMessage() {
8197
max-width: 90%;
8298
text-align: center;
8399
`;
84-
100+
85101
message.innerHTML = `
86102
<div style="display: flex; align-items: center; gap: 12px;">
87103
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
@@ -92,7 +108,7 @@ function showAudioPermissionMessage() {
92108
<span>🔊 Click anywhere on the page to enable buzzer sounds</span>
93109
</div>
94110
`;
95-
111+
96112
// Add CSS animation
97113
const style = document.createElement('style');
98114
style.textContent = `
@@ -108,10 +124,10 @@ function showAudioPermissionMessage() {
108124
}
109125
`;
110126
document.head.appendChild(style);
111-
127+
112128
// Add to page
113129
document.body.appendChild(message);
114-
130+
115131
// Initialize audio on click
116132
const initAudio = () => {
117133
// Pre-play all audio elements with volume 0 to initialize them
@@ -124,19 +140,19 @@ function showAudioPermissionMessage() {
124140
audio.volume = 1;
125141
}).catch(e => console.log('Audio init skipped:', audio.id));
126142
});
127-
143+
128144
// Remove message with fade out
129145
message.style.animation = 'slideDown 0.3s ease-out reverse';
130146
setTimeout(() => message.remove(), 300);
131-
147+
132148
// Remove click listener
133149
document.removeEventListener('click', initAudio);
134150
console.log('Audio system initialized');
135151
};
136-
152+
137153
// Add click listener to entire document
138154
document.addEventListener('click', initAudio);
139-
155+
140156
// Auto-hide after 10 seconds
141157
setTimeout(() => {
142158
if (document.getElementById('audio-permission-message')) {
@@ -151,4 +167,4 @@ document.addEventListener('DOMContentLoaded', () => {
151167
if (window.gameId) {
152168
initBuzzerListener(window.gameId);
153169
}
154-
});
170+
});

resources/views/partials/buzzer-audio.blade.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,10 @@
1313
</audio>
1414
<audio id="buzzer-illuminate" preload="auto">
1515
<source src="/sounds/buzzer/illuminate.wav" type="audio/wav">
16-
</audio>
16+
</audio>
17+
<audio id="answer-correct" preload="auto">
18+
<source src="/sounds/answer-correct.wav" type="audio/wav">
19+
</audio>
20+
<audio id="answer-incorrect" preload="auto">
21+
<source src="/sounds/answer-incorrect.wav" type="audio/wav">
22+
</audio>

vite.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,12 @@ export default defineConfig({
1717
],
1818
server: {
1919
cors: true,
20+
host: true,
21+
port: 5173,
22+
hmr: {
23+
host: 'sierra.local',
24+
protocol: 'http',
25+
clientPort: 5173,
26+
},
2027
},
2128
});

0 commit comments

Comments
 (0)