import java.util.*;
import java.awt.*;

public class BatimentAlea{
	

	public BatimentAlea(Monde monde,short locBatX,short locBatY,short tailleBatX, short tailleBatY,Catalog cat){
		
		ArrayList grille[][]=monde.grille;	
		
		ArrayList ptsMurs=new ArrayList();
		ArrayList ptsSols=new ArrayList();
		
		
		new Foreuse(grille,"Ecrit",locBatX,locBatY,tailleBatX,tailleBatY);
		new Foreuse(grille,"Wall",locBatX,locBatY,tailleBatX,tailleBatY);
		new Foreuse(grille,"Arbre",locBatX,locBatY,tailleBatX,tailleBatY);
		new Foreuse(grille,"Escalier",locBatX,locBatY,tailleBatX,tailleBatY);
		
		
		new Remplisseur(grille,null,null,null,"Sol",locBatX,locBatY,tailleBatX,tailleBatY,"./images/surfaces/floor33.gif",2,true);
		
		new ExtendedWall(grille,"standardwall","Un mur","A wall",locBatX,locBatY,tailleBatY,"v","./images/walls/roomWall33.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",locBatX+1,locBatY,tailleBatX-1,"h","./images/walls/roomWall33.gif");
		
		new ExtendedWall(grille,"standardwall","Un mur","A wall",locBatX+tailleBatX,locBatY+1,tailleBatY-1,"v","./images/walls/roomWall33.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",locBatX+1,locBatY+tailleBatY,tailleBatX-2,"h","./images/walls/roomWall33.gif");
		
		
		//Creation liste des points des murs////////////////////////
		for(int x=locBatX;x<=locBatX+tailleBatX;x++){
			ptsMurs.add(new Point(x,locBatY));
			ptsMurs.add(new Point(x,locBatY+tailleBatY));
			
		}
		
		for(int y=locBatY;y<=locBatY+tailleBatY;y++){
			ptsMurs.add(new Point(locBatX,y));
			ptsMurs.add(new Point(locBatX+tailleBatX,y));
		}
		
		
		////Création liste des surfaces interieures libres//////////////////
		for(int x=locBatX+1;x<locBatX+tailleBatX;x++){
			for(int y=locBatY+1;y<locBatY+tailleBatY;y++){
				ptsSols.add(new Point(x,y));
			}
		}
		

		
		
		
		///UNE PORTE////////////////////////////corriger porte dans les coins
		Point portePt=(Point)ptsMurs.get((int)(Math.random()*(ptsMurs.size()-1)));
		new Foreuse(grille,"Wall",(int)portePt.getX(),(int)portePt.getY(),0,0);
		grille[(int)portePt.getX()][(int)portePt.getY()].add(new Gate("Une porte","A door",false,50,false,false,"standarddoor",true,"./images/doors/door0.gif","./images/doors/openDoor0.gif","./images/walls/roomWall33.gif","./sons/door_open.wav","./sons/door_close.wav"));
		
		
		///un escalier vers donjon
		Point escalierDonjPt=(Point)ptsSols.get((int)(Math.random()*(ptsSols.size()-1)));
		grille[(int)escalierDonjPt.getX()][(int)escalierDonjPt.getY()].add(new Escalier(false,"standardstairDOWN","Entree d un donjon","A Dungeon","Escalier",true,"./images/escaliers/escalierdown.gif"));
		
		
	}	
	
	
}