引數 :
$poker 是乙個陣列例子:"size": 1 - 13 表示
$size_arr = ['a','二','三','四','五','六','七','八','九','十','j','q','k'];
"tag": 1 - 4 表示
$tag_arr = ['黑桃','紅桃','梅花','方片'];
豹子a
$poker = [
['size' => 1,'tag' => 1,'name' => '黑桃a'],
['size' => 1,'tag' => 2,'name' => '紅桃a'],
['size' => 1,'tag' => 3,'name' => '梅花a']
];順金:a二三
$poker = [
['size' => 1,'tag' => 1,'name' => '黑桃a'],
['size' => 2,'tag' => 1,'name' => '黑桃二'],
['size' => 3,'tag' => 1,'name' => '黑桃三']
]; 金花:a六八
$poker = [
['size' => 1,'tag' => 1,'name' => '黑桃a'],
['size' => 6,'tag' => 1,'name' => '黑桃六'],
['size' => 8,'tag' => 1,'name' => '黑桃八']
];順子:a二三
$poker = [
['size' => 1,'tag' => 1,'name' => '黑桃a'],
['size' => 2,'tag' => 2,'name' => '紅桃二'],
['size' => 3,'tag' => 1,'name' => '黑桃三']
];對子:a掛三
$poker = [
['size' => 1,'tag' => 1,'name' => '黑桃a'],
['size' => 1,'tag' => 2,'name' => '紅桃a'],
['size' => 3,'tag' => 1,'name' => '黑桃三']
];單張:a三九
$poker = [
['size' => 1,'tag' => 1,'name' => '黑桃a'],
['size' => 3,'tag' => 2,'name' => '紅桃三'],
['size' => 9,'tag' => 1,'name' => '黑桃九']
];
**:
/**
* 獲取牌型別
* @param array $poker 撲克牌資料
* @return array
*/function getpokertype($poker)else
}elseif ($poker[0]['size'] == $poker[1]['size'] && $poker[0]['size'] == $poker[2]['size']) elseif($poker[1]['size'] == $poker[0]['size'] + 1 && $poker[2]['size'] == $poker[0]['size'] + 2 && $poker[0]['tag'] == $poker[1]['tag'] && $poker[0]['tag'] == $poker[2]['tag'] ) else
return [
'type' => 8,
'size' => $size,
'size2' => $size2,
'size3' => $size3,
'tag' => $tag,
't_name' => '順金:'.$size_arr[$poker[0]['size']-1].$size_arr[$poker[1]['size']-1].$size_arr[$poker[2]['size']-1]
];}elseif($poker[0]['tag'] == $poker[1]['tag'] && $poker[0]['tag'] == $poker[2]['tag']) else
return [
'type' => 7,
'size' => $size,
'size2' => $size2,
'size3' => $size3,
'tag' => $tag,
't_name' => "金花:".$size_arr[$poker[0]['size']-1].$size_arr[$poker[1]['size']-1].$size_arr[$poker[2]['size']-1]
];}elseif ($poker[1]['size'] == $poker[0]['size'] + 1 && $poker[2]['size'] == $poker[0]['size'] + 2) else
return [
'type' => 6,
'size' => $size,
'size2' => $size2,
'size3' => $size3,
'tag' => $tag,
't_name' => '順子:'.$size_arr[$poker[0]['size']-1].$size_arr[$poker[1]['size']-1].$size_arr[$poker[2]['size']-1]
];}elseif ($poker[0]['size'] == $poker[1]['size'] || $poker[0]['size'] == $poker[2]['size'] || $poker[1]['size'] == $poker[2]['size']) elseif ($poker[0]['size'] == $poker[2]['size']) else
return [
'type' => 5,
'size' => $size,
'size2' => $size2,
'tag' => $tag,
't_name' => $t_name
];}elseif ($poker[0]['size'] == 2 && $poker[1]['size'] == 3 && $poker[2]['size'] == 5 ) elseelse
return [
'type' => 3,
'size' => $size,
'size2' => $size2,
'size3' => $size3,
'tag' => $tag,
't_name' => '單張:'.$size_arr[$poker[0]['size']-1].$size_arr[$poker[1]['size']-1].$size_arr[$poker[2]['size']-1]
];}
}
}
/**
* 判斷炸金花輸贏
* @param array $poker1 玩家1撲克牌資料
* @param array $poker2 玩家2撲克牌資料
* @return boole
*/function pokerwinning($poker1,$poker2)else
}elseelse
}}elseelse
}}elseif ($type1['type'] == $type2['type']) else
}elseelse
}}elseelse
}}elseelse
}
}elseelse if ($type1['type'] == 4 && $type2['type'] == 9) elseelse}}
}/**
* 炸金花單張比大小
* @param array $poker1 玩家1撲克牌資料
* @param array $poker2 玩家2撲克牌資料
* @return boole
*/function compare($data1,$data2,$datatype)else if( $data2 == 1)else
if ($tag1 > $tag2) else
}// tag (花色):1 -- 黑桃 2 -- 紅桃 3 -- 梅花 4 -- 方片
if ($datatype == 'tag') else
}}
過年回家炸金花
過年的時候和親戚朋友們一起炸金花,小贏了一把,仔細想想,我覺得炸金花的目的有三 1.娛樂,增進彼此間的感情 2.練 賭博 的氣概 3.建模 第一條很容易理解,而第二條,我是這樣理解的 人的一生會面臨種種抉擇,有時候沒能完全了解整個情況,可能只會根據目前的情況去推測事情的趨勢,勝負不明朗。這時候需要有...
Swift 炸金花遊戲
1 豹子 同花順 同花 順子 對子 單張 2 處於一級別的兩手牌比較最大的一張牌的大小 3 若兩手牌為同一級別且最大的一張牌一樣,則比較剩下的牌 4.3張牌都相等後再從最大的牌比花色,但此機率實在太小,省略 設計思路 建立以下類 cards類 描述單張牌 play類 描述玩家 game類 控制遊戲流...
XDU 1044 炸金花 (模擬)
時間限制 1 sec 記憶體限制 128 mb 提交 狀態 討論版 炸金花是乙個風靡全球的撲克遊戲,不少人因為這個遊戲發了家,而更多的人則輸得傾家蕩產。為了幫助賭徒們戒掉它,現在決定派你去寫乙個程式,幫助賭徒們更好的認識這個遊戲。炸金花在這裡被簡化成這樣乙個情況 每乙個人都會得到隨機派發的三張牌 每...