init: 从宝塔同步到 Gitea

This commit is contained in:
root
2026-02-25 01:50:31 +08:00
commit e633c8e27d
2444 changed files with 399341 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
<?php
namespace app\console\controller;
use think\Controller;
use think\Session;
use think\Request;
class Common Extends Controller{
public function __construct(){
parent::__construct();
$user_info = Session::get('user_info');
if(empty($user_info)){
$this->redirect('/login/index',301);
exit();
}
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace app\console\controller;
use think\Controller;
use think\Session;
use think\Request;
use think\Db;
use waybill\WayBill;
use think\Lang;
class Dn Extends Common{
public function create_online_token($user){
$ip = getIP();
$time = time();
return md5($ip.$time.$user['encrypt'].$user['password']);
}
public function index(){
$user_info = Session::get('user_info');
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
if(!$user) exit(Lang::get('userNotExit'));
$online_token = $this->create_online_token($user);
$r = Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
$memo = Db::name('memo')->where('table_id',$table['id'])->where('position',['=',2],['=',3],'or')->where('status',1)->order('id desc')->limit(1)->find();
if($table['scene_limit_money']){
$scene_limit_money = explode('-', $table['scene_limit_money']);
}else{
$scene_limit_money = array(0,0);
}
// 获取语言包信息
$langType = cookie('think_var');
$lang = Lang::get();
$lang = json_encode($lang);
// 渲染参数和模板
$this->assign('scene_limit_money',$scene_limit_money);
$this->assign('memo',$memo);
$this->assign('connections_url','connections_'.$table['port']);
$this->assign('online_token',$online_token);
$this->assign('table',$table);
$this->assign('user',$user);
$this->assign('websocketUrl',$table['ws_local_url']);
$this->assign('langType',$langType);
$this->assign('lang',$lang);
if($table['is_scavenging'] == 1){
return $this->fetch('/dn/index_auto');
}else{
return $this->fetch();
}
}
}
+410
View File
@@ -0,0 +1,410 @@
<?php
namespace app\console\controller;
use think\Controller;
use think\Session;
use think\Request;
use think\Db;
use waybill\WayBill;
use think\Lang;
class Index Extends Common{
public function index(){
$user_info = Session::get('user_info');
$table_id = $user_info['table_id'];
$tableInfo = Db::name('table')->where(array('id' => $table_id))->find();
if($tableInfo['game_id'] == 2){
$this->redirect('/index/tab_dt',301);
}else if($tableInfo['game_id'] == 1 && $tableInfo['mode'] == 2){
$this->redirect('/index/tab_b_win6',301);
}else if($tableInfo['game_id'] == 1 && $tableInfo['mode'] != 2){
$this->redirect('/index/tab_b',301);
}else{
Session::clear();
$this->redirect('login/index',301);
}
$this->redirect('/index/tab_'.$table_id,301);
}
public function create_online_token($user){
$ip = getIP();
$time = time();
return md5($ip.$time.$user['encrypt'].$user['password']);
}
public function tab_b(){
$user_info = Session::get('user_info');
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
if(!$user) exit(Lang::get('userNotExit'));
$online_token = $this->create_online_token($user);
$r = Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
$memo = Db::name('memo')->where('table_id',$table['id'])->where('position',['=',2],['=',3],'or')->where('status',1)->order('id desc')->limit(1)->find();
if($table['scene_limit_money']){
$scene_limit_money = explode('-', $table['scene_limit_money']);
}else{
$scene_limit_money = array(0,0);
}
if($table['scene_limit_money_tie']){
$scene_limit_money_tie = explode('-', $table['scene_limit_money_tie']);
}else{
$scene_limit_money_tie = array(0,0);
}
if($table['scene_limit_money_pair']){
$scene_limit_money_pair = explode('-', $table['scene_limit_money_pair']);
}else{
$scene_limit_money_pair = array(0,0);
}
if($table['scene_limit_money_usd']){
$scene_limit_money_usd = explode('-', $table['scene_limit_money_usd']);
}else{
$scene_limit_money_usd = array(0,0);
}
if($table['scene_limit_money_tie_usd']){
$scene_limit_money_tie_usd = explode('-', $table['scene_limit_money_tie_usd']);
}else{
$scene_limit_money_tie_usd = array(0,0);
}
if($table['scene_limit_money_pair_usd']){
$scene_limit_money_pair_usd = explode('-', $table['scene_limit_money_pair_usd']);
}else{
$scene_limit_money_pair_usd = array(0,0);
}
// 获取语言包信息
$langType = cookie('think_var');
$lang = Lang::get();
$lang = json_encode($lang);
// 渲染参数和模板
$this->assign('scene_limit_money',$scene_limit_money);
$this->assign('scene_limit_money_tie',$scene_limit_money_tie);
$this->assign('scene_limit_money_pair',$scene_limit_money_pair);
$this->assign('scene_limit_money_usd',$scene_limit_money_usd);
$this->assign('scene_limit_money_tie_usd',$scene_limit_money_tie_usd);
$this->assign('scene_limit_money_pair_usd',$scene_limit_money_pair_usd);
$this->assign('memo',$memo);
$this->assign('connections_url','connections_'.$table['port']);
$this->assign('online_token',$online_token);
$this->assign('table',$table);
$this->assign('user',$user);
$this->assign('websocketUrl',$table['websocket_url']);
//$this->assign('websocketUrl',$table['ws_local_url']);
$this->assign('langType',$langType);
$this->assign('lang',$lang);
if($table['is_scavenging'] == 1){
return $this->fetch('/index/tab_b_auto');
}else{
return $this->fetch();
}
}
public function tab_b_win6(){
$user_info = Session::get('user_info');
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
if(!$user) exit(Lang::get('userNotExit'));
$online_token = $this->create_online_token($user);
Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
$memo = Db::name('memo')->where('table_id',$table['id'])->where('position',['=',2],['=',3],'or')->where('status',1)->order('id desc')->limit(1)->find();
if($table['scene_limit_money']){
$scene_limit_money = explode('-', $table['scene_limit_money']);
}else{
$scene_limit_money = array(0,0);
}
if($table['scene_limit_money_tie']){
$scene_limit_money_tie = explode('-', $table['scene_limit_money_tie']);
}else{
$scene_limit_money_tie = array(0,0);
}
if($table['scene_limit_money_pair']){
$scene_limit_money_pair = explode('-', $table['scene_limit_money_pair']);
}else{
$scene_limit_money_pair = array(0,0);
}
if($table['scene_limit_money_usd']){
$scene_limit_money_usd = explode('-', $table['scene_limit_money_usd']);
}else{
$scene_limit_money_usd = array(0,0);
}
if($table['scene_limit_money_tie_usd']){
$scene_limit_money_tie_usd = explode('-', $table['scene_limit_money_tie_usd']);
}else{
$scene_limit_money_tie_usd = array(0,0);
}
if($table['scene_limit_money_pair_usd']){
$scene_limit_money_pair_usd = explode('-', $table['scene_limit_money_pair_usd']);
}else{
$scene_limit_money_pair_usd = array(0,0);
}
// 获取语言包信息
$langType = cookie('think_var');
$lang = Lang::get();
$lang = json_encode($lang);
// 渲染参数和模板
$this->assign('langType',$langType);
$this->assign('lang',$lang);
$this->assign('scene_limit_money',$scene_limit_money);
$this->assign('scene_limit_money_tie',$scene_limit_money_tie);
$this->assign('scene_limit_money_pair',$scene_limit_money_pair);
$this->assign('scene_limit_money_usd',$scene_limit_money_usd);
$this->assign('scene_limit_money_tie_usd',$scene_limit_money_tie_usd);
$this->assign('scene_limit_money_pair_usd',$scene_limit_money_pair_usd);
$this->assign('memo',$memo);
$this->assign('connections_url','connections_'.$table['port']);
$this->assign('online_token',$online_token);
$this->assign('table',$table);
$this->assign('user',$user);
$this->assign('websocketUrl',$table['websocket_url']);
//$this->assign('websocketUrl',$table['ws_local_url']);
if($table['is_scavenging'] == 1){
return $this->fetch('/index/tab_b_win6_auto');
}else{
return $this->fetch();
}
}
public function tab_dt(){
// 获取语言包信息
$langType = cookie('think_var');
$lang = Lang::get();
$lang = json_encode($lang);
$user_info = Session::get('user_info');
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
if(!$user) exit(Lang::get('userNotExit'));
$online_token = $this->create_online_token($user);
Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
$memo = Db::name('memo')->where('table_id',$table['id'])->where('position',['=',2],['=',3],'or')->where('status',1)->order('id desc')->limit(1)->find();
if($table['scene_limit_money']){
$scene_limit_money = explode('-', $table['scene_limit_money']);
}else{
$scene_limit_money = array(0,0);
}
if($table['scene_limit_money_tie']){
$scene_limit_money_tie = explode('-', $table['scene_limit_money_tie']);
}else{
$scene_limit_money_tie = array(0,0);
}
if($table['scene_limit_money_usd']){
$scene_limit_money_usd = explode('-', $table['scene_limit_money_usd']);
}else{
$scene_limit_money_usd = array(0,0);
}
if($table['scene_limit_money_tie_usd']){
$scene_limit_money_tie_usd = explode('-', $table['scene_limit_money_tie_usd']);
}else{
$scene_limit_money_tie_usd = array(0,0);
}
// 渲染参数和模板
$this->assign('lang',$lang);
$this->assign('langType',$langType);
$this->assign('scene_limit_money',$scene_limit_money);
$this->assign('scene_limit_money_tie',$scene_limit_money_tie);
$this->assign('scene_limit_money_usd',$scene_limit_money_usd);
$this->assign('scene_limit_money_tie_usd',$scene_limit_money_tie_usd);
$this->assign('memo',$memo);
$this->assign('connections_url','connections_'.$table['port']);
$this->assign('online_token',$online_token);
$this->assign('table',$table);
$this->assign('user',$user);
$this->assign('websocketUrl',$table['websocket_url']);
//$this->assign('websocketUrl',$table['ws_local_url']);
if($table['is_scavenging'] == 1){
return $this->fetch('/index/tab_dt_auto');
}else{
return $this->fetch();
}
}
//获取当前靴的结果汇总
public function get_result_total(){
if(Request::instance()->isPost()){
//获取路单对象
$table_id = Request::instance()->post('table_id');
$boot_id = Request::instance()->post('boot_id');
$game_id = Db::name('table')->where(array('id' => $table_id))->value('game_id');
$result = array();
if($game_id == 1){
//百家乐
$result['banker'] = Db::name('number_tab')->where(array('boot_id' => $boot_id, 'result' => 1))->count();
$result['player'] = Db::name('number_tab')->where(array('boot_id' => $boot_id, 'result' => 2))->count();
$result['tie'] = Db::name('number_tab')->where(array('boot_id' => $boot_id, 'result' => 3))->count();
$result['bankerPair'] = Db::name('number_tab')->where(array('boot_id' => $boot_id, 'pair' => 1))->count();
$result['playerPair'] = Db::name('number_tab')->where(array('boot_id' => $boot_id, 'pair' => 2))->count();
$both = Db::name('number_tab')->where(array('boot_id' => $boot_id, 'pair' => 3))->count();
$result['bankerPair'] = $result['bankerPair'] + $both;
$result['playerPair'] = $result['playerPair'] + $both;
}else if($game_id == 2){
//龙虎
$result['banker'] = Db::name('number_tab_dt')->where(array('boot_id' => $boot_id, 'result' => 1))->count();
$result['player'] = Db::name('number_tab_dt')->where(array('boot_id' => $boot_id, 'result' => 2))->count();
$result['tie'] = Db::name('number_tab_dt')->where(array('boot_id' => $boot_id, 'result' => 3))->count();
}else if($game_id == 3){
//龙虎
$result['banker'] = Db::name('number_tab_dn')->where(array('boot_id' => $boot_id, 'result' => 1))->count();
$result['player'] = Db::name('number_tab_dn')->where(array('boot_id' => $boot_id, 'result' => 2))->count();
}
return json(['code'=>1,'data'=>$result]);
}
}
//获取当前在线人数
public function get_online_number(){
if(Request::instance()->isPost()){
//获取路单对象
$connections = Request::instance()->post('connections');
$redis = new \Redis();
$redis->connect('127.0.0.1',6379);
$connections = json_decode($redis->get($connections),true);
$count = is_array($connections) ? count($connections) : 0;
return json(['code'=>1,'data'=>$count]);
}
}
//打印
public function stamp(){
$game_id = intval(Request::instance()->get('game_id'));
$nid = intval(Request::instance()->get('nid'));
if($game_id == 1){
$number_tab = Db::name('number_tab')->where(array('id' => $nid))->find();
if($number_tab){
$boot = Db::name('boot')->where(array('id' => $number_tab['boot_id']))->find();
$table = Db::name('table')->where(array('id' => $number_tab['table_id']))->find();
}
}elseif($game_id == 2){
$number_tab = Db::name('number_tab_dt')->where(array('id' => $nid))->find();
if($number_tab){
$boot = Db::name('boot_dt')->where(array('id' => $number_tab['boot_id']))->find();
$table = Db::name('table')->where(array('id' => $number_tab['table_id']))->find();
}
}
if($number_tab && $boot && $table){
$this->assign('nowTime',date('Y-m-d H:i:s',time()));
$this->assign('tableName',$table['table_name']);
$this->assign('bootTime',date('Y-m-d H:i:s',$boot['create_time']));
$this->assign('nTime',date('Y-m-d H:i:s',$number_tab['start_time']));
}else{
$this->assign('nowTime',date('Y-m-d H:i:s',time()));
$this->assign('tableName','');
$this->assign('bootTime','');
$this->assign('nTime','');
}
return $this->fetch(); // 渲染模板
}
// 路单接口调用
public function waybill(){
if(Request::instance()->post()){
// 接收游戏ID和靴ID
$game_id = Request::instance()->post('game_id');
$boot_id = Request::instance()->post('boot_id');
$forecast = Request::instance()->post('forecast');
//验证游戏ID
if($game_id == 1){
$numberTabTable = 'number_tab';
}elseif($game_id == 2){
$numberTabTable = 'number_tab_dt';
}elseif($game_id == 3){
$numberTabTable = 'number_tab_dn';
}else{
die(json_encode(['status'=>false,'msg'=>'游戏ID错误']));
}
// 验证靴ID
if($boot_id > 0){
$ns = Db::name($numberTabTable)->where(array('boot_id' => $boot_id, 'bet_status' => 3))->field('result,pair')->order('start_time ASC,id ASC')->select();
if($forecast == 1){
// 庄问路
$ns[] = array('result'=>1,'pair'=>0);
}elseif($forecast == 2){
// 闲问路
$ns[] = array('result'=>2,'pair'=>0);
}
// 数据存在,输出路单
if($ns){
$result = waybill($ns);
die(json_encode($result));
}else{
$waybill = array();
$waybill['bigEyeRoad'] = [];
$waybill['bigRoad'] = [];
$waybill['pathway'] = [];
$waybill['roach'] = [];
$waybill['showRoad'] = [];
die(json_encode(['status'=>false,'msg'=>'数据不存在','waybill'=>$waybill]));
}
}else{
die(json_encode(['status'=>false,'msg'=>'靴ID错误']));
}
}else{
die(json_encode(['status'=>false,'msg'=>'操作错误']));
}
}
public function lang() {
switch ($_GET['lang']) {
case 'cn':
cookie('think_var', 'zh-cn');
break;
case 'tw':
cookie('think_var', 'zh-tw');
break;
case 'en':
cookie('think_var', 'en-us');
break;
//其它语言
}
}
public function get_number(){
if(Request::instance()->post() && intval(Request::instance()->post('number_tab_id')) > 0){
$number_tab_id = intval(Request::instance()->post('number_tab_id'));
$number = Db::name('number_tab')->where(array('id' => $number_tab_id))->value('number');
return json(array('data' => $number,'status' => 1));
}else{
return json(array('msg' => '数据出错','status' => 0));
}
}
public function get_number_dt(){
if(Request::instance()->post() && intval(Request::instance()->post('number_tab_id')) > 0){
$number_tab_id = intval(Request::instance()->post('number_tab_id'));
$number = Db::name('number_tab_dt')->where(array('id' => $number_tab_id))->value('number');
return json(array('data' => $number,'status' => 1));
}else{
return json(array('msg' => '数据出错','status' => 0));
}
}
//获取上一局number_tab_id
public function get_last_number_tab_id(){
if(Request::instance()->post() && intval(Request::instance()->post('game_id')) > 0){
$game_id = intval(Request::instance()->post('game_id'));
if($game_id == 1){
$numberTabTableName = 'number_tab';
$bootTableName = 'boot';
}elseif($game_id == 2){
$numberTabTableName = 'number_tab_dt';
$bootTableName = 'boot_dt';
}else{
return json(array('msg' => '数据出错','status' => 0));
}
$table_id = intval(Request::instance()->post('table_id'));
$boot_id = intval(Request::instance()->post('boot_id'));
if($table_id > 0 && $boot_id > 0){
$table_info = Db::name('table')->where('id',$table_id)->find();
if($table_info['table_type'] == 0){
if($table_info['bet_type'] != 2){
return json(array('msg' => '该桌不允许删除露珠','status' => 0));
}
}
$lastNumberTabTableId = Db::name($numberTabTableName)->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'bet_status' => 3))->order('id DESC')->limit(1)->value('id');
if($lastNumberTabTableId > 0){
return json(array('data' => $lastNumberTabTableId,'status' => 1));
}else{
return json(array('msg' => '没有可删除的上一铺','status' => 0));
}
}
return json(array('data' => $number,'status' => 1));
}else{
return json(array('msg' => '数据出错','status' => 0));
}
}
}
+80
View File
@@ -0,0 +1,80 @@
<?php
namespace app\console\controller;
use think\Controller;
use think\Db;
use think\Request;
use think\Session;
use verifycode\Verify;
class Login extends Controller{
public function index(){
if(Session::get('user_info')){
$this->redirect('/',301);
}
return $this->fetch();
}
/**
* 处理登录
*/
public function dologin(){
if(Request::instance()->post()){
$username = Request::instance()->post('account');
$password = Request::instance()->post('password');
// $verifycode = strtolower(Request::instance()->post('code'));
// if(md5($verifycode) != Session::get("img_verify")){
// Session::delete('user_info');
// $this->error('验证码错误','login/index');
// }
$find = Db::name('user_controller')->where(array('username' => $username, 'is_delete' => 0))->find();
if(!$find){
Session::delete('user_info');
return json(['code' => 0, 'msg' => '用户不存在']);
}
if(think_ucenter_md5($password, UC_AUTH_KEY) === $find['password'] && $find['password']){
Session::set('user_info',$find);
Db::name('user_controller')->where(array('id' => $find['id']))->update(array('last_login_time' => time(), 'last_login_ip' => getIP()));
$tableInfo = Db::name('table')->where(array('id' => $find['table_id']))->find();
if($tableInfo['game_id'] == 2){
return json(['code'=>1,'msg'=>'登录成功','url'=>'/index/tab_dt']);
}else if($tableInfo['game_id'] == 3){
return json(['code'=>1,'msg'=>'登录成功','url'=>'/dn/index']);
}else if($tableInfo['game_id'] == 4){
return json(['code'=>1,'msg'=>'登录成功','url'=>'/nn/index']);
}else if($tableInfo['game_id'] == 5){
return json(['code'=>1,'msg'=>'登录成功','url'=>'/tc/index']);
}else if($tableInfo['game_id'] == 1 && $tableInfo['mode'] == 2){
return json(['code'=>1,'msg'=>'登录成功','url'=>'/index/tab_b_win6']);
}else if($tableInfo['game_id'] == 1 && $tableInfo['mode'] != 2){
return json(['code'=>1,'msg'=>'登录成功','url'=>'/index/tab_b']);
}else{
Session::delete('user_info');
return json(['code'=>0,'msg'=>'账户信息出错']);
}
/*
$preview_url = Session::get('preview_url');
if($preview_url){
return json(['code'=>1,'msg'=>'登录成功','url'=>$preview_url]);
}else{
return json(['code'=>1,'msg'=>'登录成功','url'=>'/']);
}
*/
}else{
Session::delete('user_info');
return json(['code'=>0,'msg'=>'密码错误']);
}
}
}
/**
* 退出登录
*/
public function logout(){
Session::clear();
$this->redirect('login/index',301);
}
/**
* 验证码
*/
public function verifycode(){
$verify = new verify();
$verify->doimg();
}
}
+130
View File
@@ -0,0 +1,130 @@
<?php
namespace app\console\controller;
use think\Controller;
use think\Session;
use think\Request;
use think\Db;
use waybill\WayBill;
use think\Lang;
class Nn Extends Common{
public function create_online_token($user){
$ip = getIP();
$time = time();
return md5($ip.$time.$user['encrypt'].$user['password']);
}
public function index(){
$user_info = Session::get('user_info');
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
if(!$user) exit(Lang::get('userNotExit'));
$online_token = $this->create_online_token($user);
$r = Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
$memo = Db::name('memo')->where('table_id',$table['id'])->where('position',['=',2],['=',3],'or')->where('status',1)->order('id desc')->limit(1)->find();
if($table['scene_limit_money']){
$scene_limit_money = explode('-', $table['scene_limit_money']);
}else{
$scene_limit_money = array(0,0);
}
// 获取语言包信息
$langType = cookie('think_var');
$lang = Lang::get();
$lang = json_encode($lang);
// 渲染参数和模板
$this->assign('scene_limit_money',$scene_limit_money);
$this->assign('memo',$memo);
$this->assign('connections_url','connections_'.$table['port']);
$this->assign('online_token',$online_token);
$this->assign('table',$table);
$this->assign('user',$user);
$this->assign('websocketUrl',$table['ws_local_url']);
$this->assign('langType',$langType);
$this->assign('lang',$lang);
if($table['is_scavenging'] == 1){
return $this->fetch('/nn/index');
}else{
return $this->fetch('/nn/index');
}
}
//获取当前靴的结果汇总
public function get_result_total(){
if(Request::instance()->isPost()){
//获取路单对象
$table_id = Request::instance()->post('table_id');
$boot_id = Request::instance()->post('boot_id');
// $game_id = Db::name('table')->where(array('id' => $table_id))->value('game_id');
$banker_total = 0;
$player_total = 0;
$result = array();
$all_result = Db::name('number_tab_nn')->where(array('boot_id' => $boot_id,'bet_status'=>3))->select();
foreach($all_result as $k => $v){
if($v['win_player_1'] == 1){
$player_total++;
}elseif($v['win_player_1'] == 0){
$banker_total++;
}
if($v['win_player_2'] == 1){
$player_total++;
}elseif($v['win_player_2'] == 0){
$banker_total++;
}
if($v['win_player_3'] == 1){
$player_total++;
}elseif($v['win_player_3'] == 0){
$banker_total++;
}
}
$result['banker'] = $banker_total;
$result['player'] = $player_total;
return json(['code'=>1,'data'=>$result]);
}
}
// 路单接口调用
public function waybill(){
if(Request::instance()->post()){
// 接收游戏ID和靴ID
$game_id = Request::instance()->post('game_id');
$boot_id = Request::instance()->post('boot_id');
//验证游戏ID
if($game_id == 4){
$numberTabTable = 'number_tab_nn';
}else{
die(json_encode(['status'=>false,'msg'=>'游戏ID错误']));
}
// 验证靴ID
if($boot_id > 0){
$ns = Db::name($numberTabTable)->where(array('boot_id' => $boot_id, 'bet_status' => 3))->field('result_banker,result_player_1,result_player_2,result_player_3,win_player_1,win_player_2,win_player_3')->order('start_time ASC,id ASC')->select();
// 数据存在,输出路单
if($ns){
// die(json_encode($ns));
$result = nn_waybill($ns);
die(json_encode($result));
}else{
$waybill = array();
die(json_encode(['status'=>false,'msg'=>'数据不存在','waybill'=>$waybill]));
}
}else{
die(json_encode(['status'=>false,'msg'=>'靴ID错误']));
}
}else{
die(json_encode(['status'=>false,'msg'=>'操作错误']));
}
}
//获取点数
public function get_nn_num(){
if(Request::instance()->post()){
$result_arr = Request::instance()->post('result_json');
$result = JudgeCowCow(json_decode($result_arr,true));
die(json_encode(['status'=>true,'msg'=>$result['word']]));
}else{
die(json_encode(['status'=>false,'msg'=>'操作错误']));
}
}
}
+71
View File
@@ -0,0 +1,71 @@
<?php
namespace app\console\controller;
use think\Controller;
use think\Db;
use think\Request;
use think\Session;
class Scan extends Controller{
public function create_online_token($user){
//$ip = getIP();
//$time = time();
return md5($user['encrypt'].$user['password']);
}
public function index(){
// 用户信息
$user_info = Session::get('user_info');
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
if(!$user) exit('用户不存在');
// 验证token
$online_token = $this->create_online_token($user);
$r = Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
// 获取桌子信息
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
// 渲染参数和模板
$this->assign('connections_url','connections_'.$table['port']);
$this->assign('online_token',$online_token);
$this->assign('table',$table);
$this->assign('user',$user);
$this->assign('websocketUrl',$table['websocket_url']);
return $this->fetch();
}
public function nn_index(){
// 用户信息
$user_info = Session::get('user_info');
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
if(!$user) exit('用户不存在');
// 验证token
$online_token = $this->create_online_token($user);
$r = Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
// 获取桌子信息
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
// 渲染参数和模板
$this->assign('connections_url','connections_'.$table['port']);
$this->assign('online_token',$online_token);
$this->assign('table',$table);
$this->assign('user',$user);
$this->assign('websocketUrl',$table['ws_local_url']);
return $this->fetch();
}
public function tc_index(){
// 用户信息
$user_info = Session::get('user_info');
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
if(!$user) exit('用户不存在');
// 验证token
$online_token = $this->create_online_token($user);
$r = Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
// 获取桌子信息
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
// 渲染参数和模板
$this->assign('connections_url','connections_'.$table['port']);
$this->assign('online_token',$online_token);
$this->assign('table',$table);
$this->assign('user',$user);
$this->assign('websocketUrl',$table['ws_local_url']);
return $this->fetch();
}
}
+298
View File
@@ -0,0 +1,298 @@
<?php
namespace app\console\controller;
use think\Controller;
use think\Session;
use think\Request;
use think\Db;
use waybill\WayBill;
use think\Lang;
class Tc Extends Common{
public function create_online_token($user){
$ip = getIP();
$time = time();
return md5($ip.$time.$user['encrypt'].$user['password']);
}
public function index(){
$user_info = Session::get('user_info');
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
if(!$user) exit(Lang::get('userNotExit'));
$online_token = $this->create_online_token($user);
$r = Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
$memo = Db::name('memo')->where('table_id',$table['id'])->where('position',['=',2],['=',3],'or')->where('status',1)->order('id desc')->limit(1)->find();
if($table['scene_limit_money']){
$scene_limit_money = explode('-', $table['scene_limit_money']);
}else{
$scene_limit_money = array(0,0);
}
// 获取语言包信息
$langType = cookie('think_var');
$lang = Lang::get();
$lang = json_encode($lang);
// 渲染参数和模板
$this->assign('scene_limit_money',$scene_limit_money);
$this->assign('memo',$memo);
$this->assign('connections_url','connections_'.$table['port']);
$this->assign('online_token',$online_token);
$this->assign('table',$table);
$this->assign('user',$user);
$this->assign('websocketUrl',$table['ws_local_url']);
$this->assign('langType',$langType);
$this->assign('lang',$lang);
if($table['is_scavenging'] == 1){
return $this->fetch('/tc/index');
}else{
return $this->fetch('/tc/index');
}
}
//获取当前靴的结果汇总
public function get_result_total(){
if(Request::instance()->isPost()){
//获取路单对象
$table_id = Request::instance()->post('table_id');
$boot_id = Request::instance()->post('boot_id');
// $game_id = Db::name('table')->where(array('id' => $table_id))->value('game_id');
$banker_total = 0;
$player_total = 0;
$result = array();
$all_result = Db::name('number_tab_nn')->where(array('boot_id' => $boot_id,'bet_status'=>3))->select();
foreach($all_result as $k => $v){
if($v['win_player_1'] == 1){
$player_total++;
}elseif($v['win_player_1'] == 0){
$banker_total++;
}
if($v['win_player_2'] == 1){
$player_total++;
}elseif($v['win_player_2'] == 0){
$banker_total++;
}
if($v['win_player_3'] == 1){
$player_total++;
}elseif($v['win_player_3'] == 0){
$banker_total++;
}
}
$result['banker'] = $banker_total;
$result['player'] = $player_total;
return json(['code'=>1,'data'=>$result]);
}
}
// 路单接口调用
public function waybill(){
if(Request::instance()->post()){
// 接收游戏ID和靴ID
$game_id = Request::instance()->post('game_id');
$boot_id = Request::instance()->post('boot_id');
//验证游戏ID
if($game_id == 4 || $game_id == 5){
$numberTabTable = 'number_tab_tc';
}else{
die(json_encode(['status'=>false,'msg'=>'游戏ID错误']));
}
// 验证靴ID
if($boot_id > 0){
$ns = Db::name($numberTabTable)->where(array('boot_id' => $boot_id, 'bet_status' => 3))->field('result_banker,result_player_1,result_player_2,result_player_3,win_player_1,win_player_2,win_player_3')->order('start_time ASC,id ASC')->select();
// 数据存在,输出路单
if($ns){
// die(json_encode($ns));
$result = nn_waybill($ns);
die(json_encode($result));
}else{
$waybill = array();
die(json_encode(['status'=>false,'msg'=>'数据不存在','waybill'=>$waybill]));
}
}else{
die(json_encode(['status'=>false,'msg'=>'靴ID错误']));
}
}else{
die(json_encode(['status'=>false,'msg'=>'操作错误']));
}
}
//获取点数
public function get_nn_num(){
if(Request::instance()->post()){
$result_arr = Request::instance()->post('result_json');
$result = JudgeCowCow(json_decode($result_arr,true));
die(json_encode(['status'=>true,'msg'=>$result['word']]));
}else{
die(json_encode(['status'=>false,'msg'=>'操作错误']));
}
}
public function ThredCardCowCow(){
$card = array('112','201','301');
$card_type = array();
if(!is_array($card) || count($card) !== 3){
return false;
}
//获取三张牌中最大的牌
$compare = $card;
for($i=0;$i<2;$i++){
for($j=$i+1;$j<3;$j++){
if(substr($compare[$i],1,2) < substr($compare[$j],1,2)){
$a = $compare[$i];
$compare[$i] = $compare[$j];
$compare[$j]=$a;
}
}
}
$max_card = substr($compare['0'],1,2);
if(substr($max_card,0,1) == 0){
$max_card = substr($max_card,1,1);
}
$same_num = 0;
for($i=0;$i<3; $i++){
$card_type[$i] = substr($card[$i],0,1);
$card[$i] = substr($card[$i],1,2);
if(substr($card[$i],0,1) == 0){
$card[$i] = substr($card[$i],1,1);
}
if($card[$i] == $max_card){
$same_num++;
}
}
//特殊牌型最大牌判断
$space_num = array_count_values($card);
if($same_num == 1){
$max = $compare['0'];
}
if($same_num > 1){
$compare = array_slice($compare,0,$same_num);
for($i=0;$i<$same_num-1;$i++){//对5张牌从大到小排序。
for($j=$i+1;$j<$same_num;$j++){
if($compare[$i] > $compare[$j]){
$a = $compare[$i];
$compare[$i] = $compare[$j];
$compare[$j]=$a;
}
}
}
$max = $compare['0'];
if($same_num == 2){
if($compare['0']>300 && $compare['0']<400){
$max = $compare['1'];
}
}
}
$result = array();
//豹子判断
if(count($card) != count(array_unique($card))) {
$unique_arr = array_unique($card);
if(count($unique_arr) == 1){
$cow = 11;
$word = '豹子';
if(array_key_exists(1,$space_num)){
if($space_num['1'] > 0){
if($space_num['1'] == 1){
$max = $compare[2];
}
if($space_num['1'] == 2){
if($compare[1]>300 && $compare[1]<400){
$max = $compare[2];
}else{
$max = $compare[1];
}
}
}
}
array_push($result,$word,$cow,$max);
return json($result);
}
}
if(count(array_unique($card_type)) == 1){
//皇家同花顺
$example = array(1,12,13);
$diff_result=array_diff($card,$example);
if(count($diff_result) == 0){
$cow = 13;
$word = '皇家同花顺';
if($space_num['1'] == 1){
$max = $compare[2];
}
return $max;
array_push($result,$word,$cow,$max);
return $result;
}
//同花顺
if(count($card) == count(array_unique($card))) {
$max=$min=-1;
for ($i=0; $i < 3; $i++) {
if($card[$i] > $max || $max == -1){
$max = $card[$i];
}
if($card[$i] < $min || $min == -1){
$min = $card[$i];
}
if($max - $min == 2){
$cow = 12;
$word = '同花顺';
if($space_num['1'] == 1){
$max = $compare[2];
}
array_push($result,$word,$cow,$max);
return $result;
}
}
}
}
if($card[0]>10)$card[0]=10;
if($card[1]>10)$card[1]=10;
if($card[2]>10)$card[2]=10;
$sum_num = $card[0] + $card[1] + $card[2];
if($sum_num < 10){
$cow = $sum_num;
}else{
$cow = $sum_num%10;
}
switch ($cow){
case 0:
$word = '牛牛';
break;
case 1:
$word = '牛一';
break;
case 2:
$word = '牛二';
break;
case 3:
$word = '牛三';
break;
case 4:
$word = '牛四';
break;
case 5:
$word = '牛五';
break;
case 6:
$word = '牛六';
break;
case 7:
$word = '牛七';
break;
case 8:
$word = '牛八';
break;
case 9:
$word = '牛九';
break;
}
if($cow == 0){
$cow = 10;
}
$result['word'] = $word;
$result['cow'] = $cow;
$result['max'] = $max;
return $result;
}
}
+491
View File
@@ -0,0 +1,491 @@
<?php
namespace app\console\controller;
use think\Controller;
use think\Request;
use think\Db;
class Testld Extends Common{
//测试路单
/*
public function testld(){
$ns = Db::name('number_tab')->where(array('boot_id' => 4, 'bet_status' => 3))->order('id ASC')->select();
$bigRoad = array();
$bigEyeRoad = array();
//列
$yKey = 0;
//行
$xKey = 0;
//上一回合坐标
$last = array();
foreach($ns AS $key => $value){
if($key == 0 && $value['result'] == 3){
$bigRoad[$yKey][$xKey] = array('result' => 3, 'tie_num' => 1);
$last = array('yKey' => $yKey, 'xKey' => $xKey);
}elseif($key > 0 && $value['result'] == 3){
$bigRoad[$last['yKey']][$last['xKey']]['tie_num'] = $bigRoad[$last['yKey']][$last['xKey']]['tie_num'] + 1;
}elseif($yKey == 0 && $xKey == 0 && !empty($last) && $value['result'] != 3){
$bigRoad[$last['yKey']][$last['xKey']]['result'] = $value['result'];
$last = array('yKey' => $yKey, 'xKey' => $xKey);
}else{
$bigRoad[$yKey][$xKey] = array('result' => $value['result'], 'tie_num' => 0);
$last = array('yKey' => $yKey, 'xKey' => $xKey);
if(isset($ns[$key+1]) && $ns[$key+1]['result'] != $bigRoad[$yKey][$xKey]['result']){
$yKey++;
$xKey = 0;
}else{
$xKey++;
}
}
}
$bigEyeRoadStart = false;
$bigEyeRoadYKey = 0;
$bigEyeRoadXKey = 0;
$bigEyeRoadLast = array();
foreach($bigRoad AS $key => $value){
foreach($value AS $k => $v){
if($key == 1 && $k == 1 && isset($bigRoad[1][1])){
if(isset($bigRoad[0][1])){
$bigEyeRoad[0][0] = array('result' => 1);
}else{
$bigEyeRoad[0][0] = array('result' => 2);
}
$bigEyeRoadStart = true;
$bigEyeRoadLast = $bigEyeRoad[0][0];
continue;
}
if($key == 2 && $k == 0 && !isset($bigEyeRoad[0][0])){
if(isset($bigRoad[0]) && isset($bigRoad[1]) && count($bigRoad[0]) == count($bigRoad[1])){
$bigEyeRoad[0][0] = array('result' => 1);
}else{
$bigEyeRoad[0][0] = array('result' => 2);
}
$bigEyeRoadStart = true;
$bigEyeRoadLast = $bigEyeRoad[0][0];
continue;
}
if($bigEyeRoadStart == true){
$bigEyeRoadPushData = array();
if($k == 0){ //第一个
$p1 = $key - 1;
$p2 = $key - 2;
if(count($bigRoad[$p1]) == count($bigEyeRoad[$p2])){
$bigEyeRoadPushData = array('result' => 1);
}else{
$bigEyeRoadPushData = array('result' => 2);
}
}elseif($k == 1){ //第二个
if(isset($bigRoad[$key-1][$k])){
$bigEyeRoadPushData = array('result' => 1);
}else{
$bigEyeRoadPushData = array('result' => 2);
}
}else{ //第三个或者之后那些
if(isset($bigRoad[$key-1][$k-1]) && !isset($bigRoad[$key-1][$k])){
$bigEyeRoadPushData = array('result' => 2);
}else{
$bigEyeRoadPushData = array('result' => 1);
}
}
if($bigEyeRoadLast['result'] == $bigEyeRoadPushData['result']){
$bigEyeRoadXKey++;
}else{
$bigEyeRoadYKey++;
$bigEyeRoadXKey = 0;
}
$bigEyeRoad[$bigEyeRoadYKey][$bigEyeRoadXKey] = $bigEyeRoadPushData;
$bigEyeRoadLast = $bigEyeRoadPushData;
}
}
}
echo "<pre>";
print_r($bigEyeRoad);
echo "</pre>";
}
*/
//测试路单
public function testld2(){
$ns = Db::name('number_tab')->where(array('boot_id' => 7, 'bet_status' => 3))->order('id ASC')->select();
$bigRoad = array();
$bigEyeRoad = array();
$pathway = array();
$roach = array();
/**************************** 计算 bigRoad start ***************************/
//列
$yKey = 0;
//行
$xKey = 0;
$last = array();
foreach($ns AS $key => $value){
if($value['pair'] == 1){
$pair = 'bankerPair';
}elseif($value['pair'] == 2){
$pair = 'playerPair';
}elseif($value['pair'] == 3){
$pair = 'bothPair';
}else{
$pair = 'none';
}
if($key == 0 && $value['result'] == 3){
$bigRoad[$yKey][$xKey] = array('result' => 3, 'tie_num' => 1, 'pair' => $pair);
$last = array('yKey' => $yKey, 'xKey' => $xKey);
}elseif($yKey == 0 && $xKey == 0 && !empty($last) && $value['result'] != 3){
$bigRoad[$last['yKey']][$last['xKey']]['result'] = $value['result'];
if(isset($ns[$key+1]) && $ns[$key+1]['result'] != $bigRoad[$last['yKey']][$last['xKey']]['result'] && $ns[$key+1]['result'] != 3){
$yKey++;
$xKey = 0;
}elseif(isset($ns[$key+1]) && $ns[$key+1]['result'] == $bigRoad[$last['yKey']][$last['xKey']]['result'] && $ns[$key+1]['result'] != 3){
$xKey++;
}
$last = array('yKey' => $yKey, 'xKey' => $xKey);
}elseif($key > 0 && $value['result'] == 3){
$bigRoad[$last['yKey']][$last['xKey']]['tie_num'] = $bigRoad[$last['yKey']][$last['xKey']]['tie_num'] + 1;
if(isset($ns[$key+1]) && $ns[$key+1]['result'] != $bigRoad[$last['yKey']][$last['xKey']]['result'] && $ns[$key+1]['result'] != 3 && $bigRoad[$last['yKey']][$last['xKey']]['result'] != 3){
$yKey++;
$xKey = 0;
}elseif(isset($ns[$key+1]) && $ns[$key+1]['result'] == $bigRoad[$last['yKey']][$last['xKey']]['result'] && $ns[$key+1]['result'] != 3 && $bigRoad[$last['yKey']][$last['xKey']]['result'] != 3){
$xKey++;
}
$last = array('yKey' => $last['yKey'], 'xKey' => $last['xKey']);
}else{
$bigRoad[$yKey][$xKey] = array('result' => $value['result'], 'tie_num' => 0, 'pair' => $pair);
if(isset($ns[$key+1]) && $ns[$key+1]['result'] != $bigRoad[$yKey][$xKey]['result'] && $ns[$key+1]['result'] != 3){
$yKey++;
$xKey = 0;
}elseif(isset($ns[$key+1]) && $ns[$key+1]['result'] == $bigRoad[$yKey][$xKey]['result'] && $ns[$key+1]['result'] != 3){
$xKey++;
}
$last = array('yKey' => $yKey, 'xKey' => $xKey);
}
}
//重新计算坐标
$bigRoadLocation = array();
$occupy = array();
foreach($bigRoad 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;
array_push($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;
array_push($occupy,$show_y.'-'.$show_x);
}elseif($swerve !== false){
$swerveY = $swerveY + 1;
$show_y = $swerveY;
$show_x = $swerve;
array_push($occupy,$show_y.'-'.$show_x);
}
$pushArray = array('show_y' => $show_y, 'show_x' => $show_x, 'result' => $v['result'], 'pair' => $v['pair'], 'tie_num' => $v['tie_num']);
array_push($bigRoadLocation,$pushArray);
}
}
//echo "<pre>";
//print_r($bigRoadLocation);
//echo "</pre>";
//exit();
/**************************** 计算 bigRoad end ***************************/
/**************************** 计算 bigEyeRoad start ***************************/
$bigEyeRoadStart = false;
$bigEyeRoadYKey = 0;
$bigEyeRoadXKey = 0;
$bigEyeRoadLast = array();
foreach($bigRoad AS $key => $value){
foreach($value AS $k => $v){
if($key == 1 && $k == 1 && isset($bigRoad[1][1])){
if(isset($bigRoad[0][1])){
$bigEyeRoad[0][0] = array('result' => 1);
}else{
$bigEyeRoad[0][0] = array('result' => 2);
}
$bigEyeRoadStart = true;
$bigEyeRoadLast = $bigEyeRoad[0][0];
continue;
}
if($key == 2 && $k == 0 && !isset($bigEyeRoad[0][0])){
if(isset($bigRoad[0]) && isset($bigRoad[1]) && count($bigRoad[0]) == count($bigRoad[1])){
$bigEyeRoad[0][0] = array('result' => 1);
}else{
$bigEyeRoad[0][0] = array('result' => 2);
}
$bigEyeRoadStart = true;
$bigEyeRoadLast = $bigEyeRoad[0][0];
continue;
}
if($bigEyeRoadStart == true){
$bigEyeRoadPushData = array();
if($k == 0){ //第一个
$p1 = $key - 1;
$p2 = $key - 2;
if(count($bigRoad[$p1]) == count($bigRoad[$p2])){
$bigEyeRoadPushData = array('result' => 1);
}else{
$bigEyeRoadPushData = array('result' => 2);
}
}elseif($k == 1){ //第二个
if(isset($bigRoad[$key-1][$k])){
$bigEyeRoadPushData = array('result' => 1);
}else{
$bigEyeRoadPushData = array('result' => 2);
}
}else{ //第三个或者之后那些
if(isset($bigRoad[$key-1][$k-1]) && !isset($bigRoad[$key-1][$k])){
$bigEyeRoadPushData = array('result' => 2);
}else{
$bigEyeRoadPushData = array('result' => 1);
}
}
if($bigEyeRoadLast['result'] == $bigEyeRoadPushData['result']){
$bigEyeRoadXKey++;
}else{
$bigEyeRoadYKey++;
$bigEyeRoadXKey = 0;
}
$bigEyeRoad[$bigEyeRoadYKey][$bigEyeRoadXKey] = $bigEyeRoadPushData;
$bigEyeRoadLast = $bigEyeRoadPushData;
}
}
}
//重新计算坐标
$bigEyeRoadLocation = array();
$occupyEye = array();
foreach($bigEyeRoad 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;
array_push($occupyEye,$show_y.'-'.$show_x);
}elseif(in_array($show_y.'-'.$show_x,$occupyEye)){
if($swerve === false){
$swerve = $show_x - 1;
}
$swerveY = $swerveY + 1;
$show_y = $swerveY;
$show_x = $swerve;
array_push($occupyEye,$show_y.'-'.$show_x);
}elseif($swerve !== false){
$swerveY = $swerveY + 1;
$show_y = $swerveY;
$show_x = $swerve;
array_push($occupyEye,$show_y.'-'.$show_x);
}
$pushArray = array('show_y' => $show_y, 'show_x' => $show_x, 'result' => $v['result']);
array_push($bigEyeRoadLocation,$pushArray);
}
}
echo "<pre>";
print_r($bigEyeRoadLocation);
echo "</pre>";
exit();
/**************************** 计算 bigEyeRoad end ***************************/
/**************************** 计算 pathway start ***************************/
$pathwayStart = false;
$pathwayYKey = 0;
$pathwayXKey = 0;
$pathwayLast = array();
foreach($bigRoad AS $key => $value){
foreach($value AS $k => $v){
if($key == 2 && $k == 1 && isset($bigRoad[2][1])){
if(isset($bigRoad[0][1])){
$pathway[0][0] = array('result' => 1);
}else{
$pathway[0][0] = array('result' => 2);
}
$pathwayStart = true;
$pathwayLast = $pathway[0][0];
continue;
}
if($key == 3 && $k == 0 && !isset($pathway[0][0])){
if(isset($bigRoad[0]) && isset($bigRoad[2]) && count($bigRoad[0]) == count($bigRoad[2])){
$pathway[0][0] = array('result' => 1);
}else{
$pathway[0][0] = array('result' => 2);
}
$pathwayStart = true;
$pathwayLast = $pathway[0][0];
continue;
}
if($pathwayStart == true){
$pushData = array();
if($k == 0){ //第一个
$p1 = $key - 1;
$p2 = $key - 3;
if(count($bigRoad[$p1]) == count($pathway[$p2])){
$pushData = array('result' => 1);
}else{
$pushData = array('result' => 2);
}
}elseif($k == 1){ //第二个
if(isset($bigRoad[$key-1][$k])){
$pushData = array('result' => 1);
}else{
$pushData = array('result' => 2);
}
}else{ //第三个或者之后那些
if(isset($bigRoad[$key-2][$k-1]) && !isset($bigRoad[$key-2][$k])){
$pushData = array('result' => 2);
}else{
$pushData = array('result' => 1);
}
}
if($pathwayLast['result'] == $pushData['result']){
$pathwayXKey++;
}else{
$pathwayYKey++;
$pathwayXKey = 0;
}
$pathway[$pathwayYKey][$pathwayXKey] = $pushData;
$pathwayLast = $pushData;
}
}
}
//重新计算坐标
$pathwayLocation = array();
$occupyPathway = array();
foreach($pathway 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;
array_push($occupyPathway,$show_y.'-'.$show_x);
}elseif(in_array($show_y.'-'.$show_x,$occupyPathway)){
if($swerve === false){
$swerve = $show_x - 1;
}
$swerveY = $swerveY + 1;
$show_y = $swerveY;
$show_x = $swerve;
array_push($occupyPathway,$show_y.'-'.$show_x);
}elseif($swerve !== false){
$swerveY = $swerveY + 1;
$show_y = $swerveY;
$show_x = $swerve;
array_push($occupyPathway,$show_y.'-'.$show_x);
}
$pushArray = array('show_y' => $show_y, 'show_x' => $show_x, 'result' => $v['result']);
array_push($pathwayLocation,$pushArray);
}
}
echo "<pre>";
print_r($pathwayLocation);
echo "</pre>";
exit();
/**************************** 计算 pathway end ***************************/
/**************************** 计算 roach start ***************************/
$roachStart = false;
$roachYKey = 0;
$roachXKey = 0;
$roachLast = array();
foreach($bigRoad AS $key => $value){
foreach($value AS $k => $v){
if($key == 3 && $k == 1 && isset($bigRoad[3][1])){
if(isset($bigRoad[0][1])){
$roach[0][0] = array('result' => 1);
}else{
$roach[0][0] = array('result' => 2);
}
$roachStart = true;
$roachLast = $roach[0][0];
continue;
}
if($key == 4 && $k == 0 && !isset($roach[0][0])){
if(isset($bigRoad[0]) && isset($bigRoad[3]) && count($bigRoad[0]) == count($bigRoad[3])){
$roach[0][0] = array('result' => 1);
}else{
$roach[0][0] = array('result' => 2);
}
$roachStart = true;
$roachLast = $roach[0][0];
continue;
}
if($roachStart == true){
$pushData = array();
if($k == 0){ //第一个
$p1 = $key - 1;
$p2 = $key - 4;
if(count($bigRoad[$p1]) == count($roach[$p2])){
$pushData = array('result' => 1);
}else{
$pushData = array('result' => 2);
}
}elseif($k == 1){ //第二个
if(isset($bigRoad[$key-1][$k])){
$pushData = array('result' => 1);
}else{
$pushData = array('result' => 2);
}
}else{ //第三个或者之后那些
if(isset($bigRoad[$key-3][$k-1]) && !isset($bigRoad[$key-3][$k])){
$pushData = array('result' => 2);
}else{
$pushData = array('result' => 1);
}
}
if($roachLast['result'] == $pushData['result']){
$roachXKey++;
}else{
$roachYKey++;
$roachXKey = 0;
}
$roach[$roachYKey][$roachXKey] = $pushData;
$roachLast = $pushData;
}
}
}
//重新计算坐标
$roachLocation = array();
$occupyRoach = array();
foreach($roach 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;
array_push($occupyRoach,$show_y.'-'.$show_x);
}elseif(in_array($show_y.'-'.$show_x,$occupyRoach)){
if($swerve === false){
$swerve = $show_x - 1;
}
$swerveY = $swerveY + 1;
$show_y = $swerveY;
$show_x = $swerve;
array_push($occupyRoach,$show_y.'-'.$show_x);
}elseif($swerve !== false){
$swerveY = $swerveY + 1;
$show_y = $swerveY;
$show_x = $swerve;
array_push($occupyRoach,$show_y.'-'.$show_x);
}
$pushArray = array('show_y' => $show_y, 'show_x' => $show_x, 'result' => $v['result']);
array_push($roachLocation,$pushArray);
}
}
echo "<pre>";
print_r($roachLocation);
echo "</pre>";
exit();
}
}