package com.game.player.state;

import com.game.ActionEvent;
import com.game.Global;
import com.game.Router;
import com.game.data.Player;
import com.game.state.StateBase;
import com.taurus.core.entity.ITObject;
import com.taurus.core.entity.TObject;


public class PlayerEndState extends StateBase<Player> {

	@Override
	public void enter(Player owner) {
		owner.clear();
		owner.startActionTimer();
	}
	@Override
	public void exit(Player owner) {
		owner.stopActionTimer();
	}
	
	@Override
	public void execute(Player owner, String cmd, int gid, Object param) {
		switch(cmd) {
		case ActionEvent.EVENT_READY:
		case ActionEvent.EVENT_TIMER_AUTO:
		case ActionEvent.EVENT_ENTRUST:
			Global.gameCtr.ready(owner);
			break;
		case ActionEvent.EVENT_READY_AND_XIPAI:
			Global.gameCtr.readyAndXipai(owner);
			break;
		case ActionEvent.EVENT_XIPAI:
			if (owner.xi_pai == false)
			{
			    owner.xi_pai = true;
				ITObject param1 = new TObject();
				param1.putInt("result", 0);
				owner.sendEvent(Router.GAME_EVENT_XIPAI, param1);

//				owner.room.redisUpdateXiPaiPlayer(owner);
			}
			else {
				ITObject param1 = new TObject();
				param1.putInt("result", 1);
				owner.sendEvent(Router.GAME_EVENT_XIPAI, param1);
			}
			break;
		}
	}
}
