php发扑克牌,php 扑克牌代码的简单例子
本文分享下,一段可模擬撲克牌玩法的php代碼,有需要的朋友參考下。
php 撲克牌代碼,如下:
cut();
* www: jbxue.com
*/
class cards{
/**
*
* Declare our deck variable
*
*/
private $deck;
/**
*
* Constructor.. duh!
*
*/
function __construct(){
/*** set the deck array variable ***/
$this->deck=$this->setDeck();
}
/**
*
* Function set Deck
*
* @access private
*
* @return array
*
*/
private function setDeck(){
return array("ah", "ac", "ad", "as",
"2h", "2c", "2d", "2s",
"3h", "3c", "3d", "3s",
"4h", "4c", "4d", "4s",
"5h", "5c", "5d", "5s",
"6h", "6c", "6d", "6s",
"7h", "7c", "7d", "7s",
"8h", "8c", "8d", "8s",
"9h", "9c", "9d", "9s",
"th", "tc", "td", "ts",
"jh", "jc", "jd", "js",
"qh", "qc", "qd", "qs",
"kh", "kc", "kd", "ks");
}
/**
*
* Function get Key get the array key
*
* @access private
*
* @return INT
*
*/
private function getKey(){
shuffle($this->deck);
return array_rand($this->deck);
}
/**
*
* @Function cut, get the value of the array key
*
* @access public
*
* @return string
*
*/
public function cut(){
return $this->deck[$this->getKey()];
}
} /*** end of class ***/
$cards = new cards;
echo $cards->cut();
?>
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的php发扑克牌,php 扑克牌代码的简单例子的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: HTC首款元宇宙手机上市:骁龙695卖到
- 下一篇: ibmprc.exe进程是什么文件产生的