Skip to content

Commit bfb43aa

Browse files
fix: Bugs
1 parent 909ab53 commit bfb43aa

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

app/Console/Commands/BuzzerServer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private function loopLEDs(): void
7878
{
7979
while (true) {
8080
foreach ($this->ledPins as $id => $pin) {
81-
echo 'Turning on '.$id."\n";
81+
echo 'Turning on ' . $id . "\n";
8282
$pin->turnOff();
8383
sleep(1);
8484
$pin->turnOn();
@@ -94,11 +94,11 @@ private function checkButtons(): void
9494
$this->info("Button on pin #{$index} is pressed");
9595

9696
try {
97-
Http::get('http://sierra.local:8000/api/buzzer', [
97+
Http::timeout(1)->get('http://sierra.local:8000/api/buzzer', [
9898
'pin_id' => $index,
9999
]);
100100
} catch (Exception $e) {
101-
$this->error("Failed to send request for pin #{$index}: ".$e->getMessage());
101+
$this->error("Failed to send request for pin #{$index}: " . $e->getMessage());
102102
}
103103

104104
for ($i = 0; $i < 5; $i++) {

app/Http/Controllers/Api/BuzzerController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Exception;
99
use Illuminate\Http\JsonResponse;
1010
use Illuminate\Http\Request;
11+
use RuntimeException;
1112

1213
class BuzzerController extends Controller
1314
{
@@ -37,6 +38,10 @@ public function __invoke(Request $request): JsonResponse
3738
};
3839

3940
try {
41+
if ($team->game->current_team_id) {
42+
throw new RuntimeException('Another team already has the buzzer');
43+
}
44+
4045
// Use centralized buzzer handling logic
4146
$this->buzzerService->handleBuzzerPress($team);
4247

app/Livewire/LightningRound.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ class LightningRound extends Component
2424
public function mount($gameId)
2525
{
2626
$this->game = Game::with('lightningQuestions', 'teams')->findOrFail($gameId);
27+
28+
// Clear any lingering team selection from the main game
29+
if ($this->game->current_team_id) {
30+
$this->game->update(['current_team_id' => null]);
31+
$this->game->refresh();
32+
33+
// Broadcast to clear team selection on all clients
34+
broadcast(new \App\Events\GameStateChanged($this->game->id, 'team-deselected'));
35+
}
36+
2737
$this->loadCurrentQuestion();
2838
}
2939

0 commit comments

Comments
 (0)