package extend.zp.player.rule;

import java.util.Map;
import java.util.Map.Entry;

import com.taurus.core.entity.ITArray;
import com.taurus.core.entity.ITObject;
import com.taurus.core.entity.TArray;

import com.taurus.core.entity.TObject;
import com.taurus.core.util.Logger;
import extend.zp.*;
import extend.zp.tip.IRuleBase;
import extend.zp.uitl.CardUtil;
import extend.zp.uitl.Paixing;


public class RuleDealTi implements IRuleBase {
	Logger logger = Logger.getLogger(getClass());
	@Override
	public boolean condition(EXPlayer player) {

		logger.info("jefe RuleDealTi ");
		Map<Integer, Integer> cardMap = CardUtil.getCardNumMap(player.cardInhand);
		for (Entry<Integer, Integer> entry : cardMap.entrySet()) {
			
			int card = entry.getKey();
			int num = entry.getValue();
			
			if (num == 4) {
				player.tiCount++;

				ITArray opcard = TArray.newInstance();
				opcard.addInt(card);
				opcard.addInt(card);
				opcard.addInt(card);
				opcard.addInt(card);
				CardUtil.removeCard(player.cardInhand, card, num);

				int[] tiGroup = new int[4];
				tiGroup[0] = card;
				tiGroup[1] = card;
				tiGroup[2] = card;
				tiGroup[3] = card;

				player.tiGroup.add(tiGroup);

				//清溜
				player.opCardList.add(new OpCard(RuleWeight.TYPE_TI, card, card, card, Paixing.caclHuxi(RuleWeight.TYPE_TI, card), true, RuleWeight.HAO_QING, card));
				//EXMainServer.gameCtr.actionCard(player, card, card, RuleWeight.TYPE_TI, player.seat, opcard);
			}
		}
		logger.info("jefe RuleDealTi end");
		return false;
	}

	@Override
	public void action(EXPlayer player) {
		
	}
}
