From 7b513f504045ddfc4db7122cd5125a19f25a4f1e Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 19 Feb 2023 16:19:17 +0100 Subject: [PATCH] app/Http/Livewire/Game.php: Implement jackpot. --- app/Http/Livewire/Game.php | 14 ++++++++++++-- resources/views/game.blade.php | 6 +++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/Http/Livewire/Game.php b/app/Http/Livewire/Game.php index f13b34d..78d4fdf 100644 --- a/app/Http/Livewire/Game.php +++ b/app/Http/Livewire/Game.php @@ -4,6 +4,11 @@ namespace App\Http\Livewire; class Game extends GameComponent { + /** + * If we hit the jackpot or not. + */ + public bool $jackpot = true; + /** * Get the game session */ @@ -39,9 +44,14 @@ class Game extends GameComponent /** * Triggered wen a card is pressed. */ - public function toggle($pos) + public function toggle($pos, $jackpot) { - $this->state->toggle($pos); + if ($jackpot) { + $this->state->setAll(); + $this->jackpot = true; + } else { + $this->state->toggle($pos); + } } /** diff --git a/resources/views/game.blade.php b/resources/views/game.blade.php index 2ffd378..dfb917c 100644 --- a/resources/views/game.blade.php +++ b/resources/views/game.blade.php @@ -24,7 +24,7 @@ $card_class = 'absolute backface-hidden flex items-center justify-center border + wire:click="toggle({{ $pos }}, {{ $item->jackpot }})" /> @endforeach @@ -37,7 +37,11 @@ $card_class = 'absolute backface-hidden flex items-center justify-center border @if ($this->board->hasGameEnded()) + @if ($this->jackpot) +

100 {{ __('Parse!') }}

+ @else

{{ __('Game over!') }}

+ @endif
{{ __('Go again?') }} {{ __('New Game') }}