
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author Administrador
 */
public class Tablero {
    private ArrayList<Zona> Zonas=new ArrayList();
    private int nZonas=5;
    
    public Tablero( ArrayList<Territorio> t) throws FileNotFoundException, IOException{
        InputStreamReader isr = new InputStreamReader(System.in);
        FileReader flujo=new FileReader("./ficheros/zonas.txt");
        BufferedReader fichero=new BufferedReader(flujo);
        String sCadena=fichero.readLine();
        while(!sCadena.contentEquals("EOF")){
            //if (!nterrit.contentEquals("EOF")){
                int id=Integer.parseInt(sCadena);
                String nom=fichero.readLine();
                String leeBonus=fichero.readLine();
                int bonus=Integer.parseInt(leeBonus);
                String leeNumTer=fichero.readLine();
                int nterrit = Integer.parseInt(leeNumTer);
                //int []terr=new int[nterrit];
                ArrayList<Territorio> terr=new ArrayList();
                String territ = fichero.readLine();
                int i=0;
                while(!territ.contentEquals("fin")){
                    terr.add(t.get(Integer.parseInt(territ)));
                    territ =fichero.readLine();
                    i++;
                }
                
                Zona z= new Zona(nom, id, nterrit, terr, bonus);
                Zonas.add(z);
                sCadena=fichero.readLine();
        }
    }
    public ArrayList<Zona> getZonas(){
        return Zonas; 
    }
    public Zona getZona(int indice){
        return Zonas.get(indice);
    }
    public int getNumZonas(){
        return nZonas;
    }
    public void setNumZonas(int num){
        nZonas=num;
    }
    public void mostrarTodo(){
        for(int i=0;i<nZonas;i++){
            Zona z=Zonas.get(i);
            System.out.println("Identificador: "+z.getIdZona());
            System.out.println("Nombre: "+z.getNomZona());
            System.out.println("Numero de territorios: "+z.getNumTerritorios());
            for(int j=0;j<z.getNumTerritorios();j++){
                System.out.println(z.getTerritorio(j));
            }
            
        }
    }
}
    

