master
fpgajie 2026-01-06 20:42:55 +08:00
parent 268cb2db9c
commit 34b8efc4f8
9 changed files with 588 additions and 86 deletions

Binary file not shown.

View File

@ -283,7 +283,7 @@ public class HuNanChangSha {
List<Integer> yupanhandcard = new ArrayList<>();
yupanhandcard.addAll(changShaCardInhand);
//进行操作之前能否下听
List<Integer> shifoutingpai = changShaSuanFaTest.handscardshifoutingpai(changShaCardInhand);
List<Integer> shifoutingpai = changShaSuanFaTest.handscardshifoutingpai(changShaCardInhand,chowGroup,pongGroup,gangdepai);
boolean beforelisten = false;//记录操作之前的下听状态
if (shifoutingpai.size() > 0) {
beforelisten = true;
@ -301,9 +301,12 @@ public class HuNanChangSha {
//判断开杠后是否能下听
List<Integer> gangusecars = new ArrayList<>();
gangusecars.addAll(changShaCardInhand);
if (type == 3) {
Util.removeCard(gangusecars,card,3);
List<Integer> shifoutingpai3 = changShaSuanFaTest.handscardshifoutingpai(gangusecars);
List<Integer> 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<Integer> shifoutingpai4 = changShaSuanFaTest.handscardshifoutingpai(gangusecars);
List<Integer> 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<Integer> shifoutingpai5 = changShaSuanFaTest.handscardshifoutingpai(gangusecars);
List<Integer> 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<Integer> 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);
}

View File

@ -51,11 +51,87 @@ public class ChangShaSuanFaTest {
log = Logger.getLogger(ChangShaSuanFaTest.class);
}
public String teshuXuanPai(List<Integer> cardInhand, List<Integer> pengCard, List<Integer> chowGroup,List<Integer> gangdepai){
String outcard = "";
//特殊牌型处理
//判断是否6对是否快满足清一色
//判断清一色
//查询吃碰杠是否是同一色
List<Integer> 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;i<checkcpg.size()-1;i++) {
tmp1 = checkcpg.get(i);
tmp2 = checkcpg.get(i+1);
if (Math.abs(tmp2-tmp1)>10){
//落地已经有了不同色,所以可以进行
qys = true;
}
}
Map<String,List<Integer>> cardst2 = new HashMap<>();
collectionCardse(cardInhand,cardst2);
//检测手牌
if (qys){
//检测同色牌有多少张
for (Map.Entry<String,List<Integer>> entry : cardst2.entrySet()) {
if (entry.getValue().size()==1){
//如果只有一张同色,那就打这一张
return entry.getValue().get(0).toString();
}
}
}
}else{
//检测手牌
if (cardInhand.size()==14){
//检测同色牌有多少张
Map<String,List<Integer>> cardst = new HashMap<>();
collectionCardse(cardInhand,cardst);
for (Map.Entry<String,List<Integer>> entry : cardst.entrySet()) {
if (entry.getValue().size()==1){
//如果只有一张同色,那就打这一张
return entry.getValue().get(0).toString();
}
}
}
}
return null;
}
public void collectionCardse(List<Integer> cardInhand,Map<String,List<Integer>>cardst){
Map<Integer,List<Integer>> se = new HashMap<>();
int wanzi = 0;
int tongzi = 0;
List<Integer> wanzicards = new ArrayList<>();
List<Integer> tongzicards = new ArrayList<>();
for (int i=0;i<cardInhand.size();i++){
if (cardInhand.get(i)/100==1){
wanzi++;
wanzicards.add(cardInhand.get(i));
}
if (cardInhand.get(i)/100==2){
tongzi++;
tongzicards.add(cardInhand.get(i));
}
}
cardst.put("wanzi",wanzicards);
cardst.put("tongzi",tongzicards);
}
/**
*
* -> -> ->
*/
public String outCardSuanFa(List<Integer> cardInhand, List<Integer> pengCard, List<Integer> chowGroup, List<Integer> resultList) {
public String outCardSuanFa(List<Integer> cardInhand, List<Integer> pengCard, List<Integer> chowGroup,List<Integer> gangdepai, List<Integer> resultList) {
List<Integer> handCards = new ArrayList<>(cardInhand);
List<Integer> 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<Integer,List<Integer>> 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<String, Object> map2 = new HashMap<>();
System.out.println(checkCards);
Map<Integer,List<Integer>> 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<Integer> caozuoqian = handscardshifoutingpai(yupanhandcard);
List<Integer> caozuoqian = handscardshifoutingpai(yupanhandcard,chowGroup,pengGrop,gangGrop);
int caozuoqiannum = 0;//操作之前听牌张数
List<Integer> 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<Integer> yupanhandcard, int beforeIsDahu, List<Integer> allSeeCard ,List<Integer>chowGroup,List<Integer>changShachuguopai){
public static ITObject pingguChi(boolean beforelisten, int card, ITArray opcard, List<Integer> yupanhandcard, int beforeIsDahu, List<Integer> allSeeCard ,List<Integer>chowGroup,List<Integer>pengGrop,List<Integer>gangGrop,List<Integer>changShachuguopai){
ITObject chiob = new TObject();
chiob.putBoolean("isTing",beforelisten);
chiob.putInt("isDaHu",beforeIsDahu);
@ -4243,7 +4328,7 @@ public class ChangShaSuanFaTest {
Map<String, Object> map2 = new HashMap<>();
System.out.println(checkCards);
Map<Integer,List<Integer>> 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<Integer> caozuoqian = handscardshifoutingpai(yupanhandcard);
List<Integer> caozuoqian = handscardshifoutingpai(yupanhandcard,chowGroup,pengGrop,gangGrop);
int caozuoqiannum = 0;//操作之前听牌张数
List<Integer> allpai = new ArrayList<>();
allpai.addAll(yupanhandcard);
@ -4302,7 +4388,7 @@ public class ChangShaSuanFaTest {
* @param cardhand
* @return
*/
public static List<Integer> handscardshifoutingpai(List<Integer> cardhand) {
public static List<Integer> handscardshifoutingpai(List<Integer> cardhand,List<Integer>chowGroup,List<Integer> pongGroup,List<Integer> gangdepai) {
List<Integer> tpcards = new ArrayList<>();
List<Integer> 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<String, Object> quyizhangChayou(List<Integer> cardhand,Map<Integer,List<Integer>> xiatingList) {
public static Map<String, Object> quyizhangChayou(List<Integer> cardhand,List<Integer>chowGroup,List<Integer> pongGroup,List<Integer> gangdepai,Map<Integer,List<Integer>> xiatingList) {
Map<String, Object> map = new HashMap<>();
Map<Integer,Map<String, Object>> bigMap = new HashMap<>();
@ -4375,7 +4476,7 @@ public class ChangShaSuanFaTest {
//检查是否能下听
List<Integer> 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<Integer> test1 = new ArrayList<Integer>();
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<Integer> 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 {
List<Integer>changShachuguopai = new ArrayList<>();
//changShachuguopai.add(101);
// changShachuguopai.add(207);
List<Integer> gangguopai = new ArrayList<>();
//gangguopai.add(206);
// gangguopai.add(206);
//gangguopai.add(206);
//gangguopai.add(206);
int card = 105;
List<Integer>pengCard = 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);

View File

@ -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<Integer, Integer> 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<Integer> cardInhand = new java.util.ArrayList<>();
List<Integer> 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<Integer> opCards,List<Integer> 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<Integer> opCards, List<Integer> 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<Integer> opCards, List<Integer> cardInhand, int drawCard,boolean quanqiuren) {
int card1count=0,card2count=0;
Map<Integer, Integer> cardMap =Util.getCardNumMap(cardInhand);
for (Entry<Integer, Integer> 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<Integer> opCards, List<Integer> 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<Integer> opCards, List<Integer> cardInhand, int drawCard) {
if (cardInhand.size() != 13) {
return -1;
}
List<Integer> cardlist = cardInhand;
int pair = 0;
int card4count=0;
Map<Integer, Integer> cardMap =Util.getCardNumMap(cardlist);
for (Entry<Integer, Integer> 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<Integer, WinCardType> 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<Integer, WinCardType> map, List<Integer> opCards, List<Integer> cardInhand,int drawCard, int difen) {
return checkWin(map,opCards,cardInhand,drawCard,true, difen);
}
public static boolean checkWin(Map<Integer, WinCardType> map, List<Integer> opCards, List<Integer> 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<Integer> cardInhand,List<Integer> chowGrop,List<Integer> pengGroup,List<Integer> gangdepai) {
List<Integer> 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<Integer> opCards,List<Integer> 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();
}
}

View File

@ -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;
@ -229,21 +235,21 @@ public class WinCard {
long time = System.currentTimeMillis();
// for (int i = 0; i < 1000000; ++i) {
ArrayList<Integer> cardInhand = new ArrayList<Integer>();
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(204);
cardInhand.add(204);
cardInhand.add(206);
cardInhand.add(206);
cardInhand.add(305);
cardInhand.add(305);
cardInhand.add(305);
cardInhand.add(306);
cardInhand.add(306);
cardInhand.add(307);
cardInhand.add(307);
cardInhand.add(102);
// cardInhand.add(301);
// cardInhand.add(301);
// cardInhand.add(108);
@ -255,8 +261,9 @@ public class WinCard {
// 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<Integer, WinCardType> map = new HashMap<Integer, WinCardType>();

View File

@ -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;
}
}

View File

@ -193,18 +193,27 @@ public class Paixing {
}
public static void main(String[] args) {
// List<Integer> cardInhand = new java.util.ArrayList<>();
// List<OpCard> 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<Integer> cardInhand = new java.util.ArrayList<>();
List<OpCard> 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<OpCard> opCards,List<Integer> cardInhand, int drawCard) {