Archived
1
0
Fork 0

Minor fixes.

This commit is contained in:
Henrik Hautakoski 2021-11-04 12:14:52 +01:00
parent ddf09fe00c
commit c8b93095dc
7 changed files with 26 additions and 32 deletions

View file

@ -19,7 +19,6 @@ class GameBoard
*/
protected GameBoardState $state;
/**
* Create a new board.
*/
@ -56,7 +55,7 @@ class GameBoard
/**
* Clear the game board.
*/
public function clear()
public function clear() : void
{
$this->state->clear();
}
@ -72,6 +71,8 @@ class GameBoard
/**
* Regenerate the board with new cards.
*
* @throw NotEnoughCardsException
*/
public function regenerate(GameSettings $settings) : self
{

View file

@ -153,7 +153,7 @@ class GameBoardState
/**
*
*/
protected function update()
protected function update() : void
{
foreach($this->state as $pos => $_) {
$this->state[$pos] = self::STATE_PRESSED;
@ -207,10 +207,6 @@ class GameBoardState
if (!$this->isPressed($pos)) {
return [];
}
/*
if ($this->state[$pos] == self::STATE_WIN) {
continue;
} */
$cards[] = $pos;
}
@ -229,10 +225,6 @@ class GameBoardState
if (!$this->isPressed($pos)) {
return [];
}
/*
if ($this->state[$pos] == self::STATE_WIN) {
continue;
} */
$cards[] = $pos;
}

View file

@ -4,15 +4,21 @@ namespace App\Game;
class GameService
{
/**
* The game session
*/
protected GameSession $session;
/**
* Construct a new Game Service
*/
public function __construct(GameSession $session)
{
$this->session = $session;
}
/**
*
* Get the current session
*/
public function session() : GameSession
{
@ -24,11 +30,11 @@ class GameService
*/
public function newSession(?GameSettings $settings = null) : self
{
// Generate new cards
if (!$settings) {
$settings = $this->session()->getSettings();
}
// Generate a new board
$this->session->getBoard()->regenerate($settings);
return $this;

View file

@ -17,10 +17,8 @@ class GameSession
protected GameSettings $settings;
/**
*
* Create a new GameSession
*/
//protected $cards;
public function __construct(GameBoard $board, GameSettings $settings)
{
$this->board = $board;
@ -28,7 +26,7 @@ class GameSession
}
/**
*
* Get the board
*/
public function getBoard() : GameBoard
{
@ -36,7 +34,7 @@ class GameSession
}
/**
*
* Get the board state
*/
public function getBoardState() : GameBoardState
{
@ -44,7 +42,7 @@ class GameSession
}
/**
*
* Get Cards
*/
public function getCards() : Collection
{
@ -52,7 +50,7 @@ class GameSession
}
/**
*
* Get Settings
*/
public function getSettings() : GameSettings
{
@ -60,10 +58,11 @@ class GameSession
}
/**
*
* Set new settings
*/
public function setSettings(GameSettings $settings)
public function setSettings(GameSettings $settings) : self
{
$this->settings = $settings;
return $this;
}
}

View file

@ -16,6 +16,9 @@ class Character extends Model
'name',
];
/**
* Get all cards associated with this character
*/
public function cards()
{
return $this->hasMany(Card::class);

View file

@ -16,6 +16,9 @@ class Raid extends Model
'name',
];
/**
* Get all cards associated with this raid
*/
public function cards()
{
return $this->hasMany(Card::class);

View file

@ -47,14 +47,4 @@ class Setting extends Model
{
return $q->where('id', Hashids::decode($hash));
}
/*
public function __call($method, $parameters)
{
if ($method == 'find' && is_string($parameters[0])) {
$parameters[0] = Hashids::decode($$parameters[0]);
}
return parent::__call($method, $parameters);
} */
}