package extend.mj.uitl;

import com.game.Global;
import com.game.Util;
import com.taurus.core.entity.ITObject;
import extend.mj.*;

import java.util.*;

public class WinCard {
	
	public List<Integer>		cardList;
	public int 					laizi_count;
	public int 					laizi1_count;
	public int 					laizi2_count;
	public int 					laizi1 = 0;
	public int 					laizi2 = 0;
	public Map<Integer, Integer> cbCardMap;

	public WinCard(List<Integer> cardInhand, int addCard, int laizi1, int laizi2, boolean islaizi, boolean selfCard) {
		this.cardList = new ArrayList<Integer>();
		this.cardList.addAll(cardInhand);
		this.cbCardMap = new HashMap<Integer, Integer>();
		if (selfCard)
		{
			this.cardList.add(addCard);
		}
		else {
			this.cardList.add(addCard);
		}

		Collections.sort(this.cardList);
		for(int i = 0; i < this.cardList.size(); i++)
		{
			int card = this.cardList.get(i);
			if (this.cbCardMap.containsKey(card))
			{
				int num = this.cbCardMap.get(card);
				this.cbCardMap.put(card, num+1);
			}
			else
			{
				this.cbCardMap.put(card, 1);
			}
		}
	}

	//钓鱼
	static public boolean IsDiaoYu(EXPlayer player, List<Integer> cardInhand, int drawCard, int laizi1, int laizi2, boolean islaizi)
	{
		EXRoom room = player.getRoom();
		WinCard win = new WinCard(cardInhand, laizi1, laizi2, islaizi);
		if (drawCard > 0 && drawCard != laizi1 && drawCard != laizi2 && win.laizi_count == 1)
		{
			ArrayList<Integer> cardList = new ArrayList<Integer>();
			cardList.addAll(cardInhand);

			Util.removeCard(cardList, drawCard, 1);
			for (int index = 1; index <= 9; index++) {
			    for(int index2 = 1; index2 <= 3; index2++)
				{
				    int card = index2 * 100 + index;
				    if (card == laizi1 || card == laizi2)
				    	continue;
					ArrayList<Integer> tempCardList = new ArrayList<Integer>();
					tempCardList.addAll(cardList);
					tempCardList.add(card);
					WinCard temp = new WinCard(tempCardList, laizi1, laizi2, islaizi);
					HashMap<Integer, WinCardType> map = new HashMap<Integer, WinCardType>();
					if (!temp.checkWin(map, player, room, true)) {
					    return false;
					}
				}
			}

			return true;
		}
		return false;
	}

	public WinCard(List<Integer> cardInhand, int laizi1, int laizi2, boolean islaizi) {
		this.cardList = new ArrayList<Integer>();
		this.cardList.addAll(cardInhand);
		this.cbCardMap = new HashMap<Integer, Integer>();
		if (islaizi) {
			this.laizi1 = laizi1;
			this.laizi2 = laizi2;
			this.laizi1_count = Util.cardNum(laizi1, this.cardList);
			this.laizi2_count = Util.cardNum(laizi2, this.cardList);
			this.laizi_count = this.laizi1_count + this.laizi2_count;
			Util.removeCard(this.cardList, laizi1, this.laizi1_count);
			Util.removeCard(this.cardList, laizi2, this.laizi2_count);
		}
		Collections.sort(this.cardList);
		for(int i = 0; i < this.cardList.size(); i++)
		{
			int card = this.cardList.get(i);
			if (this.cbCardMap.containsKey(card))
			{
				int num = this.cbCardMap.get(card);
				this.cbCardMap.put(card, num+1);
			}
			else
			{
				this.cbCardMap.put(card, 1);
			}
		}
	}

	public boolean checkWin(Map<Integer, WinCardType> map, EXPlayer player, EXRoom room, boolean zimo) {
		if (this.cardList.size() == 0) {
			return false;
		}

		Global.logger.info(this.cardList);
		Global.logger.info(this.laizi_count);
		long startTime = System.currentTimeMillis();
		int[] intListCard = WinSplitCard.SwitchToCardData(this.cardList);
		List<TagAnalyseItem> tagAnalyseItemList = new ArrayList<TagAnalyseItem>();
		Global.logger.info(map);
		Global.logger.info(room.config);
		Global.logger.info(player.outcardList);
		Global.logger.info("checkwin");
		if (!player.opCardList.isEmpty()){
			for (int i=0;i<player.opCardList.size();i++){
				Global.logger.info(player.opCardList.get(i).opCard);
			}
		}

		boolean hu = false;
		int tangzihu = isTangZiHu(player.outcardList); //1:十老头,2:塘子十三ㄠ,3:塘子小七对
		tangzihu=0;
		if (tangzihu==1){
			hu = true;
			WinCard.putWinCardType(map, WinCardType.SHILAOTOU, 1,WinCardType.SHILAOTOU_SCORE, false, "十老头");
		}else if(tangzihu==2){
			hu = true;
			WinCard.putWinCardType(map, WinCardType.TANGZISHISANYAO, 1,WinCardType.TANGZISHISANYAO_SCORE, false, "塘子十三ㄠ");
		}else if(tangzihu==3){
			hu = true;
			WinCard.putWinCardType(map, WinCardType.TANGZIQIXIAODUI, 1,WinCardType.TANGZIQIXIAODUI_SCORE, false, "塘子小七对");
		}else if(tangzihu==4){
			//塘子胡七星
			hu = true;
			WinCard.putWinCardType(map, WinCardType.TANGZIQIXING, 1,WinCardType.TANGZIQIXING_SCORE, false, "塘子胡七星");
		}else if(tangzihu==5){
			hu = true;
			WinCard.putWinCardType(map, WinCardType.TANGZIYIBANGAO, 1,WinCardType.TANGZIYIBANGAO_SCORE, false, "塘子一般高");
		}else if(tangzihu==6){
			hu = true;
			WinCard.putWinCardType(map, WinCardType.TANGZIQIXINGYIBANGAO, 1,WinCardType.TANGZIQIXINGYIBANGAO_SCORE, false, "塘子七星一般高");
		}else if(tangzihu==7){
			hu = true;
			WinCard.putWinCardType(map, WinCardType.TANGZILANPAI, 1,WinCardType.TANGZILANPAI_SCORE, false, "塘子烂牌");
		}else{
			hu = WinSplitCard.AnalyseChiHuCard(map, room.config, intListCard, this.laizi_count, player.opCardList, tagAnalyseItemList);
		}



		if (hu)
		{
			int maxType = 0;
			int maxScore = 0;
			List<Integer> typeList = new ArrayList<Integer>();
			for (Map.Entry<Integer, WinCardType> entry : map.entrySet()) {
				WinCardType cardType = entry.getValue();
				int type = cardType.type;
				Global.logger.info("type:"+cardType.type+"isdahu:"+cardType.IsDaHu()+"score:"+cardType.score);
				if (cardType.IsDaHu())
				{
					typeList.add(type);
				}
			}

			if (maxType > 0)
			{
				for(int i = 0; i < typeList.size(); i++)
				{
					int type = typeList.get(i);
					if (type != maxType)
					{
						map.remove(type);
					}
				}
			}

			if (zimo)
			{
				WinCard.putWinCardType(map, WinCardType.YING_MO, 1,WinCardType.BASE_HU_SCORE, false, "自摸");
			}else if(tangzihu>0){
				WinCard.putWinCardType(map, WinCardType.YING_MO, 1,WinCardType.BASE_HU_SCORE, false, "塘子胡");
			}else{
				WinCard.putWinCardType(map, WinCardType.DIANPAO, 1,WinCardType.BASE_HU_SCORE, false, "点炮");
			}

			for (Map.Entry<Integer, WinCardType> entry : map.entrySet()) {
				WinCardType cardType = entry.getValue();
				Global.logger.info("get_hu_info player:" + player.playerid + " hu:" + cardType.toString());
			}
		}

		return hu;
	}


