package extend.mj.player.state;


import com.game.ActionEvent;
import com.game.Global;
import com.game.player.state.PlayerWaitState;
import com.taurus.core.entity.ITObject;

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

/**
 * Ʊ����ʾ״̬
 * 
 */
public class EXPlayerPiaoNiaoTipState extends EXPlayerTipState {

	@Override
	public void enter(EXPlayer owner) {
		if(!owner.isEntrust()) {
			EXMainServer.gameCtr.piaoNiaoTipEvent(owner);
			owner.startActionTimer();
		}else{
			_action(owner, 0, 0);
		}
	}
	@Override
	public void exit(EXPlayer owner) {
		super.exit(owner);
	}
	
	private void _action(EXPlayer owner,int id,int gid) {
		owner.piaoNiao = id;
		owner.tipMgr.clean();
		owner.stateMachine.changeState(Global.getState(PlayerWaitState.class));
		owner.getRoom().piaoNiaoCount --;
		EXMainServer.gameCtr.piaoNiaoEvent(owner);
		owner.getRoom().stateMachine.execute(EXActionEvent.EVENT_PIAO_NIAO, gid, null);
	}
	@Override
	public void execute(EXPlayer owner, String cmd, int gid, Object param) {
		super.execute(owner, cmd, gid, param);
		if (cmd.equals(EXActionEvent.EVENT_ACTION)) {
			ITObject netParam = (ITObject) param;
			int id = netParam.getInt("id");
			_action(owner,id,gid);
		}else if(cmd.equals(ActionEvent.EVENT_TIMER_AUTO)) {
			_action(owner,0,gid);
		}

	}

}
