$value) { $value['result'] = self::resultParseBS($value['dice_result']); $ns[$key] = $value; } foreach($ns AS $key => $value){ $bigRoadBS[$yKey][$xKey] = array('result' => $value['result']); if(isset($ns[$key+1]) && $ns[$key+1]['result'] != $bigRoadBS[$yKey][$xKey]['result']){ $yKey++; $xKey = 0; }else{ $xKey++; } } //重新计算坐标 $bigRoadBSLocation = array(); $occupy = array(); foreach($bigRoadBS AS $key => $value){ $swerve = false; $swerveY = $key; foreach($value AS $k => $v){ $show_y = $key; $show_x = $k; if($show_x > 5 && $swerve === false){ $swerveY = $swerveY + 1; $show_y = $swerveY; $show_x = 5; $occupy[] = $show_y . '-' . $show_x; }elseif(in_array($show_y.'-'.$show_x,$occupy)){ if($swerve === false){ $swerve = $show_x - 1; } $swerveY = $swerveY + 1; $show_y = $swerveY; $show_x = $swerve; $occupy[] = $show_y . '-' . $show_x; }elseif($swerve !== false){ $swerveY = $swerveY + 1; $show_y = $swerveY; $show_x = $swerve; $occupy[] = $show_y . '-' . $show_x; } $pushArray = array('show_x' => $show_y+1, 'show_y' => $show_x+1, 'result' => $v['result']); $bigRoadBSLocation[] = $pushArray; } } /**************************** 计算 bigRoadBS end ***************************/ /**************************** 计算 bigRoadSP start ***************************/ //列 $yKey = 0; //行 $xKey = 0; $bigRoadSP = array(); foreach($ns AS $key => $value) { $value['result'] = self::resultParseSP($value['dice_result']); $ns[$key] = $value; } foreach($ns AS $key => $value){ $bigRoadSP[$yKey][$xKey] = array('result' => $value['result']); if(isset($ns[$key+1]) && $ns[$key+1]['result'] != $bigRoadSP[$yKey][$xKey]['result']){ $yKey++; $xKey = 0; }else{ $xKey++; } } //重新计算坐标 $bigRoadSPLocation = array(); $occupy = array(); foreach($bigRoadSP AS $key => $value){ $swerve = false; $swerveY = $key; foreach($value AS $k => $v){ $show_y = $key; $show_x = $k; if($show_x > 5 && $swerve === false){ $swerveY = $swerveY + 1; $show_y = $swerveY; $show_x = 5; $occupy[] = $show_y . '-' . $show_x; }elseif(in_array($show_y.'-'.$show_x,$occupy)){ if($swerve === false){ $swerve = $show_x - 1; } $swerveY = $swerveY + 1; $show_y = $swerveY; $show_x = $swerve; $occupy[] = $show_y . '-' . $show_x; }elseif($swerve !== false){ $swerveY = $swerveY + 1; $show_y = $swerveY; $show_x = $swerve; $occupy[] = $show_y . '-' . $show_x; } $pushArray = array('show_x' => $show_y+1, 'show_y' => $show_x+1, 'result' => $v['result']); $bigRoadSPLocation[] = $pushArray; } } /**************************** 计算 bigRoadSP end ***************************/ $data = array(); $data['showRoad'] = $showRoadLocation; $data['bigRoadBS'] = $bigRoadBSLocation; $data['bigRoadSP'] = $bigRoadSPLocation; return (['status'=>true, 'msg'=>'数据存在', 'waybill'=>$data]); } // 结果分析(大小) public static function resultParseBS($resultString){ $resultArray = explode(",", $resultString); $intResultArray = []; foreach ($resultArray as $v){ $intResultArray[] = intval($v); } $total = array_sum($intResultArray); // 判断是不是全部值都是一样的 $uniqueArray = array_unique($intResultArray); if (count($uniqueArray) == 1) { return 3; } else { if ($total >= 4 && $total <= 10) { return 2; } else { return 1; } } } // 结果分析(单双) public static function resultParseSP($resultString){ $resultArray = explode(",", $resultString); $intResultArray = []; foreach ($resultArray as $v){ $intResultArray[] = intval($v); } $total = array_sum($intResultArray); // 判断是不是全部值都是一样的 $uniqueArray = array_unique($intResultArray); if (count($uniqueArray) == 1) { return 3; } else { if ($total % 2 == 0) { return 1; } else { return 2; } } } }