当前位置: 首页>>代码示例>>PHP>>正文


PHP Card::__tostring方法代码示例

本文整理汇总了PHP中Card::__tostring方法的典型用法代码示例。如果您正苦于以下问题:PHP Card::__tostring方法的具体用法?PHP Card::__tostring怎么用?PHP Card::__tostring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Card的用法示例。


在下文中一共展示了Card::__tostring方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __tostring

 public function __tostring()
 {
     if (null === self::$__tostring || !is_callable(self::$__tostring)) {
         self::$__tostring = create_function('$c', 'return \'<img src="/images/\'.$c->suit.\'_\'.$c->short.\'.gif" />\';');
     }
     return call_user_func(self::$__tostring, $this);
 }
开发者ID:rudiedirkx,项目名称:Games,代码行数:7,代码来源:inc.cls.cardgame.php

示例2: implode

<pre><?php 
require 'inc.cls.cardgame.php';
require 'inc.cls.pokertexasholdem.php';
Card::$__tostring = function ($c) {
    return '<img suit="' . $c->suit . '" src="images/' . $c->suit . '_' . $c->short . '.gif" />';
};
$fStart = microtime(true);
$iRounds = isset($_GET['rounds']) ? max(10, (int) $_GET['rounds']) : 1500;
echo $iRounds . " rounds\n\n";
$objDeck = new Deck();
$arrPlayers = array(array(new Card(26), new Card(0)), array(new Card(40), new Card(45)));
$arrWinner = array(0, 0);
for ($i = 0; $i < $iRounds; $i++) {
    $objDeck->replenish();
    $arrPublic = array_slice($objDeck->cards, 0, 5);
    $arrPublic[5] = $arrPlayers[0][0];
    $arrPublic[6] = $arrPlayers[0][1];
    $a = pokertexasholdem::score($arrPublic);
    $arrPublic[5] = $arrPlayers[1][0];
    $arrPublic[6] = $arrPlayers[1][1];
    $b = pokertexasholdem::score($arrPublic);
    $arrWinner[$a > $b ? 0 : 1]++;
}
echo implode(' ', $arrPlayers[0]) . ' vs ' . implode(' ', $arrPlayers[1]) . "\n\n";
echo $arrWinner[0] . ' (' . round($arrWinner[0] / $iRounds * 100, 2) . ' %) vs ' . $arrWinner[1] . ' (' . round($arrWinner[1] / $iRounds * 100, 2) . " %)\n\n";
$fParseTime = microtime(true) - $fStart;
echo number_format($fParseTime, 4) . ' s';
开发者ID:rudiedirkx,项目名称:Games,代码行数:27,代码来源:131d.php

示例3: function

<?php

// BLACKJACK COUNTING CARDS
require_once 'inc.cls.cardgame.php';
Card::$__tostring = function ($objCard) use(&$iCount, &$arrCardPoints) {
    return '<img class="future" src="/images/' . $objCard->suit . '_' . $objCard->short . '.gif" data-pt="' . $arrCardPoints[$objCard->short] . '" count="' . $iCount . '" title="So far: ' . $iCount . '" />';
};
$arrCardPoints = array('2' => 1, '3' => 1, '4' => 1, '5' => 1, '6' => 1, '7' => 0, '8' => 0, '9' => 0, '10' => -1, 'j' => -1, 'q' => -1, 'k' => -1, 'a' => -1);
$g_fStartUtc = microtime(1);
$iDecks = 6;
$deck = new Deck();
while (count($deck->cards) < $iDecks * 52) {
    $deck->add_deck(new Deck());
}
$deck->shuffle();
echo "<p>{$iDecks} decks, randomly ordered:</p>\n";
$iCount = 0;
foreach ($deck->cards as $i => $objCard) {
    $iCount += $arrCardPoints[$objCard->short];
    echo $objCard . "\n";
}
?>

<style>
img.future { display: none; }
img.present { display: inline; visibility: visible; }
img.past { visibility: hidden; }

body.show-past img.past { visibility: visible; }
body.show-all img { display: inline; visibility: visible; }
开发者ID:rudiedirkx,项目名称:Games,代码行数:30,代码来源:101b.php


注:本文中的Card::__tostring方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。