function it_uses_captured_cards_after_it_runs_out($battle) { $this->cardsCount()->shouldBe(0); $cards = CardsCollection::make([new Card('A', 'spades'), new Card('2', 'spades')]); $this->capturedCount()->shouldBe(0); $this->capture($cards); $this->capturedCount()->shouldBe(2); $this->playCard(); // reloads from captured and plays $this->cardsCount()->shouldBe(1); }
function it_deals_the_cards_evenly_between_players($player1, $player2) { $player1->beADoubleOf(Player::class); $player2->beADoubleOf(Player::class); $card1 = new Card('A', 'spades'); $card2 = new Card('J', 'hearts'); $this->beConstructedWith(new Deck(CardsCollection::from($card1, $card2))); $player1->acceptCard($card1)->shouldBeCalledTimes(1); $player2->acceptCard($card2)->shouldBeCalledTimes(1); $this->deal($player1, $player2); }
/** * Player constructor. * * @param $name * @param array $cards */ public function __construct($name, array $cards = []) { $this->name = $name; $this->cards = CardsCollection::make($cards); $this->captured = new CardsCollection(); }