|
@@ -50,13 +50,16 @@ class gamematch extends Command
|
|
|
if(!$data){
|
|
|
echo "未找到匹配\n";
|
|
|
if($match_times > 3){
|
|
|
- $robot = Redis::lpop('robot_list');
|
|
|
- $message = [
|
|
|
- "type" => 'gotomatch',
|
|
|
- ];
|
|
|
- if($robot && Gateway::isOnline($robot)){
|
|
|
- Gateway::sendToClient($robot, $message);
|
|
|
- echo "启动机器人: {$robot}\n";
|
|
|
+ $room = Redis::get($data['level']);
|
|
|
+ if($room){
|
|
|
+ $robot = Redis::lpop('robot_list');
|
|
|
+ $message = [
|
|
|
+ "type" => 'gotomatch',
|
|
|
+ ];
|
|
|
+ if($robot && Gateway::isOnline($robot)){
|
|
|
+ Gateway::sendToClient($robot, json_encode($message));
|
|
|
+ echo "启动机器人: {$robot}\n";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
sleep(1);
|
|
@@ -66,8 +69,8 @@ class gamematch extends Command
|
|
|
$match_times = 0;
|
|
|
$info = [];
|
|
|
$questions = [];
|
|
|
- $data = json_decode($data, 1);
|
|
|
$room = Redis::get($data['level']);
|
|
|
+ $data = json_decode($data, 1);
|
|
|
if($room){
|
|
|
Redis::del($data['level']);
|
|
|
$room = json_decode($room, 1);
|