package extend.zp.room.state;

import com.game.Global;
import com.game.state.StateBase;

import extend.zp.EXMainServer;
import extend.zp.EXPlayer;
import extend.zp.EXRoom;
import extend.zp.PlayBack;
import extend.zp.player.state.EXPlayerPreDrawState;

public class EXRoomDealState extends StateBase<EXRoom> {

	@Override
	public void enter(EXRoom owner) {
		owner.card.init();
		if (owner.bankerSeat == 0) {
			owner.bankerSeat = 1;
		}

		deal(owner);
	}
	
	private void deal(EXRoom owner) {
		EXMainServer.gameCtr.dealCard(owner);
		owner.playBackData = new PlayBack(owner);
		toNextState(owner);
	}

	public void execute(EXRoom owner, String cmd, int gid, Object param) {
	}

	@Override
	public void toNextState(EXRoom owner) {
		EXPlayer player = (EXPlayer) owner.playerMapBySeat.get(owner.bankerSeat);
		EXMainServer.gameCtr.changeActiveSeat(owner, player.seat);
		player.stateMachine.changeState(Global.getState(EXPlayerPreDrawState.class));
	}

}
