放炮罚机器人
parent
ed801cebd2
commit
4ea9fea6f0
|
|
@ -520,8 +520,8 @@ public class RobotConnectionManager {
|
|||
}
|
||||
//摸牌
|
||||
else if ("819".equalsIgnoreCase(command)) {
|
||||
System.out.println("cliend" + client.getSession());
|
||||
System.out.println("819 +++++++" + robotId);
|
||||
// System.out.println("cliend" + client.getSession());
|
||||
// System.out.println("819 +++++++" + robotId);
|
||||
handler.drawCard(message,robotUser);
|
||||
//处理完协议后保存到Redis
|
||||
FangPaoFaHandler currentInstance = fangpaofaHandlerInstances.get(connecId);
|
||||
|
|
@ -544,12 +544,12 @@ public class RobotConnectionManager {
|
|||
handler.actionTip(param, client,robotUser);
|
||||
//放跑提示
|
||||
} else if ("822".equalsIgnoreCase(command)) {
|
||||
System.out.println("放跑提示");
|
||||
// System.out.println("放跑提示");
|
||||
FangPaoFaHandler.fangPaoTipEvent(message, client);
|
||||
//打鸟提示
|
||||
}else if ("832".equalsIgnoreCase(command)){
|
||||
handler.daniao(param,client);
|
||||
System.out.println("打鸟提示" + param);
|
||||
// System.out.println("打鸟提示" + param);
|
||||
}
|
||||
//飘操作
|
||||
else if ("1015".equalsIgnoreCase(command)) {
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public class FangPaoFaHandler {
|
|||
for (int i = 0; i < cardList.size(); i++) {
|
||||
handCards.add(cardList.getInt(i));
|
||||
}
|
||||
System.out.println("放炮罚初始化手牌" + handCards);
|
||||
// System.out.println("放炮罚初始化手牌" + handCards);
|
||||
log.info("放炮罚初始化手牌:{} 张", handCards.size());
|
||||
log.debug("手牌详情:{}", handCards);
|
||||
}
|
||||
|
|
@ -112,18 +112,18 @@ public class FangPaoFaHandler {
|
|||
jiqirenseat = robotUser.getSeat();
|
||||
}
|
||||
int seat = param.getInt("seat");
|
||||
System.out.println("819 jiqirenseat" + jiqirenseat);
|
||||
System.out.println("819 seat" + seat);
|
||||
// System.out.println("819 jiqirenseat" + jiqirenseat);
|
||||
// System.out.println("819 seat" + seat);
|
||||
int drawnCard = param.getInt("card");
|
||||
System.out.println("819摸牌 ++++ " + drawnCard);
|
||||
// System.out.println("819摸牌 ++++ " + drawnCard);
|
||||
|
||||
if (drawnCard > 0 && seat == jiqirenseat) {
|
||||
// ✅ 只记录modepai,不加入手牌
|
||||
currentCard = drawnCard;
|
||||
modepai = drawnCard;
|
||||
System.out.println("进入摸牌里面" + drawnCard);
|
||||
System.out.println("摸牌下面" + modepai);
|
||||
System.out.println("摸完后的手牌(未加入)" + handCards);
|
||||
// System.out.println("进入摸牌里面" + drawnCard);
|
||||
// System.out.println("摸牌下面" + modepai);
|
||||
// System.out.println("摸完后的手牌(未加入)" + handCards);
|
||||
log.info("放炮罚摸牌:{}", drawnCard);
|
||||
log.debug("当前手牌数量:{}", handCards.size());
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ public class FangPaoFaHandler {
|
|||
*/
|
||||
public void actionTip(ITObject param, TaurusClient client, RobotUser robotUser) {
|
||||
// robotUser.getSeat()
|
||||
System.out.println("获取后台发给客户端的动作处理的所有参数" + param);
|
||||
// System.out.println("获取后台发给客户端的动作处理的所有参数" + param);
|
||||
Integer uid = param.getInt("uid");
|
||||
ITArray tipList = param.getTArray("tip_list");
|
||||
if (tipList == null || tipList.size() == 0) {
|
||||
|
|
@ -162,9 +162,9 @@ public class FangPaoFaHandler {
|
|||
TObject tip = (TObject) tipList.get(i).getObject();
|
||||
type = tip.getInt("type");
|
||||
id = tip.getInt("id");
|
||||
System.out.println("type+++++++" + type);
|
||||
// System.out.println("type+++++++" + type);
|
||||
if (type == 8) { // 胡牌
|
||||
System.out.println("收到胡牌提示");
|
||||
// System.out.println("收到胡牌提示");
|
||||
ITObject params = TObject.newInstance();
|
||||
params.putString("session", session + "," + token);
|
||||
params.putInt("qi", 0);
|
||||
|
|
@ -182,9 +182,9 @@ public class FangPaoFaHandler {
|
|||
params.putString("session", session + "," + token);
|
||||
|
||||
if (result.shouldAct) {
|
||||
System.out.println("执行type" + type);
|
||||
System.out.println("执行吃或碰 id" + result.actionId);
|
||||
System.out.println("执行吃或碰 具体牌和分数 " + result.reason);
|
||||
// System.out.println("执行type" + type);
|
||||
// System.out.println("执行吃或碰 id" + result.actionId);
|
||||
// System.out.println("执行吃或碰 具体牌和分数 " + result.reason);
|
||||
|
||||
// 从手牌中删除opcard里的牌
|
||||
// removeOpCardsFromHand(tipList, result.actionId);
|
||||
|
|
@ -198,10 +198,10 @@ public class FangPaoFaHandler {
|
|||
delayedAction(client, params, actionName);
|
||||
log.info("吃碰决策: 执行{}", result.reason);
|
||||
} else {
|
||||
System.out.println("跳过吃或碰");
|
||||
// System.out.println("跳过吃或碰");
|
||||
params.putInt("id", uid);
|
||||
delayedAction(client, params, "过");
|
||||
System.out.println("吃碰决策: 跳过, 原因: {}" + result.reason);
|
||||
// System.out.println("吃碰决策: 跳过, 原因: {}" + result.reason);
|
||||
log.info("吃碰决策: 跳过, 原因: {}", result.reason);
|
||||
}
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ public class FangPaoFaHandler {
|
|||
// ✅ 关键: 执行任何动作前,先将摸的牌加入手牌
|
||||
if (modepai > 0) {
|
||||
handCards.add(modepai);
|
||||
System.out.println("执行动作前将摸的牌加入手牌: " + modepai);
|
||||
// System.out.println("执行动作前将摸的牌加入手牌: " + modepai);
|
||||
}
|
||||
|
||||
// 找到对应的tip
|
||||
|
|
@ -239,7 +239,7 @@ public class FangPaoFaHandler {
|
|||
for (int j = 0; j < opcardArray.size(); j++) {
|
||||
int card = opcardArray.getInt(j);
|
||||
removeCardFromHand(card);
|
||||
System.out.println("删除opcard中的牌: " + card);
|
||||
// System.out.println("删除opcard中的牌: " + card);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -249,12 +249,12 @@ public class FangPaoFaHandler {
|
|||
if (type == 1 && card1 == modepai) {
|
||||
// 吃自己摸的牌,需要删除这张牌
|
||||
removeCardFromHand(card1);
|
||||
System.out.println("吃自己摸的牌,删除: " + card1);
|
||||
// System.out.println("吃自己摸的牌,删除: " + card1);
|
||||
}
|
||||
|
||||
if (type == 2 && card1 == modepai) {
|
||||
removeCardFromHand(card1);
|
||||
System.out.println("碰自己摸的牌,删除: " + card1);
|
||||
// System.out.println("碰自己摸的牌,删除: " + card1);
|
||||
}
|
||||
|
||||
// ✅ 执行完动作后,清除modepai
|
||||
|
|
@ -264,7 +264,7 @@ public class FangPaoFaHandler {
|
|||
|
||||
// 重新排序手牌
|
||||
handCards.sort(Integer::compareTo);
|
||||
System.out.println("吃碰后手牌: " + handCards);
|
||||
// System.out.println("吃碰后手牌: " + handCards);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -275,12 +275,12 @@ public class FangPaoFaHandler {
|
|||
private void removeCardFromHand(int card) {
|
||||
Integer cardObj = Integer.valueOf(card);
|
||||
|
||||
System.out.println("从手牌中删除指定的一张牌 hands " + handCards);
|
||||
// System.out.println("从手牌中删除指定的一张牌 hands " + handCards);
|
||||
int index = handCards.indexOf(cardObj);
|
||||
if (index != -1) {
|
||||
System.out.println("从手牌中删除指定的一张牌 " + index);
|
||||
// System.out.println("从手牌中删除指定的一张牌 " + index);
|
||||
handCards.remove(index);
|
||||
System.out.println("从手牌中删除指定的一张牌的手牌" + handCards);
|
||||
// System.out.println("从手牌中删除指定的一张牌的手牌" + handCards);
|
||||
} else {
|
||||
log.warn("手牌中找不到要删除的牌: {}", card);
|
||||
}
|
||||
|
|
@ -333,14 +333,14 @@ public class FangPaoFaHandler {
|
|||
// 出牌前,如果modepai有值,先加入手牌
|
||||
if (modepai > 0) {
|
||||
handCards.add(modepai);
|
||||
System.out.println("出牌前将摸的牌加入手牌: " + modepai);
|
||||
// System.out.println("出牌前将摸的牌加入手牌: " + modepai);
|
||||
modepai = 0;
|
||||
}
|
||||
|
||||
System.out.println(robotId + "放炮罚机器人手牌" + handCards);
|
||||
// System.out.println(robotId + "放炮罚机器人手牌" + handCards);
|
||||
int i = FangPaoFaSuanFa.selectBestCard(handCards, chiCards,pengCards,weiCards,paoCards,tiCards);
|
||||
Integer cardToOut = handCards.get(i);
|
||||
System.out.println(robotId + "放炮罚出牌 最新出牌" + cardToOut);
|
||||
// System.out.println(robotId + "放炮罚出牌 最新出牌" + cardToOut);
|
||||
|
||||
ITObject params = TObject.newInstance();
|
||||
params.putInt("card", cardToOut);
|
||||
|
|
@ -359,7 +359,7 @@ public class FangPaoFaHandler {
|
|||
|
||||
// 记录出牌
|
||||
handCards.sort(Integer::compareTo);
|
||||
System.out.println(robotId + " 最新版本 放炮罚牌 删掉出的牌了" + handCards);
|
||||
// System.out.println(robotId + " 最新版本 放炮罚牌 删掉出的牌了" + handCards);
|
||||
|
||||
log.info("放炮罚出牌:{}", cardToOut);
|
||||
log.debug("放炮罚剩余手牌:{}", handCards);
|
||||
|
|
@ -435,25 +435,25 @@ public class FangPaoFaHandler {
|
|||
}
|
||||
|
||||
public void onPlayerAction(ITObject param, RobotUser robotUser) {
|
||||
System.out.println("815所有参数" + param);
|
||||
// System.out.println("815所有参数" + param);
|
||||
|
||||
//机器人id
|
||||
System.out.println("进入815");
|
||||
System.out.println(robotUser.getRobotId() + " 815下当前机器人手牌 " + handCards);
|
||||
// System.out.println("进入815");
|
||||
// System.out.println(robotUser.getRobotId() + " 815下当前机器人手牌 " + handCards);
|
||||
Integer type = param.getInt("type");
|
||||
|
||||
String robotId = robotUser.getRobotId();
|
||||
Integer playerid = param.getInt("playerid");
|
||||
Integer from_seat = param.getInt("from_seat");
|
||||
System.out.println("from_seat++++++++ " + from_seat);
|
||||
System.out.println("robotUser.getSeat() " + robotUser.getSeat());
|
||||
// System.out.println("from_seat++++++++ " + from_seat);
|
||||
// System.out.println("robotUser.getSeat() " + robotUser.getSeat());
|
||||
ITArray opcard = param.getTArray("opcard");
|
||||
Integer card = param.getInt("card");
|
||||
System.out.println("815 判断之前 card" + card);
|
||||
System.out.println("815 type" + type);
|
||||
// System.out.println("815 判断之前 card" + card);
|
||||
// System.out.println("815 type" + type);
|
||||
//如果是机器人玩家进来的话,就判断删除手牌
|
||||
System.out.println("机器人id" + robotId);
|
||||
System.out.println("玩家id" + playerid);
|
||||
// System.out.println("机器人id" + robotId);
|
||||
// System.out.println("玩家id" + playerid);
|
||||
|
||||
//单独将吃碰畏提跑的牌存起来
|
||||
if (robotId.equals(playerid.toString())){
|
||||
|
|
@ -465,14 +465,14 @@ public class FangPaoFaHandler {
|
|||
}
|
||||
chiCards.addAll(tem);
|
||||
chiCards.add(card);
|
||||
System.out.println("吃的牌组" + chiCards);
|
||||
// System.out.println("吃的牌组" + chiCards);
|
||||
}
|
||||
//碰
|
||||
if (type == 2){
|
||||
pengCards.add(card);
|
||||
pengCards.add(card);
|
||||
pengCards.add(card);
|
||||
System.out.println("碰的牌组" + pengCards);
|
||||
// System.out.println("碰的牌组" + pengCards);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -487,7 +487,7 @@ public class FangPaoFaHandler {
|
|||
paoCards.add(card);
|
||||
paoCards.add(card);
|
||||
paoCards.add(card);
|
||||
System.out.println("跑的牌组" + paoCards);
|
||||
// System.out.println("跑的牌组" + paoCards);
|
||||
|
||||
}
|
||||
//提
|
||||
|
|
@ -523,7 +523,7 @@ public class FangPaoFaHandler {
|
|||
for (int i = 0; i < opcard.size(); ++i) {
|
||||
tem.add(opcard.getInt(i));
|
||||
}
|
||||
System.out.println("tem.size" + tem.size());
|
||||
// System.out.println("tem.size" + tem.size());
|
||||
CardUtilFangpaofa.removeCard(handCards, card, tem.size());
|
||||
modepai = 0;
|
||||
} else if (type != 3){
|
||||
|
|
@ -532,7 +532,7 @@ public class FangPaoFaHandler {
|
|||
for (int i = 0; i < opcard.size(); ++i) {
|
||||
tem.add(opcard.getInt(i));
|
||||
}
|
||||
System.out.println("tem.size" + tem.size());
|
||||
// System.out.println("tem.size" + tem.size());
|
||||
CardUtilFangpaofa.removeCard(handCards, card, tem.size());
|
||||
modepai = 0;
|
||||
}else if (type == 3){
|
||||
|
|
@ -558,7 +558,7 @@ public class FangPaoFaHandler {
|
|||
// 执行任何动作前,先将摸的牌加入手牌
|
||||
if (modepai > 0) {
|
||||
handCards.add(modepai);
|
||||
System.out.println("执行动作前将摸的牌加入手牌: " + modepai);
|
||||
// System.out.println("执行动作前将摸的牌加入手牌: " + modepai);
|
||||
}
|
||||
|
||||
if (opcard.size() > 0) {
|
||||
|
|
@ -566,7 +566,7 @@ public class FangPaoFaHandler {
|
|||
for (int j = 0; j < opcard.size(); j++) {
|
||||
int card2 = opcard.getInt(j);
|
||||
removeCardFromHand(card2);
|
||||
System.out.println("删除opcard中的牌: " + card2);
|
||||
// System.out.println("删除opcard中的牌: " + card2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -574,21 +574,21 @@ public class FangPaoFaHandler {
|
|||
if (type == 1 && card == modepai) {
|
||||
// 吃自己摸的牌,需要删除这张牌
|
||||
removeCardFromHand(card);
|
||||
System.out.println("吃自己摸的牌,删除: " + card);
|
||||
// System.out.println("吃自己摸的牌,删除: " + card);
|
||||
}
|
||||
|
||||
if (type == 2 && card == modepai) {
|
||||
removeCardFromHand(card);
|
||||
System.out.println("碰自己摸的牌,删除: " + card);
|
||||
// System.out.println("碰自己摸的牌,删除: " + card);
|
||||
}
|
||||
|
||||
// 执行完动作后,清除modepai
|
||||
modepai = 0;
|
||||
System.out.println("吃碰后手牌: " + handCards);
|
||||
// System.out.println("吃碰后手牌: " + handCards);
|
||||
}
|
||||
//如果是真人进入 并且是操作的机器人摸到的牌,进行为提等操作,
|
||||
} else if (from_seat == robotUser.getSeat()) {
|
||||
System.out.println("进入真人玩家进入815");
|
||||
// System.out.println("进入真人玩家进入815");
|
||||
modepai = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -598,12 +598,12 @@ public class FangPaoFaHandler {
|
|||
int seat = robotUser.getSeat();
|
||||
int card = param.getInt("card");
|
||||
|
||||
System.out.println("过牌/自动出牌");
|
||||
System.out.println("过牌删除手牌前" + handCards);
|
||||
System.out.println("打印机器人座位号" + seat);
|
||||
System.out.println("后台发过来的座位号" + param.getInt("seat"));
|
||||
System.out.println("818中的card=" + card);
|
||||
System.out.println("当前modepai=" + modepai);
|
||||
// System.out.println("过牌/自动出牌");
|
||||
// System.out.println("过牌删除手牌前" + handCards);
|
||||
// System.out.println("打印机器人座位号" + seat);
|
||||
// System.out.println("后台发过来的座位号" + param.getInt("seat"));
|
||||
// System.out.println("818中的card=" + card);
|
||||
// System.out.println("当前modepai=" + modepai);
|
||||
|
||||
if (seat == param.getInt("seat")) {
|
||||
// 自己座位的818
|
||||
|
|
@ -613,20 +613,20 @@ public class FangPaoFaHandler {
|
|||
// 这张牌从未加入手牌,所以不需要删除
|
||||
// 只需要清零modepai
|
||||
modepai = 0;
|
||||
System.out.println("清除modepai");
|
||||
// System.out.println("清除modepai");
|
||||
}
|
||||
}
|
||||
System.out.println("过牌删除手牌删除后" + handCards);
|
||||
System.out.println("最终modepai=" + modepai);
|
||||
// System.out.println("过牌删除手牌删除后" + handCards);
|
||||
// System.out.println("最终modepai=" + modepai);
|
||||
}
|
||||
// ... ex
|
||||
|
||||
public void bupai(ITObject param, RobotUser robotUser) {
|
||||
Integer card = param.getInt("card");
|
||||
Integer seat = param.getInt("seat");
|
||||
System.out.println("机器人seat" + robotUser.getSeat());
|
||||
System.out.println("后台发过来的座位号" + seat);
|
||||
System.out.println("放炮罚补牌" + card);
|
||||
// System.out.println("机器人seat" + robotUser.getSeat());
|
||||
// System.out.println("后台发过来的座位号" + seat);
|
||||
// System.out.println("放炮罚补牌" + card);
|
||||
if (seat == robotUser.getSeat() && card != modepai && modepai != 3) {
|
||||
handCards.add(card);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue