/** * @param integer $position * * @return $this */ public function get($position) { if ($this->position() !== $position) { return $this->nextSquare->get($position); } return $this; }
private function createTrack() { $homeSquares = function (Player $player) { return (new HomeSquare(41, $player))->nextTo(new HomeSquare(42, $player))->nextTo(new HomeSquare(43, $player))->nextTo(new HomeSquare(44, $player)); }; $this->createSquares(2, 9)->nextTo(new EndingSquare(10, $homeSquares(Player::$RED))); $this->createSquares(11, 19)->nextTo(new EndingSquare(20, $homeSquares(Player::$BLUE))); $this->createSquares(21, 29)->nextTo(new EndingSquare(30, $homeSquares(Player::$YELLOW))); $this->createSquares(31, 39)->nextTo(new EndingSquare(40, $homeSquares(Player::$GREEN))); $this->squares->get(40)->nextTo($this->squares->get(1)); }
/** @test */ public function squareOccupied() { $this->start->occupyNext(1); $this->assertTrue($this->start->get(1)->isOccupied()); }