package extend.mj.player.state;

import com.game.ActionEvent;
import com.game.state.StateBase;
import extend.mj.Config;
import extend.mj.EXMainServer;
import extend.mj.EXPlayer;
import extend.mj.RuleWeight;
import extend.mj.tip.Tip;

/**
 * �����ʾ�������
 * 
 *
 * 2017��8��30��
 * EXPlayerTipState.java
 */
public abstract class EXPlayerTipState extends StateBase<EXPlayer> {

	@Override
	public void enter(EXPlayer owner) {
		if (owner.getRoom().config.getBoolean(Config.ROOM_CONFIG_ZI_DONG_HU))
		{
			Tip tip = owner.tipMgr.getTip(RuleWeight.TYPE_WIN);
			if (tip != null)
			{
				owner.startActionTimer(1000);
				return;
			}
		}

		if(!owner.isEntrust()) {
			EXMainServer.gameCtr.tipEvent(owner);
		}
		owner.startActionTimer();
	}

	@SuppressWarnings("unchecked")
	@Override
	public void toNextState(EXPlayer owner) {
		owner.stateMachine.lastState.toNextState(owner);
	}

	@Override
	public void exit(EXPlayer owner) {
		owner.tipMgr.clean();
		owner.stopActionTimer();
	}

	public void reload(EXPlayer owner) {
		super.reload(owner);
		this.enter(owner);
	}
	
	@Override
	public void execute(EXPlayer owner, String cmd, int gid, Object param) {
		if(cmd.equals(ActionEvent.EVENT_ENTRUST)) {
			owner.startActionTimer();
		}
	}
}
