public function testRegularGame() { $wallet = new Wallet(1000, 100); $cards = array(new Card(new Rank(4)), new Card(new Rank(8)), new Card(new Rank(3)), new Card(new Rank(Rank::QUEEN)), new Card(new Rank(5)), new Card(new Rank(Rank::ACE)), new Card(new Rank(3))); $game = new BlackjackGame(new TestDeck($cards)); $game->start(); $this->assertTrue($game->getState() == State::PLAYING); $game->hitUser(); $this->assertTrue($game->getState() == State::PLAYING_ACTIVE); $game->userStands(); $this->assertTrue($game->getState() == State::DEALER_WIN); $this->assertTrue($game->getDealerHand()->getScore() == 18); $this->assertTrue($game->getUserHand()->getScore() == 16); $wallet->reconcile($game); $this->assertTrue($wallet->getMoney() == 900); $wallet->reconcile($game); $this->assertTrue($wallet->getMoney() == 900); $cards = array(); for ($i = 0; $i < 100; $i++) { array_push($cards, new Card(new Rank(Rank::ACE))); } $game = new BlackjackGame(new TestDeck($cards)); $game->start(); $this->assertTrue($game->getState() == State::OFFER_INSURANCE); $game->buyInsurance(false); $this->assertTrue($game->getState() == State::PLAYING); $game->hitUser(); // 3 $this->assertTrue($game->getState() == State::PLAYING_ACTIVE); $game->hitUser(); // 4 $game->hitUser(); // 5 $game->hitUser(); // 6 $game->hitUser(); // 7 $game->hitUser(); // 8 $game->hitUser(); // 9 $game->hitUser(); // 10 $game->hitUser(); // 11/21 $game->userStands(); $this->assertTrue($game->getState() == State::USER_WIN); $this->assertTrue($game->getDealerHand()->getScore() == 17); $this->assertTrue($game->getUserHand()->getScore() == 21); $wallet->reconcile($game); $this->assertTrue($wallet->getMoney() == 1000); $wallet->reconcile($game); $this->assertTrue($wallet->getMoney() == 1000); }