Browse Source

牌型,转蛋随机分配

xhb 2 months ago
parent
commit
d6829ce4df

+ 25 - 46
incubator-game/src/main/java/com/incubator/game/room/GDRoom.java

@@ -1260,28 +1260,6 @@ public class GDRoom extends Room {
         // 原级牌点数
         int oldLevelPoint = this.data.curLevelPoint;
 
-        // 2人房
-        if (this.data.maxNum == 2) {
-            Struct.SettlementData loserPlayerData = this.data.result.getOrDefault(2, null);
-            if (loserPlayerData == null || StringUtils.isEmpty(loserPlayerData.playerId)) {
-                return;
-            }
-            p4 = this.actors.getOrDefault(loserPlayerData.playerId, null);
-            if (p4 == null) {
-                return;
-            }
-            builder.append("1游玩家: ").append(winPlayer.data.name)
-                    .append(" 升3级, ");
-            // 设置我方玩家级牌点数展示
-            int myIndex = Math.min(winPlayer.data.levelIndex + 3, GDUtils.levelPoint.length - 1);
-            winPlayer.data.levelIndex = myIndex;
-            winPlayer.data.levelPointView[0] = GDUtils.levelPoint[myIndex];
-            // 设置对方级牌点数展示
-            p4.data.levelPointView[1] = winPlayer.data.levelPointView[0];
-            // 设置全局当前级牌点数
-            this.data.curLevelPoint = Math.max(winPlayer.data.levelPointView[0], winPlayer.data.levelPointView[1]);
-        }
-
         // 4人房
         if (this.data.maxNum == 4) {
             // 升级数
@@ -1313,32 +1291,34 @@ public class GDRoom extends Room {
             }
             // 根据类型判断结束走向
             if (this.data.mode == 1) {
-                if (winPlayer.data.levelPointView[0] >= this.data.modev) {
-                    this.data.isOver = true;
-                    // 设置全局当前级牌点数
-                    this.data.curLevelPoint = this.data.modev;
-                } else {
-                    this.data.isOver = false;
-                    // 升级
-                    winPlayer.data.levelIndex = Math.min(winPlayer.data.levelIndex + upLevel, GDUtils.levelPoint.length - 1);
-                    // 设置分数等级
-                    for (Struct.SettlementData settlementData : this.data.result.values()) {
-                        if (settlementData != null) {
-                            Player tmPlayer = this.actors.getOrDefault(settlementData.playerId, null);
-                            if (tmPlayer != null) {
-                                if (settlementData.playerId.equals(winPlayer.getId())
-                                        || settlementData.playerId.equals(teammateData.player.getId())) {
-                                    settlementData.score = upLevel;
-                                    tmPlayer.data.levelPointView[0] = Math.min(GDUtils.levelPoint[winPlayer.data.levelIndex], this.data.modev);
-                                } else {
-                                    settlementData.score = 0;
-                                    tmPlayer.data.levelPointView[1] = Math.min(GDUtils.levelPoint[winPlayer.data.levelIndex], this.data.modev);
-                                }
+                this.data.isOver = false;
+                // 升级
+                winPlayer.data.levelIndex = Math.min(winPlayer.data.levelIndex + upLevel, GDUtils.levelPoint.length - 1);
+                int score = winPlayer.data.levelPointView[0] + upLevel;//胜利方牌级
+                // 设置分数等级
+                for (Struct.SettlementData settlementData : this.data.result.values()) {
+                    if (settlementData != null) {
+                        Player tmPlayer = this.actors.getOrDefault(settlementData.playerId, null);
+                        if (tmPlayer != null) {
+                            if (settlementData.playerId.equals(winPlayer.getId()) || settlementData.playerId.equals(teammateData.player.getId())) {
+                                settlementData.score = upLevel;
+//                                tmPlayer.data.levelPointView[0] = Math.min(GDUtils.levelPoint[winPlayer.data.levelIndex], this.data.modev);
+                                tmPlayer.data.levelPointView[0] = Math.min(score, this.data.modev);
+                            } else {
+                                settlementData.score = 0;
+//                                tmPlayer.data.levelPointView[1] = Math.min(GDUtils.levelPoint[winPlayer.data.levelIndex], this.data.modev);
+                                tmPlayer.data.levelPointView[1] = Math.min(score, this.data.modev);
                             }
                         }
                     }
+                }
+                // 设置全局当前级牌点数
+                this.data.curLevelPoint = winPlayer.data.levelPointView[0];
+
+                if (winPlayer.data.levelPointView[0] >= this.data.modev) {
+                    this.data.isOver = true;
                     // 设置全局当前级牌点数
-                    this.data.curLevelPoint = winPlayer.data.levelPointView[0];
+                    this.data.curLevelPoint = this.data.modev;
                 }
             } else {
                 // 升级
@@ -1348,8 +1328,7 @@ public class GDRoom extends Room {
                     if (settlementData != null) {
                         Player tmPlayer = this.actors.getOrDefault(settlementData.playerId, null);
                         if (tmPlayer != null) {
-                            if (settlementData.playerId.equals(winPlayer.getId())
-                                    || settlementData.playerId.equals(teammateData.player.getId())) {
+                            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 {

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

@@ -582,6 +582,12 @@ public class ZDRoom extends Room {
             }
             // 设置当前操作玩家
             this.data.currentPlayer = this.data.playerMap[this.data.zhuangPos];
+            if (this.jsonData.getInteger("team") == 2&&this.data.result.size()>0){
+                Struct.SettlementData orDefault = this.data.result.getOrDefault(4, null);
+                String playerId = orDefault.getPlayerId();
+                this.data.currentPlayer = this.actors.getOrDefault(playerId, null);
+            }
+            this.data.result.clear();//清理排名信息
             // 广播
             for (Player tmPlayer : this.actors.values()) {
                 if (tmPlayer != null) {
@@ -1528,7 +1534,7 @@ public class ZDRoom extends Room {
         // 根据配置清理参数
         if (!this.data.isTribute) {
 //            if (this.data.type !=1){
-                this.data.result.clear();
+//                this.data.result.clear();
 //            }
             this.data.tributeList.clear();
             this.data.towKingList.clear();

+ 8 - 4
incubator-game/src/main/java/com/incubator/game/util/GDUtils.java

@@ -940,19 +940,23 @@ public final class GDUtils {
         // 6. 三顺(赖子可补齐缺失三张)
         if (cardCount >= 6 && cardCount % 3 == 0 && uniqueCount + wildCount >= cardCount / 3
                 && isTripleSequenceWithWild(pointFrequency, wildCount)) {
-            if (previousCardsType!=null&&previousCardsType==CardType.TRIPLE_SEQUENCE){
+            if (previousCardsType!=null&&previousCardsType.equals(CardType.TRIPLE_SEQUENCE)){
+                return CardType.TRIPLE_SEQUENCE;
+            }
+            if (previousCardsType==null){
                 return CardType.TRIPLE_SEQUENCE;
             }
-            return CardType.TRIPLE_SEQUENCE;
         }
 
         // 7. 连对(赖子可补齐缺失对数)
         if (cardCount >= 6 && cardCount % 2 == 0 && uniqueCount + wildCount >= cardCount / 2
                 && isPairSequenceWithWild(pointFrequency, wildCount)) {
-            if (previousCardsType!=null&&previousCardsType==CardType.PAIR_SEQUENCE){
+            if (previousCardsType!=null&&previousCardsType.equals(CardType.PAIR_SEQUENCE)){
+                return CardType.PAIR_SEQUENCE;
+            }
+            if (previousCardsType==null){
                 return CardType.PAIR_SEQUENCE;
             }
-            return CardType.PAIR_SEQUENCE;
         }
 
         // 8. 三带二