Browse Source

解决掼蛋升级问题

johnclot69 2 tháng trước cách đây
mục cha
commit
9d35171dcf

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

@@ -421,8 +421,6 @@ public class GDRoom extends Room {
     public synchronized void doStart() {
         try {
             this.data.curRound += 1;
-            // 升级
-            this.upgrade();
             // 定庄
             if (this.data.curRound == 1) {
                 // 随机定庄
@@ -1242,46 +1240,48 @@ public class GDRoom extends Room {
 
         // 4人房
         if (this.data.maxNum == 4) {
-            // 级牌下标
-            int index = 0;
+            // 升级数
+            int upLevel = 0;
             // 头游搭档数据
             Struct.TeammateData teammateData = this.getTeammate(winPlayer.data.teammateId);
             switch (teammateData.getRank()) {
                 case 2:
                     // 搭档2游, 升3级
-                    index = Math.min(winPlayer.data.levelIndex + 3, GDUtils.levelPoint.length - 1);
+                    upLevel = 3;
                     builder.append("1游玩家: ").append(winPlayer.data.name)
                             .append(", 搭档玩家: ").append(teammateData.player.data.name)
                             .append(" 2游, 升3级");
                     break;
                 case 3:
                     // 搭档3游, 升2级
-                    index = Math.min(winPlayer.data.levelIndex + 2, GDUtils.levelPoint.length - 1);
+                    upLevel = 2;
                     builder.append("1游玩家: ").append(winPlayer.data.name)
                             .append(", 搭档玩家: ").append(teammateData.player.data.name)
                             .append(" 3游, 升2级");
                     break;
                 case 4:
                     // 搭档4游, 升1级
-                    index = Math.min(winPlayer.data.levelIndex + 1, GDUtils.levelPoint.length - 1);
+                    upLevel = 1;
                     builder.append("1游玩家: ").append(winPlayer.data.name)
                             .append(", 搭档玩家: ").append(teammateData.player.data.name)
                             .append(" 4游, 升1级");
                     break;
             }
+            // 升级
+            winPlayer.data.levelIndex = Math.min(winPlayer.data.levelIndex + upLevel, GDUtils.levelPoint.length - 1);
 
-            // 设置头游玩家级牌点数展示
-            winPlayer.data.levelIndex = index;
-            winPlayer.data.levelPointView[0] = GDUtils.levelPoint[index];
-            // 设置我方玩家级牌点数展示
-            teammateData.player.data.levelPointView[0] = GDUtils.levelPoint[index];
-            // 设置对方级牌点数展示
-            for (Map.Entry<Integer, Struct.SettlementData> entry1 : this.data.result.entrySet()) {
-                if (!entry1.getValue().playerId.equals(winPlayer.getId())
-                        && !entry1.getValue().playerId.equals(teammateData.player.getId())) {
-                    Player tmPlayer = this.actors.getOrDefault(entry1.getValue().playerId, null);
+            for (Struct.SettlementData settlementData : this.data.result.values()) {
+                if (settlementData != null) {
+                    Player tmPlayer = this.actors.getOrDefault(settlementData.playerId, null);
                     if (tmPlayer != null) {
-                        tmPlayer.data.levelPointView[1] = GDUtils.levelPoint[index];
+                        if (settlementData.playerId.equals(winPlayer.getId())
+                                || settlementData.playerId.equals(teammateData.player.getId())) {
+                            settlementData.score = upLevel;
+                            tmPlayer.data.levelPointView[0] = GDUtils.levelPoint[winPlayer.data.levelIndex];
+                        } else {
+                            settlementData.score = 0;
+                            tmPlayer.data.levelPointView[1] = GDUtils.levelPoint[winPlayer.data.levelIndex];
+                        }
                     }
                 }
             }
@@ -1340,6 +1340,8 @@ public class GDRoom extends Room {
      * 牌局结算
      */
     private synchronized void settlement() {
+        // 升级
+        this.upgrade();
         // 头游
         Struct.SettlementData winPlayerData = this.data.result.getOrDefault(1, null);
         if (winPlayerData == null || StringUtils.isEmpty(winPlayerData.playerId)) {
@@ -1545,6 +1547,7 @@ public class GDRoom extends Room {
             for (Map.Entry<Integer, Struct.SettlementData> entry : this.data.result.entrySet()) {
                 Map<String, Object> settlementData = new HashMap<>();
                 settlementData.put("playerId", entry.getValue().playerId);
+                settlementData.put("score", entry.getValue().score);
                 settlementInfo.put(entry.getKey(), settlementData);
             }
             data.put("settlementInfo", settlementInfo);