package extend.mj;

import com.game.Global;
import com.game.Util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


public class RoomCard {
	public List<Integer>	cardList;
	EXRoom						room;
	public ArrayList<Integer>    subCardList;
	public Integer	laiziCard;
	public Integer	laiziCard2;
	public Integer	laiziCardBefore;
	public Integer	laiziCard2Before;

	public RoomCard(EXRoom table) {
		this.cardList = new ArrayList<Integer>();
		subCardList  = new ArrayList<>();
		this.room = table;
		laiziCard = 0;
		laiziCard2 = 0;
		laiziCardBefore = 0;
		laiziCard2Before = 0;
	}

	public void init() {
		this.cardList.clear();
		this.subCardList.clear();
		this.initCard();
		this.shuffle();

		//this.cardList.add(106);
		//this.cardList.add(109);
		//this.cardList.add(107);
		//this.cardList.add(108);
		//this.cardList.add(109);
		this.setbugang();
	}

	private void setbugang(){
		// 136 - 13- 14 = 109
		this.room.gangnum = 0;
		this.room.gangzi1 = this.cardList.get(this.cardList.size()-1);
		this.room.gangzi2 = this.cardList.get(this.cardList.size()-2);
	}
	private void initCard() {

		boolean notiao = false;
		boolean notuo = false;

			for (int index = 1; index <= 9; index++) {
				for (int index2 = 0; index2 < 4; index2++) {
					this.cardList.add(100 + index);
					this.cardList.add(200 + index);
					this.cardList.add(300 + index);
				}
			}


			for(int i =0;i<4;++i) {
				this.cardList.add(Config.DONGFENG);
				this.cardList.add(Config.NANFENG);
				this.cardList.add(Config.XIFENG);
				this.cardList.add(Config.BEIFENG);
				this.cardList.add(Config.HONGZHONG);
				this.cardList.add(Config.FACAI);
				this.cardList.add(Config.BAIBAN);
			}


		//0 无鬼 1白板做鬼 2翻鬼（随机一个牌做鬼) 3翻双鬼
		int laizi = 0;



		deal_select++;
		//deal_select = 9;

		deal_index = 1;
		deal_tempCards_1 = 0;
		deal_tempCards_2 = 0;
		deal_tempCards_3 = 0;
		deal_tempCards_4 = 0;
	}

	private int GetBeforeCard(int card)
	{
		if (card < 400)
		{
			if (card % 100 >= 2 && card % 100 <= 9)
			{
				return card - 1;
			}
			else if (card % 100 == 1)
			{
				return card / 100 + 9;
			}
			else
			{
				return card;
			}
		}
		else
		{
			if (card == Config.DONGFENG)
			{
				return 	Config.BAIBAN;
			}
			else if (card ==Config.NANFENG)
			{
				return 	Config.DONGFENG;
			}
			else if (card ==Config.XIFENG)
			{
				return 	Config.NANFENG;
			}
			else if (card ==Config.BEIFENG)
			{
				return 	Config.XIFENG;
			}
			else if (card ==Config.HONGZHONG)
			{
				return 	Config.BEIFENG;
			}
			else if (card ==Config.FACAI)
			{
				return 	Config.HONGZHONG;
			}
			else if (card ==Config.BAIBAN)
			{
				return 	Config.FACAI;
			}
			else
			{
				return Config.BAIBAN;
			}
		}
	}

	private void shuffle() {
		Collections.shuffle(this.cardList);
	}

	public boolean isLaizi(int card)
	{
		if (laiziCard != 0 && card == laiziCard)
		{
			return true;
		}
		else if (laiziCard2 != 0 && card == laiziCard2)
		{
			return true;
		}

		return false;
	}

	public boolean isFanPai(int card)
	{
		if (laiziCardBefore != 0 && card == laiziCardBefore)
		{
			return true;
		}
		else if (laiziCard2Before != 0 && card == laiziCard2Before)
		{
			return true;
		}

		return false;
	}

