package extend.mj.player.state;

import com.game.ActionEvent;
import com.game.state.StateBase;

import extend.mj.EXMainServer;
import extend.mj.EXPlayer;

/**
 * 
 */
public abstract class EXPlayerTipState extends StateBase<EXPlayer> {

	@Override
	public void enter(EXPlayer owner) {
		if (!owner.isEntrust()) {
			_tipEvent(owner);
			owner.startActionTimer();
		} else {
			owner.startActionTimer(500);
		}
	}

	protected void _tipEvent(EXPlayer owner) {
		EXMainServer.gameCtr.tipEvent(owner);
	}

	protected void _action(EXPlayer owner, int id, int gid) {
	}

	@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();
		}
	}
}
