/** * @test * @dataProvider games * @expectedException \DomainException * * @param Game $game */ public function cannotPlayTurnIfAllPlayersFinish(Game $game) { $seatsOccupied = array_slice(Player::values(), 0, $game->playersInGame()); foreach ($seatsOccupied as $seat) { $this->finishPlayer($game, $seat); } $game->playTurn(new CheaterDice(6, 1), new TokenNumber(1)); }
private function positionPlayers($positions) { $position = 0; $players = array_slice(Player::values(), 0, $positions); /** @var Player $player */ foreach ($players as $player) { $this->players[$position++] = $player; } }
/** * @test * @dataProvider playerAfterTurns * * @param int $turns * @param Player $color */ public function isPlayerGivenTurn($turns, Player $color) { $this->passTurns($turns); $this->assertEquals($color->toString(), $this->positions->currentPlayer()); }
<?php namespace jb\ludo; use precore\lang\Enum; final class Player extends Enum { public static $GREEN; public static $RED; public static $BLUE; public static $YELLOW; } Player::init(); // @codeCoverageIgnore
/** * @param Player $player * * @return Square */ public function getStartingSquare(Player $player) { $start = $this->startingSquares[$player->name()]; return $this->squares->get($start); }