package extend.zp.player.rule;

import com.game.Global;
import com.taurus.core.entity.ITArray;
import com.taurus.core.entity.TArray;

import extend.zp.EXPlayer;
import extend.zp.player.rulestate.PRWeiState;
import extend.zp.tip.IRuleBase;
import extend.zp.uitl.CardUtil;


public class RuleWei implements IRuleBase {
	@Override
	public boolean condition(EXPlayer player) {
		int eventCard = player.drawCard;
		if (CardUtil.cardNum(eventCard, player.cardInhand) >= 2) {
			player.winCard = player.drawCard;
			player.drawCard = 0;
			CardUtil.removeCard(player.cardInhand, eventCard, 2);
			ITArray opcard = TArray.newInstance();
			opcard.addInt(eventCard);
			opcard.addInt(eventCard);
			player.initOpCard(opcard);
			this.action(player);
		}
		return false;
	}

	@Override
	public void action(EXPlayer player) {
		player.stateMachine.changeState(Global.getState(PRWeiState.class));
	}
}
