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 Map<Integer, Room> roomList;
    private String name;

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

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

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

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

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

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