加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
t2.php 31.81 KB
一键复制 编辑 原始数据 按行查看 历史
zhoubin001 提交于 2018-01-11 10:16 . 麻将
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
<?php
$act['5842'][]='peng';
echo count($act);
exit();
$dataPost=[
'room_id'=>376010, //房间号
'operation'=>'ShowCard', //牌操作
'action'=>3, // 操作种类
'account_id'=>5842, // 操作者id
'cur_dpai'=>6, //操作牌
'kind'=>1, //吃碰杠种类
'wintype'=>2, //胡的种类
];
echo time() . "\n";
$url = 'http://127.0.0.1/game.php/Xiangshan/PlayerShowCard';
$returnData = https_post(json_encode($dataPost), $url);
$returnData = json_decode($returnData);
print_r($returnData);
if($returnData->type>0) {
echo 1111;
exit();
}
exit();
$bianrow=[2,12,22,6,16,26];
$hupai=array([2,2,2],[5,3,4],[2,3,4],[5,5]);
$winpai=2;
foreach($hupai as $k=>$v){
if(count($v)>2){
if(in_array($winpai,$v)){
if($v[0]==$v[1] && $v[1]==$v[2]) return true;
}
}
}
;
exit();
//
//
//$peng=[0];
//$chi=[0];
//$gang=[1];
//$hu=[];
//$s=[5940];
//unset($s[0]);
//print_r($s);
//exit();
//for($i=0;$i<4;$i++){
// if(in_array($i,$peng)){
// $act[$s[$i]][]='peng';
// }if(in_array($i,$chi)){
// $act[$s[$i]][]='chi';
// }if(in_array($i,$gang)){
// $act[$s[$i]][]='gang';
// }if(in_array($i,$hu)){
// $act[$s[$i]][]='hu';
// }
//}
//$return_data = ['act' =>$act];
//$return_data = json_encode($return_data);
//$return_data = json_decode($return_data,true);
//print_r($return_data);
//echo count($return_data['act']);
//exit();
//if($returnData->act){
// $returnData->act=json_decode(json_encode($returnData->act),true);
// $button=['result'=>0, "operation"=>'pull_Can_Do', 'data'=>$returnData->data, 'act'=>$returnData->act,'account_id'=>$returnData->zhuang[$returnData->act->peng]];
// $button['result_message']='吃碰杠胡';
// Sendplayers($returnData,$button);
// SendWeiplayers($returnData,$button);
//}
//
//
//$dataPost=[
// 'room_id'=>375994, //房间号
// 'operation'=>'ShowCard', //牌操作
// 'action'=>2, // 操作种类
// 'account_id'=>5941, // 操作者id
// 'cur_dpai'=>1, //操作牌
// 'kind'=>0, //吃碰杠种类
// 'wintype'=>0, //胡的种类
//];
//
//
//
//echo time() . "\n";
//$url = 'http://127.0.0.1/game.php/Xiangshan/PlayerShowCard';
//$returnData = https_post(json_encode($dataPost), $url);
//$returnData = json_decode($returnData);
//print_r($returnData);
if(isset($timer_all[12][$returnData->room_id])) Timer::del($timer_all[12][$returnData->room_id]);
$timer_all[12][$returnData->room_id]=Timer::add(2, 'GameGuo',[$returnData->room_id, $returnData->zhuang[$returnData->mopaiinfo->index], $timer_all], false);
function GameGuo($roomid,$account_id, $timer_all){
global $ws_worker, $connection_all, $timer_all,$baseUrl;
echo "\nGameGuo,接收到的参数值:{$roomid} " . time() . "\n";
$url = $baseUrl.'game.php/Xiangshan/PlayerShowCard';
$dataPost=[
'room_id'=>$roomid, //房间号
'operation'=>'ShowCard', //牌操作
'action'=>8, // 操作种类
'account_id'=>$account_id, // 操作者id
'cur_dpai'=>0, //操作牌
'kind'=>0, //吃碰杠种类
'wintype'=>4, //胡的种类
];
var_dump($dataPost);
echo time() . "\n";
$url = $baseUrl.'game.php/Xiangshan/PlayerShowCard';
$returnData = https_post(json_encode($dataPost), $url);
var_dump(['GameMopai_result' => $returnData]);
$returnData = json_decode($returnData);
$returnData->zhuang = json_decode(json_encode($returnData->zhuang), true);
if($returnData->mopaiinfo->type==1) {
$button = ['result' => 0, "operation" => 'pull_Mopai', 'data' => $returnData->mopaiinfo->data, 'index' => $returnData->mopaiinfo->index, 'account_id' => $returnData->zhuang[$returnData->mopaiinfo->index], 'yupai' => $returnData->yupai];
Sendplayers($returnData,$button);
SendWeiplayers($returnData,$button);
//杠胡
if(@$returnData->mopaiinfo->act){
$returnData->mopaiinfo->act=json_decode(json_encode($returnData->mopaiinfo->act),true);
$button=['result'=>0, "operation"=>'pull_Can_Do','wintype'=>1, 'data'=>$returnData->data, 'act'=>$returnData->mopaiinfo->act,'account_id'=>$returnData->zhuang[$returnData->mopaiinfo->index]];
$button['result_message']='杠胡';
Sendplayers($returnData,$button);
SendWeiplayers($returnData,$button);
}
//10秒之后,自动执行打牌操作
if ($returnData->autoplay) {
if (isset($timer_all[2][$returnData->room_id])) Timer::del($timer_all[2][$returnData->room_id]);
$timer_all[2][$returnData->room_id] = Timer::add($returnData->timer, 'GameAutoPlaycard', [$returnData->room_id, 2, $returnData->zhuang[$returnData->mopaiinfo->index], $returnData->mopaiinfo->data, 0, $timer_all], false);
}
}elseif($returnData->mopaiinfo->type==2){ //花牌
$button = ['result' => 0, "operation" => 'pull_Huapai', 'data' => $returnData->mopaiinfo->data, 'index' => $returnData->mopaiinfo->index, 'account_id' => $returnData->zhuang[$returnData->mopaiinfo->index], 'yupai' => $returnData->yupai];
//向玩家发送
if (isset($returnData->players) && is_array($returnData->players)) {
foreach ($returnData->players as $player) {
$id = $player->id;
if (isset($connection_all[$id])) {
echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
if ($ws_worker->connections[$connection_all[$id]]) {
$ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
}
}
}
}
//向围观者发送
if (isset($returnData->weiplayers) && is_array($returnData->weiplayers)) {
foreach ($returnData->weiplayers as $players) {
$id = $players->id;
// if (isset($connection_all[$id]) && $index==$returnData->index) {
if (isset($connection_all[$id])) {
echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
if ($ws_worker->connections[$connection_all[$id]]) {
$ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
}
}
}
}
//种下一个定时器,继续摸牌去
if(isset($timer_all[11][$returnData->room_id])) Timer::del($timer_all[11][$returnData->room_id]);
$timer_all[11][$returnData->room_id]=Timer::add(2, 'GameMopai',[$returnData->room_id, $returnData->zhuang[$returnData->mopaiinfo->index], $timer_all], false);
}else{ //荒局啦
$button=['result'=>0, "operation"=>'pull_Huangju','data'=>$returnData->data, 'index' => $returnData->mopaiinfo->index, 'account_id' => $returnData->zhuang[$returnData->mopaiinfo->index], 'result_message'=>'荒局啦'];
Sendplayers($returnData,$button);
SendWeiplayers($returnData,$button);
//开启一个定时器,第二局开始
Timer::add($returnData->gameautotimer, 'GameAutoStart',[$returnData->room_id, $returnData->account_id, $timer_all], false);
}
}
//$url = 'http://127.0.0.1/game.php/Xiangshan/GameAutoStart';
//$dataPost = [
// 'account_id' => 5942,
// 'operation' => 'GameAutoStart',
// 'data' => [
// 'room_id' => 375953,
// ]
//];
//$returnData = https_post(json_encode($dataPost), $url);
//$returnData = json_decode($returnData);
//if($returnData->autoplay) {
// // if(isset($timer_all[2][$returnData->data->room_id])) Timer::del($timer_all[2][$returnData->room_id]);
// echo $returnData->cards_info[0]->data->pai[0];
// ///$timer_all[2][$returnData->data->room_id]=Timer::add(10, 'GameAutoPlaycard',[$returnData->data->room_id,2,$returnData->data->account_id,$returnData->players[0]->data->pai[0],0, $timer_all],false);
//}
//print_r($returnData);
//e
//$dataPost=[
// 'room_id'=>375953, //房间号
// 'operation'=>'ShowCard', //牌操作
// 'action'=>2, // 操作种类
// 'account_id'=>5941, // 操作者id
// 'cur_dpai'=>0, //操作牌
// 'kind'=>0, //吃碰杠种类
// 'wintype'=>0, //胡的种类
//];
//
//$onlineUrl = 'http://127.0.0.1/game.php/Xiangshan/PlayerShowCard';
//$returnData = https_post(json_encode(['account_id' => 5942, 'online_status' => 0]), $onlineUrl); //把玩家数据更新到数据库并且取得新的房间数据
//$returnData =json_decode($returnData);
//var_dump($returnData);
//print_r($returnData);
//
//$cards = [ 1,2, 3, 4,4,7,8,9];
//$f=ispinghu($cards);
//
//print_r($f);
//
//function ispinghu($pai){
// $_push=[];
// if(!$pai) return false;
// $_push=winkind_one($pai);
// if($_push==false) $_push=winkind_two($pai);
// if($_push==false) return false;
// return $_push;
//}
////判断是否胡
//function winkind_one($cards)
//{
// global $_push;
// $cards=array_values($cards);
// if (count($cards) == 2) {
// if ($cards[0] == $cards[1]) {
// $_push[]=[$cards[0],$cards[1]];
// return $_push;
// } else {
// return false;
// }
// } else {
// //从中取出一对成顺或者成刻的牌
// sort($cards);
// //再找一对成顺的牌
// $duizi=0;
// $cardsnum=array_count_values($cards);
// foreach ($cardsnum as $key => $val) {
// if($val==2) ++$duizi;
// }
// for ($i = 1; $i < count($cards) - 1; $i++) {
// if (@$cards[$i - 1] + 1 == @$cards[$i] && ((@$cardsnum[$cards[$i - 1]]!=2) || $duizi>1) && @$cards[$i]<29 ) {
// //从它的后面找一个比它大1的数,优先走单个顺子
// for ($j= $i + 1; $j < count($cards); $j++) {
// if (@$cards[$j] == @$cards[$i] + 1 && $cards[$i]) {
// //此时已经找到
// $_push[]=[@$cards[$i-1],@$cards[$i],@$cards[$j]];
// unset($cards[$i-1],$cards[$i],$cards[$j]);
// if (winkind_one($cards)) {
// return $_push;
// }
// else {
// return false;
// }
// }
// else if ($cards[$j] > $cards[$i] + 1) {
// break;
// }
// }
// }
// }
// //再找一对成刻的牌
// for ($i = 1; $i < count($cards) - 1; $i++) {
// if (@$cards[$i - 1] == @$cards[$i] && @$cards[$i] == @$cards[$i + 1]) {
// $_push[]=[@$cards[$i-1],@$cards[$i],@$cards[$i+1]];
// unset($cards[$i-1],$cards[$i],$cards[$i+1]);
// if (winkind_one($cards)) {
// return $_push;
// } else {
// break;
// }
// }
// }
// //如果刻和顺都找不到,那么说明没胡
// return false;
//
// }
//
//}
////判断是否胡
//function winkind_two($cards)
//{
// global $_push;
// $cards=array_values($cards);
// if (count($cards) == 2) {
// if ($cards[0] == $cards[1]) {
// $_push[]=[$cards[0],$cards[1]];
// return $_push;
// } else {
// return false;
// }
// } else {
// //从中取出一对成顺或者成刻的牌
// sort($cards);
// //先找一对成刻的牌
// for ($i = 1; $i < count($cards) - 1; $i++) {
// if (@$cards[$i - 1] == @$cards[$i] && @$cards[$i] == @$cards[$i + 1]) {
// $_push[]=[@$cards[$i-1],@$cards[$i],@$cards[$i+1]];
// unset($cards[$i-1],$cards[$i],$cards[$i+1]);
// if (winkind_two($cards)) {
// return $_push;
// } else {
// break;
// }
// }
// }
//
// //再找一对成顺的牌
// $duizi=0;
// $cardsnum=array_count_values($cards);
// foreach ($cardsnum as $key => $val) {
// if($val==2) ++$duizi;
// }
// for ($i = 1; $i < count($cards) - 1; $i++) {
// if (@$cards[$i - 1] + 1 == @$cards[$i] && ((@$cardsnum[$cards[$i - 1]]!=2) || $duizi>1)) {
// //从它的后面找一个比它大1的数,优先走单个顺子
// for ($j= $i + 1; $j < count($cards); $j++) {
// if (@$cards[$j] == @$cards[$i] + 1 && @$cards[$i]<29)
// {
// //此时已经找到
// $_push[]=[@$cards[$i-1],@$cards[$i],@$cards[$j]];
// unset($cards[$i-1],$cards[$i],$cards[$j]);
// if (winkind_two($cards)) {
// return $_push;
// }
// else {
// return false;
// }
// }
// else if (@$cards[$j] > @$cards[$i] + 1) {
// break;
// }
// }
// }
// }
//
// //如果刻和顺都找不到,那么说明没胡
// return false;
//
// }
//
//}
exit();
//
//
//
//$str='{"msg":"\u6253\u724c\u6210\u529f","type":1,"data":35,"index":0,"turn":1,"action":{"chi":-1,"peng":1,"gang":-1,"chigang":-1},"hu":[],"mp":0,"mopaiinfo":[],"yupai":69,"autoplay":false,"zhuang":{"1":5841,"2":5842,"3":5843,"0":5840},"players":[{"id":5840,"sort":1,"nickname":"","photo":"http:\/\/wx.qlogo.cn\/mmopen\/vi_32\/Q0j4TwGTfTJhibVwX1zg8ibgPxfzPy03eEbwlCiamRDyrD34ic90Igm0YEpTReiaeS2dM4FicopKIxXjuFBufiaRB4e5A\/0","online_status":1,"data":{"pai":[0,1,4,6,6,14, 15,17,18,18,21,25,33],"huapai":[45],"agangpai":[],"mgangpai":[],"wgangpai":[],"pengpai":[],"chipai":[],"mopai":[],"dapai":[35],"dispai":[],"tuoguan":0},"isspecial":"false","score":3600},{"id":5841,"sort":2,"nickname":"","photo":"http:\/\/wx.qlogo.cn\/mmopen\/vi_32\/Jstogu0jaTGvHficoHwNh5Tpju1zba2ylIMgHibfCmEyZiaA92qjtP8hQb8EYmSXXibDDD4PV2sLMfXoSPc12dhRsg\/0","online_status":1,"data":{"pai":[4,7,11,14,15,23,24,24,25,28,34,35,35],"huapai":[],"agangpai":[],"mgangpai":[],"wgangpai":[],"pengpai":[],"chipai":[],"mopai":[],"dapai":[],"dispai":[],"tuoguan":0},"isspecial":"false","score":6250},{"id":5842,"sort":3,"nickname":"","photo":"http:\/\/wx.qlogo.cn\/mmopen\/vi_32\/Q0j4TwGTfTK45iap26R41Q3v7mibQcuB9suhFHKD82Dlpf6jjCC11henqKt4l2ibo6L9QpH5sEWamnjRahlvsRc0A\/0","online_status":1,"data":{"pai":[0,8,10,11,11,13,13,20,21,23,26,28,32],"huapai":[43],"agangpai":[],"mgangpai":[],"wgangpai":[],"pengpai":[],"chipai":[],"mopai":[],"dapai":[],"dispai":[],"tuoguan":0},"isspecial":"false","score":6500},{"id":5843,"sort":4,"nickname":"","photo":"http:\/\/wx.qlogo.cn\/mmopen\/vi_32\/wc6zGHCbc8aF3RR18uHicdSkibXFbnMK1mOE8UMia1oVk5tDZXweEwU0wzh9h07PWJmoyqKQzBhFB1tm1nF0yshUA\/0","online_status":1,"data":{"pai":[1,1,3,7,10,11,12,12,21,27,31,32,36],"huapai":[44,41,47,46],"agangpai":[],"mgangpai":[],"wgangpai":[],"pengpai":[],"chipai":[],"mopai":[],"dapai":[],"dispai":[],"tuoguan":0},"isspecial":"false","score":6650}],"weiplayers":[],"room_id":"375767","account_id":5840}';
//
//$returnData = json_decode($str);
//$returnData->zhuang = json_decode(json_encode($returnData->zhuang),true);
//print_r($returnData->zhuang[1]);
//
//exit();
//$baseUrl='http://127.0.0.1/';
//游戏自动托管打牌
//$dataPost=[
// 'room_id'=>375619, //房间号
// 'operation'=>'ShowCard', //牌操作
// 'action'=>6, // 暗杠
// 'data'=>[
// 'index'=>1,//摸牌者id
// 'ppai'=>array(3,3,3,3)
// ]
// ];
//$dataPost=[
// 'room_id'=>375745, //房间号
// 'operation'=>'ShowCard', //牌操作
// 'action'=>2, // 操作种类
// 'account_id'=>5940, // 操作者id
// 'cur_dpai'=>0, //操作牌
// 'kind'=>1 //吃碰杠种类
// ];
//print_r(json_encode($dataPost));
//exit();
//$s=GameAutoPlaycard(375750,2,5941,10,0,0);
//var_dump($s);
//exit();
//
//
//
//function GameAutoPlaycard($roomid,$action,$account_id,$dpai,$kind,$timer_all)
//{
// global $ws_worker, $connection_all, $timer_all,$baseUrl;
// $dataPost=[
// 'room_id'=>$roomid, //房间号
// 'operation'=>'ShowCard', //牌操作
// 'action'=>$action, // 操作种类
// 'account_id'=>$account_id, // 操作者id
// 'cur_dpai'=>$dpai, //操作牌
// 'kind'=>$kind //吃碰杠种类
// ];
//
// $url = $baseUrl.'game.php/Xiangshan/PlayerShowCard';
// $returnData = https_post(json_encode($dataPost), $url);
//
// //var_dump(['GameAutoPlaycard_result' => $returnData]);
// $returnData = json_decode($returnData);
//
// if($action==2){
//
// //清除定时器
// if($timer_all[1][$returnData->room_id]) Timer::del($timer_all[1][$returnData->room_id]);
// //向所有玩家发送自己打的的牌
// print_r($returnData->players);
// $button=['result'=>0, "operation"=>'pull_Dapai', 'data'=>$returnData->data,'index'=>$returnData->index, 'result_message'=>'打牌回应'];
// if(isset($returnData->players) && is_array($returnData->players)){
// foreach ($returnData->players as $player) {
//
// $id=$player->id;
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if (isset($connection_all[$id])) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
// }
// //向围观者发送
// if(isset($returnData->weiplayers) && is_array($returnData->weiplayers)){
// foreach ($returnData->weiplayers as $players) {
// $id=$players->id;
// // if (isset($connection_all[$id]) && $index==$returnData->index) {
// if (isset($connection_all[$id])) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
// }
// //向对应玩家发送是否可以吃碰杠
// $button=['result'=>0, "operation"=>'pull_Can_Pengpai', 'data'=>$returnData->data];
// if(isset($returnData->players) && is_array($returnData->players)){
// //碰
// if(@$returnData->action->peng>=0){
// $button['index']=$returnData->action->peng;
// $button['operation']='pull_Can_Pengpai';
// $button['result_message']='碰';
// foreach ($returnData->players as $player) {
// $id=$player->id;
// $index=$player->sort-1;
// if (isset($connection_all[$id]) && $index==$button['index']) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
// }
// //吃
// if(@$returnData->action->chi>=0){
// $button['index']=$returnData->action->chi;
// $button['result_message']='吃';
// $button['operation']='pull_Can_Chipai';
// foreach ($returnData->players as $player) {
// $id=$player->id;
// $index=$player->sort-1;
// if (isset($connection_all[$id]) && $index==$button['index']) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
//
// }
// //杠
// if(@$returnData->action->gang>=0){
// $button['index']=$returnData->action->gang;
// $button['result_message']='杠';
// $button['operation']='pull_Can_Gangpai';
// foreach ($returnData->players as $player) {
// $id=$player->id;
// $index=$player->sort-1;
// if (isset($connection_all[$id]) && $index==$button['index']) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
// }
//
// //吃碰
// if(@$returnData->action->chipeng>=0){
// $button['index']=$returnData->action->chipeng;
// $button['operation']='pull_Can_ChiPengpai';
// $button['result_message']='吃碰';
// foreach ($returnData->players as $player) {
// $id=$player->id;
// $index=$player->sort-1;
// if (isset($connection_all[$id]) && $index==$button['index']) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
// }
// //吃杠
// if(@$returnData->action->chigang>=0){
// $button['index']=$returnData->action->chigang;
// $button['result_message']='吃杠';
// $button['operation']='pull_Can_ChiGangpai';
// foreach ($returnData->players as $player) {
// $id=$player->id;
// $index=$player->sort-1;
// if (isset($connection_all[$id]) && $index==$button['index']) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
// }
//
// }
// //向对应玩家发送是否可以胡
// $button=['result'=>0, "operation"=>'pull_Can_Win', 'data'=>$returnData->data, 'result_message'=>'胡'];
// if(isset($returnData->players) && is_array($returnData->players) && $returnData->hu){
// foreach ($returnData->hu as $huid) {
// $button['index']=$huid;
// foreach ($returnData->players as $player) {
// $id=$player->id;
// $index=$player->sort-1;
// if (isset($connection_all[$id]) && $index==$button['index']) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
//
// }
// }
// //向所有玩家推送摸牌人的ID和摸到的牌
// if($returnData->mp>0 && $returnData->mopaiinfo->type==1){
// $button=['result'=>0, "operation"=>'pull_Mopai', 'data'=>$returnData->mopaiinfo->data,'index'=>$returnData->mopaiinfo->index, 'yupai'=>$returnData->yupai];
// //向玩家发送
// if(isset($returnData->players) && is_array($returnData->players)){
// foreach ($returnData->players as $player) {
// $id=$player->id;
// if (isset($connection_all[$id])) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
// }
// //向围观者发送
// if(isset($returnData->weiplayers) && is_array($returnData->weiplayers)){
// foreach ($returnData->weiplayers as $players) {
// $id=$players->id;
// // if (isset($connection_all[$id]) && $index==$returnData->index) {
// if (isset($connection_all[$id])) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
// }
// //判断是否有暗杠
// if(in_array('angang',$returnData->mopaiinfo->action)){
// $button=['result'=>0, "operation"=>'pull_Can_Angang', 'index'=>$returnData->mopaiinfo->index];
// if(isset($returnData->players) && is_array($returnData->players)){
// foreach ($returnData->players as $player) {
// $id=$player->id;
// $index=$player->sort-1;
// if (isset($connection_all[$id]) && $index==$returnData->index) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
// }
// }
// //判断是否有弯杠
// if(in_array('wgang',$returnData->mopaiinfo->action)){
// $button=['result'=>0, "operation"=>'pull_Can_Wgang', 'index'=>$returnData->mopaiinfo->index];
// if(isset($returnData->players) && is_array($returnData->players)){
// foreach ($returnData->players as $player) {
// $id=$player->id;
// $index=$player->sort-1;
// if (isset($connection_all[$id]) && $index==$returnData->index) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
// }
// }
// //判断是否可以胡
// if(in_array('hu',$returnData->mopaiinfo->action)){
// $button=['result'=>0, "operation"=>'pull_Can_Win', 'index'=>$returnData->mopaiinfo->index];
// if(isset($returnData->players) && is_array($returnData->players)){
// foreach ($returnData->players as $player) {
// $id=$player->id;
// $index=$player->sort-1;
// if (isset($connection_all[$id]) && $index==$returnData->index) {
// echo "\n准备给玩家: {$id} 推消息, 找到的连接是: {$connection_all[$id]}\n";
// if ($ws_worker->connections[$connection_all[$id]]){
// $ws_worker->connections[$connection_all[$id]]->send(json_encode($button));
// }
// }
// }
// }
// }
// }
//
//
// }
//
//
//}
//
//
//
////
////$cards[0]=array(1=>21);
////$cards[1]=array(2=>21);
////$cards[2]=array(3=>16);
////$cards[3]=array(0=>31);
////$cards[4]=array(1=>11);
////
////$cards=[1,2,3,4];
////echo $a=end($cards);
////echo $index=array_keys($a)[0];
////exit();
////$data=[1,2,2,3,4,5,6];
////$targetPai=2;
////function checkCanPeng($data,$targetPai) {
//// $data=array_count_values($data);
//// $count = @$data[$targetPai];
//// if($count != null && $count >= 2){
//// return true;
//// }
//// return false;
////}
////var_dump(checkCanPeng($data,$targetPai));
$playcards[0]['gang'][0]=array(array(1,1,1),array(2,2,2));
$playcards[0]['gang'][1]=array(array(1,1,1),array(2,2,2));
echo count($playcards[0]['gang'],1);
exit();
$pai=2;
$is_peng=-1;
if($gang){
foreach($gang as $k=>$v){
foreach($v as $ks=>$vs){
$allcount=array_count_values($vs);
foreach($allcount as $kd=>$vd){
if(@$allcount[$pai]>=3) {
$is_peng=$k;
$row=$vs;
}
}
}
}
}
print_r($row);
exit();
function https_post($data, $url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_TIMEOUT, 20); // 设置超时限制防止死循环
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8')
);
ob_start();
curl_exec($ch);
if (curl_errno($ch)) {
return curl_error($ch); //捕抓异常
}
$return_content = ob_get_contents();
ob_end_clean();
curl_close($ch);
return $return_content;
}
$dataPost=[
'account_id'=>5840,//会员账号
'operation'=>'SitDown',
'data'=>[
'room_id'=>375678,//房间id
'sort'=>2//座位 (1 2 3 4)
]
];
$url = "http://127.0.0.1/game.php/Xiangshan/SitDown";
$returnData = https_post(json_encode($dataPost), $url);
$returnData=json_decode($returnData);
print_r($returnData);
//
//$onlineUrl = "http://127.0.0.1/game.php/Xiangshan/GetOffLine";
//$returnData = https_post(json_encode(['account_id' => 5841, 'online_status' => 0]), $onlineUrl); //把玩家数据更新到数据库并且取得新的房间数据
//$returnData =json_decode($returnData);
//
//
//
//$url = 'http://127.0.0.1/game.php/Xiangshan/GameOver';
//$result = https_post(json_encode(['room_id' => 375597,'account_id'=>5841]), $url);
//$returnData = json_decode($result);
//$returnData_row = json_decode($result,true);
//
GameOver(375599,5841,array());
function GameOver($room_id,$account_id,$timer_all){
$url = 'http://127.0.0.1/game.php/Xiangshan/Test';
$result = https_post(json_encode(['room_id' => $room_id,'account_id'=>$account_id,'time_all'=>$timer_all]), $url);
$returnData = json_decode($result);
print_r($returnData->action->chi);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化