You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.5 KiB

<?php
include_once "cardAttributes.php";
include_once "card.php";
include_once "functions.php";
class Deck {
public $cards = array();
public function __construct($changes) {
$this->createDeck($changes);
}
private function createDeck($changes)
{
$colors = [];
if ($changes === 'deal') {
$colors = array('green', 'red', 'purple');
}elseif ($changes === 'deal1') {
$colors = array('yellow', 'blue', 'gray');
}
$shapes = array('oval', 'diamond', 'wave');
$fills = array('filled', 'shaded', 'empty');
$numbers = array(1, 2, 3);
$index = 1;
foreach ($colors as $color) {
foreach ($shapes as $shape) {
foreach ($fills as $fill) {
foreach ($numbers as $number) {
$cardAttributes = new CardAttributes($color, $shape, $fill, $number, $index);
$card = new Card($cardAttributes, $this);
$index++;
}
}
}
}
}
public function removeSet($cards) {
}
private function shuffle() {
shuffle($this->cards);
}
public function deal() {
// shuffle the deck
$this->shuffle();
// remove 12 cards from the top and return them
$dealtCards = array_chop($this->cards, 12);
return $dealtCards;
}
public function threeMore() {
return array_chop($this->cards, 3);
}
}