72 lines
1.2 KiB
PHP
72 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
class Game extends GameComponent
|
|
{
|
|
/**
|
|
* If we hit the jackpot or not.
|
|
*/
|
|
public bool $jackpot = true;
|
|
|
|
/**
|
|
* Get the game session
|
|
*/
|
|
public function getSessionProperty()
|
|
{
|
|
return $this->service->session();
|
|
}
|
|
|
|
/**
|
|
* Get the game board.
|
|
*/
|
|
public function getBoardProperty()
|
|
{
|
|
return $this->session->getBoard();
|
|
}
|
|
|
|
/**
|
|
* Get the game state.
|
|
*/
|
|
public function getStateProperty()
|
|
{
|
|
return $this->session->getBoardState();
|
|
}
|
|
|
|
/**
|
|
* Clear everything.
|
|
*/
|
|
public function clear()
|
|
{
|
|
$this->board->clear();
|
|
}
|
|
|
|
/**
|
|
* Triggered wen a card is pressed.
|
|
*/
|
|
public function toggle($pos, $jackpot)
|
|
{
|
|
if ($jackpot) {
|
|
$this->state->setAll();
|
|
$this->jackpot = true;
|
|
} else {
|
|
$this->state->toggle($pos);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Reset game session.
|
|
*/
|
|
public function restart()
|
|
{
|
|
$this->service->newSession();
|
|
}
|
|
|
|
/**
|
|
* Render the game board.
|
|
*/
|
|
public function render()
|
|
{
|
|
return view('game');
|
|
}
|
|
}
|