jefe0105
parent
2ba7c82c92
commit
b6230c2c92
|
|
@ -7,6 +7,7 @@
|
|||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="web_group" />
|
||||
<module name="game_mj_changsha" />
|
||||
<module name="taurus-core" />
|
||||
<module name="taurus-permanent" />
|
||||
<module name="robot_common" />
|
||||
|
|
|
|||
|
|
@ -17,5 +17,7 @@
|
|||
<file url="file://$PROJECT_DIR$/libs/taurus-server/taurus-permanent/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/libs/taurus-server/taurus-web/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/libs/taurus-server/taurus-web/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/majiang/changsha/game_mj_cs/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/majiang/changsha/game_mj_cs/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
<option value="$PROJECT_DIR$/libs/game_common/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/game_web/web_group/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/libs/robot_common/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/majiang/changsha/game_mj_cs/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/libs/taurus-server/taurus-server.iml" filepath="$PROJECT_DIR$/libs/taurus-server/taurus-server.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/xtserver_anchou.iml" filepath="$PROJECT_DIR$/.idea/xtserver_anchou.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
|
|
@ -1,23 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" />
|
||||
<orderEntry type="module" module-name="taurus-core" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.6.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" />
|
||||
<orderEntry type="module" module-name="data_cache" />
|
||||
<orderEntry type="module" module-name="taurus-core" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.6.1" level="project" />
|
||||
<orderEntry type="module" module-name="taurus-permanent" />
|
||||
<orderEntry type="library" name="Maven: io.undertow:undertow-core:2.0.16.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.xnio:xnio-api:3.3.8.Final" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.jboss.xnio:xnio-nio:3.3.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="taurus-core" />
|
||||
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.6.1" level="project" />
|
||||
<orderEntry type="module" module-name="taurus-web" />
|
||||
<orderEntry type="module" module-name="game_common" />
|
||||
<orderEntry type="module" module-name="data_cache" />
|
||||
<orderEntry type="module" module-name="taurus-permanent" />
|
||||
<orderEntry type="library" name="Maven: io.undertow:undertow-core:2.0.16.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.xnio:xnio-api:3.3.8.Final" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.jboss.xnio:xnio-nio:3.3.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.10.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -4,6 +4,7 @@ import com.game.Global;
|
|||
import com.game.Util;
|
||||
import com.taurus.core.entity.ITArray;
|
||||
import com.taurus.core.entity.ITObject;
|
||||
import com.taurus.core.entity.TArray;
|
||||
import com.taurus.core.entity.TObject;
|
||||
import com.taurus.core.plugin.database.DataBase;
|
||||
import com.taurus.core.util.Logger;
|
||||
|
|
@ -23,18 +24,21 @@ public class HuNanChangSha {
|
|||
public static boolean isTinChi = false;
|
||||
public static boolean isTinPeng = false;
|
||||
|
||||
public static Logger logger;
|
||||
private static final Logger log = Logger.getLogger(DoTest.class);
|
||||
|
||||
//湖南红中麻将手牌
|
||||
//湖南长沙麻将手牌
|
||||
private List<Integer> changShaCardInhand = new ArrayList<>();
|
||||
|
||||
private List<Integer> changShaCardInhandgang = new ArrayList<>();
|
||||
|
||||
|
||||
//红中麻将出过的牌
|
||||
//长沙麻将出过的牌
|
||||
private List<Integer> changShachuguopai = new ArrayList<>();
|
||||
|
||||
private Map<Integer,Integer> chuGuoPainum = new HashMap<>();
|
||||
|
||||
|
||||
//杠的牌
|
||||
private List<Integer> gangdepai = new ArrayList<>();
|
||||
|
||||
|
||||
|
|
@ -89,6 +93,9 @@ public class HuNanChangSha {
|
|||
return changShachuguopai;
|
||||
}
|
||||
|
||||
public Map<Integer,Integer> getChuGuoPainum() {
|
||||
return chuGuoPainum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 出牌广播协议 812
|
||||
|
|
@ -126,14 +133,10 @@ public class HuNanChangSha {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (param.getInt("player") != null) {
|
||||
int drawnCard = param.getInt("card");
|
||||
|
||||
changShaSuanFaTest.drawnCards = drawnCard;//存储摸到的牌
|
||||
changShaCardInhand.add(drawnCard);
|
||||
|
||||
|
||||
changShaSuanFaTest.analyzeHand(changShaCardInhand);
|
||||
|
||||
|
||||
|
|
@ -225,19 +228,565 @@ public class HuNanChangSha {
|
|||
return jiangnum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理 吃,碰,杠,补,胡
|
||||
* @param param
|
||||
* @param client
|
||||
* @return
|
||||
吃
|
||||
[TCP->814] data:{"tip_list":[{"type":1,"id":1,"opcard":[108,109],"weight":1,"card":107}]}
|
||||
吃 碰
|
||||
{"tip_list":[{"type":1,"id":1,"opcard":[206,205],"weight":1,"card":207},{"type":2,"id":2,"opcard":[207],"weight":2,"card":207}]}
|
||||
碰补
|
||||
{"tip_list":[{"type":2,"id":1,"opcard":[101],"weight":2,"card":101},{"type":3,"id":2,"opcard":[101],"weight":3,"card":101}]}
|
||||
补
|
||||
[TCP->814] data:{"tip_list":[{"type":5,"id":1,"opcard":[101],"weight":3,"card":101}]}
|
||||
吃,碰,补,杠,
|
||||
{"tip_list":[{"type":1,"id":1,"opcard":[206,204],"weight":1,"card":205},{"type":1,"id":2,"opcard":[206,207],"weight":1,"card":205},{"type":2,"id":3,"opcard":[205],"weight":2,"card":205},{"type":3,"id":4,"opcard":[205],"weight":3,"card":205},{"type":3,"id":5,"opcard":[205],"weight":4,"card":205}]}
|
||||
碰
|
||||
{"tip_list":[{"type":2,"id":1,"opcard":[207],"weight":2,"card":207}]}
|
||||
补,杠
|
||||
{"tip_list":[{"type":5,"id":1,"opcard":[207],"weight":3,"card":207},{"type":5,"id":2,"opcard":[207],"weight":4,"card":207}]}
|
||||
|
||||
//拟定:
|
||||
1、对应的提示事件遍历 实行假设做了处理之后的结果 对应结果的对象
|
||||
boolean isTing 是否听牌
|
||||
boolean canTing 能否听牌
|
||||
int tingNum 听多少张
|
||||
int isDaHu 是否大胡
|
||||
int guzhang 有多少孤章
|
||||
int lastHands 差多少手
|
||||
int id tiplist id
|
||||
List<Integer> opcard
|
||||
int weight tiplist weight
|
||||
int card tiplist card
|
||||
int type tiplist type
|
||||
2、通过遍历后的结果进行打分
|
||||
打分系统:
|
||||
已经听牌: ---> 40
|
||||
操作后能听 ---> 20
|
||||
操作之后散听 ---> -50
|
||||
听多张,每一张:---> 3
|
||||
孤章,每一张:----> -3
|
||||
差手数:每一手 ----> -5
|
||||
操作之前是否大胡 ----> 10
|
||||
去掉大胡 -----> -10
|
||||
*/
|
||||
public String actionCard(ITObject param, TaurusClient client){
|
||||
ITArray tipList = param.getTArray("tip_list");
|
||||
log.info("tipList" +tipList);
|
||||
ITObject params = TObject.newInstance();
|
||||
int card = 0;
|
||||
|
||||
//循环
|
||||
List<Integer> yupanhandcard = new ArrayList<>();
|
||||
yupanhandcard.addAll(changShaCardInhand);
|
||||
//进行操作之前能否下听
|
||||
List<Integer> shifoutingpai = changShaSuanFaTest.handscardshifoutingpai(changShaCardInhand);
|
||||
boolean beforelisten = false;//记录操作之前的下听状态
|
||||
if (shifoutingpai.size() > 0) {
|
||||
beforelisten = true;
|
||||
}
|
||||
|
||||
//如果杠了之后还能继续听牌则杠
|
||||
//如果下听了,可以杠
|
||||
for (int i = 0; i < tipList.size(); i++) {
|
||||
TObject firstTip = (TObject) tipList.get(i).getObject();
|
||||
int type = firstTip.getInt("type");
|
||||
int id = firstTip.getInt("id");
|
||||
int weight = firstTip.getInt("weight");
|
||||
card = firstTip.getInt("card");
|
||||
if ((type == 5 || type == 3 || type==4)&&weight==4) {
|
||||
//判断开杠后是否能下听
|
||||
List<Integer> gangusecars = new ArrayList<>();
|
||||
gangusecars.addAll(changShaCardInhand);
|
||||
if (type == 3) {
|
||||
Util.removeCard(gangusecars,card,3);
|
||||
List<Integer> shifoutingpai3 = changShaSuanFaTest.handscardshifoutingpai(gangusecars);
|
||||
if (shifoutingpai3.size() > 0) {
|
||||
//开杠
|
||||
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{
|
||||
params.putString("session", session + "," + token);
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", 0);
|
||||
client.send("612", params, response -> {
|
||||
});
|
||||
return "不开杠";
|
||||
}
|
||||
}
|
||||
|
||||
if (type == 4) {
|
||||
// Util.removeCard(changShaCardInhand,card,4);
|
||||
Util.removeCard(gangusecars,card,4);
|
||||
List<Integer> shifoutingpai4 = changShaSuanFaTest.handscardshifoutingpai(gangusecars);
|
||||
if (shifoutingpai4.size() > 0) {
|
||||
//开杠
|
||||
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{
|
||||
params.putString("session", session + "," + token);
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", 0);
|
||||
client.send("612", params, response -> {
|
||||
});
|
||||
return "不开杠";
|
||||
}
|
||||
}
|
||||
if (type == 5) {
|
||||
//Util.removeCard(changShaCardInhand,card,1);
|
||||
|
||||
Util.removeCard(gangusecars,card,1);
|
||||
List<Integer> shifoutingpai5 = changShaSuanFaTest.handscardshifoutingpai(gangusecars);
|
||||
if (shifoutingpai5.size() > 0) {
|
||||
//开杠
|
||||
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{
|
||||
params.putString("session", session + "," + token);
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", 0);
|
||||
client.send("612", params, response -> {
|
||||
});
|
||||
return "不开杠";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否是大胡
|
||||
int beforeIsDahu = 0;
|
||||
beforeIsDahu = changShaSuanFaTest.checkDahu(yupanhandcard,chowGroup,pongGroup,gangdepai);
|
||||
//5、门清
|
||||
if (yupanhandcard.size()==13&&beforelisten){
|
||||
beforeIsDahu = 5;//门清
|
||||
}
|
||||
|
||||
//操作之前出现的牌
|
||||
List<Integer> allSeeCard = new ArrayList<>();
|
||||
|
||||
|
||||
Map<Integer,ITObject> pingfenResult = new HashMap<>();
|
||||
Map<Integer,ITObject> idObject = new HashMap<>();
|
||||
//int bupaiid = 0;//补牌id
|
||||
for (int i = 0; i < tipList.size(); i++) {
|
||||
TObject firstTip = (TObject) tipList.get(i).getObject();
|
||||
int type = firstTip.getInt("type");
|
||||
int id = firstTip.getInt("id");
|
||||
int weight = firstTip.getInt("weight");
|
||||
card = firstTip.getInt("card");
|
||||
ITArray opcard = TArray.newInstance();
|
||||
opcard = firstTip.getTArray("opcard");
|
||||
if (type == 6){
|
||||
params.putString("session", session + "," + token);
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", id);
|
||||
client.send("612", params, response -> {
|
||||
});
|
||||
return "胡牌";
|
||||
}
|
||||
//if((type==4||type==5||type==6)&&weight==3){
|
||||
// bupaiid = id;
|
||||
// }
|
||||
//对应的数据
|
||||
ITObject tmp = new TObject();
|
||||
//处理听的结果
|
||||
switch (type) {
|
||||
case 1:
|
||||
//吃
|
||||
tmp = changShaSuanFaTest.pingguChi( beforelisten,card,opcard,yupanhandcard,beforeIsDahu,allSeeCard,chowGroup,changShachuguopai);
|
||||
break;
|
||||
case 2:
|
||||
//碰
|
||||
tmp = changShaSuanFaTest.pingguPeng(beforelisten,card,opcard,yupanhandcard,beforeIsDahu,allSeeCard,chowGroup,pongGroup,gangdepai,changShachuguopai);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//记录下来事件
|
||||
if(tmp.size()>0){
|
||||
pingfenResult.put(id,tmp);
|
||||
}
|
||||
ITObject sj = new TObject();
|
||||
sj.putInt("weight", weight);
|
||||
sj.putTArray("opcard", opcard);
|
||||
idObject.put(id,sj);
|
||||
}
|
||||
//计算分数
|
||||
System.out.println(pingfenResult);
|
||||
if(pingfenResult.size()>0){
|
||||
int changeid=changShaSuanFaTest.suanfen(pingfenResult);
|
||||
System.out.println("changeid:"+changeid);
|
||||
//选择最优的分数
|
||||
if (changeid==0){
|
||||
params.putString("session", session + "," + token);
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", 0);
|
||||
client.send("612", params, response -> {
|
||||
});
|
||||
return null;
|
||||
}else {
|
||||
//获取
|
||||
for(Map.Entry<Integer,ITObject> entry : idObject.entrySet()){
|
||||
if(entry.getKey()==changeid){
|
||||
ITObject tmp = entry.getValue();
|
||||
if (tmp.getInt("weight")==2){
|
||||
//碰
|
||||
ITArray outcards = tmp.getTArray("opcard");
|
||||
for (int i = 0; i < outcards.size(); i++) {
|
||||
Util.removeCard(changShaCardInhand,outcards.getInt(0),2);
|
||||
}
|
||||
}else if (tmp.getInt("weight")==1){
|
||||
//吃
|
||||
ITArray outcards = tmp.getTArray("opcard");
|
||||
for (int i = 0; i < outcards.size(); i++) {
|
||||
Util.removeCard(changShaCardInhand,outcards.getInt(i),1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
params.putString("session", session + "," + token);
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", changeid);
|
||||
client.send("612", params, response -> {
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//计算牌数
|
||||
|
||||
//如果 不吃,不碰,而且差三手牌情况,则补
|
||||
//if (bupaiid>0) {
|
||||
for (int i = 0; i < tipList.size(); i++) {
|
||||
TObject firstTip = (TObject) tipList.get(i).getObject();
|
||||
int type = firstTip.getInt("type");
|
||||
int id = firstTip.getInt("id");
|
||||
int weight = firstTip.getInt("weight");
|
||||
card = firstTip.getInt("card");
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
List<Integer> tmpChangSch = new ArrayList<>();
|
||||
tmpChangSch.addAll(yupanhandcard);
|
||||
ChangshaWinSplitCard.checkNormalHu(tmpChangSch, map);
|
||||
System.out.println("map:" + map);
|
||||
|
||||
if (map.size() > 0 && weight==3) {
|
||||
|
||||
if (Integer.parseInt(map.get("remainingMelds").toString()) > 2) {
|
||||
params.putString("session", session + "," + token);
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", id);
|
||||
|
||||
if (type == 3) {
|
||||
Util.removeCard(changShaCardInhand,card,3);
|
||||
}
|
||||
if (type == 4) {
|
||||
Util.removeCard(changShaCardInhand,card,4);
|
||||
}
|
||||
if (type == 5) {
|
||||
Util.removeCard(changShaCardInhand,card,1);
|
||||
}
|
||||
client.send("612", params, response -> {
|
||||
});
|
||||
return null;
|
||||
} else {
|
||||
params.putString("session", session + "," + token);
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", 0);
|
||||
client.send("612", params, response -> {
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
params.putString("session", session + "," + token);
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", 0);
|
||||
client.send("612", params, response -> {
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String actionCardBak2(ITObject param, TaurusClient client) {
|
||||
ITArray tipList = param.getTArray("tip_list");
|
||||
log.info("tipList" +tipList);
|
||||
//tipList[{opcard=[207, 208], weight=1, id=1, type=1, card=206}]
|
||||
boolean chiflag = false;//吃
|
||||
boolean pengflag = false; //碰
|
||||
boolean bupai = false; //补
|
||||
boolean minggang = false; //杠
|
||||
boolean angang = false; //暗杠
|
||||
boolean penggang = false; //开杠
|
||||
|
||||
int card = 0;//当前 消息的牌
|
||||
ITObject params = TObject.newInstance();
|
||||
|
||||
for (int i = 0; i < tipList.size(); i++) {
|
||||
TObject firstTip = (TObject) tipList.get(i).getObject();
|
||||
int type = firstTip.getInt("type");
|
||||
int id = firstTip.getInt("id");
|
||||
int weight = firstTip.getInt("weight");
|
||||
card = firstTip.getInt("card");
|
||||
if (type == 6){
|
||||
params.putString("session", session + "," + token);
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", id);
|
||||
client.send("612", params, response -> {
|
||||
});
|
||||
return "胡牌";
|
||||
}
|
||||
if (type == 1){
|
||||
chiflag = true;
|
||||
}
|
||||
if (type == 2){
|
||||
pengflag = true;
|
||||
}
|
||||
if (type == 3 && weight ==3){
|
||||
//补
|
||||
bupai = true;
|
||||
}
|
||||
if (type == 3 && weight ==4){
|
||||
//杠
|
||||
minggang = true;
|
||||
}
|
||||
if (type == 5){
|
||||
penggang = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//如果吃,没有碰
|
||||
if (chiflag&&!pengflag){
|
||||
chiNoPeng(tipList,card,client);
|
||||
}
|
||||
|
||||
//如果有吃有碰
|
||||
if (chiflag&&pengflag&&!minggang&&!penggang){
|
||||
chiOrPeng(tipList,card,client);
|
||||
}
|
||||
|
||||
//没有吃,有碰
|
||||
if (!chiflag&&penggang&&!minggang&&!angang){
|
||||
pengNoChi(tipList,card,client);
|
||||
}
|
||||
|
||||
if (bupai&&!penggang&&!angang){
|
||||
//补
|
||||
|
||||
}
|
||||
|
||||
//杠
|
||||
if (minggang||bupai||penggang){
|
||||
gangNoChiPeng(tipList,card,client);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 处理吃 问题
|
||||
* @param tipList
|
||||
* @param client
|
||||
*/
|
||||
public int chiNoPeng(ITArray tipList,int card,TaurusClient client){
|
||||
ITObject params = TObject.newInstance();
|
||||
params.putString("session", session + "," + token);
|
||||
//判断是否能吃
|
||||
//1、吃之后能否下听
|
||||
List<Integer> shifoutingpai = TinHuChi.shifoutingpai(changShaCardInhand);
|
||||
if (shifoutingpai.size() == 0) {
|
||||
//没下听
|
||||
//如果吃了可以立马下听,则吃
|
||||
int chitingpaiid = changShaSuanFaTest.checkChiTingAction(card,changShaCardInhand);
|
||||
if (chitingpaiid>0){
|
||||
//处理吃后的数据
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", chitingpaiid-1);
|
||||
|
||||
//记录吃掉的牌
|
||||
List<List<Integer>> lists = new ArrayList<>();
|
||||
lists.addAll(TinHuChi.checkChi(changShaCardInhand, card));
|
||||
|
||||
List<Integer> integers = lists.get(chitingpaiid-1);
|
||||
List<Integer> result1 = getOtherCards1(integers, card);
|
||||
|
||||
chowGroup.add(card);
|
||||
chowGroup.add(result1.get(0));
|
||||
chowGroup.add(result1.get(1));
|
||||
changShaCardInhand.add(card);
|
||||
Util.removeCard(changShaCardInhand,result1.get(0),1);
|
||||
Util.removeCard(changShaCardInhand,result1.get(1),1);
|
||||
Util.removeCard(changShaCardInhand,card,1);
|
||||
|
||||
client.send("612", params, response -> {});
|
||||
return chitingpaiid;
|
||||
}
|
||||
//2、吃之后是否没了大胡
|
||||
//判断是否满足7对
|
||||
int pisCardsCount = changShaSuanFaTest.countPairs(changShaCardInhand);
|
||||
if (pisCardsCount>=4){
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", 0);
|
||||
}else{
|
||||
//判断是否可以执行 清一色操作
|
||||
boolean isChow = changShaSuanFaTest.checkAllSameSuitAll(card,changShaCardInhand,pongGroup,chowGroup,gangdepai);
|
||||
if (isChow){
|
||||
//判断是否可以吃
|
||||
//判断吃之后是否会破坏下听
|
||||
//3、吃之后是否破坏牌型
|
||||
int canchiId = changShaSuanFaTest.checkCanChiAction(card,changShaCardInhand);
|
||||
|
||||
if (canchiId>0){
|
||||
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", canchiId-1);
|
||||
|
||||
//记录吃掉的牌
|
||||
List<List<Integer>> lists = new ArrayList<>();
|
||||
lists.addAll(TinHuChi.checkChi(changShaCardInhand, card));
|
||||
|
||||
List<Integer> integers2 = lists.get(canchiId-1);
|
||||
List<Integer> result2 = getOtherCards1(integers2, card);
|
||||
|
||||
chowGroup.add(card);
|
||||
chowGroup.add(result2.get(0));
|
||||
chowGroup.add(result2.get(1));
|
||||
changShaCardInhand.add(card);
|
||||
Util.removeCard(changShaCardInhand,result2.get(0),1);
|
||||
Util.removeCard(changShaCardInhand,result2.get(1),1);
|
||||
Util.removeCard(changShaCardInhand,card,1);
|
||||
|
||||
client.send("612", params, response -> {});
|
||||
return chitingpaiid;
|
||||
|
||||
|
||||
}else{
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", 0);
|
||||
}
|
||||
|
||||
}else{
|
||||
//不可以吃
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", 0);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//不吃
|
||||
|
||||
//吃之后没有下听
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
client.send("612", params, response -> {});
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同时有吃有碰
|
||||
* @param tipList
|
||||
* @param client
|
||||
*/
|
||||
public void chiOrPeng(ITArray tipList,int card,TaurusClient client){
|
||||
ITObject params = TObject.newInstance();
|
||||
//判断碰和吃
|
||||
//判断牌型是否下听
|
||||
params.putString("session", session + "," + token);
|
||||
List<Integer> shifoutingpai = TinHuChi.shifoutingpai(changShaCardInhand);
|
||||
if (shifoutingpai.size() == 0) {
|
||||
|
||||
//1、先判断是否碰之后破坏听牌
|
||||
|
||||
|
||||
//2、如果能碰,则进入判断吃逻辑,对比吃、碰那个会更优
|
||||
|
||||
|
||||
//3、判断吃或者碰之后都会破坏听牌,不能吃和碰
|
||||
|
||||
}else{
|
||||
//有下听 先不做操作,后续判断换牌
|
||||
params.putInt("qi", 0);
|
||||
params.putInt("id", 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
client.send("612", params, response -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* 没吃,有碰
|
||||
* @param tipList
|
||||
* @param client
|
||||
*/
|
||||
public void pengNoChi(ITArray tipList,int card,TaurusClient client){
|
||||
ITObject params = TObject.newInstance();
|
||||
|
||||
client.send("612", params, response -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* 杠没有吃,没有碰
|
||||
* @param tipList
|
||||
* @param client
|
||||
*/
|
||||
public void gangNoChiPeng(ITArray tipList,int card,TaurusClient client){
|
||||
ITObject params = TObject.newInstance();
|
||||
|
||||
|
||||
|
||||
client.send("612", params, response -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理杠碰胡操作
|
||||
*
|
||||
* @param param 消息参数
|
||||
* @return
|
||||
*/
|
||||
public String actionCard(ITObject param, TaurusClient client) {
|
||||
// TinHuChi tinHuChi = new TinHuChi();
|
||||
public String actionCardbak(ITObject param, TaurusClient client) {
|
||||
TinHuPeng tinHuPeng = new TinHuPeng();
|
||||
|
||||
|
||||
//获取碰杠胡参数 type 和id 后续算法接入,是否能让碰和杠
|
||||
ITArray tipList = param.getTArray("tip_list");
|
||||
|
||||
int id = 0;
|
||||
int type = 0;
|
||||
int opcard = 0;
|
||||
|
|
@ -969,7 +1518,7 @@ public class HuNanChangSha {
|
|||
}
|
||||
|
||||
|
||||
// 红中麻将出牌
|
||||
// 长沙麻将出牌
|
||||
String changShaOutCard = changShaSuanFaTest.outCardSuanFa(changShaCardInhand, pongGroup, chowGroup, resultList);
|
||||
// String changShaOutCard = changShaSuanFaTest.outCardSuanFa(list, changShaCard,pongGroup);
|
||||
ITObject params = TObject.newInstance();
|
||||
|
|
@ -1047,5 +1596,66 @@ public class HuNanChangSha {
|
|||
return null;
|
||||
}
|
||||
|
||||
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);
|
||||
List<Integer> hands1 = new ArrayList<>();
|
||||
hands1.add(206);
|
||||
hands1.add(204);
|
||||
hands1.add(203);
|
||||
hands1.add(203);
|
||||
|
||||
hands1.add(203);
|
||||
hands1.add(107);
|
||||
hands1.add(107);
|
||||
|
||||
hands1.add(106);
|
||||
hands1.add(105);
|
||||
hands1.add(104);
|
||||
|
||||
hands1.add(103);
|
||||
hands1.add(102);
|
||||
hands1.add(101);
|
||||
|
||||
int card= 205;
|
||||
huNanChangSha.changShaCardInhand.addAll(hands1);
|
||||
TArray tiplist= new TArray();
|
||||
ITArray opcard = TArray.newInstance();
|
||||
opcard.addInt(204);
|
||||
opcard.addInt(203);
|
||||
TObject tob = new TObject();
|
||||
tob.putInt("weight",1);
|
||||
tob.putInt("id",1);
|
||||
tob.putInt("type",1);
|
||||
tob.putInt("card",card);
|
||||
tob.putTArray("opcard", opcard);
|
||||
tiplist.addTObject(tob);
|
||||
|
||||
ITArray opcard2 = TArray.newInstance();
|
||||
opcard2.addInt(204);
|
||||
opcard2.addInt(206);
|
||||
TObject tob2 = new TObject();
|
||||
tob2.putInt("weight",1);
|
||||
tob2.putInt("id",2);
|
||||
tob2.putInt("type",1);
|
||||
tob2.putInt("card",card);
|
||||
tob2.putTArray("opcard", opcard2);
|
||||
tiplist.addTObject(tob2);
|
||||
|
||||
params.putTArray("tip_list",tiplist);
|
||||
System.out.println(params);
|
||||
//已经吃掉数据
|
||||
// huNanChangSha.chowGroup.add(205);
|
||||
//huNanChangSha.chowGroup.add(204);
|
||||
// huNanChangSha.chowGroup.add(206);
|
||||
|
||||
//huNanChangSha.chowGroup.add(201);
|
||||
// huNanChangSha.chowGroup.add(202);
|
||||
// huNanChangSha.chowGroup.add(203);
|
||||
|
||||
huNanChangSha.actionCard(params,tc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
package hunan;
|
||||
|
||||
import com.game.Util;
|
||||
import com.taurus.core.entity.ITArray;
|
||||
import com.taurus.core.entity.ITObject;
|
||||
import com.taurus.core.entity.TObject;
|
||||
import com.taurus.core.plugin.database.DataBase;
|
||||
import com.taurus.core.util.Logger;
|
||||
import com.taurus.core.util.StringUtil;
|
||||
import taurus.client.Message;
|
||||
import taurus.client.TaurusClient;
|
||||
import taurus.util.*;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class HuNanChangShaNew {
|
||||
|
||||
private static final Logger log = Logger.getLogger(DoTest.class);
|
||||
//湖南红中麻将手牌
|
||||
private List<Integer> changShaCardInhand = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* 初始化手牌协议 811
|
||||
* @param command
|
||||
* @param message
|
||||
* @param client
|
||||
* @return
|
||||
*/
|
||||
public String cardInHead(String command, Message message, TaurusClient client) {
|
||||
if (command.equalsIgnoreCase("811")) {
|
||||
log.info("cardInhand changsha new");
|
||||
ITObject param = message.param;
|
||||
if (param == null) {
|
||||
return null;
|
||||
}
|
||||
// {bank_seat=1, laiziCard=0, laiziCard2=0, laiziCard2Before=0, jing=0, laiziCardBefore=0, card_list=[101, 103, 104, 201, 204, 207, 208, 209, 307, 309, 501, 502, 503]}
|
||||
ITArray cardList = param.getTArray("card_list");
|
||||
for (int i = 0; i < cardList.size(); i++) {
|
||||
changShaCardInhand.add(cardList.getInt(i));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void drawCard(String command, Message message,ITObject param) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -72,6 +72,9 @@ public class JiQiRens {
|
|||
|
||||
private HuNanChangSha huNanChangSha = new HuNanChangSha();
|
||||
|
||||
// private HuNanChangShaNew huNanChangShaNew = new HuNanChangShaNew();//新的机器人处理对象
|
||||
|
||||
|
||||
private TinHuChi tinHuChi = new TinHuChi();
|
||||
|
||||
|
||||
|
|
@ -352,13 +355,13 @@ public class JiQiRens {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
System.out.println(wanfaId);
|
||||
if ("22".equalsIgnoreCase(wanfaId)) { //湖南红中麻将
|
||||
client = new TaurusClient("8.138.242.190:6421", "game", TaurusClient.ConnectionProtocol.Tcp);
|
||||
}
|
||||
|
||||
if ("10".equalsIgnoreCase(wanfaId)) {
|
||||
client = new TaurusClient("8.138.242.190:6311", "game", TaurusClient.ConnectionProtocol.Tcp);
|
||||
client = new TaurusClient("127.0.0.1:6311", "game", TaurusClient.ConnectionProtocol.Tcp);
|
||||
}
|
||||
//
|
||||
if ("66".equalsIgnoreCase(wanfaId)) {
|
||||
|
|
@ -962,11 +965,14 @@ public class JiQiRens {
|
|||
}
|
||||
}
|
||||
} else if ("10".equalsIgnoreCase(wanfaId)) {
|
||||
//长沙麻将
|
||||
//长沙麻将 机器人处理事件
|
||||
|
||||
//[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);
|
||||
} 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");
|
||||
ITArray opchicards = param.getTArray("opchicards");
|
||||
ITArray oppengcards = param.getTArray("oppengcards");
|
||||
|
|
@ -1058,20 +1064,16 @@ public class JiQiRens {
|
|||
}
|
||||
}
|
||||
|
||||
System.out.println("playerOutcardsMap 99999999999999999999999999999999999999 " + playerOutcardsMap);
|
||||
System.out.println("playerchisMap 88888888888888888888888888 " + playerchisMap);
|
||||
System.out.println("playerpengsMap 7777777777777777777777777777 " + playerpengsMap);
|
||||
System.out.println("playermingsMap 6666666666666666 " + playermingsMap);
|
||||
System.out.println("playerzisMap 555555555555555555555 " + playerzisMap);
|
||||
|
||||
HuNanChangSha.drawCard(command, message);
|
||||
} else if ("819".equalsIgnoreCase(command)) {//摸牌
|
||||
} else if ("819".equalsIgnoreCase(command)) {
|
||||
//摸牌
|
||||
huNanChangSha.getCard(command, message);
|
||||
} else if ("813".equalsIgnoreCase(command)) {//出牌提示
|
||||
|
||||
huNanChangSha.outCard(client,playerOutcardsMap,playerchisMap,playerpengsMap,playermingsMap,playerzisMap);
|
||||
} else if ("814".equalsIgnoreCase(command)) {//放招提示
|
||||
} else if ("814".equalsIgnoreCase(command)) {
|
||||
//放招提示
|
||||
huNanChangSha.actionCard(param, client);
|
||||
|
||||
} else if ("2009".equalsIgnoreCase(command)) {
|
||||
Jedis jedis22 = Redis.use().getJedis();
|
||||
sleepTime(3000);
|
||||
|
|
@ -1214,6 +1216,7 @@ public class JiQiRens {
|
|||
//写定时器
|
||||
|
||||
} else if ("815".equalsIgnoreCase(command)) { //服务器通知客户端有玩家执行了操作
|
||||
//[TCP->815] data:{"playerid":101555,"card":104,"opcard":[105,103],"from_seat":2,"type":1,"opengang":false}
|
||||
huNanChangSha.shanchuchuguopai(param);
|
||||
} else if ("820".equalsIgnoreCase(command)) {//换牌提示
|
||||
huNanChangSha.changePlayer(command, message);
|
||||
|
|
@ -1258,8 +1261,11 @@ public class JiQiRens {
|
|||
});
|
||||
} else if ("822".equalsIgnoreCase(command)) {
|
||||
ITObject params = TObject.newInstance();
|
||||
params.putInt("qi", 0);
|
||||
//params.putInt("qi", 0);
|
||||
params.putInt("id", 1);
|
||||
//[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}]}
|
||||
|
||||
client.send("612", params, response -> {
|
||||
|
||||
});
|
||||
|
|
@ -1273,6 +1279,8 @@ public class JiQiRens {
|
|||
|
||||
}
|
||||
|
||||
|
||||
//END 长沙麻将
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1669,22 +1677,16 @@ public class JiQiRens {
|
|||
try {
|
||||
// 添加2秒延迟
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ITObject params = TObject.newInstance();
|
||||
params.putString("session", session + "," + token);
|
||||
|
||||
|
||||
|
||||
client.send("1002", params, response -> {
|
||||
|
||||
|
||||
|
||||
ITObject obj = response.messageData.param.getTObject("tableInfo");
|
||||
|
||||
|
||||
});
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -38,10 +38,10 @@ public class ChangshaWinSplitCard {
|
|||
counts[type][value] += 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
counts[type][value] += 2;
|
||||
} else {
|
||||
group = checkMelds(counts, (cardInHand.size() / 3) + 1, map);
|
||||
|
||||
if (group == 0) { // 剩余12张牌需要组成4个顺子或刻子
|
||||
counts[type][value] += 2;
|
||||
return 0;
|
||||
|
|
@ -49,7 +49,9 @@ public class ChangshaWinSplitCard {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Integer> cardResiue = (List<Integer>) map.get("cardResiue");
|
||||
|
||||
for (int i = 0; i < cardResiue.size() - 1; i++) {
|
||||
if (cardResiue.get(i).equals(cardResiue.get(i + 1)) && (cardResiue.get(i) % 100 == 2 || cardResiue.get(i) % 100 == 5 || cardResiue.get(i) % 100 == 8)) {
|
||||
cardResiue.remove(i);
|
||||
|
|
@ -57,12 +59,48 @@ public class ChangshaWinSplitCard {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
haveBetween(cardResiue, cardInHand);
|
||||
|
||||
System.out.println("可以打出的牌:" + cardResiue);
|
||||
System.out.println("总共差几手牌:" + map.get("remainingMelds"));
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
public static void haveBetween(List<Integer> cards, List<Integer> cardInHand) {
|
||||
if (cards.size() <= 1 || cardInHand.size() <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建要删除的牌列表
|
||||
Set<Integer> toRemove = new HashSet<>();
|
||||
|
||||
// 遍历手牌中的每一张牌
|
||||
for (int handCard : cardInHand) {
|
||||
// 检查cards中是否有与手牌形成靠章的牌
|
||||
for (int card : cards) {
|
||||
// 定义靠章规则:相同、相邻或隔一张
|
||||
int diff = Math.abs(card - handCard);
|
||||
if (diff == 1 || diff == 2) {
|
||||
toRemove.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 只有当cards中还有多于1张牌时才执行删除
|
||||
//if (toRemove.size()- cards.size() > 1){
|
||||
if(cards.size()-toRemove.size()>0){
|
||||
cards.removeAll(toRemove);
|
||||
}
|
||||
|
||||
// 可选:打印信息
|
||||
if (!toRemove.isEmpty()) {
|
||||
System.out.println("删除的牌: " + toRemove);
|
||||
System.out.println("cards剩余: " + cards);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 递归检查是否可以组成顺子或刻子
|
||||
public static int checkMelds(int[][] counts, int remainingMelds, Map<String, Object> map) {
|
||||
|
|
@ -113,21 +151,32 @@ public class ChangshaWinSplitCard {
|
|||
List<Integer> cardResiue = convertCountToCards(counts);
|
||||
|
||||
// System.out.println("只差几手牌" + remainingMelds + "," + cardResiue);
|
||||
|
||||
if (cardResiue.size()!=0) {
|
||||
//优先保留连续张
|
||||
removeConsecutivePairs1(cardResiue);
|
||||
}
|
||||
|
||||
if (cardResiue.size()!=0) {
|
||||
//第二优先保留对子
|
||||
removeConsecutivePairsTwo(cardResiue);
|
||||
}
|
||||
//最后保留坎张
|
||||
//如果坎张,为空则取边张
|
||||
if (cardResiue.size()!=0) {
|
||||
List<Integer> tmp3 = new ArrayList<>();
|
||||
tmp3.addAll(cardResiue);
|
||||
removeConsecutivePairs2(cardResiue);
|
||||
if (cardResiue.size() == 0) {
|
||||
//取边站
|
||||
cardResiue = qubianzhang(tmp3);
|
||||
}
|
||||
}
|
||||
|
||||
// System.out.println("孤章" + cardResiue.toString());
|
||||
if (remainingMelds == 0) {
|
||||
map.put("remainingMelds", 0);
|
||||
map.put("cardResiue", "已经胡牌");
|
||||
|
||||
}
|
||||
|
||||
if (map.get("remainingMelds") == null) {
|
||||
map.put("remainingMelds", remainingMelds);
|
||||
|
||||
|
|
@ -149,6 +198,11 @@ public class ChangshaWinSplitCard {
|
|||
// 如果没有258做将则需要进入这里判断
|
||||
if (remainingMelds == 1 && cardResiue.size() == 2) {
|
||||
for (int i = 0; i < cardResiue.size(); i++) {
|
||||
int diff = Math.abs(cardResiue.get(0) - cardResiue.get(1));
|
||||
if (diff>1) {
|
||||
map.put("remainingMelds", remainingMelds + 1);// 删除符合258做将的牌if (cardResiue.size() > 1) {cardResiue.remove(i);}map.put("cardResiue", cardResiue);
|
||||
|
||||
}else {
|
||||
if (cardResiue.get(i) % 100 == 2 || cardResiue.get(i) % 100 == 5 || cardResiue.get(i) % 100 == 8) {
|
||||
// 删除符合258做将的牌
|
||||
if (cardResiue.size() > 1) {
|
||||
|
|
@ -163,6 +217,7 @@ public class ChangshaWinSplitCard {
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (remainingMelds == 1) {
|
||||
map.put("remainingMelds", remainingMelds);
|
||||
|
|
@ -186,8 +241,8 @@ public class ChangshaWinSplitCard {
|
|||
int i = 0;
|
||||
|
||||
while (i < sorted.size()) {
|
||||
boolean isleft = sorted.get(i) % 100 == 1 || sorted.get(i) % 100 == 8;
|
||||
if (!isleft && i < sorted.size() - 1 && sorted.get(i + 1) - sorted.get(i) == 0) {
|
||||
// boolean isleft = sorted.get(i) % 100 == 1 || sorted.get(i) % 100 == 8;
|
||||
if (i < sorted.size() - 1 && sorted.get(i + 1) - sorted.get(i) == 0) {
|
||||
// 跳过对子
|
||||
i += 2;
|
||||
} else {
|
||||
|
|
@ -231,6 +286,16 @@ public class ChangshaWinSplitCard {
|
|||
cards.addAll(result);
|
||||
}
|
||||
|
||||
public static List<Integer> qubianzhang(List<Integer> cards) {
|
||||
List<Integer> result = new ArrayList<>();
|
||||
for (int i = 0; i < cards.size(); i++) {
|
||||
if (cards.get(i)%100 == 1||cards.get(i)%100 == 9) {
|
||||
result.add(cards.get(i));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void removeConsecutivePairs2(List<Integer> cards) {
|
||||
if (cards == null || cards.size() < 2) {
|
||||
return;
|
||||
|
|
@ -334,6 +399,31 @@ public class ChangshaWinSplitCard {
|
|||
return tpcards;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isJiangPai(int card){
|
||||
if (card%100==2||card%100==5||card%100==8){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int checkduijiang(List<Integer> cardInHand,Map<String,List<Integer>> map) {
|
||||
Map<Integer, Integer> countMap = new HashMap<>();
|
||||
for (Integer item : cardInHand) {
|
||||
countMap.put(item, countMap.getOrDefault(item, 0) + 1);
|
||||
}
|
||||
int jiangnum = 0;
|
||||
for (int key : countMap.keySet()) {
|
||||
if (isJiangPai(key)&&countMap.get(key)>=2){
|
||||
jiangnum++;
|
||||
List<Integer> tmpI = new ArrayList<>();
|
||||
tmpI.add(key);
|
||||
map.put("jiangcard", tmpI);
|
||||
}
|
||||
}
|
||||
return jiangnum;
|
||||
}
|
||||
|
||||
// 分析最优出牌
|
||||
public static List<Integer> analyzeBestDiscard(List<Integer> cardInHand) {
|
||||
|
||||
|
|
@ -342,6 +432,36 @@ public class ChangshaWinSplitCard {
|
|||
List<Integer> checktingpai = checktingpai(cardInHand);
|
||||
System.out.println("打出这种牌后可以听牌 " + checktingpai);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, List<Integer>> jmap = new HashMap<>();//对将map
|
||||
//先定将,再做分析
|
||||
/* int jiangnum = checkduijiang(cardInHand,jmap);
|
||||
System.out.println(jmap.get("jiangcard").get(0));
|
||||
if (jiangnum==1){
|
||||
//如果只有一对将
|
||||
//去将 后判断方案
|
||||
List<Integer> tmphc = new ArrayList<>();
|
||||
tmphc.addAll(cardInHand);
|
||||
Util.removeCard(tmphc,jmap.get("jiangcard").get(0),2);
|
||||
Map<String, Object> tmap = new HashMap<>();
|
||||
checkNormalHu(tmphc, tmap);
|
||||
|
||||
//不去将 判断
|
||||
|
||||
Map<String, Object> tmap2 = new HashMap<>();
|
||||
System.out.println(cardInHand);
|
||||
checkNormalHu(cardInHand, tmap2);
|
||||
System.out.println(tmap2);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}else if(jiangnum>1){
|
||||
|
||||
}else{
|
||||
|
||||
}*/
|
||||
|
||||
checkNormalHu(cardInHand, map);
|
||||
|
||||
List<Integer> suggested = (List<Integer>) map.get("cardResiue");
|
||||
|
|
@ -592,6 +712,7 @@ public class ChangshaWinSplitCard {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// 都没有,返回第一张
|
||||
return cards.get(0);
|
||||
}
|
||||
|
|
@ -667,7 +788,7 @@ public class ChangshaWinSplitCard {
|
|||
test1.add(204);
|
||||
test1.add(203);
|
||||
test1.add(202);
|
||||
test1.add(202);
|
||||
test1.add(209);
|
||||
test1.add(201);
|
||||
test1.add(108);
|
||||
test1.add(107);
|
||||
|
|
@ -676,7 +797,7 @@ public class ChangshaWinSplitCard {
|
|||
test1.add(104);
|
||||
|
||||
test1.add(103);
|
||||
test1.add(103);
|
||||
test1.add(102);
|
||||
test1.add(101);
|
||||
// test1.add(103);
|
||||
// test1.add(102);
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.6.1" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" />
|
||||
<orderEntry type="module" module-name="taurus-core" />
|
||||
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.6.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.undertow:undertow-core:2.0.16.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.xnio:xnio-api:3.3.8.Final" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.jboss.xnio:xnio-nio:3.3.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -1,14 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<component name="AdditionalModuleElements">
|
||||
<content url="file://$MODULE_DIR$" dumb="true">
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" />
|
||||
<orderEntry type="module" module-name="taurus-core" />
|
||||
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.6.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.eclipse.jetty:jetty-webapp:8.2.0.v20160908" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.eclipse.jetty:jetty-xml:8.2.0.v20160908" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.eclipse.jetty:jetty-util:8.2.0.v20160908" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.eclipse.jetty:jetty-servlet:8.2.0.v20160908" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.eclipse.jetty:jetty-security:8.2.0.v20160908" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.eclipse.jetty:jetty-server:8.2.0.v20160908" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.eclipse.jetty:jetty-continuation:8.2.0.v20160908" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.eclipse.jetty:jetty-http:8.2.0.v20160908" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.eclipse.jetty:jetty-io:8.2.0.v20160908" level="project" />
|
||||
<orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
Loading…
Reference in New Issue