处理红中胡牌问题

master
miaoqingshuai 2026-06-15 18:09:32 +08:00
parent 2093f434df
commit 950f739e0a
1 changed files with 29 additions and 16 deletions

View File

@ -303,6 +303,7 @@ public class HuNanHongZhong {
for (int i = 0; i < cardList.size(); i++) {
hongZhongCardInhand.add(cardList.getInt(i));
}
System.out.println("初始化手牌" + hongZhongCardInhand);
if (hongZhongCardInhand.size() > 13) {
outCard(client);
log.info("机器人:{}为庄家,需要出牌,牌为:{}", param.getInt("seat"), hongZhongCardInhand.get(0));
@ -325,17 +326,32 @@ public class HuNanHongZhong {
int type = 0;
int opcard = 0;
ITObject params = TObject.newInstance();
System.out.println("机器人杠碰胡参数 " + tipList);
//先优先胡牌
if (tipList != null && tipList.size() > 0) {
TObject firstTip = (TObject) tipList.get(0).getObject();
id = firstTip.getInt("id");
type = firstTip.getInt("type");
opcard = firstTip.getTArray("opcard").getInt(0);
// 先查找 type == 6 的对象
for (int i = 0; i < tipList.size(); i++) {
TObject item = (TObject) tipList.get(i).getObject();
int currentType = item.getInt("type");
if (currentType == 6) {
id = item.getInt("id");
type = currentType;
opcard = item.getTArray("opcard").getInt(0);
break; // 找到后立即退出循环
}
}
// 如果没有找到 type==6 的对象,则取第一个
if (type != 6 && tipList.size() > 0) {
TObject firstTip = (TObject) tipList.get(0).getObject();
id = firstTip.getInt("id");
type = firstTip.getInt("type");
opcard = firstTip.getTArray("opcard").getInt(0);
}
log.debug("id ++ {}", id);
log.debug("type ++ {}", type);
}
//弃 是根据算法选择是否要弃掉 不进行碰杠胡
//params.putInt("qi", 0);
//params.putInt("id", 0);
//执行碰牌
if (type == 2) {
@ -343,7 +359,7 @@ public class HuNanHongZhong {
if (shouldPong(opcard)) {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", 1);
params.putInt("id", id);
Util.removeCard(hongZhongCardInhand, opcard, 2);
log.info("执行碰牌并删除碰的牌");
} else {
@ -357,35 +373,31 @@ public class HuNanHongZhong {
} else if (type == 6) {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", 1);
params.putInt("id", id); //改为发送id之前发送的是写死的1胡牌的id是2
log.info("执行胡牌");
//执行吃杠
} else if (type == 3) {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", 1);
params.putInt("id", id);
Util.removeCard(hongZhongCardInhand, opcard, 3);
log.info("执行吃杠");
//执行自杠
} else if (type == 4) {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", 1);
params.putInt("id", id);
Util.removeCard(hongZhongCardInhand, opcard, 4);
log.info("执行自杠");
// 碰后补杠
} else if (type == 5) {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", 1);
params.putInt("id", id);
Util.removeCard(hongZhongCardInhand, opcard, 1);
log.info("执行碰后补杠");
}
// cardInhand.remove(0);
// cardInhand.remove(1);
log.info("执行id为{}的操作", 0);
//使用线程池执行延迟动作
getBusinessThreadPool().execute(() -> {
try {
@ -422,6 +434,7 @@ public class HuNanHongZhong {
public String outCard(TaurusClient client) {
// 调用分离分析方法,将刻子、顺子、红中单独拎出后分析剩余牌
try {
System.out.println("当前机器人手牌" + hongZhongCardInhand);
log.info("[HuNanHongZhong] 出牌前分离分析手牌结构...");
hongZhongSuanFaTest.separateAndAnalyzeHand(hongZhongCardInhand);