package com.game.player.state;

import com.game.ActionEvent;
import com.game.Global;
import com.game.data.Player;
import com.game.state.StateBase;

/**
 * 玩家进房间的初始状态
 * 
 *
 */
public class PlayerInitState extends StateBase<Player> {

	@Override
	public void enter(Player owner) {
		if(owner.room.round==0&&owner.room.kickTime>0) {
			owner.startActionTimer(owner.room.kickTime * 1000);
		}
	}

	@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:
				Global.gameCtr.ready(owner);
				break;
			case ActionEvent.EVENT_READY_AND_XIPAI:
				Global.gameCtr.readyAndXipai(owner);
				break;
			case ActionEvent.EVENT_EXIT_ROOM:
				if(owner.room.round>0)return;
				Global.gameCtr.exitRoom(owner, gid,false);
				break;
			case ActionEvent.EVENT_TIMER_AUTO:
				if(owner.room.round>0)return;
				Global.gameCtr.exitRoom(owner, gid,true);
				break;
		}
	}

}
