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.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;
			
			player.entrust_round = 0;
			if (owner.isEntrust()) {
				if(player.offlineTime == 0) {
					if (player.isEntrust()) {
						player.offlineTime = owner.default_entrust_time;
					} else {
						player.offlineTime = owner.entrustTime;
					}
				}
			}
		}
		
		owner.startGame();

		this.toNextState(owner);
	}

	@Override
	public void toNextState(EXRoom owner) {
		
		owner.stateMachine.changeState(Global.getState(EXRoomDealState.class));
	}
}
