소스 검색

更新机器人 匹配规则

郑晓宇 6 년 전
부모
커밋
d15bd205f0
2개의 변경된 파일17개의 추가작업 그리고 17개의 파일을 삭제
  1. 13 14
      app/Console/Commands/gamematch.php
  2. 4 3
      app/Console/Commands/robot.php

+ 13 - 14
app/Console/Commands/gamematch.php

@@ -71,7 +71,6 @@ class gamematch extends Command
                     if(!Gateway::isUidOnline($user->user_id)){
                         $update_data = [
                             "is_login" => 0,
-                            "client_id" => '',
                         ];
                         //更新机器人登陆状态
                         User::where("user_id", $user->user_id)->update($update_data);
@@ -91,19 +90,19 @@ class gamematch extends Command
             $info = [];
             $room_id = $this->get_free_room();
             $user = User::select('user_id', 'avatar', 'name', 'win_count', 'lose_count','client_id')->where("user_id", $user_id)->first();
-            if($user->is_robot && !$user->is_login){
-                if(Gateway::isUidOnline($user_id)){
-                    //更新用户登陆状态
-                    unset($update_data);
-                    $update_data = [
-                        "is_login" => 1,
-                        "client_id" => $user->client_id,
-                    ];
-                    User::where("user_id", $user_id)->update($update_data);
-                }else{
-                    continue;
-                }
-            }
+            // if($user->is_robot && !$user->is_login){
+            //     if(Gateway::isUidOnline($user_id)){
+            //         //更新用户登陆状态
+            //         unset($update_data);
+            //         $update_data = [
+            //             "is_login" => 1,
+            //             "client_id" => $user->client_id,
+            //         ];
+            //         User::where("user_id", $user_id)->update($update_data);
+            //     }else{
+            //         continue;
+            //     }
+            // }
             if($room_id){
                 //获取房间信息
                 $room = Room::where("room_id", $room_id)->first();

+ 4 - 3
app/Console/Commands/robot.php

@@ -111,7 +111,10 @@ class robot extends Command
                     User::where("user_id", $user->user_id)->update($update_data);
                     $result = json_decode($response->getBody()->getContents());
                     if($result->code == 400 || ($result->code == 0 && $result->info->in_game == 1)){
-                        echo "断线重连中 ...";
+                        //结束进程
+                        $sig = SIGINT;
+                        $master_pid = is_file($worker::$pidFile) ? file_get_contents($worker::$pidFile) : 0;
+                        $master_pid && posix_kill($master_pid, $sig);
                         return 0;
                     }
                     echo "client: {$client_id} 成功绑定socket\n";
@@ -158,7 +161,6 @@ class robot extends Command
 
                 //结算
                 if($json_data->type == 'round_end'){
-                    file_get_contents($worker::$pidFile);
                     echo "回合结束,已结算";
                 }
 
@@ -173,7 +175,6 @@ class robot extends Command
                     unset($update_data);
                     $update_data['state'] = 2;
                     RoomUser::where("user_id", $user->user_id)->where("state", 1)->update($update_data);
-                    Gateway::leaveGroup($client_id, $room_id);
                     echo "已结算,机器人离开房间";
                     //结束进程
                     $sig = SIGINT;