package jguard.client;

import cucky.jGuard.lib.Status;
import cucky.jGuard.lib.object.Map;
import cucky.jGuard.lib.object.MapObject;
import jguard.client.gui.MapTree;
import jguard.client.gui.Tray;


public class MapManager {
    
    
    private static Map getMapById(int id){
        for (Map map : Client.map) {
            if (map.getId() == id) {
                return map;
            }
        }
        return null;
    }

    public static void addMap(Map m) {
        // pridani do seznamu
        Client.map.add(m);
        // pridání do stromu map
        MapTree.add();
    }

    public static void setLock(int map, int state) {
        for (Map mp : Client.map) {
            if (mp.getId() == map) {
                mp.setLock((state == 1));
            }
        }
    }
    

    public static void setObjectStatus(int mapId, int objId, int status) {
        for (Map map : Client.map) {
            for (MapObject obj : map.getObjects()) {
                // aktualizace stavu u objektu
                if (obj.getId() == objId) {
                    obj.setStatus(status);
                    break;
                }
            }
        }
    }
    
    
    

}
