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;
import extend.mj.EXRoom;
import extend.mj.room.state.EXRoomSetpState;

/**
 * 
 */
public class EXPlayerHaidiTipState extends EXPlayerTipState {
	
	@Override
	protected void _tipEvent(EXPlayer owner) {
		EXMainServer.gameCtr.haidiTipEvent(owner);
	}
	@Override
	protected void _action(EXPlayer owner,int id,int gid) {
		EXRoom room = owner.getRoom();
		owner.tipMgr.clean();
		if (id == 0) {
			owner.stateMachine.changeState(Global.getState(PlayerWaitState.class));
			room.haidiCount ++;
			owner.room.stateMachine.changeState(Global.getState(EXRoomSetpState.class));
		} else {
			room.niao.clear();
			owner.autoOutCard = true;
			room.activeHaidi = true;
			owner.stateMachine.changeState(Global.getState(EXPlayerDrawState.class));
		}
	}
	
	@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);
		}

	}

}
