Visa källkod
Nedanstående filer finns i denna katalog. Klicka på en fil för att visa dess innehåll.
- .buildpath
- .project
- CCard.php
- CCardHand.php
- CDeck.php
- argyle.jpg
- card.php
- common.php
- deck.php
- grunge.jpg
- hand.php
- index.php
- sessDest.php
- sessions.php
- sessions_mroos.php
- source.php
- template.php
- tiles.jpg
Stäng "CDeck.php"
<?php
// ===============================================================
// Contents: Kortlek.
// Author: Staffan Lindsgård
// ===============================================================
require_once("CCard.php");
class CDeck {
private $theDeck;
function __construct() {
$this->theDeck = Array();
$this->InitDeck();
}
function __destruct() {
;
}
public function InitDeck() {
$suits = Array('S', 'H', 'C', 'D', 'X');
$pos = 1;
foreach($suits as $suit) {
for($i=1; $i<=13; $i++) {
$this->deck[$pos++] = new CCard($suit, $i, 'B');
if($suit == 'X' && $i == 2) break;
}
}
}
public function Shuffle() {
return shuffle($this->deck);
}
public function InitAndShuffle() {
$this->InitDeck();
return shuffle($this->deck);
}
public function DealFromTop() {
return array_pop($this->deck);
}
}
?>