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.EXGameController;
import extend.mj.EXMainServer;
import extend.mj.EXPlayer;
import extend.mj.tip.Tip;

/**
 * 
 */
public class EXPlayerQSWinTipState extends EXPlayerTipState {

	@Override
	protected void _tipEvent(EXPlayer owner) {
		EXMainServer.gameCtr.qsTipEvent(owner);
	}
	@Override
	protected void _action(EXPlayer owner,int id,int gid) {
		if (id != 0) {
			Tip tip = owner.tipMgr.tipMap.get(id);
			((EXGameController)Global.gameCtr).banbanWinEvent(owner,tip);
		}
		owner.tipMgr.clean();

		owner.stateMachine.changeState(Global.getState(PlayerWaitState.class));
		owner.getRoom().qsWinCount --;
		owner.getRoom().stateMachine.execute(EXActionEvent.EVENT_QSWIN, 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);
		}
	}

}
