package extend.zp.room.state;

import java.util.Map.Entry;

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

import extend.zp.Config;
import extend.zp.EXRoom;


public class EXRoomStartGameState extends StateBase<EXRoom> {

	@Override
	public void enter(EXRoom owner) {

		for (Entry<Integer, Player> entry : owner.playerMapById.entrySet()) {
			
			Player player = entry.getValue();
			player.clear();
			player.initSeat();
			player.ready = false;
		}
		
		owner.startGame();

		this.toNextState(owner);
	}

	@Override
	public void toNextState(EXRoom owner) {
		if(owner.config.containsKey(Config.ROOM_CONFIG_PIAO) && owner.config.getInt(Config.ROOM_CONFIG_PIAO) != 0) {
			owner.stateMachine.changeState(Global.getState(EXRoomPiaoState.class));
		}
		else{
			owner.stateMachine.changeState(Global.getState(EXRoomDealState.class));
		}
		//owner.stateMachine.changeState(Global.getState(EXRoomDealState.class));
	}
}
