Prechádzať zdrojové kódy

修改赛事单服务问题

xhb 2 mesiacov pred
rodič
commit
a40484b818

+ 36 - 39
incubator-game/src/main/java/com/incubator/game/contest/Contest.java

@@ -343,19 +343,16 @@ public class Contest {
 //                    RedisUtil.set(RedisKeyConstant.COMPETE_PLAYERS+this.data.contestId, keyList);
 //                }
                 //从redis中获取玩家
-                String ids = RedisUtil.get(RedisKeyConstant.COMPETE_PLAYERS+this.data.contestId);
-                if (ids!=null){
-                    JSONArray jsonArray = new JSONArray(ids);
-                    for (Object o : jsonArray) {
-                        String playerId = (String) o;
-                        Player player = (Player)PlayerUtil.getOnlinePlayer(playerId);
-                        if (player != null) {
-                            this.actors.put(playerId, player);
-                        }
-                    }
-                }
-//                if (this.checkReadyStart()) {
-//                    this.isActive = false;
+//                String ids = RedisUtil.get(RedisKeyConstant.COMPETE_PLAYERS+this.data.contestId);
+//                if (ids!=null){
+//                    JSONArray jsonArray = new JSONArray(ids);
+//                    for (Object o : jsonArray) {
+//                        String playerId = (String) o;
+//                        Player player = (Player)PlayerUtil.getOnlinePlayer(playerId);
+//                        if (player != null) {
+//                            this.actors.put(playerId, player);
+//                        }
+//                    }
 //                }
                 if (this.checkReadyStart()) {
                     this.state = 1;
@@ -466,27 +463,27 @@ public class Contest {
 //            jsonData.put("team", rule.get("teamType")==null?0:rule.get("teamType"));
             jsonData.put("team",0);
             // 房间id
-            //jsonData.put("roomId", RoomService.getInstance().randomRoomIdByContest());
-            HashMap<String, RoomStatus> wkToRedis = RedisUtil.getRoomToRedis(RedisKeyConstant.WK_ROOM_MAP);
-            jsonData.put("roomId", SubRoomHandler.randomRoomId7(wkToRedis));
-
-            //保存房间信息
-            RoomStatus roomStatus = new RoomStatus();
-            roomStatus.setRoomId(jsonData.getLong("roomId"));
-            roomStatus.setRoomType(1);
-            //查询服务器信息
-            HashMap<String, WkServerStatus> wkServes = RedisUtil.getWkToRedis(RedisKeyConstant.WK_SERVE);
-            ArrayList<WkServerStatus> wkServerStatuses = new ArrayList<>();
-            for (Map.Entry<String, WkServerStatus> entry : wkServes.entrySet()) {
-                String type1 = entry.getValue().getType();
-                if (type1.equals(String.valueOf(1))){
-                    wkServerStatuses.add(entry.getValue());
-                }
-            }
-            String name = SubRoomHandler.selectLeastPopulatedServer(wkServerStatuses).get().getName();
-            roomStatus.setName(name);
-            // 保存房间信息
-            RedisUtil.saveRoomToRedis(RedisKeyConstant.WK_ROOM_MAP, roomStatus);
+            jsonData.put("roomId", RoomService.getInstance().randomRoomIdByContest());
+//            HashMap<String, RoomStatus> wkToRedis = RedisUtil.getRoomToRedis(RedisKeyConstant.WK_ROOM_MAP);
+//            jsonData.put("roomId", SubRoomHandler.randomRoomId7(wkToRedis));
+//
+//            //保存房间信息
+//            RoomStatus roomStatus = new RoomStatus();
+//            roomStatus.setRoomId(jsonData.getLong("roomId"));
+//            roomStatus.setRoomType(1);
+//            //查询服务器信息
+//            HashMap<String, WkServerStatus> wkServes = RedisUtil.getWkToRedis(RedisKeyConstant.WK_SERVE);
+//            ArrayList<WkServerStatus> wkServerStatuses = new ArrayList<>();
+//            for (Map.Entry<String, WkServerStatus> entry : wkServes.entrySet()) {
+//                String type1 = entry.getValue().getType();
+//                if (type1.equals(String.valueOf(1))){
+//                    wkServerStatuses.add(entry.getValue());
+//                }
+//            }
+//            String name = SubRoomHandler.selectLeastPopulatedServer(wkServerStatuses).get().getName();
+//            roomStatus.setName(name);
+//            // 保存房间信息
+//            RedisUtil.saveRoomToRedis(RedisKeyConstant.WK_ROOM_MAP, roomStatus);
 
 
             // 人数模式 2:2人 4:4人
@@ -555,7 +552,7 @@ public class Contest {
                     data.put("roomId", room.data.roomId);
                     data.put("roomType", room.data.type);
                     data.put("type", 1);
-                    data.put("wkIp", roomStatus.getName());
+//                    data.put("wkIp", roomStatus.getName());
                     Log.debug("比赛开始 : 比赛 : {}, 玩家 : {}", this.data.contestId, this.actors);
                     tmPlayer.receive(CommonProto.Cmd.MatchOfficialStart_VALUE, data);
                 }
@@ -688,7 +685,7 @@ public class Contest {
                     player1.data.contestId = 0;
                     player1.data.roomId = 0;
                     player1.data.matchPoints = 0;
-                    player1.data.accumulatedPoints = 0;
+                    player1.data.accumulatedPoints = 10000;
                 });
                 Log.info("比赛结束 : 比赛 : {}, 结束时间 : {}", this.data.contestId, DateUtils.formatFullDate(new Date()));
                 //给在线玩家发送比赛列表
@@ -712,8 +709,8 @@ public class Contest {
                 rooms.values().forEach(Room::resetNextRoom);
 
                 //组装赛况数据
-                List<Map<String, Object>> mapList = assembleContest(this);
-                RedisUtil.set(RedisKeyConstant.COMPETE_RESULT+this.data.contestId, mapList);
+//                List<Map<String, Object>> mapList = assembleContest(this);
+//                RedisUtil.set(RedisKeyConstant.COMPETE_RESULT+this.data.contestId, mapList);
             }
             return true;
         }
@@ -785,7 +782,7 @@ public class Contest {
                     if (settlementData != null) {
                         Player tmPlayer = this.actors.getOrDefault(settlementData.playerId, null);
                         if (tmPlayer != null) {
-                            list.add(new Struct.PromotionData(tmPlayer.getId(), tmPlayer.data.avatarUrl,tmPlayer.data.name , settlementData.score,i,this.rooms.size() == 1));
+                            list.add(new Struct.PromotionData(tmPlayer.getId(), tmPlayer.data.avatarUrl,tmPlayer.data.name , tmPlayer.data.accumulatedPoints-10000,i,this.rooms.size() == 1));
                             tmPlayer.data.matchPoints = settlementData.score;
                             tmPlayer.data.accumulatedPoints = 10000;
                             objects.add(tmPlayer);

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

@@ -38,7 +38,7 @@ public class Room implements GRoomInterface {
     public JSONObject jsonData;
 
     /** 激活标记 **/
-    private boolean isActive;
+    public boolean isActive;
     /** 检测标记 **/
     public boolean flag;
     /** 时间秒数 **/

+ 9 - 4
incubator-game/src/main/java/com/incubator/game/room/ZDRoom.java

@@ -275,7 +275,10 @@ public class ZDRoom extends Room {
                                             tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
                                         }
                                     }
-                                    this.destroy();
+                                    if (this.data.type != 1){
+                                        this.destroy();
+                                    }
+                                    this.isActive = false;
                                 }
                                 break;
                             case 3:
@@ -293,7 +296,9 @@ public class ZDRoom extends Room {
                                             tmPlayer.receive(CommonProto.Cmd.DisbandRoom_VALUE, new HashMap<>());
                                         }
                                     }
-                                    this.destroy();
+                                    if (this.data.type != 1){
+                                        this.destroy();
+                                    }
                                 }
                                 break;
                         }
@@ -1500,9 +1505,9 @@ public class ZDRoom extends Room {
         this.data.cardList.clear();
         // 根据配置清理参数
         if (!this.data.isTribute) {
-            if (this.data.type !=1){
+//            if (this.data.type !=1){
                 this.data.result.clear();
-            }
+//            }
             this.data.tributeList.clear();
             this.data.towKingList.clear();
         }

+ 3 - 3
incubator-game/src/main/java/com/incubator/game/util/Struct.java

@@ -35,13 +35,13 @@ public final class Struct {
     public static class PromotionData {
         public String playerId;
         public String avatar;
-        public int score;
+        public long score;
         public long roomId;
         public int rank;
         public boolean isPromotion;
         public String name;
         public PromotionData() {}
-        public PromotionData(String playerId, String avatar,String name, int score, int rank, boolean isPromotion) {
+        public PromotionData(String playerId, String avatar,String name, long score, int rank, boolean isPromotion) {
             this.playerId = playerId;
             this.avatar = avatar;
             this.score = score;
@@ -62,7 +62,7 @@ public final class Struct {
             this.rank = rank;
         }
 
-        public int getScore() {
+        public long getScore() {
             return score;
         }