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.Config;
import extend.mj.EXPlayer;
import extend.mj.EXRoom;
import extend.mj.RuleWeight;
import extend.mj.player.rulestate.PROtherKongState;
import extend.mj.tip.IRuleBase;
import extend.mj.tip.Tip;

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

	@Override
	public boolean condition(EXPlayer player) {
		EXRoom room = player.getRoom();

		int eventCard = room.activeCard;
		if (eventCard == Config.HONGZHONG || player.isEntrust()) {
			return false;
		}

		if (Util.checkCard(eventCard, player.cardInhand, 3)) {
			ITArray opcard = TArray.newInstance();
			opcard.addInt(eventCard);
			Tip tip = new Tip(eventCard, opcard, RuleWeight.KONG, this, RuleWeight.TYPE_KONG);
			player.tipMgr.addTip(tip);
			return true;
		}
		return false;
	}

	@Override
	public void action(EXPlayer player, Tip tip) {
		player.stateMachine.changeState(Global.getState(PROtherKongState.class));

	}

}
