1
0
Fork 0

app/Http/Livewire/Game.php: Implement jackpot.

This commit is contained in:
Henrik Hautakoski 2023-02-19 16:19:17 +01:00
parent 5881efeb75
commit 7b513f5040
2 changed files with 17 additions and 3 deletions

View file

@ -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);
}
}
/**

View file

@ -24,7 +24,7 @@ $card_class = 'absolute backface-hidden flex items-center justify-center border
<x-card :number="$item->id" :card="$item"
:win="$this->state->isWin($pos)"
:flipped="$this->state->isPressed($pos)"
wire:click="toggle({{ $pos }})" />
wire:click="toggle({{ $pos }}, {{ $item->jackpot }})" />
@endforeach
</div>
@ -37,7 +37,11 @@ $card_class = 'absolute backface-hidden flex items-center justify-center border
@if ($this->board->hasGameEnded())
<x-modal wire:loading.remove>
@if ($this->jackpot)
<h2 class="text-6xl mb-12"><span class="text-yellow-400">100</span> {{ __('Parse!') }}</h2>
@else
<h2 class="text-6xl mb-12">{{ __('Game over!') }}</h2>
@endif
<div class="flex justify-between space-x-2">
<x-button type="info" wire:click="clear">{{ __('Go again?') }}</x-button>
<x-button type="success" wire:click="restart">{{ __('New Game') }}</x-button>