package com.backfire.arithmetic;

import com.backfire.arithmetic.CardJudge.CardType;
import com.backfire.arithmetic.CardJudge3_Laizi.CardType_Laizi;

public class CardReturn_Laizi {
	public CardType_Laizi mCardType; // 牌的类型
	public Card mCardHead; // 牌头
	public int mCardNum; // 牌的数量

	public CardReturn_Laizi() {
		mCardType = CardType_Laizi.CardEnd;
		mCardNum = 0;
		mCardHead = new Card(Card.Club, Card.PointError);
	}

	public void clear() {

	}
	
	@Override
	public String toString() {
		return "CardReturn [mCardType=***" + mCardType +"***,mCardHead="+mCardHead.toString()
				+", mCardNum=***"+ mCardNum + "***]";
	}
	
	public void setmCardNum(int mCardNum) {
		this.mCardNum = mCardNum;
	}
	
	public void copy(CardType_Laizi type, final Card pCard) {
		mCardHead.setColor(pCard.getColor());
		mCardHead.setPoint(pCard.getPoint());
		mCardType = type;
	}

	public void copy(CardType_Laizi type, final Card pCard, int iNum) {
		mCardNum = iNum;
		mCardHead.setColor(pCard.getColor());
		mCardHead.setPoint(pCard.getPoint());
		mCardType = type;
	}

	public void copy(CardType type, final Card pCard, int iNum) {
		mCardNum = iNum;
		mCardHead.setColor(pCard.getColor());
		mCardHead.setPoint(pCard.getPoint());

		switch (type) {
		case CardSingle:
			mCardType = CardType_Laizi.SOLO;
			break;
		case CardPair:
			mCardType = CardType_Laizi.PAIR;
			break;
		case CardThreeWithNo:
			mCardType = CardType_Laizi.TRIO;
			break;
		case CardThreeWithOne:
			mCardType = CardType_Laizi.TRIO_X;
			break;
		case CardThreeWithTwo:
			mCardType = CardType_Laizi.TRIO_X;
			break;
		case CardFourWithTwo:
			mCardType = CardType_Laizi.FOUR_WITH_X;
			break;
		case CardFourWithTwoPair:
			mCardType = CardType_Laizi.FOUR_WITH_X;
			break;
		case CardChain:
			mCardType = CardType_Laizi.CHAIN;
			break;
		case CardChainPair:
			mCardType = CardType_Laizi.PAIR_CHAIN;
			break;
		case CardAirplaneNo:
			mCardType = CardType_Laizi.PLANE;
			break;
		case CardAirplaneOne:
			mCardType = CardType_Laizi.PLANE_1;
			break;
		case CardAirplaneTwo:
			mCardType = CardType_Laizi.PLANE_2;
			break;
		case CardBombWith_4:
			mCardType = CardType_Laizi.BOMB;
			break;
		case CardBombBoss:
			mCardType = CardType_Laizi.ROCKET;
			break;
		case CardEnd:
			mCardType = CardType_Laizi.CardEnd;
			break;
		}
	}
	
	public static CardReturn copy(CardReturn_Laizi cardReturn_Laizi) {
		int cardNum=cardReturn_Laizi.mCardNum;
		CardType_Laizi type=cardReturn_Laizi.mCardType;
		Card headCard=cardReturn_Laizi.mCardHead;
		CardType cardType=CardType.CardEnd;
		switch (type) {
		case SOLO:
			cardType = CardType.CardSingle;
			break;
		case PAIR:
			cardType = CardType.CardPair;
			break;
		case TRIO:
			cardType = CardType.CardThreeWithNo;
			break;
		case TRIO_X:
			if(4==cardNum){
				cardType = CardType.CardThreeWithOne;
			}else if(5==cardNum){
				cardType = CardType.CardThreeWithTwo;
			}
			break;
		case FOUR_WITH_X:
			if(6==cardNum){
				cardType = CardType.CardFourWithTwo;
			}else if(8==cardNum){
				cardType = CardType.CardFourWithTwoPair;
			}
			break;
		case CHAIN:
			cardType = CardType.CardChain;
			break;
		case PAIR_CHAIN:
			cardType = CardType.CardChainPair;
			break;
		case PLANE:
			cardType = CardType.CardAirplaneNo;
			break;
		case PLANE_1:
			cardType = CardType.CardAirplaneOne;
			break;
		case PLANE_2:
			cardType = CardType.CardAirplaneTwo;
			break;
		case MIX_BOMB:
		case BOMB:
		case LAIZHI_BOMB:
			cardType = CardType.CardBombWith_4;
			break;
		case ROCKET:
			cardType = CardType.CardBigBombBoss;
			break;
		case CardEnd:
			cardType = CardType.CardEnd;
			break;
		}
		CardReturn cardReturn=new CardReturn();
		cardReturn.copy(cardType, headCard, cardNum);
		return cardReturn;
	}
}
