opcard
+ * int weight tiplist weight
+ * int card tiplist card
+ * int type tiplist type
+ * 2、通过遍历后的结果进行打分
+ * 打分系统:
+ * 已经听牌: ---> 40
+ * 操作后能听 ---> 20
+ * 操作之后散听 ---> -50
+ * 听多张,每一张:---> 3
+ * 孤章,每一张:----> -3
+ * 差手数:每一手 ----> -5
+ * 操作之前是否大胡 ----> 10
+ * 去掉大胡 -----> -10
+ *
+ * 先碰107,后补:
+ * {"tip_list":[{"type":5,"id":1,"opcard":[107],"weight":3,"card":107},{"type":5,"id":2,"opcard":[107],"weight":4,"card":107}]}
+ *
+ * 手上有3个摸一个204:开补
+ * {"tip_list":[{"type":4,"id":1,"opcard":[204],"weight":3,"card":204},{"type":4,"id":2,"opcard":[204],"weight":4,"card":204}]}
+ *
+ * 手上有3个,对家打一个206:开补
+ * {"tip_list":[{"type":3,"id":1,"opcard":[206],"weight":3,"card":206}]}
*/
- public String actionCard(ITObject param, TaurusClient client){
+ public String actionCard(ITObject param, TaurusClient client) {
ITArray tipList = param.getTArray("tip_list");
- log.info("tipList" +tipList);
+// log.info("tipList" +tipList);
ITObject params = TObject.newInstance();
int card = 0;
@@ -294,22 +303,22 @@ public class HuNanChangSha {
yupanhandcard.addAll(changShaCardInhand);
//进行操作之前能否下听
- List shifoutingpai = changShaSuanFaTest.handscardshifoutingpai(changShaCardInhand,chowGroup,pongGroup,gangdepai);
+ List shifoutingpai = changShaSuanFaTest.handscardshifoutingpai(changShaCardInhand, chowGroup, pongGroup, gangdepai);
boolean beforelisten = false;//记录操作之前的下听状态
- System.out.println("shifoutingpai"+shifoutingpai);
+ System.out.println("shifoutingpai" + shifoutingpai);
if (shifoutingpai.size() > 0) {
beforelisten = true;
}
- System.out.println("beforelisten"+beforelisten);
+ System.out.println("beforelisten" + beforelisten);
//如果杠了之后还能继续听牌则杠
//优先处理胡牌
- for(int i=0;i gangusecars = new ArrayList<>();
gangusecars.addAll(changShaCardInhand);
if (type == 3) {
- Util.removeCard(gangusecars,card,3);
- List shifoutingpai3 = changShaSuanFaTest.handscardshifoutingpai(gangusecars,chowGroup,pongGroup,gangdepai);
+ Util.removeCard(gangusecars, card, 3);
+ List shifoutingpai3 = changShaSuanFaTest.handscardshifoutingpai(gangusecars, chowGroup, pongGroup, gangdepai);
System.out.println(shifoutingpai3);
if (shifoutingpai3.size() > 0) {
@@ -346,24 +353,24 @@ public class HuNanChangSha {
List allList = new ArrayList<>();
allList.addAll(changShaCardInhand);
allList.addAll(changShachuguopai);
- int jutingnum = changShaSuanFaTest.getTingPainum(shifoutingpai3,allList);
- if (jutingnum==0){
- params.putString("session", session + "," + token);
- params.putInt("qi", 0);
- params.putInt("id", 0);
- client.send("612", params, response -> {
- });
- return "不开杠";
- }
+ int jutingnum = changShaSuanFaTest.getTingPainum(shifoutingpai3, allList);
+ if (jutingnum == 0) {
+ params.putString("session", session + "," + token);
+ params.putInt("qi", 0);
+ params.putInt("id", 0);
+ client.send("612", params, response -> {
+ });
+ return "不开杠";
+ }
- Util.removeCard(changShaCardInhand,card,3);
+ Util.removeCard(changShaCardInhand, card, 3);
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", id);
client.send("612", params, response -> {
});
return "开杠";
- }else{
+ } else {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", 0);
@@ -376,10 +383,9 @@ public class HuNanChangSha {
if (type == 4) {
-
- // Util.removeCard(changShaCardInhand,card,4);
- Util.removeCard(gangusecars,card,4);
- List shifoutingpai4 = changShaSuanFaTest.handscardshifoutingpai(gangusecars,chowGroup,pongGroup,gangdepai);
+ // Util.removeCard(changShaCardInhand,card,4);
+ Util.removeCard(gangusecars, card, 4);
+ List shifoutingpai4 = changShaSuanFaTest.handscardshifoutingpai(gangusecars, chowGroup, pongGroup, gangdepai);
if (shifoutingpai4.size() > 0) {
//开杠
@@ -387,8 +393,8 @@ public class HuNanChangSha {
List allList = new ArrayList<>();
allList.addAll(changShaCardInhand);
allList.addAll(changShachuguopai);
- int jutingnum = changShaSuanFaTest.getTingPainum(shifoutingpai4,allList);
- if (jutingnum==0){
+ int jutingnum = changShaSuanFaTest.getTingPainum(shifoutingpai4, allList);
+ if (jutingnum == 0) {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", 0);
@@ -397,14 +403,14 @@ public class HuNanChangSha {
return "不开杠";
}
- Util.removeCard(changShaCardInhand,card,4);
+ Util.removeCard(changShaCardInhand, card, 4);
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", id);
client.send("612", params, response -> {
});
return "开杠";
- }else{
+ } else {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", 0);
@@ -416,8 +422,8 @@ public class HuNanChangSha {
if (type == 5) {
//Util.removeCard(changShaCardInhand,card,1);
- Util.removeCard(gangusecars,card,1);
- List shifoutingpai5 = changShaSuanFaTest.handscardshifoutingpai(gangusecars,chowGroup,pongGroup,gangdepai);
+ Util.removeCard(gangusecars, card, 1);
+ List shifoutingpai5 = changShaSuanFaTest.handscardshifoutingpai(gangusecars, chowGroup, pongGroup, gangdepai);
if (shifoutingpai5.size() > 0) {
//开杠
@@ -425,8 +431,8 @@ public class HuNanChangSha {
List allList = new ArrayList<>();
allList.addAll(changShaCardInhand);
allList.addAll(changShachuguopai);
- int jutingnum = changShaSuanFaTest.getTingPainum(shifoutingpai5,allList);
- if (jutingnum==0){
+ int jutingnum = changShaSuanFaTest.getTingPainum(shifoutingpai5, allList);
+ if (jutingnum == 0) {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", 0);
@@ -435,14 +441,14 @@ public class HuNanChangSha {
return "不开杠";
}
- Util.removeCard(changShaCardInhand,card,1);
+ Util.removeCard(changShaCardInhand, card, 1);
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", id);
client.send("612", params, response -> {
});
return "开杠";
- }else{
+ } else {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", 0);
@@ -459,10 +465,10 @@ public class HuNanChangSha {
//判断是否是大胡
int beforeIsDahu = 0;
- beforeIsDahu = changShaSuanFaTest.checkDahu(yupanhandcard,chowGroup,pongGroup,gangdepai);
- System.out.println("bef:"+beforeIsDahu);
+ beforeIsDahu = changShaSuanFaTest.checkDahu(yupanhandcard, chowGroup, pongGroup, gangdepai);
+ System.out.println("bef:" + beforeIsDahu);
//5、门清
- if (yupanhandcard.size()==13&&beforelisten){
+ if (yupanhandcard.size() == 13 && beforelisten) {
beforeIsDahu = 5;//门清
}
@@ -470,8 +476,8 @@ public class HuNanChangSha {
List allSeeCard = new ArrayList<>();
- Map pingfenResult = new HashMap<>();
- Map idObject = new HashMap<>();
+ Map pingfenResult = new HashMap<>();
+ Map idObject = new HashMap<>();
//int bupaiid = 0;//补牌id
for (int i = 0; i < tipList.size(); i++) {
@@ -482,7 +488,7 @@ public class HuNanChangSha {
card = firstTip.getInt("card");
ITArray opcard = TArray.newInstance();
opcard = firstTip.getTArray("opcard");
- if (type == 6){
+ if (type == 6) {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", id);
@@ -491,67 +497,67 @@ public class HuNanChangSha {
return "胡牌";
}
//if((type==4||type==5||type==6)&&weight==3){
- // bupaiid = id;
- // }
+ // bupaiid = id;
+ // }
//对应的数据
ITObject tmp = new TObject();
//处理听的结果
switch (type) {
case 1:
//吃
- tmp = changShaSuanFaTest.pingguChi( beforelisten,card,opcard,yupanhandcard,beforeIsDahu,allSeeCard,chowGroup,pongGroup,gangdepai,changShachuguopai);
+ tmp = changShaSuanFaTest.pingguChi(beforelisten, card, opcard, yupanhandcard, beforeIsDahu, allSeeCard, chowGroup, pongGroup, gangdepai, changShachuguopai);
break;
case 2:
//碰
- tmp = changShaSuanFaTest.pingguPeng(beforelisten,card,opcard,yupanhandcard,beforeIsDahu,allSeeCard,chowGroup,pongGroup,gangdepai,changShachuguopai);
+ tmp = changShaSuanFaTest.pingguPeng(beforelisten, card, opcard, yupanhandcard, beforeIsDahu, allSeeCard, chowGroup, pongGroup, gangdepai, changShachuguopai);
break;
default:
break;
}
//记录下来事件
- if(tmp.size()>0){
- pingfenResult.put(id,tmp);
+ if (tmp.size() > 0) {
+ pingfenResult.put(id, tmp);
}
ITObject sj = new TObject();
sj.putInt("weight", weight);
sj.putInt("type", type);
sj.putTArray("opcard", opcard);
- idObject.put(id,sj);
+ idObject.put(id, sj);
}
//计算分数
System.out.println(pingfenResult);
- if(pingfenResult.size()>0){
- int changeid=changShaSuanFaTest.suanfen(pingfenResult);
- System.out.println("changeid:"+changeid);
+ if (pingfenResult.size() > 0) {
+ int changeid = changShaSuanFaTest.suanfen(pingfenResult);
+ System.out.println("changeid:" + changeid);
//选择最优的分数
- if (changeid==0){
+ if (changeid == 0) {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", 0);
client.send("612", params, response -> {
});
return null;
- }else {
+ } else {
//获取
- for(Map.Entry entry : idObject.entrySet()){
- if(entry.getKey()==changeid){
+ for (Map.Entry entry : idObject.entrySet()) {
+ if (entry.getKey() == changeid) {
ITObject tmp = entry.getValue();
System.out.println("tmp ++++++++++= " + tmp);
- if (tmp.getInt("type")==2){
+ if (tmp.getInt("type") == 2) {
//碰
ITArray outcards = tmp.getTArray("opcard");
for (int i = 0; i < outcards.size(); i++) {
- Util.removeCard(changShaCardInhand,outcards.getInt(0),2);
+ Util.removeCard(changShaCardInhand, outcards.getInt(0), 2);
}
pongGroup.add(outcards.getInt(0));
pongGroup.add(outcards.getInt(0));
pongGroup.add(outcards.getInt(0));
- }else if (tmp.getInt("type")==1){
+ } else if (tmp.getInt("type") == 1) {
//吃
ITArray outcards = tmp.getTArray("opcard");
for (int i = 0; i < outcards.size(); i++) {
- Util.removeCard(changShaCardInhand,outcards.getInt(i),1);
+ Util.removeCard(changShaCardInhand, outcards.getInt(i), 1);
}
System.out.println("判断吃 +++++++++" + card);
System.out.println("判断吃 ==========" + outcards);
@@ -591,11 +597,11 @@ public class HuNanChangSha {
List tmpChangSch2 = new ArrayList<>();
tmpChangSch2.addAll(yupanhandcard);
if (type == 3) {
- Util.removeCard(tmpChangSch2,card,3);
- }else if(type==4){
- Util.removeCard(tmpChangSch2,card,3);
- }else if(type==5){
- Util.removeCard(tmpChangSch2,card,4);
+ Util.removeCard(tmpChangSch2, card, 3);
+ } else if (type == 4) {
+ Util.removeCard(tmpChangSch2, card, 3);
+ } else if (type == 5) {
+ Util.removeCard(tmpChangSch2, card, 4);
}
ChangshaWinSplitCard.checkNormalHu(tmpChangSch2, map2);
@@ -603,7 +609,7 @@ public class HuNanChangSha {
System.out.println(yupanhandcard);
//假设补牌
//如果下听不能不能补牌
- if(beforelisten){
+ if (beforelisten) {
System.out.println("b补");
params.putString("session", session + "," + token);
params.putInt("qi", 0);
@@ -613,9 +619,9 @@ public class HuNanChangSha {
return null;
}
//去一张下听?
- Map> afterDahuOpbg = changShaSuanFaTest.quyizhangDahuTingPai(yupanhandcard,chowGroup,pongGroup,gangdepai);
- Map> afterOpbg = changShaSuanFaTest.quyizhangTingPai(yupanhandcard);
- if(type==4) {
+ Map> afterDahuOpbg = changShaSuanFaTest.quyizhangDahuTingPai(yupanhandcard, chowGroup, pongGroup, gangdepai);
+ Map> afterOpbg = changShaSuanFaTest.quyizhangTingPai(yupanhandcard);
+ if (type == 4) {
if (afterDahuOpbg.size() > 0 || afterOpbg.size() > 0) {
System.out.println("bs补");
params.putString("session", session + "," + token);
@@ -627,11 +633,11 @@ public class HuNanChangSha {
}
}
- if (map.size() > 0 && weight==3) {
+ if (map.size() > 0 && weight == 3) {
if (map2.size() > 0) {
//判断补牌后
- if (Integer.parseInt(map2.get("remainingMelds").toString())>Integer.parseInt(map.get("remainingMelds").toString())&&Integer.parseInt(map.get("remainingMelds").toString())<=2){
+ if (Integer.parseInt(map2.get("remainingMelds").toString()) > Integer.parseInt(map.get("remainingMelds").toString()) && Integer.parseInt(map.get("remainingMelds").toString()) <= 2) {
System.out.println("b补");
params.putString("session", session + "," + token);
params.putInt("qi", 0);
@@ -639,11 +645,11 @@ public class HuNanChangSha {
client.send("612", params, response -> {
});
return null;
- }else{
+ } else {
//判断七对
- int dh = changShaSuanFaTest.checkDahu(yupanhandcard,chowGroup,pongGroup,gangdepai);
- if (dh>0){
+ int dh = changShaSuanFaTest.checkDahu(yupanhandcard, chowGroup, pongGroup, gangdepai);
+ if (dh > 0) {
System.out.println("不补");
params.putString("session", session + "," + token);
params.putInt("qi", 0);
@@ -723,7 +729,7 @@ public class HuNanChangSha {
}
*/
- }else{
+ } else {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", id);
@@ -765,11 +771,9 @@ public class HuNanChangSha {
}
-
-
public String actionCardBak2(ITObject param, TaurusClient client) {
ITArray tipList = param.getTArray("tip_list");
- log.info("tipList" +tipList);
+// log.info("tipList" +tipList);
//tipList[{opcard=[207, 208], weight=1, id=1, type=1, card=206}]
boolean chiflag = false;//吃
boolean pengflag = false; //碰
@@ -787,7 +791,7 @@ public class HuNanChangSha {
int id = firstTip.getInt("id");
int weight = firstTip.getInt("weight");
card = firstTip.getInt("card");
- if (type == 6){
+ if (type == 6) {
params.putString("session", session + "," + token);
params.putInt("qi", 0);
params.putInt("id", id);
@@ -795,21 +799,21 @@ public class HuNanChangSha {
});
return "胡牌";
}
- if (type == 1){
+ if (type == 1) {
chiflag = true;
}
- if (type == 2){
+ if (type == 2) {
pengflag = true;
}
- if (type == 3 && weight ==3){
+ if (type == 3 && weight == 3) {
//补
bupai = true;
}
- if (type == 3 && weight ==4){
+ if (type == 3 && weight == 4) {
//杠
minggang = true;
}
- if (type == 5){
+ if (type == 5) {
penggang = true;
}
}
@@ -843,8 +847,6 @@ public class HuNanChangSha {
}
-
-
/**
* 处理吃 问题
* @param tipList
@@ -1016,10 +1018,11 @@ public class HuNanChangSha {
client.send("612", params, response -> {});
}
*/
+
/**
* 处理杠碰胡操作
*
- * @param param 消息参数
+ * @param
* @return
*/
/*
@@ -1682,8 +1685,6 @@ public class HuNanChangSha {
}
*/
-
-
public static List getOtherCards1(List integers, int card) {
List result = new ArrayList<>();
for (Integer num : integers) {
@@ -1762,7 +1763,6 @@ public class HuNanChangSha {
resultList.addAll(zigang);
}
-
// 长沙麻将出牌
String changShaOutCard = changShaSuanFaTest.outCardSuanFa(changShaCardInhand, pongGroup, chowGroup, gangdepai, resultList);
// String changShaOutCard = changShaSuanFaTest.outCardSuanFa(list, changShaCard,pongGroup);
@@ -1791,12 +1791,12 @@ public class HuNanChangSha {
changShachuguopai.add(cardToOut);
// 从手牌中移除
changShaCardInhand.remove(Integer.valueOf(cardToOut));
-
-
params.putString("session", session + "," + token);
client.send("611", params, response -> {
});
+
+
return null;
}
@@ -1844,7 +1844,7 @@ public class HuNanChangSha {
public static void main(String[] args) {
HuNanChangSha huNanChangSha = new HuNanChangSha();
ITObject params = TObject.newInstance();
- TaurusClient tc = new TaurusClient("127.0.0.1","10", TaurusClient.ConnectionProtocol.Tcp);
+ TaurusClient tc = new TaurusClient("127.0.0.1", "10", TaurusClient.ConnectionProtocol.Tcp);
List hands1 = new ArrayList<>();
hands1.add(209);
hands1.add(209);
@@ -1860,64 +1860,63 @@ public class HuNanChangSha {
hands1.add(104);
hands1.add(104);
- // hands1.add(105);
+ // hands1.add(105);
//hands1.add(103);
//hands1.add(102);
- int card= 203;
+ int card = 203;
huNanChangSha.changShaCardInhand.addAll(hands1);
- TArray tiplist= new TArray();
+ TArray tiplist = new TArray();
ITArray opcard = TArray.newInstance();
opcard.addInt(102);
- // opcard.addInt(205);
+ // opcard.addInt(205);
- // opcard.addInt(203);
+ // opcard.addInt(203);
TObject tob = new TObject();
- tob.putInt("weight",3);
- tob.putInt("id",1);
- tob.putInt("type",4);
- tob.putInt("card",card);
+ tob.putInt("weight", 3);
+ tob.putInt("id", 1);
+ tob.putInt("type", 4);
+ tob.putInt("card", card);
tob.putTArray("opcard", opcard);
//tiplist.addTObject(tob);
ITArray opcard2 = TArray.newInstance();
- // opcard2.addInt(106);
+ // opcard2.addInt(106);
opcard2.addInt(107);
TObject tob2 = new TObject();
- tob2.putInt("weight",5);
- tob2.putInt("id",2);
- tob2.putInt("type",5);
- tob2.putInt("card",card);
+ tob2.putInt("weight", 5);
+ tob2.putInt("id", 2);
+ tob2.putInt("type", 5);
+ tob2.putInt("card", card);
tob2.putTArray("opcard", opcard2);
- // tiplist.addTObject(tob2);
+ // tiplist.addTObject(tob2);
ITArray opcard3 = TArray.newInstance();
opcard3.addInt(204);
opcard3.addInt(205);
TObject tob3 = new TObject();
- tob3.putInt("weight",1);
- tob3.putInt("id",1);
- tob3.putInt("type",1);
- tob3.putInt("card",card);
+ tob3.putInt("weight", 1);
+ tob3.putInt("id", 1);
+ tob3.putInt("type", 1);
+ tob3.putInt("card", card);
tob3.putTArray("opcard", opcard3);
tiplist.addTObject(tob3);
-
- params.putTArray("tip_list",tiplist);
+ params.putTArray("tip_list", tiplist);
System.out.println(params);
//已经吃掉数据
- // huNanChangSha.chowGroup.add(205);
+ // huNanChangSha.chowGroup.add(205);
//huNanChangSha.chowGroup.add(204);
- // huNanChangSha.chowGroup.add(206);
+ // huNanChangSha.chowGroup.add(206);
//huNanChangSha.chowGroup.add(201);
- // huNanChangSha.chowGroup.add(202);
- // huNanChangSha.chowGroup.add(203);
- // huNanChangSha.chowGroup.add(206);
+ // huNanChangSha.chowGroup.add(202);
+ // huNanChangSha.chowGroup.add(203);
+ // huNanChangSha.chowGroup.add(206);
//huNanChangSha.chowGroup.add(204);
//huNanChangSha.chowGroup.add(205);
- String res = huNanChangSha.actionCard(params,tc);
+ String res = huNanChangSha.actionCard(params, tc);
System.out.println(res);
}
diff --git a/libs/robot_common/src/main/java/hunan/JiQiRens.java b/libs/robot_common/src/main/java/hunan/JiQiRens.java
index 6447ed4..02fbf5a 100644
--- a/libs/robot_common/src/main/java/hunan/JiQiRens.java
+++ b/libs/robot_common/src/main/java/hunan/JiQiRens.java
@@ -957,7 +957,8 @@ public class JiQiRens {
//[TCP->822] data:{"tip_list":[{"type":8,"id":1,"opcard":[],"weight":8,"card":0}],"types":[{"type":21,"value":1}]}
//板胡Event [TCP->823] data:{"type":8,"seat":1,"data":[{"opcard":[204,204,204,108,108,108],"type":21,"value":1}]}
if ("811".equalsIgnoreCase(command)) {//初始化收手牌
- huNanChangSha.cardInHead(command, message, client);
+ Map d = null;
+// huNanChangSha.cardInHead(command, message, client);
} else if ("812".equalsIgnoreCase(command)) {//出牌广播
//{"opzicards":[{"opzicards":[],"playerId":101555}],"opmingcards":[{"opmingcards":[],"playerId":101555}],"outcard_map":[{"outcards":[209,205],"playerId":101555},{"outcards":[],"playerId":112233}],"card":205,"opchicards":[{"opchicards":[105,103],"playerId":101555}],"oppengcards":[{"oppengcards":[],"playerId":101555}],"seat":1}
ITArray outcard_map = param.getTArray("outcard_map");
@@ -1054,9 +1055,10 @@ public class JiQiRens {
HuNanChangSha.drawCard(command, message);
} else if ("819".equalsIgnoreCase(command)) {
//摸牌
- huNanChangSha.getCard(command, message);
+// huNanChangSha.getCard(command, message);
} else if ("813".equalsIgnoreCase(command)) {//出牌提示
- huNanChangSha.outCard(client,playerOutcardsMap,playerchisMap,playerpengsMap,playermingsMap,playerzisMap);
+
+// huNanChangSha.outCard(client,playerOutcardsMap,playerchisMap,playerpengsMap,playermingsMap,playerzisMap,null);
} else if ("814".equalsIgnoreCase(command)) {
//放招提示
huNanChangSha.actionCard(param, client);
diff --git a/libs/robot_common/src/main/java/taurus/newRobot/AddRoomRobot.java b/libs/robot_common/src/main/java/taurus/newRobot/AddRoomRobot.java
index 1f9f8cc..1ed06f2 100644
--- a/libs/robot_common/src/main/java/taurus/newRobot/AddRoomRobot.java
+++ b/libs/robot_common/src/main/java/taurus/newRobot/AddRoomRobot.java
@@ -1,108 +1,58 @@
package taurus.newRobot;
-import com.taurus.core.entity.ITArray;
-import com.taurus.core.entity.ITObject;
-import com.taurus.core.entity.TObject;
-import com.taurus.core.events.Event;
-import com.taurus.core.events.IEventListener;
-import com.taurus.core.plugin.database.DataBase;
import com.taurus.core.plugin.redis.Redis;
-import com.taurus.core.util.ICallback;
-import com.taurus.core.util.StringUtil;
-import hunan.*;
import redis.clients.jedis.*;
-import taurus.client.Message;
-import taurus.client.MessageResponse;
-import taurus.client.SocketCode;
-import taurus.client.TaurusClient;
-import taurus.client.business.AccountBusiness;
-import taurus.client.business.GroupRoomBusiness;
-import taurus.util.ChangShaSuanFaTest;
-import taurus.util.TinHuChi;
-import java.sql.SQLException;
import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
+import taurus.client.TaurusClient;
-import static hunan.JiQiRens.sleepTime;
public class AddRoomRobot {
- public String wanfaId = "";
- // 会话标识
- private String session = "";
- // 访问令牌
- public String token = "";
- // 客户端连接对象
- private static TaurusClient client = null;
-
-
- private HuNanHongZhong huNanHongZhong = new HuNanHongZhong();
-
- private HuNanZhuanZhuan huNanZhuanZhuan = new HuNanZhuanZhuan();
-
- private HuNanFangPaoFa huNanFangPaoFa = new HuNanFangPaoFa();
-
- private HuNanPaoDeKuai huNanPaoDeKuai = new HuNanPaoDeKuai();
-
- private HuNanChangSha huNanChangSha = new HuNanChangSha();
-
-
- private Map> playerOutcardsMap = new HashMap<>();
-
-
- private Map> playerchisMap = new HashMap<>();
-
- private Map> playerpengsMap = new HashMap<>();
-
- private Map> playermingsMap = new HashMap<>();
-
- private Map> playerzisMap = new HashMap<>();
-
- private Map mapclient = new HashMap<>();
public void addRoom() {
Jedis jedis2 = Redis.use("group1_db2").getJedis();
Jedis jedis11 = Redis.use("group1_db11").getJedis();
- Jedis jedis0 = Redis.use().getJedis();
+ System.out.println("进入1111111111111111111111111");
+ //给玩法分配机器人
+ if (jedis11.keys("group:*") != null) {
+ Set groupIds = jedis11.keys("group:*");
+ for (String group : groupIds) {
+ String groupId = group.substring(group.indexOf(":") + 1);
+ String groupKey = "g{" + groupId + "}:play:*";
+ if (jedis11.keys(groupKey) != null) {
+ Set playIds = jedis11.keys(groupKey);
+ // 遍历圈子下面的玩法
+ for (String pid : playIds) {
+ String playId = pid.substring(pid.indexOf("play:") + 5);
+ String playKey = "g{" + groupId + "}:play:" + playId;
- //获取圈子id和玩法id
- List gKeys = scanKeysByPattern(jedis2, "g{*}:play:*");
-
- try {
-
- if (jedis11.keys("group:*") != null) {
- Set groupIds = jedis11.keys("group:*");
- for (String group : groupIds) {
- String groupId = group.substring(group.indexOf(":") + 1);
- String groupKey = "g{" + groupId + "}:play:*";
- if (jedis11.keys(groupKey) != null) {
- Set playIds = jedis11.keys(groupKey);
- // 遍历圈子下面的玩法
- for (String pid : playIds) {
- String playId = pid.substring(pid.indexOf("play:") + 5);
- String playKey = "g{" + groupId + "}:play:" + playId;
-
- String leftover_robot = "0";
- if (jedis11.hget(playKey, "leftover_robot") != null) {
- leftover_robot = jedis11.hget(playKey, "leftover_robot");
- if (Integer.parseInt(leftover_robot) > 0) {
- //给圈子玩法分配机器人,创建到redis
- addPlayRobot(groupId, playId, leftover_robot);
- }
+ String leftover_robot = "0";
+ if (jedis11.hget(playKey, "leftover_robot") != null) {
+ leftover_robot = jedis11.hget(playKey, "leftover_robot");
+ if (Integer.parseInt(leftover_robot) > 0) {
+ //给圈子玩法分配机器人,创建到redis
+ addPlayRobot(groupId, playId, leftover_robot);
}
}
}
-
}
}
+ }
+ System.out.println("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
+ //机器人主动找真人
+ joinzhenrenRoom();
+ System.out.println("进入22222222222222222222222");
+ //机器人主动进入退出, 这里进入的是中括号机器人退出的房间
+ zhongJoninRoom();
+// System.out.println("进入3333333333333333333");
+ //机器人创建房间 进入房间
+ List gKeys = scanKeysByPattern(jedis2, "g{*}:play:*");
+ try {
Map> stringListMap = analyzePlayStructure(gKeys);
-
//取出 圈子玩法里的 机器人使用所有的状态
Map>> playDetails = getPlayDetails(jedis2, stringListMap);
System.out.println("result" + playDetails);
@@ -110,37 +60,17 @@ public class AddRoomRobot {
//统计 玩法里 等待中的次数 为1的有几个 ,然后需要建立几个房间
Map> stringMapMap = analyzeAndMarkRoomsWithCircle(playDetails);
System.out.println("stringIntegerMap" + stringMapMap);
-
-
- Map>> allCreatedRooms = new HashMap<>();
// 按圈子ID排序处理
List circleIds = new ArrayList<>(stringMapMap.keySet());
Collections.sort(circleIds);
for (String circleId : circleIds) {
Map playRoomMap = stringMapMap.get(circleId);
-
- System.out.println("\n=== 处理圈子 " + circleId + " ===");
-
- // 为当前圈子创建房间
- Map> createdRooms = createRoomsForCircle(circleId, playRoomMap);
-
-
- allCreatedRooms.put(circleId, createdRooms);
+ System.out.println("创建房间,进入房间");
+ jiqiren jiqiren = new jiqiren();
+ System.out.println("circleId +++" + circleId);
+ System.out.println("playRoomMap +++ " + playRoomMap);
+ jiqiren.createRoomsForCircle(circleId, playRoomMap);
}
-
-
-// Object room = GroupRoomBusiness.matchRoom(groupId, pid, session, "Android", false);
-// try {
-// String game = jedis0.hget(String.valueOf(room), "game");
-// wanfaId = String.valueOf(game);
-// }catch (Exception e){
-// e.printStackTrace();
-// }finally {
-// jedis0.close();
-// }
-// System.out.println("chaungjianwanfa" + gKeys);
-
-
} catch (Exception e) {
e.printStackTrace();
} finally {
@@ -150,921 +80,24 @@ public class AddRoomRobot {
}
- /**
- * 为单个圈子创建房间
- */
- public Map> createRoomsForCircle(String circleId, Map playRoomMap) {
- Map> createdRooms = new HashMap<>();
- Jedis jedis2 = Redis.use("group1_db2").getJedis();
- Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ //机器人进入中括号房间
+ public void zhongJoninRoom() {
Jedis jedis0 = Redis.use().getJedis();
- // 按玩法ID排序处理
- List> sortedPlays = playRoomMap.entrySet().stream()
- .sorted(Map.Entry.comparingByKey())
- .collect(Collectors.toList());
-
- for (Map.Entry entry : sortedPlays) {
- String playId = entry.getKey();
- int requiredRooms = entry.getValue();
-
- if (requiredRooms <= 0) {
- System.out.println("玩法 " + playId + ": 跳过创建 (需求数=" + requiredRooms + ")");
- continue;
+ try {
+ //获取所有房间
+ Set roomIds = jedis0.keys("room:*");
+ for (String id : roomIds) {
+ jiqiren jiqiren = new jiqiren();
+ jiqiren.tcp_jiqirezhongkouhao(id);
}
-
- System.out.println("玩法 " + playId + ": 创建 " + requiredRooms + " 个房间");
-
- List