Administrator vor 2 Monaten
Ursprung
Commit
ca5cadaec9

+ 14 - 0
incubator-game/src/main/java/com/incubator/game/room/FSGDRoom.java

@@ -214,6 +214,8 @@ public class FSGDRoom extends Room {
                     }
                     break;
                 case 1:
+                    //锁
+                    RedisUtil.set("roomGambit:"+this.data.roomId, "0");
                     // 开局
                     if (!this.flag) {
                         //开始
@@ -249,6 +251,14 @@ public class FSGDRoom extends Room {
                             this.flag = false;
                             this.time = 0;
                         } else {
+                            //判断锁是否存在 //等待消失
+                            while (RedisUtil.exists("roomGambit:"+this.data.roomId)){
+                                try {
+                                    Thread.sleep(1000);
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }
                             // 120秒未开始直接解散
 //                            if (this.time >= 120 && this.type != 1) {
 //                                // 广播
@@ -262,6 +272,9 @@ public class FSGDRoom extends Room {
                         }
                     }
                     break;
+                   default:
+                    break;
+
             }
 
             this.time += 1;
@@ -504,6 +517,7 @@ public class FSGDRoom extends Room {
                 tmPlayer.receive(CommonProto.Cmd.GameStateChange_VALUE, data);
             }
         }
+        RedisUtil.del("roomGambit:"+this.data.roomId);
     }
 
     /**

+ 21 - 0
incubator-game/src/main/java/com/incubator/game/room/GDRoom.java

@@ -211,6 +211,8 @@ public class GDRoom extends Room {
                     }
                     break;
                 case 1:
+                    //锁
+                    RedisUtil.set("roomGambit:"+this.data.roomId, "0");
                     // 开局
                     if (!this.flag) {
                         //开始
@@ -287,6 +289,14 @@ public class GDRoom extends Room {
                                     this.flag = false;
                                     this.time = 0;
                                 } else {
+                                    //判断锁是否存在 //等待消失
+                                    while (RedisUtil.exists("roomGambit:"+this.data.roomId)){
+                                        try {
+                                            Thread.sleep(1000);
+                                        } catch (InterruptedException e) {
+                                            e.printStackTrace();
+                                        }
+                                    }
                                     // 广播
                                     for (Player tmPlayer : this.actors.values()) {
                                         if (tmPlayer != null) {
@@ -305,6 +315,14 @@ public class GDRoom extends Room {
                                     this.flag = false;
                                     this.time = 0;
                                 } else {
+                                    //判断锁是否存在 //等待消失
+                                    while (RedisUtil.exists("roomGambit:"+this.data.roomId)){
+                                        try {
+                                            Thread.sleep(1000);
+                                        } catch (InterruptedException e) {
+                                            e.printStackTrace();
+                                        }
+                                    }
                                     // 广播
                                     for (Player tmPlayer : this.actors.values()) {
                                         if (tmPlayer != null) {
@@ -314,6 +332,8 @@ public class GDRoom extends Room {
                                     this.destroy();
                                 }
                                 break;
+                            default:
+                                break;
                         }
 
                         // 120秒未开始直接解散
@@ -1460,6 +1480,7 @@ public class GDRoom extends Room {
                 tmPlayer.receive(CommonProto.Cmd.GameStateChange_VALUE, data);
             }
         }
+        RedisUtil.del("roomGambit:"+this.data.roomId);
         Log.debug("牌局结算...roomId : {}", this.data.roomId);
     }
 

+ 23 - 1
incubator-game/src/main/java/com/incubator/game/room/ZDRoom.java

@@ -203,6 +203,9 @@ public class ZDRoom extends Room {
                     }
                     break;
                 case 1:
+                    //锁
+                    RedisUtil.set("roomGambit:"+this.data.roomId, "0");
+
                     // 开局
                     if (!this.flag) {
                         //开始
@@ -269,6 +272,14 @@ public class ZDRoom extends Room {
                                     this.flag = false;
                                     this.time = 0;
                                 } else {
+                                    //判断锁是否存在 //等待消失
+                                    while (RedisUtil.exists("roomGambit:"+this.data.roomId)){
+                                        try {
+                                            Thread.sleep(1000);
+                                        } catch (InterruptedException e) {
+                                            e.printStackTrace();
+                                        }
+                                    }
                                     // 广播
                                     for (Player tmPlayer : this.actors.values()) {
                                         if (tmPlayer != null) {
@@ -290,6 +301,14 @@ public class ZDRoom extends Room {
                                     this.flag = false;
                                     this.time = 0;
                                 } else {
+                                    //判断锁是否存在 //等待消失
+                                    while (RedisUtil.exists("roomGambit:"+this.data.roomId)){
+                                        try {
+                                            Thread.sleep(1000);
+                                        } catch (InterruptedException e) {
+                                            e.printStackTrace();
+                                        }
+                                    }
                                     // 广播
                                     for (Player tmPlayer : this.actors.values()) {
                                         if (tmPlayer != null) {
@@ -301,6 +320,8 @@ public class ZDRoom extends Room {
                                     }
                                 }
                                 break;
+                            default:
+                                break;
                         }
 
                         // 120秒未开始直接解散
@@ -321,6 +342,7 @@ public class ZDRoom extends Room {
                         return;
                     }
                     break;
+
             }
 
             this.time += 1;
@@ -1393,7 +1415,7 @@ public class ZDRoom extends Room {
                 tmPlayer.receive(CommonProto.Cmd.GameStateChange_VALUE, data);
             }
         }
-
+        RedisUtil.del("roomGambit:"+this.data.roomId);
         Log.info("牌局结算...roomId={}, {}", this.data.roomId, builder.toString());
 
         // 记录游戏回放