package extend.pk.player.state;

import com.game.Global;
import com.game.data.Timer;
import com.game.player.state.PlayerWaitState;
import com.game.state.StateBase;

import extend.pk.EXMainServer;
import extend.pk.EXPlayer;
import extend.pk.EXRoom;
import extend.pk.room.state.EXRoomSetpState;

/**
 * 等待玩家Pass状态
 * 
 * 
 */
public class EXPlayerPassState extends StateBase<EXPlayer> {

	private void pass(EXPlayer owner) {
		EXMainServer.gameCtr.pass(owner);//打不起过
		this.toNextState(owner);//下一位大哥
	}
	
	@Override
	public void enter(EXPlayer owner) {
		EXRoom room = owner.getRoom();
		if(!owner.entrust) {
			Timer passTimer = new Timer(1000, new Timer.ITaskHandler() {
                @Override
				public void doTask(Timer timer) {
					pass(owner);
				}
			});
			room.addTimer(passTimer);
		}else {
			pass(owner);
		}
	}


	@Override
	public void exit(EXPlayer owner) {
		owner.stopActionTimer();
	}
	
	@Override
	public void toNextState(EXPlayer owner) {
		owner.stateMachine.changeState(Global.getState(PlayerWaitState.class));
		owner.room.stateMachine.changeState(Global.getState(EXRoomSetpState.class));
	}
}