	public final static WinCardType putWinCardType(Map<Integer, WinCardType> map, int type, int value,int score, boolean isDaHu, String desc) {
		if (map == null)
			return null;
		if (isDaHu)
		{
			map.remove(WinCardType.DIANPAO);
			map.remove(WinCardType.PINGHU);
		}
		if (map.containsKey(type)) {
			WinCardType wct = map.get(type);
			wct.value += value;
			//Global.logger.info("putWinCardType: " + wct.toString());
			return wct;
		} else {
			WinCardType wct = new WinCardType(type, value,score, isDaHu, desc);
			map.put(type, wct);
			//Global.logger.info("putWinCardType: " + wct.toString());
			return wct;
		}
	}



	//七小对
	public int IsQiXiaoDui(Map<Integer, Integer> tempCardList, List<OpCard> opCards)
	{
		//组合判断
		if (opCards.size() != 0) return -1;

		//麻将判断
		int mCountTmp = 0;
		int mDaDuiNum = 0;

		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			int num = entry.getValue();
			if ((num!=0) && (num!=2) && (num!=4))
			{
			    return -1;
			}
			if (num == 2) {
				mCountTmp++;
			}
			else if (num == 4) {
				mCountTmp += 2;
				mDaDuiNum++;
			}
		}

		if (mCountTmp == 7)
		{
			return mDaDuiNum;
		}

