Browse Source

Merge remote-tracking branch 'origin/master'

xhb 2 months ago
parent
commit
b03b55e04b

+ 9 - 0
incubator-game/src/main/java/com/incubator/game/handler/room/DisCardHandler.java

@@ -62,6 +62,13 @@ public class DisCardHandler extends NetHandler {
             response.setMessage("操作失败,房间或玩家不在游戏中状态...");
             return;
         }
+        // 当前状态是否可操作
+        if (room.data.tributeState != 0) {
+            Log.info("当前不是自己出牌回合...");
+            response.setCode(8);
+            response.setMessage("操作失败,当前不是自己出牌回合...");
+            return;
+        }
 
         switch (room.data.gameType) {
             case 1:
@@ -84,6 +91,8 @@ public class DisCardHandler extends NetHandler {
                     }
                 }
                 break;
+             default:
+                 break;
         }
 
         // 判断参数

+ 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 {
+                                    //判断锁是否存在 //等待消失
+
+                                        try {
+                                            Thread.sleep(2000);
+                                        } 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 {
+                                    //判断锁是否存在 //等待消失
+
+                                        try {
+                                            Thread.sleep(2000);
+                                        } 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);
     }
 

+ 1 - 0
incubator-game/src/main/java/com/incubator/game/room/Room.java

@@ -130,6 +130,7 @@ public class Room implements GRoomInterface {
         this.scheduler = null;
         // 从缓存移除
         RoomService.getInstance().roomMap.remove(this.data.roomId);
+        RedisUtil.del("roomGambit:"+this.data.roomId);
         RedisUtil.delRoomToRedis(RedisKeyConstant.WK_ROOM_MAP, String.valueOf(this.data.roomId));
         //RedisUtil.removeKeyFromRoomMap(RedisKeyConstant.WK_ROOM_MAP, 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 {
+                                    //判断锁是否存在 //等待消失
+
+                                        try {
+                                            Thread.sleep(2000);
+                                        } 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 {
+                                    //判断锁是否存在 //等待消失
+
+                                        try {
+                                            Thread.sleep(2000);
+                                        } 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());
 
         // 记录游戏回放