	public void reInitCards(List<Integer> cards) {
		//从底牌移除
		for(Integer card : cards) {
			for(int i = cardList.size() - 1;i >= 0;i--) {
				if(cardList.get(i).intValue() == card.intValue()) {
					if(cardList.remove(i) > 0) {
						this.subCardList.add(card);
					}
					break;
				}
			}
		}
	}

//	public int pop() {
//
//		if (this.cardList.size() == 0) {
//			this.room.bankerSeat = this.room.activeSeat;
////			this.room.roundSettle();
//		}
//
//		int card = this.cardList.remove(0);
//
//		return card;
//
//	}

	public int pop() {
		Global.logger.info("pop cardlist size=>"+this.cardList.size()+":sub size==>"+subCardList.size());
		int card = 0;
		if (this.cardList.size() == 0) {
			if(this.subCardList.size() > 0) {
				card = this.subCardList.remove(0);
			}else {
				this.room.bankerSeat = this.room.activeSeat;
			}
		}else {
			card = this.cardList.remove(0);
		}
		return card;

	}

	public int popsub() {
		Global.logger.info("pop sub cardlist size=>"+this.cardList.size()+":sub size==>"+subCardList.size());
		int card = 0;
		if (this.subCardList.size() == 0) {
			if (this.cardList.size() == 0) {
				this.room.bankerSeat = this.room.activeSeat;
			}else {
				card = this.cardList.remove(0);
			}
		}else {
			card = this.subCardList.remove(0);
		}
		return card;
	}

	public int getCount() {
		return this.cardList.size() + this.subCardList.size();
	}

	public int deal_select = 0;
	public List<Integer> deal() {
		if (deal_select >= 0)
		//if (deal_select == 0)
		{
			List<Integer> dealCards = new ArrayList<Integer>();

			for (int index = 0; index < 13; index++) {
				dealCards.add(this.pop());
			}

			return dealCards;
		}

	    if (deal_select == 1)
		{
			return deal_shishanyao();
		}
	    else if (deal_select == 2)
		{
			return deal_qixiaodui();
		}
	    else if (deal_select == 3)
		{
			return deal_shibaluohan();
		}
	    else if (deal_select == 4)
		{
			return deal_hunyise();
		}
	    else if (deal_select == 5)
		{
			return deal_xiaoshanyuan();
		}
	    else if (deal_select == 6)
		{
			return deal_dashanyuan();
		}
	    else if (deal_select == 7)
		{
			return deal_xiaosixi();
		}
	    else if (deal_select == 8)
		{
			return deal_dasixi();
		}
	    else if (deal_select == 9)
		{
			return deal_qiangganghu();
		}
	    else if (deal_select == 10)
		{
			return deal_gangshangkaihua();
		}
		else if(deal_select==11){
			return deal_ceshigang();
		}else if(deal_select==12){
			return deal_pengpenghu();
		}else if(deal_select==13){
			return deal_yibangao();
		}else{
			List<Integer> dealCards = new ArrayList<Integer>();

			for (int index = 0; index < 13; index++) {
				dealCards.add(this.pop());
			}

			return dealCards;
		}
	}

	public int deal_index = 1;
	public int deal_tempCards_1 = 0;
	public int deal_tempCards_2 = 0;
	public int deal_tempCards_3 = 0;
	public int deal_tempCards_4 = 0;
	public List<Integer> deal_shishanyao() {
		List<Integer> dealCards = new ArrayList<Integer>();

		dealCards.add(101);
		dealCards.add(104);
		dealCards.add(107);
		//dealCards.add(101);

		dealCards.add(201);
		dealCards.add(204);
		dealCards.add(207);
		//dealCards.add(203);

		//dealCards.add(204);
		//dealCards.add(204);
	//	dealCards.add(309);
		//dealCards.add(309);

		dealCards.add(301);
		//dealCards.add(305);

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

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}

		deal_index++;

