package extend.mj.player.rule;

import com.game.Global;
import com.game.Util;
import com.taurus.core.entity.ITArray;
import com.taurus.core.entity.TArray;
import extend.mj.EXPlayer;
import extend.mj.EXRoom;
import extend.mj.RuleWeight;
import extend.mj.player.rulestate.PRPongState;
import extend.mj.tip.IRuleBase;
import extend.mj.tip.Tip;

/**
 * �����
 * 
 *
 * 2017��8��30��
 * RulePong.java
 */
public class RulePong implements IRuleBase {

	@Override
	public boolean condition(EXPlayer player) {
		EXRoom room = player.getRoom();
		int eventCard = room.activeCard;
		if (player.isEntrust()) {
			return false;
		}


		if (player.getRoom().isFanPai(eventCard))
		{
			return false;
		}

		if (player.getRoom().isLaizi(eventCard))
		{
			return false;
		}

		if (Util.checkCard(eventCard, player.cardInhand, 2)) {

			ITArray opcard = TArray.newInstance();
			opcard.addInt(eventCard);
			Tip tip = new Tip(eventCard, opcard, RuleWeight.PONG, this, RuleWeight.TYPE_PONG);
			player.tipMgr.addTip(tip);

			return true;
		}
		return false;
	}

	@Override
	public void action(EXPlayer player, Tip tip) {

		player.stateMachine.changeState(Global.getState(PRPongState.class));

	}

}
