فهرست منبع

feat(system): 优化玩家信息解析并添加底牌信息

- 在 PlayerInfo 类中添加 holeCards 字段,用于存储解析后的底牌列表
- 修改 parsePlayerInfo 方法,解析并存储玩家的底牌信息
- 更新 buildChineseActions 方法,将底牌信息添加到玩家动作描述中
fugui001 4 ماه پیش
والد
کامیت
50e5d038ac
1فایلهای تغییر یافته به همراه14 افزوده شده و 5 حذف شده
  1. 14 5
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/utils/ActionParserUtils.java

+ 14 - 5
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/utils/ActionParserUtils.java

@@ -55,6 +55,9 @@ public class ActionParserUtils {
                 long id = playerNode.get("id").asLong();
                 String name = playerNode.get("name").asText();
                 int seat = playerNode.get("seat").asInt();
+                //手牌
+                String holeCards= playerNode.get("holeCards").asText();
+                List<String> holeCardsList = PokerCardParserUtils.parseHoleCardsV2(holeCards);
 
                 List<String> tags = new ArrayList<>();
                 if (seat == smallBlindSeat) {
@@ -66,7 +69,7 @@ public class ActionParserUtils {
                     bbPlayerName = name;
                 }
 
-                playerInfoMap.put(id, new PlayerInfo(name, seat, tags));
+                playerInfoMap.put(id, new PlayerInfo(name, seat, tags,holeCardsList));
             }
         }
 
@@ -93,7 +96,7 @@ public class ActionParserUtils {
 
                 PlayerInfo playerInfo = playerInfoMap.get(playerId);
                 if (playerInfo == null) {
-                    playerInfo = new PlayerInfo("未知玩家", seatNumber, Collections.emptyList());
+                    playerInfo = new PlayerInfo("未知玩家", seatNumber, Collections.emptyList(), Collections.emptyList());
                 }
 
                 // 构建带标签的玩家名称
@@ -112,9 +115,13 @@ public class ActionParserUtils {
                 if (isBigBlindFreeAction && "CALL".equals(actionKey)) {
                     actionDetail = "跟注(大盲免费过牌)";
                 }
+                String holeCardsText = "";
+                if (!playerInfo.holeCards.isEmpty()) {
+                    holeCardsText = ",底牌:" + String.join(",", playerInfo.holeCards);
+                }
 
-                String desc = String.format("[%s] 玩家 %s(座位%d)%s,加注金额为 %d",
-                    stage, playerNameWithTags, seatNumber, actionDetail, addAmount);
+                String desc = String.format("[%s] 玩家 %s(座位%d%s)%s,加注金额为 %d",
+                    stage, playerNameWithTags, seatNumber, holeCardsText, actionDetail, addAmount);
 
                 chineseActions.add(desc);
             }
@@ -186,11 +193,13 @@ public class ActionParserUtils {
         String name;
         int seat;
         List<String> tags;
+        List<String> holeCards; // 新增:解析后的底牌列表
 
-        public PlayerInfo(String name, int seat, List<String> tags) {
+        public PlayerInfo(String name, int seat, List<String> tags, List<String> holeCards) {
             this.name = name;
             this.seat = seat;
             this.tags = new ArrayList<>(tags);
+            this.holeCards = holeCards != null ? new ArrayList<>(holeCards) : new ArrayList<>();
         }
     }