app/Http/Livewire/Game.php: Implement jackpot.
This commit is contained in:
parent
5881efeb75
commit
7b513f5040
2 changed files with 17 additions and 3 deletions
|
|
@ -4,6 +4,11 @@ namespace App\Http\Livewire;
|
||||||
|
|
||||||
class Game extends GameComponent
|
class Game extends GameComponent
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* If we hit the jackpot or not.
|
||||||
|
*/
|
||||||
|
public bool $jackpot = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the game session
|
* Get the game session
|
||||||
*/
|
*/
|
||||||
|
|
@ -39,9 +44,14 @@ class Game extends GameComponent
|
||||||
/**
|
/**
|
||||||
* Triggered wen a card is pressed.
|
* 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ $card_class = 'absolute backface-hidden flex items-center justify-center border
|
||||||
<x-card :number="$item->id" :card="$item"
|
<x-card :number="$item->id" :card="$item"
|
||||||
:win="$this->state->isWin($pos)"
|
:win="$this->state->isWin($pos)"
|
||||||
:flipped="$this->state->isPressed($pos)"
|
:flipped="$this->state->isPressed($pos)"
|
||||||
wire:click="toggle({{ $pos }})" />
|
wire:click="toggle({{ $pos }}, {{ $item->jackpot }})" />
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -37,7 +37,11 @@ $card_class = 'absolute backface-hidden flex items-center justify-center border
|
||||||
|
|
||||||
@if ($this->board->hasGameEnded())
|
@if ($this->board->hasGameEnded())
|
||||||
<x-modal wire:loading.remove>
|
<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>
|
<h2 class="text-6xl mb-12">{{ __('Game over!') }}</h2>
|
||||||
|
@endif
|
||||||
<div class="flex justify-between space-x-2">
|
<div class="flex justify-between space-x-2">
|
||||||
<x-button type="info" wire:click="clear">{{ __('Go again?') }}</x-button>
|
<x-button type="info" wire:click="clear">{{ __('Go again?') }}</x-button>
|
||||||
<x-button type="success" wire:click="restart">{{ __('New Game') }}</x-button>
|
<x-button type="success" wire:click="restart">{{ __('New Game') }}</x-button>
|
||||||
|
|
|
||||||
Reference in a new issue