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 "hand.php"

<?php

// ===============================================================
// Contents: Kortgrejer.
// Author: Staffan Lindsgård
// ===============================================================

$pagetitle = "Kortelikort!";
$customhead = "";

require_once "common.php";
echo $page_top;


// ===============================================================
// Inkluderar externa PHP-filer.

require_once "CCard.php";
require_once "CDeck.php";
require_once "CCardHand.php";


// ===============================================================
// Inställningar för felsökning.

error_reporting(-1);
$debug = true;
$debug = (empty($_POST['debug']) ? $debug : $_POST['debug']);
$debug = ($debug=="true" ? true : false);
$debug_out = "<h2 class='debug'>Debug</h2>\n";


// ===============================================================
// XX

// Vi skapar en ny kortlek och blandar den.
$deck = new CDeck();
$deck->Shuffle();
$hand1 = new CCardHand();
$hand2 = new CCardHand();

// Sedan drar vi de fem översta korten, placerar dem i vår hand och tittar på dem.
$html = "<h2>Min hand...</h2>\n";
for($i=0;$i<5;$i++) {
	$card = $deck->DealFromTop();
	$card->FlipCard();
	$hand1->AddCard($card);
}
$html .= $hand1->GetHandAsCSS();

// Vi drar nästa fem kort och tittar.
$html .= "<h2>Min andra hand...</h2>\n";
for($i=0;$i<5;$i++) {
	$card = $deck->DealFromTop();
	$card->FlipCard();
	$hand2->AddCard($card);
}
$html .= $hand2->GetHandAsCSS();

// Vi tittar på de första fem korten igen.
$html .= "<h2>Min första hand igen...</h2>\n";
$html .= $hand1->GetHandAsCSS();

// Sedan slänger vi hela handen första handen och tittar på den.
$html .= "<h2>Min första hand efter att slängt korten.</h2>\n";
$hand1->DropAllCards();
$html .= $hand1->GetHandAsCSS();

$html .= "\n";

?>

<h1>Då skall vi se på den lilla handen...</h1>
<p>Jaha, där ser man...</p>
<?php echo $html; ?>
<?php echo $debug_out; ?>

<?php
echo $page_bottom;
?>