diff --git a/game_web/web_group/target/ROOT.war b/game_web/web_group/target/ROOT.war index 431f31c..5c80fd0 100644 Binary files a/game_web/web_group/target/ROOT.war and b/game_web/web_group/target/ROOT.war differ diff --git a/game_web/web_group/target/ROOT/WEB-INF/lib/robot_common-1.0.1.jar b/game_web/web_group/target/ROOT/WEB-INF/lib/robot_common-1.0.1.jar index a8db78e..1fdd143 100644 Binary files a/game_web/web_group/target/ROOT/WEB-INF/lib/robot_common-1.0.1.jar and b/game_web/web_group/target/ROOT/WEB-INF/lib/robot_common-1.0.1.jar differ diff --git a/libs/robot_common/src/main/java/hunan/HuNanChangSha.java b/libs/robot_common/src/main/java/hunan/HuNanChangSha.java index 4157287..7499d26 100644 --- a/libs/robot_common/src/main/java/hunan/HuNanChangSha.java +++ b/libs/robot_common/src/main/java/hunan/HuNanChangSha.java @@ -283,7 +283,7 @@ public class HuNanChangSha { List yupanhandcard = new ArrayList<>(); yupanhandcard.addAll(changShaCardInhand); //进行操作之前能否下听 - List shifoutingpai = changShaSuanFaTest.handscardshifoutingpai(changShaCardInhand); + List shifoutingpai = changShaSuanFaTest.handscardshifoutingpai(changShaCardInhand,chowGroup,pongGroup,gangdepai); boolean beforelisten = false;//记录操作之前的下听状态 if (shifoutingpai.size() > 0) { beforelisten = true; @@ -301,9 +301,12 @@ public class HuNanChangSha { //判断开杠后是否能下听 List gangusecars = new ArrayList<>(); gangusecars.addAll(changShaCardInhand); + if (type == 3) { Util.removeCard(gangusecars,card,3); - List shifoutingpai3 = changShaSuanFaTest.handscardshifoutingpai(gangusecars); + List shifoutingpai3 = changShaSuanFaTest.handscardshifoutingpai(gangusecars,chowGroup,pongGroup,gangdepai); + System.out.println(shifoutingpai3); + if (shifoutingpai3.size() > 0) { //开杠 Util.removeCard(changShaCardInhand,card,3); @@ -326,7 +329,7 @@ public class HuNanChangSha { if (type == 4) { // Util.removeCard(changShaCardInhand,card,4); Util.removeCard(gangusecars,card,4); - List shifoutingpai4 = changShaSuanFaTest.handscardshifoutingpai(gangusecars); + List shifoutingpai4 = changShaSuanFaTest.handscardshifoutingpai(gangusecars,chowGroup,pongGroup,gangdepai); if (shifoutingpai4.size() > 0) { //开杠 Util.removeCard(changShaCardInhand,card,4); @@ -349,7 +352,7 @@ public class HuNanChangSha { //Util.removeCard(changShaCardInhand,card,1); Util.removeCard(gangusecars,card,1); - List shifoutingpai5 = changShaSuanFaTest.handscardshifoutingpai(gangusecars); + List shifoutingpai5 = changShaSuanFaTest.handscardshifoutingpai(gangusecars,chowGroup,pongGroup,gangdepai); if (shifoutingpai5.size() > 0) { //开杠 Util.removeCard(changShaCardInhand,card,1); @@ -413,7 +416,7 @@ public class HuNanChangSha { switch (type) { case 1: //吃 - tmp = changShaSuanFaTest.pingguChi( beforelisten,card,opcard,yupanhandcard,beforeIsDahu,allSeeCard,chowGroup,changShachuguopai); + tmp = changShaSuanFaTest.pingguChi( beforelisten,card,opcard,yupanhandcard,beforeIsDahu,allSeeCard,chowGroup,pongGroup,gangdepai,changShachuguopai); break; case 2: //碰 @@ -1519,7 +1522,7 @@ public class HuNanChangSha { // 长沙麻将出牌 - String changShaOutCard = changShaSuanFaTest.outCardSuanFa(changShaCardInhand, pongGroup, chowGroup, resultList); + String changShaOutCard = changShaSuanFaTest.outCardSuanFa(changShaCardInhand, pongGroup, chowGroup,gangdepai, resultList); // String changShaOutCard = changShaSuanFaTest.outCardSuanFa(list, changShaCard,pongGroup); ITObject params = TObject.newInstance(); int cardToOut; @@ -1601,44 +1604,44 @@ public class HuNanChangSha { ITObject params = TObject.newInstance(); TaurusClient tc = new TaurusClient("127.0.0.1","10", TaurusClient.ConnectionProtocol.Tcp); List hands1 = new ArrayList<>(); - hands1.add(206); - hands1.add(204); - hands1.add(203); - hands1.add(203); + hands1.add(207); + hands1.add(207); + hands1.add(202); + hands1.add(202); - hands1.add(203); - hands1.add(107); - hands1.add(107); + hands1.add(202); + hands1.add(109); + hands1.add(109); - hands1.add(106); - hands1.add(105); + hands1.add(109); + hands1.add(102); hands1.add(104); - hands1.add(103); + hands1.add(104); + hands1.add(102); hands1.add(102); - hands1.add(101); - int card= 205; + int card= 109; huNanChangSha.changShaCardInhand.addAll(hands1); TArray tiplist= new TArray(); ITArray opcard = TArray.newInstance(); - opcard.addInt(204); - opcard.addInt(203); + opcard.addInt(109); + // opcard.addInt(203); TObject tob = new TObject(); tob.putInt("weight",1); tob.putInt("id",1); - tob.putInt("type",1); + tob.putInt("type",2); tob.putInt("card",card); tob.putTArray("opcard", opcard); tiplist.addTObject(tob); ITArray opcard2 = TArray.newInstance(); - opcard2.addInt(204); - opcard2.addInt(206); + opcard2.addInt(109); + // opcard2.addInt(206); TObject tob2 = new TObject(); - tob2.putInt("weight",1); + tob2.putInt("weight",4); tob2.putInt("id",2); - tob2.putInt("type",1); + tob2.putInt("type",3); tob2.putInt("card",card); tob2.putTArray("opcard", opcard2); tiplist.addTObject(tob2); @@ -1654,7 +1657,8 @@ public class HuNanChangSha { // huNanChangSha.chowGroup.add(202); // huNanChangSha.chowGroup.add(203); - huNanChangSha.actionCard(params,tc); + String res = huNanChangSha.actionCard(params,tc); + System.out.println(res); } diff --git a/libs/robot_common/src/main/java/taurus/util/ChangShaSuanFaTest.java b/libs/robot_common/src/main/java/taurus/util/ChangShaSuanFaTest.java index c01bd3f..b665b1c 100644 --- a/libs/robot_common/src/main/java/taurus/util/ChangShaSuanFaTest.java +++ b/libs/robot_common/src/main/java/taurus/util/ChangShaSuanFaTest.java @@ -51,11 +51,87 @@ public class ChangShaSuanFaTest { log = Logger.getLogger(ChangShaSuanFaTest.class); } + + + public String teshuXuanPai(List cardInhand, List pengCard, List chowGroup,List gangdepai){ + String outcard = ""; + //特殊牌型处理 + //判断是否6对,是否快满足清一色 + //判断清一色 + //查询吃碰杠是否是同一色 + List checkcpg = new ArrayList<>(); + checkcpg.addAll(pengCard); + checkcpg.addAll(chowGroup); + checkcpg.addAll(gangdepai); + + boolean qys = false; + if (checkcpg.size()>0){ + int tmp1 = 0; + int tmp2 = 0; + for (int i=0;i10){ + //落地已经有了不同色,所以可以进行 + qys = true; + } + } + Map> cardst2 = new HashMap<>(); + collectionCardse(cardInhand,cardst2); + //检测手牌 + if (qys){ + //检测同色牌有多少张 + for (Map.Entry> entry : cardst2.entrySet()) { + if (entry.getValue().size()==1){ + //如果只有一张同色,那就打这一张 + return entry.getValue().get(0).toString(); + } + } + } + }else{ + //检测手牌 + if (cardInhand.size()==14){ + //检测同色牌有多少张 + Map> cardst = new HashMap<>(); + collectionCardse(cardInhand,cardst); + for (Map.Entry> entry : cardst.entrySet()) { + if (entry.getValue().size()==1){ + //如果只有一张同色,那就打这一张 + return entry.getValue().get(0).toString(); + } + } + } + } + return null; + } + + public void collectionCardse(List cardInhand,Map>cardst){ + Map> se = new HashMap<>(); + int wanzi = 0; + int tongzi = 0; + List wanzicards = new ArrayList<>(); + List tongzicards = new ArrayList<>(); + for (int i=0;i 听牌检测 -> 策略制定 -> 出牌选择 */ - public String outCardSuanFa(List cardInhand, List pengCard, List chowGroup, List resultList) { + public String outCardSuanFa(List cardInhand, List pengCard, List chowGroup,List gangdepai, List resultList) { List handCards = new ArrayList<>(cardInhand); List pinghuhandCards = new ArrayList<>(cardInhand); @@ -77,8 +153,16 @@ public class ChangShaSuanFaTest { System.out.println("resultList +++++++++++++++++++++++================" + resultList); + //特殊牌型处理 + String tscard = teshuXuanPai(cardInhand, pengCard, chowGroup, gangdepai); + if (tscard!=null){ + return tscard; + } + + //循环去一张还能听多牌 Map> afterOp = quyizhangTingPai(cardInhand); + System.out.println(afterOp); if (afterOp.size()>0){ //执行 int xuanzecard = 0; @@ -95,7 +179,7 @@ public class ChangShaSuanFaTest { xuanzecard = entry.getKey(); } } - + // return String.valueOf(xuanzecard); } @@ -324,6 +408,7 @@ public class ChangShaSuanFaTest { // 调用清一色特定出牌策略 int outcard = selectCardToDiscardForAllSameSuit(handCards, chowGroup, pengCard); if (outcard != -1) { + return String.valueOf(outcard); } } @@ -4056,7 +4141,7 @@ public class ChangShaSuanFaTest { Map map2 = new HashMap<>(); System.out.println(checkCards); Map> xiatingList = new HashMap<>(); - map2 = quyizhangChayou(checkCards,xiatingList); + map2 = quyizhangChayou(checkCards,chowGroup,pengGrop,gangGrop,xiatingList); System.out.println("map2:"+map2); System.out.println("xiatingList:"+xiatingList); //比对 @@ -4071,7 +4156,7 @@ public class ChangShaSuanFaTest { //听多张问题: - List caozuoqian = handscardshifoutingpai(yupanhandcard); + List caozuoqian = handscardshifoutingpai(yupanhandcard,chowGroup,pengGrop,gangGrop); int caozuoqiannum = 0;//操作之前听牌张数 List allpai = new ArrayList<>(); allpai.addAll(yupanhandcard); @@ -4166,7 +4251,7 @@ public class ChangShaSuanFaTest { * int card tiplist card * int type tiplist type */ - public static ITObject pingguChi(boolean beforelisten, int card, ITArray opcard, List yupanhandcard, int beforeIsDahu, List allSeeCard ,ListchowGroup,ListchangShachuguopai){ + public static ITObject pingguChi(boolean beforelisten, int card, ITArray opcard, List yupanhandcard, int beforeIsDahu, List allSeeCard ,ListchowGroup,ListpengGrop,ListgangGrop,ListchangShachuguopai){ ITObject chiob = new TObject(); chiob.putBoolean("isTing",beforelisten); chiob.putInt("isDaHu",beforeIsDahu); @@ -4243,7 +4328,7 @@ public class ChangShaSuanFaTest { Map map2 = new HashMap<>(); System.out.println(checkCards); Map> xiatingList = new HashMap<>(); - map2 = quyizhangChayou(checkCards,xiatingList); + map2 = quyizhangChayou(checkCards,chowGroup,pengGrop,gangGrop,xiatingList); System.out.println("map2:"+map2); System.out.println("xiatingList:"+xiatingList); //比对 @@ -4257,7 +4342,8 @@ public class ChangShaSuanFaTest { } //听多张问题: - List caozuoqian = handscardshifoutingpai(yupanhandcard); + List caozuoqian = handscardshifoutingpai(yupanhandcard,chowGroup,pengGrop,gangGrop); + int caozuoqiannum = 0;//操作之前听牌张数 List allpai = new ArrayList<>(); allpai.addAll(yupanhandcard); @@ -4302,7 +4388,7 @@ public class ChangShaSuanFaTest { * @param cardhand * @return */ - public static List handscardshifoutingpai(List cardhand) { + public static List handscardshifoutingpai(List cardhand,ListchowGroup,List pongGroup,List gangdepai) { List tpcards = new ArrayList<>(); List tmphc = cardhand; for (int j = 101; j <= 109; j++) { @@ -4312,15 +4398,30 @@ public class ChangShaSuanFaTest { tpcards.add(j); } } + Paixing px = new Paixing(); + if(px.tingCheck(cardhand,chowGroup,pongGroup,gangdepai)){ + if (!tpcards.contains(j)) { + tpcards.add(j); + } + } } for (int k = 201; k<= 209; k++) { WinCard win = new WinCard(tmphc, k); + Paixing px = new Paixing(); if (win.tryWin()) { if (!tpcards.contains(k)) { tpcards.add(k); } } + if(px.tingCheck(cardhand,chowGroup,pongGroup,gangdepai)){ + if (!tpcards.contains(k)) { + tpcards.add(k); + } + } } + //如果没有则检测大胡 + + return tpcards; } @@ -4360,7 +4461,7 @@ public class ChangShaSuanFaTest { return quxiatingmap; } - public static Map quyizhangChayou(List cardhand,Map> xiatingList) { + public static Map quyizhangChayou(List cardhand,ListchowGroup,List pongGroup,List gangdepai,Map> xiatingList) { Map map = new HashMap<>(); Map> bigMap = new HashMap<>(); @@ -4375,7 +4476,7 @@ public class ChangShaSuanFaTest { //检查是否能下听 List tmxt = new ArrayList<>(); - tmxt =handscardshifoutingpai(tmphc); + tmxt =handscardshifoutingpai(tmphc,chowGroup,pongGroup,gangdepai); if (tmxt.size()>0){ xiatingList.put(tmpcard,tmxt); } @@ -4427,22 +4528,22 @@ public class ChangShaSuanFaTest { // 测试用例:没有258将牌的情况 List test1 = new ArrayList(); - test1.add(207); - test1.add(207); - test1.add(207); - test1.add(206); - - test1.add(205); - test1.add(203); - test1.add(202); - test1.add(109); test1.add(109); test1.add(108); + test1.add(107); + + test1.add(107); + test1.add(107); + test1.add(104); test1.add(102); - test1.add(107); test1.add(103); + test1.add(102); + + test1.add(102); + test1.add(101); + test1.add(101); int lg = countPairs(test1); System.out.println(lg); @@ -4452,7 +4553,8 @@ public class ChangShaSuanFaTest { //测试吃: List allcard = new ArrayList<>(); - + allcard.add(208); + allcard.add(208); /*ITArray opcard = TArray.newInstance(); opcard.addInt(209); opcard.addInt(208);*/ @@ -4466,21 +4568,26 @@ public class ChangShaSuanFaTest { ListchangShachuguopai = new ArrayList<>(); //changShachuguopai.add(101); // changShachuguopai.add(207); + List gangguopai = new ArrayList<>(); + //gangguopai.add(206); + // gangguopai.add(206); + //gangguopai.add(206); + //gangguopai.add(206); - + int card = 105; ListpengCard = new ArrayList<>(); // pengCard.add(102); //出牌求优 - /* ChangShaSuanFaTest ct = new ChangShaSuanFaTest(); + ChangShaSuanFaTest ct = new ChangShaSuanFaTest(); test1.add(card); - String outcard = ct.outCardSuanFa(test1,pengCard,chipai,changShachuguopai); + String outcard = ct.outCardSuanFa(test1,pengCard,chipai,gangguopai,changShachuguopai); - System.out.println("outcard:"+outcard);*/ + System.out.println("outcard:"+outcard); // pingguChi(false,card,opcard,test1,0,allcard,chipai,changShachuguopai); //测试碰 - int card = 109; + /* int card = 109; ITArray opcardpeng = TArray.newInstance(); opcardpeng.addInt(109); diff --git a/libs/robot_common/src/main/java/taurus/util/Paixing.java b/libs/robot_common/src/main/java/taurus/util/Paixing.java new file mode 100644 index 0000000..3b523b0 --- /dev/null +++ b/libs/robot_common/src/main/java/taurus/util/Paixing.java @@ -0,0 +1,288 @@ +package taurus.util; + +import java.util.*; +import java.util.Map.Entry; + +import com.game.Util; +import com.taurus.core.entity.ITArray; +import com.taurus.core.entity.ITObject; +import com.taurus.core.entity.TArray; + + + + +public class Paixing { + + private final static boolean qs_yijihua_check(Map cardMap,int se,int index) { + Integer num = cardMap.get(se+index); + if(num!=null&&num==1) { + for(int i=1;i<=9;++i) { + if(i !=index) { + if(cardMap.containsKey(se+i)){ + return false; + } + } + } + return true; + } + return false; + } + + + + + + public static void main(String[] args) { + List cardInhand = new java.util.ArrayList<>(); + List opCards = new java.util.ArrayList<>(); + //opCards.add(new OpCard(RuleWeight.TYPE_PONG, 109)); + //opCards.add(new OpCard(RuleWeight.TYPE_PONG, 209)); + cardInhand.add(207); + cardInhand.add(207); + cardInhand.add(202); + cardInhand.add(202); + cardInhand.add(202); + cardInhand.add(109); + + cardInhand.add(109); + cardInhand.add(109); + cardInhand.add(104); + cardInhand.add(104); + cardInhand.add(102); + cardInhand.add(102); + + cardInhand.add(102); + + //System.out.println(tingKongCheck( opCards,cardInhand,109,false)); + } + + private final static boolean quanqiuren(List opCards,List cardInhand, int drawCard) { + if (cardInhand.size() > 1) { + return false; + } + if(drawCard == 0)return true; + if (cardInhand.get(0) != drawCard) + return false; + return true; + } + + private final static boolean qingyise(List opCards, List cardInhand, int drawCard) { + int se = cardInhand.get(0) / 100; + if (drawCard!=0&&drawCard / 100 != se) + return false; + for (Integer card : opCards) { + if (se != card / 100) { + return false; + } + } + for (int card : cardInhand) { + if (se != card / 100) { + return false; + } + } + return true; + } + + private final static boolean pongpong(List opCards, List cardInhand, int drawCard,boolean quanqiuren) { + int card1count=0,card2count=0; + Map cardMap =Util.getCardNumMap(cardInhand); + for (Entry entry : cardMap.entrySet()) { + int card = entry.getKey(); + int num = entry.getValue(); + if(num == 4) return false; + switch(num) { + case 1: + if(card1count>=1)return false; + if(drawCard!=0&&card != drawCard)return false; + card1count++; + break; + case 2: + if(card2count >=2)return false; + card2count ++; + break; + } + } + if(card1count>0&&card2count>0)return false; + if(card1count>0&&drawCard!=0&&!cardMap.containsKey(drawCard))return false; + if(card2count == 2&&drawCard!=0) { + if(!cardMap.containsKey(drawCard))return false; + if(cardMap.get(drawCard)!=2)return false; + } + return true; + } + + private final static boolean jiangjiang(List opCards, List cardInhand, int drawCard) { + if(drawCard!=0){ + if (drawCard % 100 != 2 && drawCard % 100 != 5 && drawCard % 100 != 8) { + return false; + } + } + for (Integer card : opCards) { + if (card % 100 != 2 && card % 100 != 5 && card % 100 != 8) { + return false; + } + } + for (int card : cardInhand) { + if (card % 100 != 2 && card % 100 != 5 && card % 100 != 8) { + return false; + } + + } + return true; + } + + private final static int qixiaodui(List opCards, List cardInhand, int drawCard) { + if (cardInhand.size() != 13) { + return -1; + } + List cardlist = cardInhand; + int pair = 0; + int card4count=0; + Map cardMap =Util.getCardNumMap(cardlist); + for (Entry entry : cardMap.entrySet()) { + int num = entry.getValue(); + int card = entry.getKey(); + if (num == 4) { + pair +=2; + card4count ++; + }else if(num >=2) { + if(num==3&&drawCard!=0&&drawCard != card) { + return -1; + } + pair +=1; + }else if(num ==1) { + if(drawCard!=0&&drawCard != card) { + return -1; + } + } + } + if(pair<6) return -1; + if(drawCard ==0)return card4count+1; + if(!cardMap.containsKey(drawCard)) return -1; + if(cardMap.get(drawCard) == 3) { + card4count++; + } + return card4count+1; + } + + public final static WinCardType putWinCardType(Map map, int type, int value,int score) { + if (map == null) + return null; + if (map.containsKey(type)) { + WinCardType wct = map.get(type); + wct.value += value; + return wct; + } else { + WinCardType wct = new WinCardType(type, value,score); + map.put(type, wct); + return wct; + } + } + + public static boolean checkWin(Map map, List opCards, List cardInhand,int drawCard, int difen) { + return checkWin(map,opCards,cardInhand,drawCard,true, difen); + } + + public static boolean checkWin(Map map, List opCards, List cardInhand,int drawCard,boolean jiang, int difen) { + int qixiaodui = qixiaodui(opCards,cardInhand, drawCard); + if (qixiaodui != -1) { + putWinCardType(map, WinCardType.QIXIAODUI, qixiaodui,WinCardType.WIN_TYPE_SCORE); + if (qingyise(opCards,cardInhand, drawCard)) { + putWinCardType(map, WinCardType.QINGYISE, 1,WinCardType.WIN_TYPE_SCORE); + } + if (jiangjiang(opCards,cardInhand, drawCard)) { + putWinCardType(map, WinCardType.JIANGJIANGHU, 1,WinCardType.WIN_TYPE_SCORE); + } + return true; + } + if (jiangjiang(opCards,cardInhand, drawCard)) { + putWinCardType(map, WinCardType.JIANGJIANGHU, 1,WinCardType.WIN_TYPE_SCORE); + boolean _qqr =quanqiuren(opCards,cardInhand, drawCard); + if (_qqr) { + putWinCardType(map, WinCardType.QUANQIUREN, 1,WinCardType.WIN_TYPE_SCORE); + } + if (pongpong(opCards,cardInhand, drawCard,_qqr)) { + putWinCardType(map, WinCardType.PENGPENGHU, 1,WinCardType.WIN_TYPE_SCORE); + } + return true; + } + if (quanqiuren(opCards,cardInhand, drawCard)) { + putWinCardType(map, WinCardType.QUANQIUREN, 1,WinCardType.WIN_TYPE_SCORE); + if (qingyise(opCards,cardInhand, drawCard)) { + putWinCardType(map, WinCardType.QINGYISE, 1,WinCardType.WIN_TYPE_SCORE); + } + if (jiangjiang(opCards,cardInhand, drawCard)) { + putWinCardType(map, WinCardType.JIANGJIANGHU, 1,WinCardType.WIN_TYPE_SCORE); + } + if (pongpong(opCards,cardInhand, drawCard,true)) { + putWinCardType(map, WinCardType.PENGPENGHU, 1,WinCardType.WIN_TYPE_SCORE); + } + return true; + } + if (pongpong(opCards,cardInhand, drawCard,false)) { + putWinCardType(map, WinCardType.PENGPENGHU, 1,WinCardType.WIN_TYPE_SCORE); + if (qingyise(opCards,cardInhand, drawCard)) { + putWinCardType(map, WinCardType.QINGYISE, 1,WinCardType.WIN_TYPE_SCORE); + } + return true; + } + if (qingyise(opCards,cardInhand, drawCard)) { + WinCard win = new WinCard(cardInhand, drawCard); + win.jiang = false; + if (win.tryWin()) { + putWinCardType(map, WinCardType.QINGYISE, 1,WinCardType.WIN_TYPE_SCORE); + return true; + } + } else { + WinCard win = new WinCard(cardInhand, drawCard); + win.jiang = jiang; + if (win.tryWin()) { + putWinCardType(map, WinCardType.XIAOHU, 1, difen); + return true; + } + } + return false; + } + + static public boolean tingCheck(List cardInhand,List chowGrop,List pengGroup,List gangdepai) { + List listadd = new ArrayList<>(); + listadd.addAll(chowGrop); + listadd.addAll(pengGroup); + listadd.addAll(gangdepai); + + if(qixiaodui(listadd,cardInhand, 0)!=-1)return true; + + if (quanqiuren(chowGrop,cardInhand, 0))return true; + + if (chowGrop.size()==0){ + if (jiangjiang(pengGroup,cardInhand, 0))return true; + } + if (chowGrop.size()==0){ + if (pongpong(pengGroup,cardInhand, 0,false))return true; + } + + if (qingyise(listadd,cardInhand, 0)) { + WinCard win = new WinCard(cardInhand, 0); + win.jiang = false; + return win.tryWin(); + } + WinCard win = new WinCard(cardInhand, 0); + return win.tryWin(); + } + + + static public boolean tingKongCheck(List opCards,List cardInhand,int kongCard,boolean jiang) { + if (quanqiuren(opCards,cardInhand, 0))return true; + if (jiangjiang(opCards,cardInhand, kongCard))return true; + if (pongpong(opCards,cardInhand, 0,false))return true; + if (qingyise(opCards,cardInhand, kongCard)) { + WinCard win = new WinCard(cardInhand, 0); + win.jiang = false; + return win.tryWin(); + } + WinCard win = new WinCard(cardInhand, 0); + win.jiang = jiang; + return win.tryWin(); + } + +} diff --git a/libs/robot_common/src/main/java/taurus/util/WinCard.java b/libs/robot_common/src/main/java/taurus/util/WinCard.java index 2a85bc8..0f6eb71 100644 --- a/libs/robot_common/src/main/java/taurus/util/WinCard.java +++ b/libs/robot_common/src/main/java/taurus/util/WinCard.java @@ -1,9 +1,15 @@ package taurus.util; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Stack; + import com.game.Util; -import java.util.*; public class WinCard { public int pair_count; @@ -143,7 +149,7 @@ public class WinCard { if (this.zhong_count < 1) { return false; } - + Util.removeCard(cardList, card, 1); List cardGroup = new ArrayList(); cardGroup.add(card); @@ -228,39 +234,40 @@ public class WinCard { long time = System.currentTimeMillis(); // for (int i = 0; i < 1000000; ++i) { - ArrayList cardInhand = new ArrayList(); - cardInhand.add(102); - cardInhand.add(102); - cardInhand.add(204); - cardInhand.add(204); - cardInhand.add(206); - cardInhand.add(206); + ArrayList cardInhand = new ArrayList(); + cardInhand.add(207); + cardInhand.add(207); + cardInhand.add(202); + cardInhand.add(202); + cardInhand.add(202); + cardInhand.add(109); - cardInhand.add(305); - cardInhand.add(305); - cardInhand.add(305); - cardInhand.add(306); - cardInhand.add(306); - cardInhand.add(307); + cardInhand.add(109); + cardInhand.add(109); + cardInhand.add(104); + cardInhand.add(104); + cardInhand.add(102); + cardInhand.add(102); - cardInhand.add(307); + cardInhand.add(102); // cardInhand.add(301); // cardInhand.add(301); // cardInhand.add(108); - + // cardInhand.contains(204); // Util.checkCard(204, cardInhand); // CardUtil.checkCardAndRomve(204, cardInhand, 2); - + // if(Util.checkCard(204, cardInhand)) { // CardUtil.removeCard(cardInhand, 204, 2); // } - WinCard win = new WinCard(cardInhand, 0); - win.tryWin(); + WinCard win = new WinCard(cardInhand, 104); + boolean c = win.tryWin(); + System.out.println(c); // Paixing.tingKongCheck(new ArrayList<>(), cardInhand, 301); // } - //Map map = new HashMap(); - //Paixing.checkWin(map, new ArrayList<>(), cardInhand, 305, room.difen_score); + //Map map = new HashMap(); + //Paixing.checkWin(map, new ArrayList<>(), cardInhand, 305, room.difen_score); System.out.println(System.currentTimeMillis() - time); diff --git a/libs/robot_common/src/main/java/taurus/util/WinCardType.java b/libs/robot_common/src/main/java/taurus/util/WinCardType.java new file mode 100644 index 0000000..1f79ec6 --- /dev/null +++ b/libs/robot_common/src/main/java/taurus/util/WinCardType.java @@ -0,0 +1,87 @@ +package taurus.util; + +import com.taurus.core.entity.ITArray; +import com.taurus.core.entity.ITObject; +import com.taurus.core.entity.TObject; + +public class WinCardType { + + public static final int QIXIAODUI = 1; //七小对多少分? + + public static final int JIANGJIANGHU = 2; //将将胡多少分? + + public static final int QINGYISE = 3; //清一色多少分? + + public static final int PENGPENGHU = 4; //碰碰胡多少分? + + public static final int GANGSHANGHUA = 5; //杠上花多少分? + + public static final int GANGSHANGPAO = 6; //杠上炮多少分? + + public static final int QUANQIUREN = 7; //全求人多少分? + + public static final int HAIDI = 8; //海底多少分? + + public static final int HAIDIPAO = 9; //海底炮多少分? + + public static final int QIANG_GANG_HU =10; //抢杠胡? + + public static final int XIAOHU = 11; + + public final static int TYPE_TIANHU = 12; + + public final static int TYPE_TIANTINGHU = 13; + + public final static int TYPE_MENQING = 14; + + public final static int TYPE_LIULIUSHUN = 21; + + public final static int TYPE_DASIXI = 22; + + public final static int TYPE_QUEYISE = 23; + + public final static int TYPE_BANBANHU = 24; + + public final static int TYPE_JIEJIEGAO = 25; + + public final static int TYPE_SANTONG = 26; + + + public final static int TYPE_YIZHIHUA = 27; + + public final static int WIN_TYPE_SCORE = 7; + public final static int WIN_PING_TYPE_SCORE = 3; + + public int type; + + public int value; + + public int score; + + public ITArray opcard; + + public WinCardType(int type, int value, int score) { + this.type = type; + this.value = value; + this.score = score; + } + + public ITObject toTObject() { + return toTObject(false); + } + + public ITObject toTObject(boolean is_opcard) { + ITObject obj = TObject.newInstance(); + obj.putInt("type", type); + obj.putInt("value", value); + if(is_opcard&&opcard!=null) { + obj.putTArray("opcard", opcard); + } + return obj; + } + + public String toString() { + return "type:" + type + " value:" + value; + + } +} diff --git a/majiang/changsha/game_mj_cs/src/main/java/extend/mj/uitl/Paixing.java b/majiang/changsha/game_mj_cs/src/main/java/extend/mj/uitl/Paixing.java index cb3a1c6..ac5678c 100644 --- a/majiang/changsha/game_mj_cs/src/main/java/extend/mj/uitl/Paixing.java +++ b/majiang/changsha/game_mj_cs/src/main/java/extend/mj/uitl/Paixing.java @@ -193,18 +193,27 @@ public class Paixing { } public static void main(String[] args) { -// List cardInhand = new java.util.ArrayList<>(); -// List opCards = new java.util.ArrayList<>(); -// opCards.add(new OpCard(RuleWeight.TYPE_PONG, 109)); -// opCards.add(new OpCard(RuleWeight.TYPE_PONG, 209)); -// cardInhand.add(106); -// cardInhand.add(106); -// cardInhand.add(107); -// cardInhand.add(108); -//// cardInhand.add(109); -// -// -// System.out.println(tingKongCheck(opCards,cardInhand, 109)); + List cardInhand = new java.util.ArrayList<>(); + List opCards = new java.util.ArrayList<>(); + //opCards.add(new OpCard(RuleWeight.TYPE_PONG, 109)); + //opCards.add(new OpCard(RuleWeight.TYPE_PONG, 209)); + cardInhand.add(207); + cardInhand.add(207); + cardInhand.add(202); + cardInhand.add(202); + cardInhand.add(202); + cardInhand.add(109); + + cardInhand.add(109); + cardInhand.add(109); + cardInhand.add(104); + cardInhand.add(104); + cardInhand.add(102); + cardInhand.add(102); + + cardInhand.add(102); + + //System.out.println(tingKongCheck( opCards,cardInhand,109,false)); } private final static boolean quanqiuren(List opCards,List cardInhand, int drawCard) { diff --git a/majiang/changsha/game_mj_cs/target/classes/extend/mj/uitl/Paixing.class b/majiang/changsha/game_mj_cs/target/classes/extend/mj/uitl/Paixing.class index 5913343..fe3be43 100644 Binary files a/majiang/changsha/game_mj_cs/target/classes/extend/mj/uitl/Paixing.class and b/majiang/changsha/game_mj_cs/target/classes/extend/mj/uitl/Paixing.class differ