import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
/**
 * Liest Level aus Textdatei aus
 * 
 * @author Marek Parucha 
 * @version 1.0
 */
public class LevelReader extends Reader
{
    public LevelReader(String r)
    {
        super(r);
    }
    /**
     * Act - do whatever the LevelReader wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public int waves()
    {
        newScanner();
        int count = 0;
        while(s.hasNextLine()) 
            {
                count++;
                s.nextLine();
                
            }
            
        close();
        return (count-1);
        
    }
    /**
      * liest nächste Monsterzahl aus
      * * @param 'line': Zeile
      */
    public int getAnzahlMonster(int line)
    {
        newScanner();
        int a;
        for(int i = 0 ; i<line; i++)
        {
            s.nextLine();
            
        }
        s.nextLine();
        a = readInt();
        close();
        
        return a;
    }
     /**
      * liest nächster MonsterIntervall aus
      * * @param 'line': Zeile
      */
    public int getIntervallMonster(int line)
    {
        newScanner();
        int a;
        for(int i = 0 ; i<line; i++)
        {
            s.nextLine();
            
        }
        s.nextLine();
        s.nextInt();
        a = readInt();
        close();
        
        return a;
    }
     /**
      * liest nächste Monsterart aus
      * * @param 'line': Zeile
      */
    public String getStringMonster(int line)
    {
        newScanner();
        String a;
        for(int i = 0 ; i<line; i++)
        {
            s.nextLine();
            
        }
        s.nextLine();
        s.nextInt();
        s.nextInt();
        a = s.next();
        close();

        return a;
    }
     /**
      * liest Leben aus
      */
    public int getLife()
    {
        newScanner();
        int a;
        a = readInt();
        close();
        
        return a;
    }
    /**
      * liest Geld aus
      */
    public int getMoney()
    {
        newScanner();
        int a;
        s.nextInt();
        a = readInt();
        close();
        
        return a;
    }
    /**
      * öffnet neuen Scanner
      */
    public void newScanner()
    {
        try
        {
            s = new Scanner(f);
        }
        catch( FileNotFoundException e )
        {
            e.printStackTrace();
        }
    }
}
