// Todo // $g_fStartUtc = microtime(true); error_reporting(4095); require_once 'inc.cls.cardgame.php'; // config // define('S_NAME', '101_blackjack_v2_2008_02_05'); define('USE_DECKS', 6); define('CUT_CARD', 15); define('HIGHEST_HITTER', 16); define('DEFAULT_SCORE', 1000); // config // // session start after config, because session creation uses classes which use config constants session_start(); $bDebug = !empty($_SESSION[S_NAME]['debug']); card::$__tostring = function ($c) { return '<img src="/images/' . $c->suit . '_' . $c->short . '.gif" />'; }; if (!empty($_GET['reset']) || empty($_SESSION[S_NAME]['game'])) { $_SESSION[S_NAME]['game'] = null; $_SESSION[S_NAME]['game'] = new Blackjack(USE_DECKS); $_SESSION[S_NAME]['game']->dealer = new Dealer('Dealer'); $_SESSION[S_NAME]['game']->player = new Player('You'); $_SESSION[S_NAME]['game']->player->balance = DEFAULT_SCORE; if (!empty($_GET['reset'])) { header('Location: ' . basename($_SERVER['PHP_SELF'])); exit; } } else { if (isset($_GET['debug'])) { $_SESSION[S_NAME]['debug'] = !empty($_GET['debug']); header('Location: ' . basename($_SERVER['PHP_SELF']));
<?php require_once 'inc.cls.cardgame.php'; card::$__tostring = function ($c) { return '<img src="images/' . $c->suit . '.gif" /> ' . strtoupper($c->short); }; $objDeck = new Deck(); $objDeck->shuffle(); $iPlayers = 12; define('LOWEST_WORTHY_HAND', (int) @$_GET['min'] ?: 6); $arrPublic = $arrPlayers = array(); for ($i = 0; $i < $iPlayers; $i++) { $arrPlayers[$i] = array(); array_push($arrPlayers[$i], $objDeck->next()); array_push($arrPlayers[$i], $objDeck->next()); } while (5 > count($arrPublic)) { array_push($arrPublic, $objDeck->next()); } $fUtcStart = microtime(true); /* test * $arrPublic = array( new Card(8), new Card(0), new Card(3), new Card(7), new Card(6), ); $arrPlayers[0] = array( new Card(5), new Card(4),
<pre><?php require_once 'inc.cls.cardgame.php'; require_once 'inc.cls.pokertexasholdem.php'; card::$__tostring = function ($c) { return '<img title="' . $c->id . '" src="images/' . $c->suit . '_' . $c->short . '.gif" />'; }; if (!isset($_GET['cards']) || count($arrCards = array_map('intval', explode(',', $_GET['cards']))) < 3) { $arrCards = array(1, 40, 25, 38, 14, 12, 31); } $arrCards = array_map(function ($c) { return new Card($c); }, $arrCards); echo implode(' ', array_map('strval', $arrCards)) . "\n\n"; $hand = pokertexasholdem::score($arrCards, $o); echo $hand . ' (' . pokertexasholdem::readable_hand($hand) . ")\n\n"; echo 'one pair ' . ($o->one_pair() ? 'Y' : 'N') . "\n"; echo 'two pair ' . ($o->two_pair() ? 'Y' : 'N') . "\n"; echo '3 of a kind ' . ($o->three_of_a_kind() ? 'Y' : 'N') . "\n"; echo 'straight ' . ($o->straight() ? 'Y' : 'N') . "\n"; echo 'flush ' . ($o->flush() ? 'Y' : 'N') . "\n"; echo 'full house ' . ($o->full_house() ? 'Y' : 'N') . "\n"; echo '4 of a kind ' . ($o->four_of_a_kind() ? 'Y' : 'N') . "\n"; echo "\n"; print_r($o);
session_start(); define('BASEPAGE', '/142'); define('S_NAME', 'mpp_142_v2'); define('TABLE_USERS', 'mpp_users'); define('TABLE_TABLES', 'mpp_tables'); define('TABLE_PLAYERS', 'mpp_players'); define('TABLE_BETS', 'mpp_bets'); define('TABLE_POOLS', 'mpp_pools'); define('MAX_PLAYERS_EVER', 10); require_once 'inc.db_mysql.php'; db_set(db_connect('localhost', 'usager', 'usager', 'games')); require_once 'inc.cls.json.php'; require_once 'inc.cls.cardgame.php'; require_once 'inc.cls.pokertexasholdem.php'; if (isset($_GET['card'])) { card::$__tostring = create_function('$c', 'return "images/".$c->suit."_".$c->short.".gif";'); $objCard = new Card($_GET['card']); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT'); header('Content-type: image/gif'); readfile((string) $objCard); exit; } // Two stages for every user: logged in, not logged in // not logged in if (!logincheck()) { if (isset($_POST['username'], $_POST['password'])) { $szMessage = 'ERROR'; $arrUser = db_select(TABLE_USERS, "username = '******'username']) . "' AND password = '******'password']) . "'"); if (1 == count($arrUser)) { $arrSession = array('hash' => randString(20), 'ip' => ifsetor($_SERVER['REMOTE_ADDR'], ""), 'uid' => $arrUser[0]['id']); db_update(TABLE_USERS, 'hash = \'' . $arrSession['hash'] . "'", "id = '" . $arrSession['uid'] . "'");