package worldoffri;

import java.util.HashMap;
import java.util.TreeMap;

/**
 * Class Room - a room in an adventure game.
 *
 * This class is part of the "World of Zuul" application. 
 * "World of Zuul" is a very simple, text based adventure game.  
 *
 * A "Room" represents one location in the scenery of the game.  It is 
 * connected to other rooms via exits.  The exits are labelled north, 
 * east, south, west.  For each direction, the room stores a reference
 * to the neighboring room, or null if there is no exit in that direction.
 * 
 * @author  Michael Kolling and David J. Barnes
 * @version 2006.03.30
 */
public class Miestnost {

    private String aPopisMiestnosti;
    private HashMap<String, Miestnost> ZoznamSmerov;
    private TreeMap<String, Predmet> aPredmety;

    /**
     * Create a room described "description". Initially, it has
     * no exits. "description" is something like "a kitchen" or
     * "an open court yard".
     * @param paPopis The room's description.
     */
    public Miestnost(String paPopis) {
        this.aPopisMiestnosti = paPopis;
        ZoznamSmerov = new HashMap<String, Miestnost>();
        aPredmety = new TreeMap<String, Predmet>();

    }

    /**
     * Define the exits of this room.  Every direction either leads
     * to another room or is null (no exit there).
     * @param paSever The north exit.
     * @param paVychod The east east.
     * @param paJuh The south exit.
     * @param paZapad The west exit.
     */
    public void nastavVychody(String paSmer, Miestnost m) {

        if (paSmer != null && !"".equals(paSmer) && m != null) {
            ZoznamSmerov.put(paSmer, m);
        }


    }

    /**
     * @return The description of the room.
     */
    public String dajPopis() {
        return aPopisMiestnosti;
    }

    public boolean masMiestnostVSmere(String paSmer) {
        if (ZoznamSmerov.containsKey(paSmer)) {
            return true;
        } else {
            return false;
        }

    }

    public void vypisVychody() {
        System.out.println("Mozne vychody " + ZoznamSmerov.keySet());
        System.out.println("Zoznam predmetov v miestnosti: " + aPredmety.keySet());

        // System.out.println ("Predmety v inventári" + aHrac.)
    }

    public Miestnost dajVychod(String smer) {
        return ZoznamSmerov.get(smer);
    }

    public void polozPredmet(Predmet predmet) {
        if (predmet != null) {

            aPredmety.put(predmet.dajNazov(), predmet);
        }
    }

    private void vypisPredmety() {
        if (!aPredmety.isEmpty()) {
            System.out.println("predmety: " + aPredmety.keySet());
        }
    }

    public Predmet zdvihniPredmet(String paNazov) {
        if (paNazov == null) {
            paNazov = "";
        }
        //vlozDoInventara(Predmet, paNazov);

        return aPredmety.remove(paNazov);
    }
}
