Skip to content

Commit 25f939e

Browse files
feat(host-control): allow deselecting active team
- Click active team button to deselect (sets no team as active) - Add visual feedback with checkmark on active team button - Update tooltip to indicate deselection action when hovering active team - Broadcast team-deselected event when clearing active team Also includes fix for negative score display in scoreboard
1 parent 8f57496 commit 25f939e

3 files changed

Lines changed: 38 additions & 19 deletions

File tree

app/Livewire/HostControl.php

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,37 @@ public function loadGame($gameId)
8383
// Team Selection
8484
public function selectCurrentTeam($teamId)
8585
{
86-
$this->currentTeam = Team::find($teamId);
86+
// If clicking on already selected team, deselect it
87+
if ($this->currentTeam && $this->currentTeam->id == $teamId) {
88+
$this->currentTeam = null;
89+
$this->game->current_team_id = null;
90+
$this->game->save();
8791

88-
// Update the database and ensure it's saved
89-
$this->game->current_team_id = $teamId;
90-
$this->game->save();
92+
Log::info('Team deselected', [
93+
'game_id' => $this->game->id,
94+
'previous_team_id' => $teamId,
95+
]);
9196

92-
// Verify the save worked
93-
Log::info('Team selected', [
94-
'game_id' => $this->game->id,
95-
'team_id' => $teamId,
96-
'saved_team_id' => $this->game->fresh()->current_team_id,
97-
]);
97+
// Broadcast team deselection to all clients
98+
broadcast(new GameStateChanged($this->game->id, 'team-deselected'));
99+
} else {
100+
// Select the new team
101+
$this->currentTeam = Team::find($teamId);
102+
103+
// Update the database and ensure it's saved
104+
$this->game->current_team_id = $teamId;
105+
$this->game->save();
106+
107+
// Verify the save worked
108+
Log::info('Team selected', [
109+
'game_id' => $this->game->id,
110+
'team_id' => $teamId,
111+
'saved_team_id' => $this->game->fresh()->current_team_id,
112+
]);
98113

99-
// Broadcast team selection to all clients
100-
broadcast(new GameStateChanged($this->game->id, 'team-selected', ['teamId' => $teamId]));
114+
// Broadcast team selection to all clients
115+
broadcast(new GameStateChanged($this->game->id, 'team-selected', ['teamId' => $teamId]));
116+
}
101117
}
102118

103119
// Clue Control

resources/views/livewire/host-control.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ class="font-bold text-green-400">${{ number_format($team->score) }}</span>
5252
<button wire:click="selectCurrentTeam({{ $team->id }})"
5353
class="cursor-pointer px-4 py-3 rounded-lg font-bold transition-all hover:scale-105
5454
{{ $currentTeam && $currentTeam->id === $team->id
55-
? 'bg-yellow-500 text-slate-900'
55+
? 'bg-yellow-500 text-slate-900 hover:bg-yellow-600'
5656
: 'bg-slate-700 hover:bg-slate-600 text-white' }}"
57-
title="Set as active team">
57+
title="{{ $currentTeam && $currentTeam->id === $team->id ? 'Click to deselect' : 'Set as active team' }}">
5858
@if($currentTeam && $currentTeam->id === $team->id)
59-
Active
59+
Active
6060
@else
6161
Set Active
6262
@endif

resources/views/livewire/team-scoreboard.blade.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ class="text-lg font-bold mb-3 tracking-wider uppercase transition-all duration-3
2929
class="text-3xl font-black transition-all duration-300
3030
{{ $team['score'] < 0 ? 'text-red-400' : 'text-white' }}
3131
{{ $hasRecentChange && $isCorrect ? 'animate-pulse' : '' }}">
32-
<span class="text-sm">$</span>
33-
@if($team['score'] < 0)
34-
<span class="text-red-400">-</span>
35-
@endif
32+
<span class="text-sm">
33+
@if($team['score'] < 0)
34+
<span class="text-red-400">-</span>
35+
@endif
36+
37+
$
38+
</span>
3639
<span>{{ number_format(abs($team['score'])) }}</span>
3740
</div>
3841

0 commit comments

Comments
 (0)