Browse Source

增加解散房间推送

johnclot69 4 months ago
parent
commit
b1fe161dec

+ 18 - 8
incubator-game/src/main/java/com/incubator/game/room/JDGDRoom.java

@@ -61,10 +61,15 @@ public class JDGDRoom extends Room implements GRoomInterface {
                 }
 
                 // 120秒未开始直接解散
-//                if (this.data.time >= 120) {
-//                    logger.debug("解散房间...");
-//                    this.destroy();
-//                }
+                if (this.data.time >= 120) {
+                    // 广播
+                    for (Player tmPlayer : this.data.playerMap.values()) {
+                        if (tmPlayer != null) {
+                            tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
+                        }
+                    }
+                    this.destroy();
+                }
                 break;
             case 1:
                 // 开局
@@ -119,10 +124,15 @@ public class JDGDRoom extends Room implements GRoomInterface {
                         this.data.time = 0;
                     } else {
                         // 120秒未开始直接解散
-//                        if (this.data.time >= 120) {
-//                            logger.debug("解散房间...");
-//                            this.destroy();
-//                        }
+                        if (this.data.time >= 120) {
+                            // 广播
+                            for (Player tmPlayer : this.data.playerMap.values()) {
+                                if (tmPlayer != null) {
+                                    tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
+                                }
+                            }
+                            this.destroy();
+                        }
                     }
                 }
                 break;

+ 1 - 0
incubator-message/src/main/proto/CommonProto.proto

@@ -86,6 +86,7 @@ enum Cmd {
     ReadyStateUpdate = 900012;  // 玩家准备状态数据同步推送
     GameStateChange = 900014;   // 游戏状态变化推送
     OtherPlayCards = 900020;    // 其他玩家出牌通知
+    DisbandRoom = 900022;       // 解散房间推送
 
     ShopUpdate = 900016;        // 商城更新推送
     BagUpdate = 900018;         // 背包更新推送