/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.nplusc.iZc.MazeGame.cells;

import de.nplusc.iZc.MazeGame.Objects.Player;
import java.util.List;
import java.util.Map;

/**
 *
 * @author LH
 */
public class DoorCell extends MazeCell
{

    public DoorCell(String[] validKeyIDs, Map<Integer, boolean[]> pexits, Map<Integer, boolean[]> pentrances,int bl)
    {
        super(pexits, pentrances,bl,1);
        this.validKeyIDs = validKeyIDs;
    }

    public DoorCell(String[] validKeyIDs)
    {
        this.validKeyIDs = validKeyIDs;
    }
    
    
    
    
    private String[] validKeyIDs;

    public String[] getValidKeyIDs()
    {
        return validKeyIDs;
    }

    public void setValidKeyIDs(String[] validKeyIDs)
    {
        this.validKeyIDs = validKeyIDs;
    }
    
    private boolean hasKey(Player p)
    {
        List<String> keyRing = p.getKeys();
        for (String vkey : validKeyIDs)
        {
            if(keyRing.contains(vkey))
            {
                return true;
            }
        }
        return false;
    }
    
    public boolean canEnter(int direction,int layer,Player p)
    {
        return super.canEnter(direction, layer, p)&& hasKey(p);
    }
    public String onCellEnter(Player p)
    {
        return "";
    }
}
