郑晓宇 6 年之前
父節點
當前提交
c0dedb7095
共有 2 個文件被更改,包括 11 次插入1 次删除
  1. 1 1
      app/Console/Commands/robot.php
  2. 10 0
      app/Jobs/Settlement.php

+ 1 - 1
app/Console/Commands/robot.php

@@ -159,7 +159,7 @@ class robot extends Command
                     $update_data['state'] = 2;
                     RoomUser::where("user_id", $user->user_id)->where("state", 1)->update($update_data);
                     echo "已结算,关闭机器人";
-                    die;
+                    exit;
                 }
 
             };

+ 10 - 0
app/Jobs/Settlement.php

@@ -53,6 +53,14 @@ class Settlement implements ShouldQueue
         //注册gateway地址
         Gateway::$registerAddress = '127.0.0.1:1238';
         if($room_question_count > 4){
+
+            //结算当前局
+            $update_data["end_at"] = date("Y-m-d H:i:s");
+            RoomQuestion::where([
+                "room_id" => $this->room_id,
+                "question_id" => $question_id,
+            ])->update($update_data);
+
             //当前房间结束
             $update_data["end_at"] = date("Y-m-d H:i:s");
             Room::where("room_id", $this->room_id)->update($update_data);
@@ -134,6 +142,8 @@ class Settlement implements ShouldQueue
                 $message['winer_score'] = $winer_score;
                 $message['type'] = 'game_end';
                 Gateway::sendToUid($user->user_id, json_encode($message));
+                //结束当前房间
+                Gateway::ungroup($this->room_id);
             }
 
         }else{