package com.backfire.arithmetic;

import java.util.ArrayList;

import com.backfire.arithmetic.CardJudge.CardType;

public class CardCompare3 extends CardCompare {

	public CardCompare3() {
		super();
		m_firstCardType = CardType.CardEnd;
		m_secondCardType = CardType.CardEnd;
	}

	public void clear() {

	}

	@Override
	public int compareCard(final ArrayList<Card> myCardFirst,
			final ArrayList<Card> myCardSecond) {
		int value = CompareValue.Error;
		// 数据判空
		do {
			if (myCardFirst.isEmpty() || myCardSecond.isEmpty()) {
				value = CompareValue.ErrorEmpty;
				break;
			}

			CardJudge m_pCardJudgePointerFirst = new CardJudge3();
			CardJudge m_pCardJudgePointerSecond = new CardJudge3();
			// 保存牌头 牌数量 牌类型三项属性
			getReturnTypeDate(
					m_pCardJudgePointerFirst.judgeCardType(myCardFirst),
					m_pCardJudgePointerSecond.judgeCardType(myCardSecond));
			if (m_pCardJudgePointerFirst != null) {
				m_pCardJudgePointerFirst = null;
			}
			if (m_pCardJudgePointerSecond != null) {
				m_pCardJudgePointerSecond = null;
			}

			m_CardVecFirst = myCardFirst;
			m_CardVecSecond = myCardSecond;

			if (m_firstCardType == CardType.CardEnd
					|| m_secondCardType == CardType.CardEnd) {
				value = CompareValue.ErrorCardAll;
				break;
			}
			// 如果其中一个是王炸
			if (m_firstCardType == CardType.CardBombBoss
					|| m_secondCardType == CardType.CardBombBoss) {
				value = compareBombBoss();// 王炸一方大
			} else if (m_firstCardType == CardType.CardBombWith_4
					|| m_secondCardType == CardType.CardBombWith_4) {// 如果其中有一张为四张同牌炸弹
				value = compareBomb();// 比较炸弹大小
			} else if (m_iFitstNum != m_iSecondNum)// 数量不相同
			{
				value = CompareValue.ErrorNum;
			} else {
				value = compareSame(); // 同种牌型比较
			}
		} while (false);

		return value;
	}

	/** 比较王炸 **/
	public int compareBombBoss() {
		// 王炸的大
		if (m_firstCardType == CardType.CardBombBoss) {
			return CompareValue.MoreThan;
		} else {
			return CompareValue.Lessthan;
		}
	}
}