		return dealCards;
	}

	public List<Integer> deal_qixiaodui() {
		List<Integer> dealCards = new ArrayList<Integer>();
		List<Integer> tempCards = new ArrayList<Integer>();

		if (deal_index == 1)
		{
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(105);
			dealCards.add(105);
			dealCards.add(105);
			dealCards.add(105);
			dealCards.add(107);
			deal_tempCards_1 = 107;
		}
		else if (deal_index == 2)
		{
			dealCards.add(201);
			dealCards.add(201);
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(205);
			dealCards.add(205);
			dealCards.add(206);
			deal_tempCards_2 = 206;
		}
		else if (deal_index == 3)
		{
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(305);
			deal_tempCards_3 = 305;
		}
		else if (deal_index == 4)
		{
			dealCards.add(Config.DONGFENG);
			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.NANFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(305);
			deal_tempCards_4 = 305;
		}

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}
		if (deal_tempCards_1 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_1, 1);
			tempCards.add(deal_tempCards_1);
		}
		if (deal_tempCards_2 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_2, 1);
			tempCards.add(deal_tempCards_2);
		}
		if (deal_tempCards_3 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_3, 1);
			tempCards.add(deal_tempCards_3);
		}
		if (deal_tempCards_4 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_4, 1);
			tempCards.add(deal_tempCards_4);
		}
		tempCards.addAll(this.cardList);
		this.cardList.clear();
		this.cardList.addAll(tempCards);

		deal_index++;
		if (deal_index > 4)
		{
			deal_index = 1;
		}

		return dealCards;
	}

	public List<Integer> deal_pengpenghu() {
		List<Integer> dealCards = new ArrayList<Integer>();
		List<Integer> tempCards = new ArrayList<Integer>();

		if (deal_index == 1)
		{
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(102);
			dealCards.add(102);
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(105);
			deal_tempCards_1 = 105;
		}
		else if (deal_index == 2)
		{
			dealCards.add(201);
			dealCards.add(201);
			dealCards.add(201);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(205);
			deal_tempCards_2 = 205;
		}
		else if (deal_index == 3)
		{
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(305);
			deal_tempCards_3 = 305;
		}
		else if (deal_index == 4)
		{
			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.BEIFENG);
			dealCards.add(Config.BEIFENG);
			dealCards.add(Config.HONGZHONG);
			deal_tempCards_4 = Config.HONGZHONG;
		}

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}
		if (deal_tempCards_1 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_1, 1);
			tempCards.add(deal_tempCards_1);
		}
		if (deal_tempCards_2 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_2, 1);
			tempCards.add(deal_tempCards_2);
		}
		if (deal_tempCards_3 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_3, 1);
			tempCards.add(deal_tempCards_3);
		}
		if (deal_tempCards_4 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_4, 1);
			tempCards.add(deal_tempCards_4);
		}
		tempCards.addAll(this.cardList);
		this.cardList.clear();
		this.cardList.addAll(tempCards);

		deal_index++;
		if (deal_index >= 4)
		{
			deal_index = 1;
		}

		return dealCards;
	}

	public List<Integer> deal_yibangao() {
		List<Integer> dealCards = new ArrayList<Integer>();
		List<Integer> tempCards = new ArrayList<Integer>();

		if (deal_index == 1)
		{
			dealCards.add(101);
			dealCards.add(104);
			dealCards.add(107);
			dealCards.add(201);
			dealCards.add(204);
			dealCards.add(207);
			dealCards.add(302);
			dealCards.add(Config.BAIBAN);
			dealCards.add(Config.HONGZHONG);
			dealCards.add(Config.BEIFENG);
			dealCards.add(Config.NANFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.DONGFENG);
			deal_tempCards_1 = 104;
		}
		else if (deal_index == 2)
		{
			dealCards.add(101);
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(104);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(205);
			deal_tempCards_2 = 205;
		}
		else if (deal_index == 3)
		{
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(305);
			deal_tempCards_3 = 305;
		}
		else if (deal_index == 4)
		{
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(304);
			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);
			deal_tempCards_4 = Config.BEIFENG;
		}

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}
		if (deal_tempCards_1 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_1, 1);
			tempCards.add(deal_tempCards_1);
		}
		if (deal_tempCards_2 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_2, 1);
			tempCards.add(deal_tempCards_2);
		}
		if (deal_tempCards_3 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_3, 1);
			tempCards.add(deal_tempCards_3);
		}
		if (deal_tempCards_4 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_4, 1);
			tempCards.add(deal_tempCards_4);
		}
		tempCards.addAll(this.cardList);
		this.cardList.clear();
		this.cardList.addAll(tempCards);

		deal_index++;
		if (deal_index > 4)
		{
			deal_index = 1;
		}

		return dealCards;
	}

	public List<Integer> deal_shibaluohan() {
		List<Integer> dealCards = new ArrayList<Integer>();
		List<Integer> tempCards = new ArrayList<Integer>();

		if (deal_index == 1)
		{
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(102);
			dealCards.add(102);
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(105);
			deal_tempCards_1 = 105;
		}
		else if (deal_index == 2)
		{
			dealCards.add(101);
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(104);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(205);
			deal_tempCards_2 = 205;
		}
		else if (deal_index == 3)
		{
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(305);
			deal_tempCards_3 = 305;
		}
		else if (deal_index == 4)
		{
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(304);
			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);
			deal_tempCards_4 = Config.BEIFENG;
		}

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}
		if (deal_tempCards_1 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_1, 1);
			tempCards.add(deal_tempCards_1);
		}
		if (deal_tempCards_2 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_2, 1);
			tempCards.add(deal_tempCards_2);
		}
		if (deal_tempCards_3 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_3, 1);
			tempCards.add(deal_tempCards_3);
		}
		if (deal_tempCards_4 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_4, 1);
			tempCards.add(deal_tempCards_4);
		}
		tempCards.addAll(this.cardList);
		this.cardList.clear();
		this.cardList.addAll(tempCards);

		deal_index++;
		if (deal_index > 4)
		{
			deal_index = 1;
		}

		return dealCards;
	}

	public List<Integer> deal_hunyise() {
		List<Integer> dealCards = new ArrayList<Integer>();
		List<Integer> tempCards = new ArrayList<Integer>();

		if (deal_index == 1)
		{
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(102);
			dealCards.add(102);
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(Config.DONGFENG);
			deal_tempCards_1 = Config.DONGFENG;
		}
		else if (deal_index == 2)
		{
			dealCards.add(201);
			dealCards.add(201);
			dealCards.add(201);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(205);
			deal_tempCards_2 = 205;
		}
		else if (deal_index == 3)
		{
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(305);
			dealCards.add(306);
			dealCards.add(307);
			dealCards.add(308);
			dealCards.add(309);
			dealCards.add(Config.BEIFENG);
			dealCards.add(Config.BEIFENG);
			dealCards.add(Config.BEIFENG);
			dealCards.add(Config.HONGZHONG);
			deal_tempCards_3 = Config.HONGZHONG;
		}
		else if (deal_index == 4)
		{
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(305);
			dealCards.add(306);
			dealCards.add(307);
			dealCards.add(308);
			dealCards.add(309);
			dealCards.add(Config.NANFENG);
			dealCards.add(Config.NANFENG);
			dealCards.add(Config.NANFENG);
			dealCards.add(Config.HONGZHONG);
			deal_tempCards_4 = Config.HONGZHONG;
		}

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}
		if (deal_tempCards_1 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_1, 1);
			tempCards.add(deal_tempCards_1);
		}
		if (deal_tempCards_2 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_2, 1);
			tempCards.add(deal_tempCards_2);
		}
		if (deal_tempCards_3 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_3, 1);
			tempCards.add(deal_tempCards_3);
		}
		if (deal_tempCards_4 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_4, 1);
			tempCards.add(deal_tempCards_4);
		}
		tempCards.addAll(this.cardList);
		this.cardList.clear();
		this.cardList.addAll(tempCards);

		deal_index++;
		if (deal_index >= 4)
		{
			deal_index = 1;
		}

		return dealCards;
	}

	public List<Integer> deal_xiaoshanyuan() {
		List<Integer> dealCards = new ArrayList<Integer>();
		List<Integer> tempCards = new ArrayList<Integer>();

		if (deal_index == 1)
		{
			dealCards.add(Config.HONGZHONG);
			dealCards.add(Config.HONGZHONG);
			dealCards.add(Config.HONGZHONG);
			dealCards.add(Config.BAIBAN);
			dealCards.add(Config.BAIBAN);
			dealCards.add(Config.BAIBAN);
			dealCards.add(Config.FACAI);
			dealCards.add(Config.FACAI);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(Config.DONGFENG);
			dealCards.add(Config.DONGFENG);
			deal_tempCards_1 = Config.DONGFENG;
		}
		else if (deal_index == 2)
		{
			dealCards.add(201);
			dealCards.add(201);
			dealCards.add(201);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(205);
			deal_tempCards_2 = 205;
		}
		else if (deal_index == 3)
		{
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(305);
			dealCards.add(306);
			dealCards.add(307);
			dealCards.add(308);
			dealCards.add(309);
			dealCards.add(Config.BEIFENG);
			dealCards.add(Config.BEIFENG);
			dealCards.add(Config.BEIFENG);
			dealCards.add(Config.NANFENG);
			deal_tempCards_3 = Config.NANFENG;
		}
		else if (deal_index == 4)
		{
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(305);
			dealCards.add(306);
			dealCards.add(307);
			dealCards.add(308);
			dealCards.add(309);
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(303);
			dealCards.add(304);
			deal_tempCards_4 = 304;
		}

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}
		if (deal_tempCards_1 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_1, 1);
			tempCards.add(deal_tempCards_1);
		}
		if (deal_tempCards_2 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_2, 1);
			tempCards.add(deal_tempCards_2);
		}
		if (deal_tempCards_3 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_3, 1);
			tempCards.add(deal_tempCards_3);
		}
		if (deal_tempCards_4 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_4, 1);
			tempCards.add(deal_tempCards_4);
		}
		tempCards.addAll(this.cardList);
		this.cardList.clear();
		this.cardList.addAll(tempCards);

		deal_index++;
		if (deal_index > 4)
		{
			deal_index = 1;
		}

		return dealCards;
	}

	public List<Integer> deal_dashanyuan() {
		List<Integer> dealCards = new ArrayList<Integer>();
		List<Integer> tempCards = new ArrayList<Integer>();

		if (deal_index == 1)
		{
			dealCards.add(Config.HONGZHONG);
			dealCards.add(Config.HONGZHONG);
			dealCards.add(Config.HONGZHONG);
			dealCards.add(Config.BAIBAN);
			dealCards.add(Config.BAIBAN);
			dealCards.add(Config.BAIBAN);
			dealCards.add(Config.FACAI);
			dealCards.add(Config.FACAI);
			dealCards.add(Config.FACAI);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(Config.DONGFENG);
			deal_tempCards_1 = Config.DONGFENG;
		}
		else if (deal_index == 2)
		{
			dealCards.add(201);
			dealCards.add(201);
			dealCards.add(201);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(205);
			deal_tempCards_2 = 205;
		}
		else if (deal_index == 3)
		{
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(305);
			dealCards.add(306);
			dealCards.add(307);
			dealCards.add(308);
			dealCards.add(309);
			dealCards.add(Config.BEIFENG);
			dealCards.add(Config.BEIFENG);
			dealCards.add(Config.BEIFENG);
			dealCards.add(Config.NANFENG);
			deal_tempCards_3 = Config.NANFENG;
		}
		else if (deal_index == 4)
		{
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(305);
			dealCards.add(306);
			dealCards.add(307);
			dealCards.add(308);
			dealCards.add(309);
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(305);
			deal_tempCards_4 = 305;
		}

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}
		if (deal_tempCards_1 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_1, 1);
			tempCards.add(deal_tempCards_1);
		}
		if (deal_tempCards_2 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_2, 1);
			tempCards.add(deal_tempCards_2);
		}
		if (deal_tempCards_3 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_3, 1);
			tempCards.add(deal_tempCards_3);
		}
		if (deal_tempCards_4 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_4, 1);
			tempCards.add(deal_tempCards_4);
		}
		tempCards.addAll(this.cardList);
		this.cardList.clear();
		this.cardList.addAll(tempCards);

		deal_index++;
		if (deal_index > 4)
		{
			deal_index = 1;
		}

		return dealCards;
	}

	public List<Integer> deal_xiaosixi() {
		List<Integer> dealCards = new ArrayList<Integer>();
		List<Integer> tempCards = new ArrayList<Integer>();

		if (deal_index == 1)
		{
			dealCards.add(Config.DONGFENG);
			dealCards.add(Config.DONGFENG);
			dealCards.add(Config.DONGFENG);
			dealCards.add(109);
			dealCards.add(Config.NANFENG);
			dealCards.add(Config.NANFENG);
			dealCards.add(Config.NANFENG);
			dealCards.add(109);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(109);
			dealCards.add(Config.BEIFENG);
			deal_tempCards_1 = Config.BEIFENG;
		}
		else if (deal_index == 2)
		{
			dealCards.add(101);
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(104);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(205);
			deal_tempCards_2 = 205;
		}
		else if (deal_index == 3)
		{
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(305);
			deal_tempCards_3 = 305;
		}
		else if (deal_index == 4)
		{
			dealCards.add(101);
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(104);
			dealCards.add(102);
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(105);
			deal_tempCards_4 = 105;
		}

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}
		if (deal_tempCards_1 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_1, 1);
			tempCards.add(deal_tempCards_1);
		}
		if (deal_tempCards_2 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_2, 1);
			tempCards.add(deal_tempCards_2);
		}
		if (deal_tempCards_3 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_3, 1);
			tempCards.add(deal_tempCards_3);
		}
		if (deal_tempCards_4 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_4, 1);
			tempCards.add(deal_tempCards_4);
		}
		tempCards.addAll(this.cardList);
		this.cardList.clear();
		this.cardList.addAll(tempCards);

		deal_index++;
		if (deal_index > 4)
		{
			deal_index = 1;
		}

		return dealCards;
	}

	public List<Integer> deal_dasixi() {
		List<Integer> dealCards = new ArrayList<Integer>();
		List<Integer> tempCards = new ArrayList<Integer>();

		if (deal_index == 1)
		{
			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(104);
			dealCards.add(103);
			dealCards.add(102);
			dealCards.add(105);
			deal_tempCards_1 = 109;
		}
		else if (deal_index == 2)
		{
			dealCards.add(Config.DONGFENG);
			dealCards.add(Config.NANFENG);
			dealCards.add(Config.XIFENG);
			dealCards.add(Config.BEIFENG);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(205);
			deal_tempCards_2 = 205;
		}
		else if (deal_index == 3)
		{
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(301);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(305);
			deal_tempCards_3 = 305;
		}
		else if (deal_index == 4)
		{
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(102);
			dealCards.add(102);
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(103);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(104);
			dealCards.add(105);
			deal_tempCards_4 = 105;
		}

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}
		if (deal_tempCards_1 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_1, 1);
			tempCards.add(deal_tempCards_1);
		}
		if (deal_tempCards_2 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_2, 1);
			tempCards.add(deal_tempCards_2);
		}
		if (deal_tempCards_3 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_3, 1);
			tempCards.add(deal_tempCards_3);
		}
		if (deal_tempCards_4 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_4, 1);
			tempCards.add(deal_tempCards_4);
		}
		tempCards.addAll(this.cardList);
		this.cardList.clear();
		this.cardList.addAll(tempCards);

		deal_index++;
		if (deal_index > 4)
		{
			deal_index = 1;
		}

		return dealCards;
	}

	public List<Integer> deal_qiangganghu() {
		List<Integer> dealCards = new ArrayList<Integer>();
		List<Integer> tempCards = new ArrayList<Integer>();

		if (deal_index == 2)
		{
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(106);
			dealCards.add(106);
			dealCards.add(106);
			dealCards.add(107);
			dealCards.add(107);
			dealCards.add(107);
			dealCards.add(108);
			dealCards.add(108);
			dealCards.add(108);
			dealCards.add(109);
			deal_tempCards_1 = 101;
		}
		else if (deal_index == 1)
		{

			dealCards.add(102);
			dealCards.add(103);

			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(202);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(203);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(205);
			dealCards.add(205);
			deal_tempCards_2 = 205;
		}
		else if (deal_index == 3)
		{
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(305);
			dealCards.add(305);
			deal_tempCards_3 = 301;
		}
		else if (deal_index == 4)
		{
			dealCards.add(102);
			dealCards.add(103);
			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.BEIFENG);
			deal_tempCards_4 = 303;
		}

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}
		if (deal_tempCards_1 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_1, 1);
			tempCards.add(deal_tempCards_1);
		}
		if (deal_tempCards_2 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_2, 1);
			tempCards.add(deal_tempCards_2);
		}
		if (deal_tempCards_3 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_3, 1);
			tempCards.add(deal_tempCards_3);
		}
		if (deal_tempCards_4 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_4, 1);
			tempCards.add(deal_tempCards_4);
		}
		tempCards.addAll(this.cardList);
		this.cardList.clear();
		this.cardList.addAll(tempCards);

		deal_index++;
		if (deal_index > 4)
		{
			deal_index = 1;
		}

		return dealCards;
	}

	public List<Integer> deal_gangshangkaihua() {
		List<Integer> dealCards = new ArrayList<Integer>();
		List<Integer> tempCards = new ArrayList<Integer>();

		if (deal_index == 1)
		{
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(106);
			dealCards.add(106);
			dealCards.add(106);
			dealCards.add(107);
			dealCards.add(107);
			dealCards.add(107);
			dealCards.add(108);
			dealCards.add(108);
			dealCards.add(108);
			dealCards.add(109);
			deal_tempCards_1 = 102;
		}
		else if (deal_index == 2)
		{
			dealCards.add(101);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(305);
			dealCards.add(306);
			dealCards.add(307);
			dealCards.add(308);
			dealCards.add(309);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(205);
			deal_tempCards_2 = 109;
		}
		else if (deal_index == 3)
		{
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(305);
			dealCards.add(305);
			deal_tempCards_3 = 109;
		}
		else if (deal_index == 4)
		{
			dealCards.add(102);
			dealCards.add(103);
			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.BEIFENG);
			deal_tempCards_4 = 109;
		}

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}
		if (deal_tempCards_1 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_1, 1);
			tempCards.add(deal_tempCards_1);
		}
		if (deal_tempCards_2 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_2, 1);
			tempCards.add(deal_tempCards_2);
		}
		if (deal_tempCards_3 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_3, 1);
			tempCards.add(deal_tempCards_3);
		}
		if (deal_tempCards_4 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_4, 1);
			tempCards.add(deal_tempCards_4);
		}
		tempCards.addAll(this.cardList);
		this.cardList.clear();
		this.cardList.addAll(tempCards);

		deal_index++;
		if (deal_index > 4)
		{
			deal_index = 1;
		}

		return dealCards;
	}


	public List<Integer> deal_ceshigang() {
		List<Integer> dealCards = new ArrayList<Integer>();
		List<Integer> tempCards = new ArrayList<Integer>();

		if (deal_index == 1)
		{
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(101);
			dealCards.add(105);
			dealCards.add(106);
			dealCards.add(103);
			dealCards.add(102);
			dealCards.add(107);
			dealCards.add(108);
			dealCards.add(108);
			dealCards.add(108);
			dealCards.add(109);
			dealCards.add(109);
			//dealCards.add(102);
			//dealCards.add(103);
			deal_tempCards_1 = 101;
		}
		else if (deal_index == 2)
		{
			dealCards.add(101);
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(104);
			dealCards.add(105);
			dealCards.add(106);
			dealCards.add(107);
			dealCards.add(108);
			dealCards.add(203);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(204);
			dealCards.add(205);
			deal_tempCards_2 = 109;
		}
		else if (deal_index == 3)
		{
			dealCards.add(102);
			dealCards.add(103);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(302);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(303);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(304);
			dealCards.add(305);
			dealCards.add(305);
			deal_tempCards_3 = 109;
		}
		else if (deal_index == 4)
		{
			dealCards.add(102);
			dealCards.add(103);
			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.BEIFENG);
			deal_tempCards_4 = 109;
		}

		for(int i = 0; i< dealCards.size(); i++) {
			Util.removeCard(this.cardList, dealCards.get(i), 1);
		}
		if (deal_tempCards_1 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_1, 1);
			tempCards.add(deal_tempCards_1);
		}
		if (deal_tempCards_2 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_2, 1);
			tempCards.add(deal_tempCards_2);
		}
		if (deal_tempCards_3 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_3, 1);
			tempCards.add(deal_tempCards_3);
		}
		if (deal_tempCards_4 > 0)
		{
			Util.removeCard(this.cardList, deal_tempCards_4, 1);
			tempCards.add(deal_tempCards_4);
		}
		tempCards.addAll(this.cardList);
		this.cardList.clear();
		this.cardList.addAll(tempCards);

		deal_index++;
		if (deal_index > 4)
		{
			deal_index = 1;
		}

		return dealCards;
	}
}
