Code: Select all
$deck = new Cards\Deck;
$deck->shuffle();
$players = Game\Hearts\Factory::buildPlayers(); // I haven't actually created any game/player code yet. this is pseudo-code.
// Deal out 13 cards to each player...
while ($deck->hasCards()) {
foreach ($players as $player) {
$card = $deck->deal();
$player->getHand()->addCard($card);
}
}Code: Select all
$deck = new Cards\Deck;
// .. snip
$deck->burn(); // takes a card off the top and places it on the bottom
$flop = $deck->deal(3);
// .. or ..
$turn = $deck->deal();
$deck->accept($players[3]->getHand()); // player 3 folds, so his cards go back on bottom
// .. or ..
$deck->accept($discard); // deck gets a player's discard and puts it on bottomCode: Select all
if (count($deck) != 52) {
throw new Cards\Exception\InvalidDeck('Deck is short of cards');
}
$lastcard = $deck[51];Code: Select all
$deck = new Cards\Deck;
$deck->shuffle();
$deck->cut(15); // Cuts the deck in half at the 15th card, and places the top half under the bottom halfCode: Select all
foreach ($deck as $card) {
// do something with $card but dont take it outta the deck
}