Visa källkod

Nedanstående filer finns i denna katalog. Klicka på en fil för att visa dess innehåll.

bth-cards/

  1. .buildpath
  2. .project
  3. CCard.php
  4. CCardHand.php
  5. CDeck.php
  6. argyle.jpg
  7. card.php
  8. common.php
  9. deck.php
  10. grunge.jpg
  11. hand.php
  12. index.php
  13. sessDest.php
  14. sessions.php
  15. sessions_mroos.php
  16. source.php
  17. template.php
  18. 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);
	}

}
?>