package it.gotoandplay.smartfoxclient.data;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/*
 * The Zone class stores the properties of the current server zone. <p> This
 * class is used internally by the {@link
 * it.gotoandplay.smartfoxclient.SmartFoxClient} class. </p>
 * 
 * @version 1.0.0
 * 
 * @author The gotoAndPlay() Team<br> <a
 * href="http://www.smartfoxserver.com">http://www.smartfoxserver.com</a><br> <a
 * href="http://www.gotoandplay.it">http://www.gotoandplay.it</a><br>
 */
public class Zone {

	private final Map <Integer, Room> roomList;
	private final String name;

	public Zone (final String name) {
		this.name = name;
		roomList = new ConcurrentHashMap <Integer, Room> ();
	}

	public Room getRoom (final int id) {
		return roomList.get (id);
	}

	public Room getRoomByName (final String name) {
		Room room = null;
		boolean found = false;

		for (final int roomId : roomList.keySet ()) {
			room = roomList.get (roomId);

			if (room.getName ().equals (name)) {
				found = true;
				break;
			}
		}

		if (found) {
			return room;
		}
		return null;
	}
}