		return -1;
	}

	public boolean IsZiYiSe(Map<Integer, Integer> tempCardList, List<OpCard> opCards)
	{
		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			if (card < 400)
			{
				return false;
			}
		}

		for(int i = 0; i < opCards.size(); i++)
		{
			OpCard op_card = opCards.get(i);
			if (op_card.card < 400)
			{
			    return false;
			}
		}

		return true;
	}

	public boolean IsQingYiSe(Map<Integer, Integer> tempCardList, List<OpCard> opCards)
	{
		int perColor = -1;
		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			int color = card / 100;
			if (color >= 4)
			{
			    return false;
			}
			if (perColor == -1)
			{
				perColor = color;
			}
			else if (perColor != color)
			{
				return false;
			}
			else {
				perColor = color;
			}
		}

		for(int i = 0; i < opCards.size(); i++)
		{
			OpCard op_card = opCards.get(i);
			int color = op_card.card / 100;
			if (color >= 4)
			{
				return false;
			}
			if (perColor == -1)
			{
				perColor = color;
			}
			else if (perColor != color)
			{
				return false;
			}
			else {
				perColor = color;
			}
		}
		return true;
	}

	public boolean IsHunYiSe(Map<Integer, Integer> tempCardList, List<OpCard> opCards)
	{
		int perColor = -1;
		boolean hunyise = false;
		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			int color = card / 100;
			if (card < 400)
			{
				if (perColor == -1)
				{
					perColor = color;
				}
				else if (perColor != color)
				{
					return false;
				}
				else {
					perColor = color;
				}
			}
			else
			{
				hunyise = true;
			}
		}

		for(int i = 0; i < opCards.size(); i++)
		{
			OpCard op_card = opCards.get(i);
			int color = op_card.card / 100;
			if (op_card.card < 400)
			{
				if (perColor == -1)
				{
					perColor = color;
				}
				else if (perColor != color)
				{
					return false;
				}
				else {
					perColor = color;
				}
			}
			else
			{
				hunyise = true;
			}
		}

		if (perColor != -1 && hunyise)
			return true;

		return false;
	}

	boolean IsShiBaLuoHan(Map<Integer, Integer> tempCardList, List<OpCard> opCards)
	{
		int count = 0;
		for(int i = 0; i < opCards.size(); i++)
		{
			OpCard op_card = opCards.get(i);
			if (op_card.type == RuleWeight.TYPE_KONG || op_card.type == RuleWeight.TYPE_SELF_KONG)
			{
			    count++;
			}
		}

		if (count >= 4)
		{
			return true;
		}

		return false;
	}

	//混幺九
	boolean IsHuYaoJiu(TagAnalyseItem item) {
		boolean yaoKeZe = false;
		if (item.cbCardEye < 400) {
			int value = item.cbCardEye % 100;
			if (value != 1 && value != 9) {
				return false;
			}
		}

		for (int i = 0; i < item.cbOpCard.size(); i++) {
			OpCard op_card = item.cbOpCard.get(i);
			if (op_card.type == RuleWeight.TYPE_CHOW) {
				return false;
			} else {
				int card = op_card.card;
				if (card < 400) {
					int value = card % 100;
					if (value != 1 && value != 9) {
						return false;
					} else {
						yaoKeZe = true;
					}
				}
			}
		}

		if (yaoKeZe)
		{
			return true;
		}

		return false;
	}

	//清幺九
	boolean IsQingYaoJiu(TagAnalyseItem item) {
		if (item.cbCardEye < 400) {
			int value = item.cbCardEye % 100;
			if (value != 1 && value != 9) {
				return false;
			}
		}
		else
		{
			return false;
		}

		for (int i = 0; i < item.cbOpCard.size(); i++) {
			OpCard op_card = item.cbOpCard.get(i);
			if (op_card.type == RuleWeight.TYPE_CHOW) {
				return false;
			} else {
				int card = op_card.card;
				if (card < 400) {
					int value = card % 100;
					if (value != 1 && value != 9) {
						return false;
					}
				}
				else
				{
					return false;
				}
			}
		}

		return true;
	}

	boolean IsQuanFeng(TagAnalyseItem item) {
		for (int i = 0; i < item.cbOpCard.size(); i++) {
			OpCard op_card = item.cbOpCard.get(i);
			if (op_card.type == RuleWeight.TYPE_CHOW) {
				return false;
			} else {
				int card = op_card.card;
				if (card < 400) {
				    return false;
				}
			}
		}

		return true;
	}

	int IsDaXiaoSanYuan(Map<Integer, Integer> tempCardList, List<OpCard> opCards)
	{
		byte mKeCount = 0;
		byte mDuiCount = 0;
		//组合判断
		for(int i = 0; i < opCards.size(); i++)
		{
			OpCard op_card = opCards.get(i);
			if (op_card.card == Config.HONGZHONG
				|| op_card.card == Config.FACAI
				|| op_card.card == Config.BAIBAN)
			{
				mKeCount++;
			}
		}

		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			int num = entry.getValue();

			if (card == Config.HONGZHONG
					|| card == Config.FACAI
					|| card == Config.BAIBAN)
			{
			    if (num == 2)
				{
					mDuiCount++;
				}

				if (num == 3)
				{
					mKeCount++;
				}
			}
		}

		//大三元
		if (mKeCount ==3)
		{
		    return 1;
		}

		//小三元
		if ((mKeCount ==2) && (mDuiCount ==1))
		{
			return 2;
		}

		return 0;
	}

	boolean QuanQiuRen(Map<Integer, Integer> tempCardList,  List<OpCard> opCards)
	{
		if (opCards.size() != 4)
		{
			return false;
		}

		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			int num = entry.getValue();
			if (num != 0 && num != 2)
			{
				return false;
			}
		}
		return false;
	}

	static boolean ThirteenOne(Map<Integer, Integer> tempCardList, List<OpCard> opCards)
	{
	    if (opCards.size() > 0)
		{
			return false;
		}

	    List<Integer> tempList = new ArrayList<Integer>();
	    tempList.add(101);
		tempList.add(109);
		tempList.add(201);
		tempList.add(209);
		tempList.add(301);
		tempList.add(309);
		tempList.add(Config.DONGFENG);
		tempList.add(Config.NANFENG);
		tempList.add(Config.XIFENG);
		tempList.add(Config.BEIFENG);
		tempList.add(Config.HONGZHONG);
		tempList.add(Config.FACAI);
		tempList.add(Config.BAIBAN);

		int jiangnum = 0;
		for(int i = 0; i < tempList.size(); i++)
		{
			int card = tempList.get(i);
			if (tempCardList.getOrDefault(card, 0) != 1)
			{
				if (tempCardList.getOrDefault(card, 0) == 2)
				{
					jiangnum++;
					if (jiangnum >= 2)
					{
						return false;
					}
				}
				else {
					return false;
				}
			}
		}

		if (jiangnum == 1)
		{
			return true;
		}
		return false;
	}

	int IsDaXiaoSiXi(Map<Integer, Integer> tempCardList,  List<OpCard> opCards)
	{
	    int keCount = 0;
	    int duiCount = 0;
		for(int i = 0; i < opCards.size(); i++)
		{
			OpCard op_card = opCards.get(i);
			if (op_card.card == Config.DONGFENG
					|| op_card.card == Config.NANFENG
					|| op_card.card == Config.XIFENG
					|| op_card.card == Config.BEIFENG)
			{
				keCount++;
			}
		}

		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			int num = entry.getValue();
			if (card == Config.DONGFENG
					|| card == Config.NANFENG
					|| card == Config.XIFENG
					|| card == Config.BEIFENG)
			{
			    if (num == 3)
				{
					keCount++;
				}

			    if (num == 2)
				{
					duiCount++;
				}
			}
		}

		//大四喜
		if (keCount >= 4)
		{
			return 1;
		}
		//小四喜
		else if (keCount >= 3 && duiCount >= 1)
		{
			return 2;
		}

		return 0;
	}

	boolean DaSiXi(Map<Integer, Integer> tempCardList,  List<OpCard> opCards)
	{
	    int count = 0;
		for(int i = 0; i < opCards.size(); i++)
		{
			OpCard op_card = opCards.get(i);
			if (op_card.card == Config.DONGFENG
					|| op_card.card == Config.NANFENG
					|| op_card.card == Config.XIFENG
					|| op_card.card == Config.BEIFENG)
			{
				count++;
			}
		}

		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			int num = entry.getValue();
			if (num >= 3)
			{
				if (card == Config.DONGFENG
						|| card == Config.NANFENG
						|| card == Config.XIFENG
						|| card == Config.BEIFENG)
				{
					count++;
				}
			}
		}

		if (count >= 4)
		{
			return true;
		}

		return false;
	}

	/*
		一条龙判断
	 */
	int isShouDaiLong(Map<Integer, Integer> tempCardList,  List<OpCard> opCards)
	{

		return 0;
	}

	//落地龙判断
	int isLuoDiLong(Map<Integer, Integer> tempCardList,  List<OpCard> opCards)
	{
		return 0;
	}

	int isTangZiHu(Map<Integer, Integer> tempCardList,  List<OpCard> opCards)
	{

		return 0;
	} 

	boolean AnalyseChiHuCard(Map<Integer, WinCardType> map,  List<OpCard> opCards, ITObject config)
	{
		Map<Integer, Integer> tempCardList = new HashMap<Integer, Integer>();
		tempCardList.putAll(this.cbCardMap);

		List<Integer> tempCardListEx = new ArrayList<Integer>();
		for (int index = 1; index <= 9; index++) {

			tempCardListEx.add(100 + index);

			tempCardListEx.add(200 + index);
			tempCardListEx.add(300 + index);
		}


		tempCardListEx.add(Config.DONGFENG);
		tempCardListEx.add(Config.NANFENG);
		tempCardListEx.add(Config.XIFENG);
		tempCardListEx.add(Config.BEIFENG);
		tempCardListEx.add(Config.HONGZHONG);
		tempCardListEx.add(Config.FACAI);
		tempCardListEx.add(Config.BAIBAN);


		if (AnalyseChiHuCardEx(map, tempCardList, 0, opCards, config))
		{
			return true;
		}

		return false;
	}

	boolean AnalyseChiHuCardEx(Map<Integer, WinCardType> map, Map<Integer, Integer> cardListParam, int curCard, List<OpCard> opCards, ITObject config)
	{
		Map<Integer, Integer> tempCardList = new HashMap<>();
		tempCardList.putAll(cardListParam);

		if (curCard > 0)
		{
			tempCardList.put(curCard, tempCardList.getOrDefault(curCard, 0)+1);
		}

		List<Integer> clearCardList = new ArrayList<>();
		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			if (entry.getValue() == 0)
			{
				clearCardList.add(entry.getKey());
			}
		}

		for(int i = 0; i < clearCardList.size(); i++)
		{
			tempCardList.remove(clearCardList.get(i));
		}

		//变量定义
		List<TagAnalyseItem> tagAnalyseItemList = new ArrayList<TagAnalyseItem>();
		List<Integer> wChiHuKind = new ArrayList<Integer>();

		//分析麻将
		AnalyseCard(tempCardList, opCards, tagAnalyseItemList);

		//胡牌分析
		if (tagAnalyseItemList.size() > 0)
		{
			//牌型分析
			for (int i = 0;i < tagAnalyseItemList.size();i++)
			{
				//变量定义
				boolean bLianCard=false,bPengCard=false,b258Card=false;
				TagAnalyseItem pAnalyseItem= tagAnalyseItemList.get(i);

				//牌型分析
				for (int j = 0;j < pAnalyseItem.cbOpCard.size(); j++) {
					OpCard cbWeaveKind = pAnalyseItem.cbOpCard.get(j);
					if (cbWeaveKind.type == RuleWeight.TYPE_PONG
							|| cbWeaveKind.type == RuleWeight.TYPE_KONG
							|| cbWeaveKind.type == RuleWeight.TYPE_SELF_KONG
							|| cbWeaveKind.type == RuleWeight.TYPE_PONG_KONG) {
						bPengCard = true;
					}

					if (cbWeaveKind.type == RuleWeight.TYPE_CHOW) {
						bLianCard = true;
					}
				}

				//牌型判断
				if (bLianCard==false && bPengCard==false)
				{
					return false;
				}

				if (bLianCard && bPengCard == false)
				{
					wChiHuKind.add(WinCardType.PINGHU);
					putWinCardType(map, WinCardType.PINGHU, 1,WinCardType.PINGHU_SCORE, false, "平胡");
				}
				else if (bLianCard && bPengCard)
				{

					wChiHuKind.add(WinCardType.PINGHU);
					putWinCardType(map, WinCardType.PINGHU, 1,WinCardType.PINGHU_SCORE, false, "平胡");

				}

				//特殊--碰碰胡
				if ((bLianCard==false)&&(bPengCard==true))
				{


					wChiHuKind.add(WinCardType.PINGHU);
					putWinCardType(map, WinCardType.PINGHU, 1,WinCardType.PINGHU_SCORE, false, "平胡");


				}
			}
		}

		//特殊胡牌
		if (config.getBoolean(Config.ROOM_CONFIG_QIDUI))
		{
			int DaDuiNum = IsQiXiaoDui(tempCardList, opCards);
			if (DaDuiNum >= 0)
			{
				wChiHuKind.add(WinCardType.QIXIAODUI);
				if (config.getBoolean(Config.ROOM_CONFIG_HAOHUA_QIDUI))
				{
					if (DaDuiNum == 0)
					{
						if (config.getBoolean(Config.ROOM_CONFIG_QIDUI))
						{
							if (config.getBoolean(Config.ROOM_CONFIG_QIDUI_JIA_FAN))
							{
								putWinCardType(map, WinCardType.QIXIAODUI, 1,  WinCardType.QIXIAODUI_SOCRE * 2, true, "七对加番");
							}

							 putWinCardType(map, WinCardType.QIXIAODUI, 1, WinCardType.QIXIAODUI_SOCRE, true, "七小对");

						}
					}

				}
				else {
					if (config.getBoolean(Config.ROOM_CONFIG_QIDUI))
					{
						if (config.getBoolean(Config.ROOM_CONFIG_QIDUI_JIA_FAN))
						{
							putWinCardType(map, WinCardType.QIXIAODUI, 1, WinCardType.QIXIAODUI_SOCRE * 2, true, "七对加番");
						}
						else {
							putWinCardType(map, WinCardType.QIXIAODUI, 1, WinCardType.QIXIAODUI_SOCRE, true, "七小对");
						}
					}
				}
			}
		}



		//结果判断
		if (wChiHuKind.size() > 0)
		{
			if (config.getBoolean(Config.ROOM_CONFIG_QINGYISE))
			{
				if (IsQingYiSe(tempCardList, opCards))
				{
					wChiHuKind.add(WinCardType.QINGYISE);
					putWinCardType(map, WinCardType.QINGYISE, 1,WinCardType.QINGYISE_SCORE, true, "清一色");
				}
			}

			if (config.getBoolean(Config.ROOM_CONFIG_ZIYISE))
			{
				if (IsZiYiSe(tempCardList, opCards))
				{
					wChiHuKind.add(WinCardType.ZI_YI_SE);
					putWinCardType(map, WinCardType.ZI_YI_SE, 1,WinCardType.ZI_YI_SE_SCORE, true, "字一色");
				}
			}

			if (config.getBoolean(Config.ROOM_CONFIG_HUNYISE))
			{
				if (IsHunYiSe(tempCardList, opCards))
				{
					wChiHuKind.add(WinCardType.HUN_YI_SE);
					putWinCardType(map, WinCardType.HUN_YI_SE, 1,WinCardType.HUN_YI_SE_SCORE, true, "混一色");
				}
			}
			return true;
		}

		return false;
	}

	boolean AnalyseCard(Map<Integer, Integer> tempCardList, List<OpCard> opCards, List<TagAnalyseItem> tagAnalyseItemList)
	{
		//计算数目
		int cbCardCount = 0;
		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			cbCardCount += entry.getValue();
		}

		//效验数目
		if ((cbCardCount<2)||(cbCardCount>14)||((cbCardCount-2)%3!=0)) {
			return false;
		}

		//变量定义
		List<TagKindItem>  tagKindList = new ArrayList<TagKindItem>();

		//需求判断
		int cbLessKindItem=(cbCardCount-2)/3;
		if (cbLessKindItem+opCards.size()!=4)
		{
			return false;
		}

		//单吊判断
		if (cbLessKindItem==0)
		{
			//效验参数
			if (!((cbCardCount==2)&&(opCards.size()==4)))
			{
				return false;
			}

			//牌眼判断
			for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
				int card = entry.getKey();
				int num = entry.getValue();
				if (num == 2)
				{
					//变量定义
					TagAnalyseItem AnalyseItem = new TagAnalyseItem();

					//设置结果
					for (int i = 0; i < opCards.size(); i++)
					{
						OpCard src_card = opCards.get(i);
						OpCard op_card = new OpCard(src_card.type, src_card.card);
						AnalyseItem.cbOpCard.add(src_card);
					}
					AnalyseItem.cbCardEye = card;

					//插入结果
					tagAnalyseItemList.add(AnalyseItem);

					return true;
				}
			}

			return false;
		}

		//拆分分析
		if (cbCardCount>=3)
		{
			for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
				int card = entry.getKey();
				int num = entry.getValue();
				//同牌判断
				if (num >= 3)
				{
					TagKindItem kindItem = new TagKindItem();
					kindItem.type = RuleWeight.TYPE_PONG;
					kindItem.card = card;
					kindItem.cbCardList[0] = card;
					kindItem.cbCardList[1] = card;
					kindItem.cbCardList[2] = card;
					tagKindList.add(kindItem);
				}

				//连牌判断
				if (card < 400 && card % 100 <= 7 && num >0)
				{
					for(int i = 1; i <= num; i++)
					{
						if (tempCardList.getOrDefault(card + 1, 0) >= i && tempCardList.getOrDefault(card + 2, 0) >= i)
						{
							TagKindItem kindItem = new TagKindItem();
							kindItem.type = RuleWeight.TYPE_CHOW;
							kindItem.card = card;
							kindItem.cbCardList[0] = card;
							kindItem.cbCardList[1] = card + 1;
							kindItem.cbCardList[2] = card + 2;
							tagKindList.add(kindItem);
						}
					}
				}
			}
		}

		//组合分析
		if (tagKindList.size() >= cbLessKindItem)
		{
			//变量定义
			Integer[] cbIndex = new Integer[4]; //{0,1,2,3};
			cbIndex[0] = 0;
			cbIndex[1] = 1;
			cbIndex[2] = 2;
			cbIndex[3] = 3;

			TagKindItem[] pKindItem = new TagKindItem[4];
			pKindItem[0] = null;
			pKindItem[1] = null;
			pKindItem[2] = null;
			pKindItem[3] = null;

			//开始组合
			do
			{
				//设置变量
				Map<Integer, Integer> cbCardMap_temp = new HashMap<Integer, Integer>();
				cbCardMap_temp.putAll(tempCardList);

				for (int i = 0;i < cbLessKindItem; i++) {
					pKindItem[i] = tagKindList.get(cbIndex[i]);
				}

				//数量判断
				boolean bEnoughCard=true;
				for (int i = 0; i < cbLessKindItem * 3; i++)
				{
					//存在判断
					int cbCardIndex = pKindItem[i/3].cbCardList[i%3];
					if (cbCardMap_temp.getOrDefault(cbCardIndex, 0) <= 0)
					{
						bEnoughCard=false;
						break;
					}
					else
					{
						if (cbCardMap_temp.containsKey(cbCardIndex))
						{
							cbCardMap_temp.put(cbCardIndex, cbCardMap_temp.get(cbCardIndex)-1);
						}
					}
				}

				//胡牌判断
				if (bEnoughCard == true)
				{
					//牌眼判断
					int cbCardEye = 0;
					for (Map.Entry<Integer, Integer> entry : cbCardMap_temp.entrySet()) {
						int card = entry.getKey();
						int num = entry.getValue();
						if (num == 2)
						{
							cbCardEye = card;
							break;
						}
					}

					//组合类型
					if (cbCardEye != 0)
					{
						//变量定义
						TagAnalyseItem AnalyseItem = new TagAnalyseItem();

						//设置组合
						for (int i = 0; i < opCards.size(); i++)
						{
							OpCard src_card = opCards.get(i);
							OpCard op_card = new OpCard(src_card.type, src_card.card);
							AnalyseItem.cbOpCard.add(op_card);
						}

						//设置牌型
						for (int i = 0; i < cbLessKindItem; i++)
						{
							OpCard op_card = new OpCard(pKindItem[i].type, pKindItem[i].card);
							AnalyseItem.cbOpCard.add(op_card);
						}

						//设置牌眼
						AnalyseItem.cbCardEye = cbCardEye;

						//插入结果
						tagAnalyseItemList.add(AnalyseItem);
					}
				}

				//设置索引
				if (cbIndex[cbLessKindItem-1] == (tagKindList.size()-1))
				{
					int i = cbLessKindItem-1;
					for (;i>0;i--)
					{
						if ((cbIndex[i-1]+1) != cbIndex[i])
						{
							int cbNewIndex=cbIndex[i-1];
							for (int j=(i-1);j<cbLessKindItem;j++) {
								cbIndex[j]=cbNewIndex+j-i+2;
							}
							break;
						}
					}
					if (i==0) break;
				}
				else {
					cbIndex[cbLessKindItem-1]++;
				}

			} while (true);

		}

		return (tagAnalyseItemList.size() > 0);
	}

	public static int isTangZiHu(List<Integer> list){
		if (list.size()==10){
			int lt = 0;
			for (int i=0;i<list.size();i++){
				if (list.get(i) >= 400){
					lt++;
				}
			}
			if (lt==10){
				return 1;
			}
		}
		if(list.size()==13){
			//判断是否满足塘子胡
			//boolean ssy =ThirteenYao(list);
			boolean ssy = shiSanYao(list);
			if (ssy){
				return 2;
			}
			//
			int qxd = tzQixiaodui(list);
			if (qxd==6){
				return 3;
			}
			//塘子胡七星 一般高
			boolean tzqxybg = tzQiXingYiBanGao(list);
			if (tzqxybg){
				System.out.println("塘子胡七星一般高");
				return 6;
			}

			boolean tzqx = tzQiXing(list);
			if(tzqx){
				System.out.println("塘子胡七星");
				return 4;
			}
			boolean tzybg = tzYiBangao(list);
			if (tzybg){
				System.out.println("塘子胡一般高");
				return 5;
			}
			boolean tzlp = tzLanPai(list);
			if (tzlp){
				System.out.println("塘子胡烂牌");
				return 7;
			}

		}
		return 0;
	}

	static boolean tzLanPai(List<Integer> list){
		Map<Integer,Integer> tempCardList = new HashMap<>();
		for(Integer cd:list){
			if (tempCardList.containsKey(cd)){
				tempCardList.put(cd,tempCardList.get(cd)+1);
			}else{
				tempCardList.put(cd,1);
			}
		}
		int tongzi = 0;
		int wangzi = 0;
		int tiaozi = 0;
		ArrayList<Integer> wangzicard = new ArrayList<>();
		ArrayList<Integer> tongzicard = new ArrayList<>();
		ArrayList<Integer> tiaozicard = new ArrayList<>();

		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			int num = entry.getValue();
			if (num>1){
				return  false;
			}
			if (card<200&&card>100){
				wangzi++;
				wangzicard.add(card);
			}
			if (card<300&&card>200){
				tongzi++;
				tongzicard.add(card);
			}
			if(card<400&&card>300){
				tiaozi++;
				tiaozicard.add(card);
			}
		}
		if(wangzi>3||tongzi>3||tiaozi>3){
			return false;
		}

		if (wangzicard.size()>0){

			if (wangzicard.size()==3){
				if (wangzicard.get(0)+3!=wangzicard.get(1)||wangzicard.get(1)+3!=wangzicard.get(2)){
					return false;
				}
			}else if(wangzicard.size()==2){
				if (wangzicard.get(0)+3!=wangzicard.get(1)){
					return false;
				}
			}
		}
		if (tongzicard.size()>0){

			if (tongzicard.size()==3){
				if (tongzicard.get(0)+3!=tongzicard.get(1)||tongzicard.get(1)+3!=tongzicard.get(2)){
					return false;
				}
			}else if(tongzicard.size()==2){
				if (tongzicard.get(0)+3!=tongzicard.get(1)){
					return false;
				}
			}
		}
		if(tiaozicard.size()>0){

			if (tiaozicard.size()==3){
				if (tiaozicard.get(0)+3!=tiaozicard.get(1)||tiaozicard.get(1)+3!=tiaozicard.get(2)){
					return false;
				}
			}else if(tiaozicard.size()==2){
				if (tiaozicard.get(0)+3!=tiaozicard.get(1)){
					return false;
				}
			}
		}
		List<Integer> tempList = new ArrayList<Integer>();
		Collections.sort(list);
		tempList.add(Config.DONGFENG);
		tempList.add(Config.NANFENG);
		tempList.add(Config.XIFENG);
		tempList.add(Config.BEIFENG);
		tempList.add(Config.HONGZHONG);
		tempList.add(Config.FACAI);
		tempList.add(Config.BAIBAN);
		List<Integer> ziList = list.subList(wangzicard.size()+tongzicard.size()+tiaozicard.size(),list.size());
		int jiangnum = 0;
		for(int i = 0; i < ziList.size(); i++)
		{
			int card = ziList.get(i);
			jiangnum = Collections.frequency(tempList,card);
			if (jiangnum!=1){
				return false;
			}
		}
		return true;
	}

	static boolean tzQiXingYiBanGao(List<Integer> list){
		Map<Integer,Integer> tempCardList = new HashMap<>();
		for(Integer cd:list){
			if (tempCardList.containsKey(cd)){
				tempCardList.put(cd,tempCardList.get(cd)+1);
			}else{
				tempCardList.put(cd,1);
			}
		}
		int tongzi = 0;
		int wangzi = 0;
		int tiaozi = 0;
		ArrayList<Integer> wangzicard = new ArrayList<>();
		ArrayList<Integer> tongzicard = new ArrayList<>();
		ArrayList<Integer> tiaozicard = new ArrayList<>();

		ArrayList<Integer> checkmen = new ArrayList<>();

		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			int num = entry.getValue();
			if (num>1){
				return  false;
			}
			if (card<200&&card>100){
				wangzi++;
				wangzicard.add(card);
			}
			if (card<300&&card>200){
				tongzi++;
				tongzicard.add(card);
			}
			if(card<400&&card>300){
				tiaozi++;
				tiaozicard.add(card);
			}
		}
		if(wangzi>3||tongzi>3||tiaozi>3){
			return false;
		}

		if (wangzicard.size()>0){
			checkmen.add(wangzicard.get(0)%100>3?1:wangzicard.get(0)%100);
			if(wangzicard.get(0)%100>3){
				return false;
			}
			if (wangzicard.size()==3){
				if (wangzicard.get(0)+3!=wangzicard.get(1)||wangzicard.get(1)+3!=wangzicard.get(2)){
					return false;
				}
			}else if(wangzicard.size()==2){
				if (wangzicard.get(0)+3!=wangzicard.get(1)){
					return false;
				}
			}
		}
		if (tongzicard.size()>0){
			checkmen.add(tongzicard.get(0)%100>3?1:tongzicard.get(0)%100);
			if(tongzicard.get(0)%100>3){
				return false;
			}
			if (tongzicard.size()==3){
				if (tongzicard.get(0)+3!=tongzicard.get(1)||tongzicard.get(1)+3!=tongzicard.get(2)){
					return false;
				}
			}else if(tongzicard.size()==2){
				if (tongzicard.get(0)+3!=tongzicard.get(1)){
					return false;
				}
			}
		}
		if(tiaozicard.size()>0){
			checkmen.add(tiaozicard.get(0)%100>3?1:tiaozicard.get(0)%100);
			if(tiaozicard.get(0)%100>3){
				return false;
			}
			if (tiaozicard.size()==3){
				if (tiaozicard.get(0)+3!=tiaozicard.get(1)||tiaozicard.get(1)+3!=tiaozicard.get(2)){
					return false;
				}
			}else if(tiaozicard.size()==2){
				if (tiaozicard.get(0)+3!=tiaozicard.get(1)){
					return false;
				}
			}
		}

		List<Integer> uniqueList = new ArrayList<>(new HashSet<>(checkmen));
		if (uniqueList.size()>1){
			return false;
		}

		List<Integer> tempList = new ArrayList<Integer>();
		Collections.sort(list);
		tempList.add(Config.DONGFENG);
		tempList.add(Config.NANFENG);
		tempList.add(Config.XIFENG);
		tempList.add(Config.BEIFENG);
		tempList.add(Config.HONGZHONG);
		tempList.add(Config.FACAI);
		tempList.add(Config.BAIBAN);
		List<Integer> ziList = list.subList(wangzicard.size()+tongzicard.size()+tiaozicard.size(),list.size());
		int jiangnum = 0;
		if (ziList.size()<7){
			return false;
		}
		for(int i = 0; i < ziList.size(); i++)
		{
			int card = ziList.get(i);
			jiangnum = Collections.frequency(tempList,card);
			if (jiangnum!=1){
				return false;
			}
		}

		return true;
	}

	static boolean tzYiBangao(List<Integer> list){
		Map<Integer,Integer> tempCardList = new HashMap<>();
		for(Integer cd:list){
			if (tempCardList.containsKey(cd)){
				tempCardList.put(cd,tempCardList.get(cd)+1);
			}else{
				tempCardList.put(cd,1);
			}
		}
		int tongzi = 0;
		int wangzi = 0;
		int tiaozi = 0;
		ArrayList<Integer> wangzicard = new ArrayList<>();
		ArrayList<Integer> tongzicard = new ArrayList<>();
		ArrayList<Integer> tiaozicard = new ArrayList<>();

		ArrayList<Integer> checkmen = new ArrayList<>();

		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			int num = entry.getValue();
			if (num>1){
				return  false;
			}
			if (card<200&&card>100){
				wangzi++;
				wangzicard.add(card);
			}
			if (card<300&&card>200){
				tongzi++;
				tongzicard.add(card);
			}
			if(card<400&&card>300){
				tiaozi++;
				tiaozicard.add(card);
			}
		}
		if(wangzi>3||tongzi>3||tiaozi>3){
			return false;
		}

		if (wangzicard.size()>0){
			checkmen.add(wangzicard.get(0)%100>3?1:wangzicard.get(0)%100);
			if (wangzicard.size()==3){
				if(wangzicard.get(0)%100>3){
					return false;
				}
				if (wangzicard.get(0)+3!=wangzicard.get(1)||wangzicard.get(1)+3!=wangzicard.get(2)){
					return false;
				}
			}else if(wangzicard.size()==2){
				if (wangzicard.get(0)+3!=wangzicard.get(1)&&wangzicard.get(0)+6!=wangzicard.get(1)){
					return false;
				}
			}
		}
		if (tongzicard.size()>0){
			checkmen.add(tongzicard.get(0)%100>3?1:tongzicard.get(0)%100);
			if (tongzicard.size()==3){
				if(tongzicard.get(0)%100>3){
					return false;
				}
				if (tongzicard.get(0)+3!=tongzicard.get(1)||tongzicard.get(1)+3!=tongzicard.get(2)){
					return false;
				}
			}else if(tongzicard.size()==2){
				if (tongzicard.get(0)+3!=tongzicard.get(1)&&tongzicard.get(0)+6!=tongzicard.get(1)){
					return false;
				}
			}
		}
		if(tiaozicard.size()>0){
			checkmen.add(tiaozicard.get(0)%100>3?1:tiaozicard.get(0)%100);
			if (tiaozicard.size()==3){
				if(tiaozicard.get(0)%100>3){
					return false;
				}
				if (tiaozicard.get(0)+3!=tiaozicard.get(1)||tiaozicard.get(1)+3!=tiaozicard.get(2)){
					return false;
				}
			}else if(tiaozicard.size()==2){
				if (tiaozicard.get(0)+3!=tiaozicard.get(1)&&tiaozicard.get(0)+6!=tiaozicard.get(1)){
					return false;
				}
			}
		}
		List<Integer> uniqueList = new ArrayList<>(new HashSet<>(checkmen));
		if (uniqueList.size()>1){
			return false;
		}

		List<Integer> tempList = new ArrayList<Integer>();
		Collections.sort(list);
		tempList.add(Config.DONGFENG);
		tempList.add(Config.NANFENG);
		tempList.add(Config.XIFENG);
		tempList.add(Config.BEIFENG);
		tempList.add(Config.HONGZHONG);
		tempList.add(Config.FACAI);
		tempList.add(Config.BAIBAN);
		List<Integer> ziList = list.subList(wangzicard.size()+tongzicard.size()+tiaozicard.size(),list.size());
		int jiangnum = 0;
		for(int i = 0; i < ziList.size(); i++)
		{
			int card = ziList.get(i);
			jiangnum = Collections.frequency(tempList,card);
			if (jiangnum!=1){
				return false;
			}
		}

		return true;
	}

	static boolean tzQiXing(List<Integer> list){
		Map<Integer,Integer> tempCardList = new HashMap<>();
		for(Integer cd:list){
			if (tempCardList.containsKey(cd)){
				tempCardList.put(cd,tempCardList.get(cd)+1);
			}else{
				tempCardList.put(cd,1);
			}
		}
		int tongzi = 0;
		int wangzi = 0;
		int tiaozi = 0;
		ArrayList<Integer> wangzicard = new ArrayList<>();
		ArrayList<Integer> tongzicard = new ArrayList<>();
		ArrayList<Integer> tiaozicard = new ArrayList<>();


		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			int num = entry.getValue();
			if (num>1){
				return  false;
			}
			if (card<200&&card>100){
				wangzi++;
				wangzicard.add(card);
			}
			if (card<300&&card>200){
				tongzi++;
				tongzicard.add(card);
			}
			if(card<400&&card>300){
				tiaozi++;
				tiaozicard.add(card);
			}
		}
		if(wangzi>3||tongzi>3||tiaozi>3){
			return false;
		}

		//判断 147,258,369
		if (wangzicard.size()>0){

			if (wangzicard.size()==3){
				if (wangzicard.get(0)+3!=wangzicard.get(1)||wangzicard.get(1)+3!=wangzicard.get(2)){
					return false;
				}
			}else if(wangzicard.size()==2){
				if (wangzicard.get(0)+3!=wangzicard.get(1)){
					return false;
				}
			}
		}
		if (tongzicard.size()>0){

			if (tongzicard.size()==3){
				if (tongzicard.get(0)+3!=tongzicard.get(1)||tongzicard.get(1)+3!=tongzicard.get(2)){
					return false;
				}
			}else if(tongzicard.size()==2){
				if (tongzicard.get(0)+3!=tongzicard.get(1)){
					return false;
				}
			}
		}

		if(tiaozicard.size()>0){

			if (tiaozicard.size()==3){
				if (tiaozicard.get(0)+3!=tiaozicard.get(1)||tiaozicard.get(1)+3!=tiaozicard.get(2)){
					return false;
				}
			}else if(tiaozicard.size()==2){
				if (tiaozicard.get(0)+3!=tiaozicard.get(1)){
					return false;
				}
			}
		}


		List<Integer> tempList = new ArrayList<Integer>();
		Collections.sort(list);
		tempList.add(Config.DONGFENG);
		tempList.add(Config.NANFENG);
		tempList.add(Config.XIFENG);
		tempList.add(Config.BEIFENG);
		tempList.add(Config.HONGZHONG);
		tempList.add(Config.FACAI);
		tempList.add(Config.BAIBAN);
		List<Integer> ziList = list.subList(6,list.size());
		System.out.println(ziList);
		int jiangnum = 0;
		for(int i = 0; i < tempList.size(); i++)
		{
			int card = tempList.get(i);
			jiangnum = Collections.frequency(ziList,card);
			if (jiangnum!=1){
				return false;
			}
		}

		return true;
	}

	static int tzQixiaodui(List<Integer> list){

		//麻将判断
		int mCountTmp = 0;
		int mDaDuiNum = 0;
		Map<Integer,Integer> tempCardList = new HashMap<>();
		for(Integer cd:list){
			if (tempCardList.containsKey(cd)){
				tempCardList.put(cd,tempCardList.get(cd)+1);
			}else{
				tempCardList.put(cd,1);
			}
		}

		for (Map.Entry<Integer, Integer> entry : tempCardList.entrySet()) {
			int card = entry.getKey();
			int num = entry.getValue();
			if (num == 2) {
				mCountTmp++;
			}
			else if (num == 4) {
				mCountTmp += 2;
			}
		}
		if (mCountTmp == 6)
		{
			return mCountTmp;
		}
		return -1;
	}

	static boolean shiSanYao(List<Integer> list){
		List<Integer> tempList = new ArrayList<Integer>();
		int zcount = 0;
		int flag = 0;
		int dcount = 0;
		for(int i = 0; i < list.size(); i++)
		{
			int card = list.get(i);
			if(card>=400){
				zcount++;
			}else {
				dcount++;
				if (card % 100 != 1 && card % 100 != 9) {
					flag++;
				}
			}
		}
		if (zcount>=1&&flag==0&&dcount>=1){
			return true;
		}
		return false;
	}

	static boolean ThirteenYao(List<Integer> list){
		List<Integer> tempList = new ArrayList<Integer>();
		tempList.add(101);
		tempList.add(109);
		tempList.add(201);
		tempList.add(209);
		tempList.add(301);
		tempList.add(309);
		tempList.add(Config.DONGFENG);
		tempList.add(Config.NANFENG);
		tempList.add(Config.XIFENG);
		tempList.add(Config.BEIFENG);
		tempList.add(Config.HONGZHONG);
		tempList.add(Config.FACAI);
		tempList.add(Config.BAIBAN);

		int jiangnum = 0;
		int flag = 0;
		for(int i = 0; i < tempList.size(); i++)
		{
			int card = tempList.get(i);
			jiangnum = Collections.frequency(list,card);
			if (jiangnum!=1){
				return false;
			}

		}

		if (jiangnum == 1)
		{
			return true;
		}
		return false;
	}


	public static void main(String[] args) {
		List<Integer> dealCards = new ArrayList<>();
//		dealCards.add(Config.DONGFENG);
//		dealCards.add(Config.DONGFENG);
//		dealCards.add(Config.DONGFENG);
//		dealCards.add(Config.NANFENG);
//		dealCards.add(Config.NANFENG);
//		dealCards.add(Config.NANFENG);
//		dealCards.add(Config.XIFENG);
//		dealCards.add(Config.XIFENG);
//		dealCards.add(Config.XIFENG);
//		dealCards.add(Config.BEIFENG);

		/*dealCards.add(Config.DONGFENG);
		dealCards.add(Config.NANFENG);
		dealCards.add(Config.XIFENG);
		dealCards.add(Config.BEIFENG);
		dealCards.add(Config.HONGZHONG);
		dealCards.add(Config.FACAI);
		dealCards.add(Config.BAIBAN);
		dealCards.add(Config.HONGZHONG);
		dealCards.add(Config.FACAI);
		dealCards.add(Config.BAIBAN);
		dealCards.add(Config.BAIBAN);
		dealCards.add(101);
		dealCards.add(109);
		/*dealCards.add(101);
		dealCards.add(101);
		dealCards.add(101);
		dealCards.add(201);
		dealCards.add(201);
		dealCards.add(209);
		dealCards.add(209);
		dealCards.add(301);
		dealCards.add(309);
		dealCards.add(309);*/
		//dealCards.add(307);
		//dealCards.add(307);

		dealCards.add(101);
		dealCards.add(104);
		dealCards.add(107);
		dealCards.add(202);
		dealCards.add(205);
		dealCards.add(208);
		dealCards.add(309);

		//dealCards.add(Config.DONGFENG);
		dealCards.add(Config.NANFENG);
		dealCards.add(Config.XIFENG);
		dealCards.add(Config.BEIFENG);
		dealCards.add(Config.HONGZHONG);
		dealCards.add(Config.FACAI);
		dealCards.add(Config.BAIBAN);

		int a = isTangZiHu(dealCards);//1:十老头,2:塘子十三ㄠ,3:塘子小七对
		System.out.println(a);
		/*
		ITObject test = new TObject();
		test.putInt("shoudailongjiafan",1);test.putBoolean("shibaluohan",false);test.putBoolean("qidui",false);test.putInt("pid",53);test.putBoolean("tiandihu",false);
		test.putBoolean("pengpenghu",false);test.putBoolean("dashanyuan",false);test.putBoolean("haohua2_qidui",false);test.putBoolean("hunyise",false);test.putInt("isNonnegative",1);
		test.putBoolean("quan_feng",false);test.putBoolean("gangshangpao_2bei",false);test.putBoolean("shishanyao",false);test.putInt("wanfa",0);test.putBoolean("hz_hu",false);test.putBoolean("qing_yao_jiu",false);
		test.putBoolean("lian_zhuang",false);test.putBoolean("men_qing",false);test.putBoolean("ziyise",false);test.putBoolean("dianpao",false);test.putInt("qiduijiafan",1);test.putBoolean("dashanyuan",true);test.putBoolean("xiaosixi",false);
		test.putBoolean("dasixi",false);test.putBoolean("quan_qiu_ren",false);test.putBoolean("quan_feng",false);

		ArrayList<Integer> cardInhand = new ArrayList<Integer>();
		//cardInhand.add(101);
		/*cardInhand.add(102);
		cardInhand.add(103);
		cardInhand.add(104);

		cardInhand.add(105);
		cardInhand.add(106);
		cardInhand.add(107);

		cardInhand.add(107);
		cardInhand.add(108);
		cardInhand.add(109);*/
		//cardInhand.add(305);
		//cardInhand.add(305);
		//cardInhand.add(301);
		//cardInhand.add(301);
		//cardInhand.add(103);
		//cardInhand.add(102);
		/*cardInhand.add(101);
		cardInhand.add(104);
		cardInhand.add(107);
		cardInhand.add(201);
		cardInhand.add(204);
		cardInhand.add(207);
		cardInhand.add(302);
		cardInhand.add(305);
		//cardInhand.add(308);
		//cardInhand.add(Config.DONGFENG);
		cardInhand.add(Config.NANFENG);
		cardInhand.add(Config.XIFENG);
		cardInhand.add(Config.BEIFENG);
		cardInhand.add(Config.HONGZHONG);
		cardInhand.add(Config.FACAI);
		cardInhand.add(Config.BAIBAN);


		//System.out.println(cardInhand);

		int[] intListCard = WinSplitCard.SwitchToCardData(cardInhand);
		System.out.println(intListCard);
		List<TagAnalyseItem> tagAnalyseItemList = new ArrayList<TagAnalyseItem>();

		Map<Integer, WinCardType> map =new HashMap<>();
		List<OpCard> testlist = new ArrayList<>();
		*/
		/*peng
		int gangcard = Config.NANFENG;
		int pengcard = Config.BAIBAN;
		int [] kongGroup = new int [4];
		kongGroup[0] = gangcard;
		kongGroup[1] = gangcard;
		kongGroup[2] = gangcard;
		kongGroup[3] = gangcard;

		int[] pengG1 = new int[4];
		pengG1[0] = pengcard;
		pengG1[1] = pengcard;
		pengG1[2] = pengcard;
		pengG1[3] = pengcard;

		int[] pengG2 = new int[4];
		pengG2[0] = Config.FACAI;
		pengG2[1] = Config.FACAI;
		pengG2[2] = Config.FACAI;
		pengG2[3] = Config.FACAI;

		int[] pengG3 = new int[4];
		pengG3[0] = Config.HONGZHONG;
		pengG3[1] = Config.HONGZHONG;
		pengG3[2] = Config.HONGZHONG;
		pengG3[3] = Config.HONGZHONG;


		OpCard test1 = new OpCard(RuleWeight.TYPE_SELF_KONG, pengcard, 1, kongGroup);
		OpCard test2 = new OpCard(RuleWeight.TYPE_SELF_KONG, pengcard, 1, pengG1);
		OpCard test3 = new OpCard(RuleWeight.TYPE_SELF_KONG, pengcard, 1, pengG2);
		OpCard test4 = new OpCard(RuleWeight.TYPE_SELF_KONG, pengcard, 1, pengG3);
		/*OpCard test2 = new OpCard(RuleWeight.TYPE_CHOW, 102);
		test2.opCard = new TArray();
		test2.opCard.addInt(101);
		test2.opCard.addInt(103);

		testlist.add(test1);
		testlist.add(test2);
		testlist.add(test3);
		testlist.add(test4);*/

		/*
		boolean hu = WinSplitCard.AnalyseChiHuCard(map, test, intListCard, 0, testlist, tagAnalyseItemList);
		for (Map.Entry<Integer, WinCardType> entry : map.entrySet()) {
			WinCardType cardType = entry.getValue();
			System.out.println(cardType.type);
			System.out.println(cardType.desc);
			System.out.println(cardType.is_dahu);
			System.out.println(cardType.score);
		}
		System.out.println(hu);*/


	}
}
