diff --git a/app/Game/GameBoard.php b/app/Game/GameBoard.php index 128929a..57abdad 100644 --- a/app/Game/GameBoard.php +++ b/app/Game/GameBoard.php @@ -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 { diff --git a/app/Game/GameBoardState.php b/app/Game/GameBoardState.php index 301f3bc..8ea69af 100644 --- a/app/Game/GameBoardState.php +++ b/app/Game/GameBoardState.php @@ -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; } diff --git a/app/Game/GameService.php b/app/Game/GameService.php index 936067a..06f3a53 100644 --- a/app/Game/GameService.php +++ b/app/Game/GameService.php @@ -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; diff --git a/app/Game/GameSession.php b/app/Game/GameSession.php index a51230f..33d2683 100644 --- a/app/Game/GameSession.php +++ b/app/Game/GameSession.php @@ -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; } } diff --git a/app/Models/Character.php b/app/Models/Character.php index bf27de2..d25a2bb 100644 --- a/app/Models/Character.php +++ b/app/Models/Character.php @@ -16,6 +16,9 @@ class Character extends Model 'name', ]; + /** + * Get all cards associated with this character + */ public function cards() { return $this->hasMany(Card::class); diff --git a/app/Models/Raid.php b/app/Models/Raid.php index 585b1b3..74d9963 100644 --- a/app/Models/Raid.php +++ b/app/Models/Raid.php @@ -16,6 +16,9 @@ class Raid extends Model 'name', ]; + /** + * Get all cards associated with this raid + */ public function cards() { return $this->hasMany(Card::class); diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 81085dc..66f528c 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -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); - } */ }