import javax.swing.*;
import java.util.*;
import java.awt.*;
import java.io.*;

//import java.io.*;
//import java.util.*;
import java.util.zip.*;
//import java.util.Enumeration;
import java.text.*;
import sun.text.Normalizer;

public class CryptRL{
	
	
	
	
	//boolean started=false;
	
	boolean jeuInit2=false;
	boolean jeuInit=false;
	
	Monde monde=new Monde(null,null);
	
	private int tailleGrille=monde.tailleGrille; 
	private ArrayList grille[][]=new ArrayList[tailleGrille][tailleGrille];
	
	
	Catalog cat=new Catalog(monde);
	
	
	static final int BUFFER = 2048;
	
	
	public static void main(String args[]){
			
		CryptRL jeu=new CryptRL();	
			
		FramePrincipale fp = new FramePrincipale(jeu);
        
        //new ThreadSon("./sons/evilwelcome.wav",0).start();
        
        
        
	}
	
	
	
	
	/////////////////////////////////////////////////////////
	//EXEMPLE A CONSERVER
	/*	UndeadCategory spectreVert1=new UndeadCategory(false,"lesser ghost","Mr Booo",true,"Creature",true,"./images/creatures/undead/spectrevert.gif","./images/creatures/bones.gif");
		spectreVert1.setCooX(12);
		spectreVert1.setCooY(28);
		Arme epeelongueMrBoo=new Arme(false,"longsword","Epee longue banale","Objet",true,"./images/weapons/longSword.gif");
		Armure cuirMrBoo=new Armure(false,"softleather","Armure de cuir souple classique","Objet",true,"./images/armors/leatherArmor.gif");
		Arme dagueMrBoo=new Arme(false,"dagger","Une dague","Objet",true,"./images/weapons/tinydagger.gif");
		spectreVert1.getEquipementVect().add(dagueMrBoo);
		spectreVert1.setArmeEquipe(epeelongueMrBoo);
		spectreVert1.setArmureEquipe(cuirMrBoo);
		grille[12][28].add(spectreVert1);		*/
	
	
	
	
	
	////////////////////////////////////////////////////////
	//Chargement du premier terrain du personnage
	////////////////////////////////////////////////////////	
	
	public void chargementPremierTerrainPERSO(String nomGen){
		
		
		
		////////////////////////////////////////////////////////////////////////
		//if(!jeuInit2){creationUnivers();}//A METTRE EN COMMENTAIRE SI L'UNIVERS EST DEJA CREE
		
		creationUnivers();
		////////////////////////////////////////////////////////////////////////
		
		
		
		
		////SUPPRESSION DU CONTENU DU DOSSIER TERRAINSActuelsPerso
		File repertoire=new File("./TERRAINSActuelsPerso/");
		
		File[] list = repertoire.listFiles();
		
		for(int i=0;i<list.length;i++){
			list[i].delete();
		}
		
		
		
		
		
		
		
		//////////////////////////////////////////////////////////////
		////////////////////CHARGEMENT TERRAIN x0 y0 z0///////////////
		//////////////////////////////////////////////////////////////
		FileInputStream out2=null;
   		ObjectInputStream flux2=null;
		
		try{
				out2=new FileInputStream("./TERRAINSstockMonde/terrainx0y0z0.sav");
				flux2=new ObjectInputStream(out2);
				
				ArrayList[][] grid=(ArrayList[][])flux2.readObject();
				
				monde.grille=grid;
				
				
				monde.perso.indexTerrainX=0;
				monde.perso.indexTerrainY=0;
				monde.perso.indexTerrainZ=0;
				
				
				monde.perso.setCooX(28);
				monde.perso.setCooY(53);
				monde.grille[monde.perso.getCooX()][monde.perso.getCooY()].add(monde.perso);
				
			}
		catch(ClassNotFoundException f){f.printStackTrace();}
		catch(IOException i){i.printStackTrace();}
		finally{
			try {
		        flux2.close();
		  		out2.close();
			} 
			catch (IOException e1) {e1.printStackTrace();}
		}
		
		
		
		
		
		
		//////SAUVEGARDE DANS ACTUELS DUN ARRAYLIST AU NOM DU PERSO DE LA LISTE DES TERRAINS DEJA VUS////////
		
		ArrayList dv=new ArrayList();
		dv.add(nomGen+"terrainx0y0z0.sav");
		
		
		FileOutputStream out=null;
		ObjectOutputStream flux=null;
		try{
				out=new FileOutputStream("./TERRAINSActuelsPerso/"+nomGen+"DejaVus.dat");
				flux=new ObjectOutputStream(out);
				flux.writeObject(dv);
				flux.close();
				flux.flush();
				
			}
		catch(IOException i){i.printStackTrace();}
		finally{
			 try {
			    flux.flush();
			    flux.close();
			    out.close();
			 }
			 catch (IOException e1) {e1.printStackTrace();}
		}
		
		
		if(!jeuInit2){monde.ambiance();}
		
		
		jeuInit2=true;
		
		//*************************************
		cat.creationImagesCat(monde);
		//*************************************
		
	}
	
	
	
	
	
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	///////////////////////CREATION ET STOCKAGE UNIVERS (ONE TIME!!!!!!!!!)//////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	public void creationUnivers(){
	
		/////A METTRE EN COMMENTAIRE SI L'UNIVERS EST DEJA CREE//////
		
		generationX0Y0Zm1();// 1er etage au dessus niveau de départ
		sauvegardeTerrain("x0y0z-1");
		
		
		generationX0Y0Z0();// TERRAIN DE DEPART
		sauvegardeTerrain("x0y0z0");
		
		
		generationX0Ym2Z0();//nord nord
		sauvegardeTerrain("x0y-2z0");
		
		
		
		/////////////////////////////////////////////////////////////////
		////SUPPRESSION des FICHIERS .SAV DU DOSSIER TERRAINSActuelsPerso
		videur("./TERRAINSstockMonde/");
		
		/////////////////////////////////////////////////////////////////
		/////////////////////////////////////////////////////////////////
		
		unzip("./TERRAINSstockMonde/","terrainx0y0z0");
	}
	
	
	
	
	////////////////////////////////////////////////
	////////////////////////////////////////////////
	public void sauvegardeTerrain(String coord){
		
		FileOutputStream out=null;
		ObjectOutputStream flux=null;
		try{
				out=new FileOutputStream("./TERRAINSstockMonde/terrain"+coord+".sav");
				flux=new ObjectOutputStream(out);
				flux.writeObject(grille);
				flux.close();
				flux.flush();
				
			}
		catch(IOException i){i.printStackTrace();}
		finally{
			 try {
			    flux.flush();
			    flux.close();
			    out.close();
			 }
			 catch (IOException e1) {e1.printStackTrace();}
		}
		
		
		zip("./TERRAINSstockMonde/","terrain"+coord);
		
		
		
		
		
	}
	/////////////////////////////////////////////////////////////////////////////////
	public void videur(String dos){
		File repertoire=new File(dos);
		
        String direct = ".";
        File f1 = new File(direct);
        int k;
        String[] ls;
        FilenameFilter filter = new FiltreFichier("sav");
        //System.out.println("Sav Files: " );
        //for (ls = f1.list(filter), k = 0;
        //     ls != null && k < ls.length;
        //     System.out.println("\t" + ls[k++]));
    
		File[] list = repertoire.listFiles(filter);
		
		
		for(int i=0;i<list.length;i++){
			list[i].delete();
		}
		
		
	}
	
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	public void zip(String dossier,String nomFich){
		
   		/*************
   		 * Compression
   		 *************/
		try {
      	
      		// création d'un flux d'écriture sur fichier
			FileOutputStream dest = new FileOutputStream(dossier+nomFich+".zip");
			
			// calcul du checksum : Adler32 (plus rapide) ou CRC32
			CheckedOutputStream checksum = new CheckedOutputStream(dest, new Adler32());

      		// création d'un buffer d'écriture
			BufferedOutputStream buff = new BufferedOutputStream(checksum);
			
      		// création d'un flux d'écriture Zip
			ZipOutputStream out = new ZipOutputStream(buff);
			

         	// spécification de la méthode de compression
			out.setMethod(ZipOutputStream.DEFLATED);
			
			// spécifier la qualité de la compression 0..9
			out.setLevel(Deflater.BEST_COMPRESSION);
			
         
         	// buffer temporaire des données à écriture dans le flux de sortie
			byte data[] = new byte[BUFFER];
         
         
//JACKterrainx0y0z1.sav
         
			String fichier=new String(dossier+nomFich+".sav");
			
			FileInputStream fi = new FileInputStream(fichier);
	            
            // création d'un tampon de lecture sur ce flux
            BufferedInputStream buffi = new BufferedInputStream(fi, BUFFER);
            
            // création d'en entrée Zip pour ce fichier
            String [] fich=fichier.split(dossier);
            
            
            ZipEntry entry = new ZipEntry(unAccent(fich[1]));
            
            
            // ajout de cette entrée dans le flux d'écriture de l'archive Zip
            out.putNextEntry(entry);
            
            // écriture du fichier par paquet de BUFFER octets
            // dans le flux d'écriture
            int count;
            while((count = buffi.read(data, 0, BUFFER)) != -1) {
               out.write(data, 0, count);
			}
            
			// Close the current entry
     		out.closeEntry();
     		
     	    // fermeture du flux de lecture
			buffi.close();
			
			// fermeture du flux d'écriture
			out.close();
			buff.close();
			checksum.close();
			dest.close();

			//System.out.println("checksum: " + checksum.getChecksum().getValue());

         
		// traitement de toute exception         
		} catch(Exception e) {
			e.printStackTrace();
		}
		
		
		
		
		
	}
	
	
	
	public static String unAccent(String s) {
		String temp = Normalizer.normalize(s, Normalizer.DECOMP, 0);
		return temp.replaceAll("[^\\p{ASCII}]","");
	}
	
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////	
	public void unzip(String dossier,String nomFich){
		
   		 
		try {
			
			// fichier destination
			BufferedOutputStream dest = null;
			
			// ouverture fichier entrée
			FileInputStream fis = new FileInputStream(dossier+nomFich+".zip");
			
			// ouverture fichier de buffer
			BufferedInputStream buffi = new BufferedInputStream(fis);
			
			// ouverture archive Zip d'entrée
			ZipInputStream zis = new ZipInputStream(buffi);
			
			// entrée Zip
			ZipEntry entry;

			// parcours des entrées de l'archive
			while((entry = zis.getNextEntry()) != null) {
				
				// affichage du nom de l'entrée
				//System.out.println("Extracting: " +entry);
				
				int count;
				byte data[] = new byte[BUFFER];
				
				// création fichier
				//FileOutputStream fos = new FileOutputStream(entry.getName());
				FileOutputStream fos = new FileOutputStream(dossier+entry.getName());
				
				
				// affectation buffer de sortie
				dest = new BufferedOutputStream(fos, BUFFER);
				
				// écriture sur disque
				while ((count = zis.read(data, 0, BUFFER)) != -1) {
					dest.write(data, 0, count);
				}
				
				// vidage du tampon
				dest.flush();
				
				// fermeture fichier
				dest.close();
			}
			
			// fermeture archive
			zis.close();
			
		} catch(Exception e) {
			e.printStackTrace();
		}
		
	}
	
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////
	
	
	
	
	
	
	
	//////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////
	//
	//							TERRAINS PREDEFINIS
	//
	//////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////	
		
		
	
	public void generationX0Ym2Z0(){//nord nord
		grille=new ArrayList[tailleGrille][tailleGrille];
	
		//REMPLIR LA GRILLE
		
		// 0. CREATION DE LA BORDURE
		
		Vide vide=new Vide();
		for(int x=0;x<monde.tailleGrille;x++){
			for(int y=0;y<tailleGrille;y++){
				grille[x][y]=new ArrayList();	
				grille[x][y].add(vide);
			}
			
		}
		
		
		Entite objetBord=new Entite();
		// 0.1 on enleve les vides en trop //
		//Attention il faudra par la suite que toute la surface jouable soit remplie !
		for(int rx=10;rx<tailleGrille-10;rx++){
			for(int ry=10;ry<tailleGrille-10;ry++){
				
				
        		
        		if(!grille[rx][ry].isEmpty()){
        			
        			for(int i=0;i<grille[rx][ry].size();i++){
					
		 					
			 			try{
			 					
			 					
			 				objetBord = (Entite) grille[rx][ry].get(i);
		 					
		 					String strType ;			
							strType = (objetBord.getClass().getName());
							
							if(strType.compareTo("Vide")==0){
								grille[rx][ry].remove(objetBord);
							}
							
							
							
						}
						catch(NoSuchElementException exc){};
					}
				
				}
			
			}
		}
		/////////////////////////////////////////////////////////////////////
		
		
		
		/////////////HERBE///////////////////////////////////////////////////
		Surface h1=new Surface(true,"./images/surfaces/herbe.gif",1,false);
		Surface h2=new Surface(true,"./images/surfaces/herbesombre.gif",1,false);
		Surface h3=new Surface(true,"./images/surfaces/ground0.gif",1,false);
		
		for(int rx=10;rx<tailleGrille-10;rx++){
			for(int ry=10;ry<tailleGrille-10;ry++){
        		
 				int rndm=(int)((Math.random()*100)+1);	
 				if(rndm<50){grille[rx][ry].add(h1);}
 				if(rndm>=50 && rndm<75){grille[rx][ry].add(h2);}
 				if(rndm>=75){grille[rx][ry].add(h3);}
 						
			}
		}
		
		
		///////////////////////////////////////////////////////
		for(int rx=10;rx<tailleGrille-10;rx++){
			for(int ry=10;ry<tailleGrille-10;ry++){
				
				
					////ORCS
        		if(((int)(Math.abs(Math.random()*1000))+1)<=2){
        			
        			GoblinoidCategory gob=new GoblinoidCategory(false,"gobelin","Un gobelin","A goblin",true,"Creature",true,"./images/creatures/goblinoid/orc2.gif","./images/creatures/corpse.gif","./sons/goblin.wav");
					gob.setCooX(rx);
					gob.setCooY(ry);
        			grille[rx][ry].add(gob);
        			
        			
        		}
        		
        		
        		////SKEL
        		else if(((int)(Math.abs(Math.random()*1000))+1)<=2){
        			UndeadCategory skel=new UndeadCategory(false,"lesser skeleton","Un squelette","A skeleton",true,"Creature",true,"./images/creatures/undead/funkysquelette.gif","./images/creatures/bones.gif","./sons/gravel.wav");
					skel.setCooX(rx);
					skel.setCooY(ry);
        			grille[rx][ry].add(skel);
        		}
				
				
				if(rx!=54 && ry!=82){
				
	        		////ARBRES
	        		if(((int)(Math.abs(Math.random()*100))+1)>95){
	        			String ti=new String();
	        			String tiC=new String();
	        			
	        			//int roll=((int)(Math.abs(Math.random()*100))+1);
	        			
	        			
	        			ti="t"+((int)(Math.abs(Math.random()*39))+6)+".gif";
	        			tiC="tallTreeCasse.gif";
	        			
	        			
	        			
	        			grille[rx][ry].add(new Arbre(false,"mediumtree","Un arbre","A tree","Obstacle",true,"./images/vegetation/"+ti,"./images/vegetation/"+tiC));
	        		}
	        		
	        	
	        		
	        		////TOMBES
	        		else if(((int)(Math.abs(Math.random()*100))+1)==100){
	        			String ti=new String();
	        			if(((int)(Math.abs(Math.random()*100))+1)<50){
	        				ti="pierretombale.gif";
	        			}
	        			else{ti="tombstone.gif";
	        			}
	        			grille[rx][ry].add(new Ecrit(false,"standardpierretombale","Une pierre tombale","A tombstone","Ecrit",true,"./images/ecrits/"+ti,"R.I.P","R.I.P"));
	        		}
        		}
        			
			}
		}
		
		
		
		//nettoyage arbres et tombes sur la zone de la maison
		for(int rx=47;rx<=60;rx++){
			for(int ry=77;ry<=85;ry++){
				
        		if(!grille[rx][ry].isEmpty()){
        			
        			for(int i=0;i<grille[rx][ry].size();i++){
					
		 					
			 			try{
			 					
			 					
			 				objetBord = (Entite) grille[rx][ry].get(i);
		 					
							if(objetBord.getTypeObjet().compareTo("Obstacle")==0 || objetBord.getClass().getName().compareTo("Ecrit")==0){
								grille[rx][ry].remove(objetBord);
							}
							
							
							
						}
						catch(NoSuchElementException exc){};
					}
				
				}
			
			}
		}
		
		new ExtendedSol(grille,47,77,12,7,"./images/surfaces/roomFloor31.gif",2,true);
		new ExtendedWall(grille,"standardwall","Un mur","A wall",47,77,12,"h","./images/walls/w9.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",47,78,6,"v","./images/walls/w9.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",47,85,12,"h","./images/walls/w9.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",59,78,6,"v","./images/walls/w9.gif");
		
		new Foreuse(grille,"Wall",47,83,0,0);
		grille[47][83].add(new Gate("Une fenetre","A window",false,30,false,false,"standardwindow",true,"./images/doors/roomWindow31.gif","./images/doors/roomWindow0.gif","./images/walls/w9.gif","./sons/door_open.wav","./sons/door_close.wav"));
		new Foreuse(grille,"Wall",47,81,0,0);
		grille[47][81].add(new Gate("Une porte","A door",false,75,false,false,"standarddoor",true,"./images/doors/door31.gif","./images/doors/openDoor31.gif","./images/walls/w9.gif","./sons/door_open.wav","./sons/door_close.wav"));
		
		
		new ExtendedWall(grille,"standardwall","Un mur","A wall",52,78,6,"v","./images/walls/w9.gif");
		new Foreuse(grille,"Wall",52,80,0,0);
		grille[52][80].add(new Gate("Une porte","A door",false,60,false,false,"standarddoor",true,"./images/doors/door31.gif","./images/doors/openDoor31.gif","./images/walls/w9.gif","./sons/door_open.wav","./sons/door_close.wav"));
		grille[51][80].add(new Piege(monde,false,4,500,true,150,false,"explosivetrap","mine","exploding trap","Piege",false,"./images/pieges/piegeskull.gif","./sons/explosion.wav"));
		
		
		Contenant coffre1=new Contenant(cat,monde,false,true,false,50,false,false,"coffrestandard","Un coffre","A chest",true,"./images/contenant/coffrestandardferme.gif","./images/contenant/coffrestandardouvert.gif","./sons/door_open.wav","./sons/door_close.wav");
		grille[58][80].add(coffre1);
		Vector contenuCoffre1=new Vector();
		contenuCoffre1.add(new Arme(false,"flail","Fleau de puissance","The Power Flail",20,"Objet",true,"./images/weapons/goldenflail.gif"));
		contenuCoffre1.add(new Armure(false,"mail","Maille de haute magie","The High Magic Mail",20,"Objet",true,"./images/armors/goldenmail.gif"));
		coffre1.setContenu(contenuCoffre1);
		
		

		grille[54][82].add(new Escalier(false,"standardstairDOWN","Un escalier vers le bas","down stair","Escalier",true,"./images/escaliers/escalierdown.gif"));
		
		
		grille[46][80].add(new Ecrit(false,"standardscroll","Une lettre","A writ","Ecrit",true,"./images/ecrits/scroll.gif","Vous entrez a vos risques et perils...","You re warned, this is a perilous place..."));
		
	
		/*
		CthulianCategory tent=new CthulianCategory(false,"tentaclesphere","Une chose tentaculaire",true,"Creature",true,"./images/creatures/cthulian/tentaclesphere.gif","./images/creatures/corpse.gif");
		tent.setCooX(54);
		tent.setCooY(81);
		grille[54][81].add(tent);
		
		
		CthulianCategory larve=new CthulianCategory(false,"stellarlarva","Une larve stellaire",true,"Creature",true,"./images/creatures/cthulian/stellarlarva.gif","./images/creatures/corpse.gif");
		larve.setCooX(54);
		larve.setCooY(80);
		grille[54][80].add(larve);
		*/
		
		DemonCategory bal=new DemonCategory(false,"balrog","Marcel le Balrog","Jimmy the Balrog",true,"Creature",true,"./images/creatures/demon/balrog.gif","./images/creatures/corpse.gif","./sons/balrog.wav");
		bal.setCooX(54);
		bal.setCooY(79);
		grille[54][79].add(bal);
		
		
		grille[39][82].add(new Activable(39,82,null,"+T0T+T0T+T0T31T48",true,0,false,"teleporteurFixe","Un teleporteur activable","A usable teleporter","Activable",true,"./images/activable/teleporteuractivable.gif","./images/activable/teleporteuractivable.gif","./sons/detect.wav"));
		
		
		////////////////////////////////////////////////////////////////////////////////
		
	}	
	
	
	

	
	//////////////////////////////////////////////////////////////////	
	//////////////////////////////////////////////////////////////////	
	//////////////////////////////////////////////////////////////////
		
	public void generationX0Y0Zm1(){//au dessus niveau de depart
		grille=new ArrayList[tailleGrille][tailleGrille];
		
		
		////////////////CREATION DE LA BORDURE/////////////////
		Vide vide=new Vide();
		for(int x=0;x<tailleGrille;x++){
			for(int y=0;y<tailleGrille;y++){
				grille[x][y]=new ArrayList();	
				grille[x][y].add(vide);
			}
		}
		
		Entite objetBord=new Entite();
		for(int rx=10;rx<tailleGrille-10;rx++){
			for(int ry=10;ry<tailleGrille-10;ry++){
				
        		if(!grille[rx][ry].isEmpty()){
					
	        		for(int i=0;i<grille[rx][ry].size();i++){
						
			 			try{
			 					
			 				objetBord = (Entite) grille[rx][ry].get(i);
		 					
		 					String strType ;			
							strType = (objetBord.getClass().getName());
							
							if(strType.compareTo("Vide")==0){
								grille[rx][ry].remove(objetBord);
							}
							
						}
						catch(NoSuchElementException exc){};
					}
				}
			
			}
		}
		/////////////////////////////////////////////////////
	
		
		//new ExtendedSol(grille,10,10,tailleGrille-21,tailleGrille-21,"./images/surfaces/herbe.gif",1);
		/////////////HERBE///////////////////////////////////////////////////
		Surface h1=new Surface(true,"./images/surfaces/herbe.gif",1,false);
		Surface h2=new Surface(true,"./images/surfaces/herbesombre.gif",1,false);
		Surface h3=new Surface(true,"./images/surfaces/ground0.gif",1,false);
		
		for(int rx=10;rx<tailleGrille-10;rx++){
			for(int ry=10;ry<tailleGrille-10;ry++){
        		
 				int rndm=(int)((Math.random()*100)+1);	
 				if(rndm<50){grille[rx][ry].add(h1);}
 				if(rndm>=50 && rndm<75){grille[rx][ry].add(h2);}
 				if(rndm>=75){grille[rx][ry].add(h3);}
 						
			}
		}
		
		//new Remplisseur(grille,"standardwall","Un mur","Wall",30,20,15,25,false,"./images/walls/roomWall11.gif");
		new ExtendedWall(grille,"indestructiblewall","Un mur","A wall",30,20,14,"h","./images/walls/roomWall11.gif");
		new ExtendedWall(grille,"indestructiblewall","Un mur","A wall",30,20,14,"v","./images/walls/roomWall11.gif");
		new ExtendedWall(grille,"indestructiblewall","Un mur","A wall",45,20,14,"v","./images/walls/roomWall11.gif");
		new ExtendedWall(grille,"indestructiblewall","Un mur","A wall",30,35,15,"h","./images/walls/roomWall11.gif");
		new ExtendedSol(grille,31,21,13,13,"./images/surfaces/roomFloor31.gif",2,true);
		new Remplisseur(grille,"indestructiblewall","Un mur","A wall","Wall",16,26,13,10,"./images/walls/roomWall11.gif",0,true);
		
		new Foreuse(grille,"Wall",26,32,4,0);
		new Foreuse(grille,"Wall",21,29,4,4);
		new ExtendedSol(grille,26,32,4,0,"./images/surfaces/roomFloor31.gif",2,true);
		new ExtendedSol(grille,21,29,4,4,"./images/surfaces/roomFloor31.gif",2,true);
		
		grille[26][32].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"));
		
		
		grille[33][23].add(new Escalier(false,"standardstairDOWN","Un escalier vers le bas","Down stair","Escalier",true,"./images/escaliers/escalierdown.gif"));
		
		//test
		//grille[36][27].add(new Escalier(false,"standardstairUP","Un escalier vers le haut","Escalier",true,"./images/escaliers/escalierup.gif"));
		
		grille[36][22].add(new Arme(false,"dagger","Une dague magique","A magic dagger",5,"Objet",true,"./images/weapons/tinydagger.gif"));
		grille[36][25].add(new EcritMagique(36,25,false,"magicscroll","Parchemin de teleportation parametrable","Scroll of custom teleportation","EcritMagique",true,"./images/ecritsmagiques/scroll2.gif",new Spell("customteleport","Teleportation Parametrable","Custom Teleportation","./sons/detect.wav","./images/sorts/teleport1.gif")));		
		grille[36][26].add(new EcritMagique(36,26,false,"magicscroll","Parchemin de teleportation parametrable","Scroll of custom teleportation","EcritMagique",true,"./images/ecritsmagiques/scroll2.gif",new Spell("customteleport","Teleportation Parametrable","Custom Teleportation","./sons/detect.wav","./images/sorts/teleport1.gif")));		
		grille[36][27].add(new EcritMagique(36,27,false,"magicscroll","Parchemin de teleportation parametrable","Scroll of custom teleportation","EcritMagique",true,"./images/ecritsmagiques/scroll2.gif",new Spell("customteleport","Teleportation Parametrable","Custom Teleportation","./sons/detect.wav","./images/sorts/teleport1.gif")));		
		grille[36][28].add(new EcritMagique(36,28,false,"magicscroll","Parchemin de teleportation parametrable","Scroll of custom teleportation","EcritMagique",true,"./images/ecritsmagiques/scroll2.gif",new Spell("customteleport","Teleportation Parametrable","Custom Teleportation","./sons/detect.wav","./images/sorts/teleport1.gif")));		
		grille[36][29].add(new EcritMagique(36,29,false,"magicscroll","Parchemin de teleportation parametrable","Scroll of custom teleportation","EcritMagique",true,"./images/ecritsmagiques/scroll2.gif",new Spell("customteleport","Teleportation Parametrable","Custom Teleportation","./sons/detect.wav","./images/sorts/teleport1.gif")));		
		
		grille[37][25].add(new EcritMagique(37,25,false,"magicscroll","Parchemin d'invisibilite","Scroll of invisibility","EcritMagique",true,"./images/ecritsmagiques/scroll2.gif",new Spell("invisibility","Invisibilite","Invisibility","./sons/magic_spell_casting.wav","./images/sorts/1.gif")));		
		
		grille[37][26].add(new EcritMagique(37,26,false,"magicscroll","Parchemin de passe-muraille","Scroll of ectoplasmic consistency","EcritMagique",true,"./images/ecritsmagiques/scroll1.gif",new Spell("passemuraille","Passe-Muraille","Ectoplasmic Consistency","./sons/gulp.wav","./images/sorts/4.gif")));		
		
		grille[37][27].add(new EcritMagique(37,27,false,"grimoire","Grimoire d'invisibilite","Spellbook of invisibility","EcritMagique",true,"./images/ecritsmagiques/grim17.gif",new Spell("invisibility","Invisibilite","Invisibility","./sons/magic_spell_casting.wav","./images/sorts/1.gif")));		
		grille[37][28].add(new EcritMagique(37,28,false,"grimoire","Grimoire de teleportation parametrable","Spellbook of custom teleportation","EcritMagique",true,"./images/ecritsmagiques/grim12.gif",new Spell("customteleport","Teleportation Parametrable","Custom Teleportation","./sons/detect.wav","./images/sorts/teleport1.gif")));		
		grille[37][29].add(new EcritMagique(37,29,false,"grimoire","Grimoire de passe-muraille","Spellbook of ectoplasmic consistency","EcritMagique",true,"./images/ecritsmagiques/grim15.gif",new Spell("passemuraille","Passe-Muraille","Ectoplasmic Consistency","./sons/gulp.wav","./images/sorts/4.gif")));		
		
		
		
		grille[40][24].add(new EcritMagique(40,24,false,"magicscroll","Parchemin d'infravision","Scroll of infravision","EcritMagique",true,"./images/ecritsmagiques/scroll2.gif",new Spell("nightvision","Infravision","Infravision","./sons/magic_spell_casting.wav","./images/sorts/infravision.gif")));		
		grille[41][24].add(new EcritMagique(41,24,false,"grimoire","Grimoire d'infravision","Spellbook of infravision","EcritMagique",true,"./images/ecritsmagiques/grim15.gif",new Spell("nightvision","Infravision","Infravision","./sons/magic_spell_casting.wav","./images/sorts/infravision.gif")));		
		
		grille[40][25].add(new EcritMagique(40,25,false,"magicscroll","Parchemin de rayonX","Scroll of X-ray vision","EcritMagique",true,"./images/ecritsmagiques/scroll1.gif",new Spell("rayonx","RayonX","X-Ray","./sons/magic_spell_casting.wav","./images/sorts/rayonX.gif")));		
		grille[41][25].add(new EcritMagique(41,25,false,"grimoire","Grimoire de rayonX","Spellbook of X-ray vision","EcritMagique",true,"./images/ecritsmagiques/grim11.gif",new Spell("rayonx","RayonX","X-Ray","./sons/magic_spell_casting.wav","./images/sorts/rayonX.gif")));		
		
		grille[40][26].add(new EcritMagique(40,26,false,"magicscroll","Parchemin de vol","Scroll of Fly","EcritMagique",true,"./images/ecritsmagiques/scroll1.gif",new Spell("fly","Vol","Fly","./sons/magic_spell_casting.wav","./images/sorts/fly.gif")));		
		grille[41][26].add(new EcritMagique(41,26,false,"grimoire","Grimoire de vol","Spellbook of Fly","EcritMagique",true,"./images/ecritsmagiques/grim8.gif",new Spell("fly","Vol","Fly","./sons/magic_spell_casting.wav","./images/sorts/fly.gif")));		
		
		
		
		
		
		
		
		
		UndeadCategory mum=new UndeadCategory(false,"mummy","Une momie","A mummy",true,"Creature",true,"./images/creatures/undead/mummy.gif","./images/creatures/bones.gif","./sons/mummy.wav");
		mum.setCooX(24);
		mum.setCooY(32);
		grille[24][32].add(mum);
		
	}
	
	
	//////////////////////////////////////////////////////////////////	
	//////////////////////////////////////////////////////////////////	
	//////////////////////////////////////////////////////////////////
	public void generationX0Y0Z0(){
		grille=new ArrayList[tailleGrille][tailleGrille];
		//une grille de tailleGrille sur tailleGrille  (X 32 = pixels)
		//le terrain jouable est à l'interieur et fait tailleGrille-10 sur tailleGrille-10 
		//mais l'affichage dans TerrainPanel fera 640*480 soit 20 sur 15 tiles
		
		
		//REMPLIR LA GRILLE
		
		// 0. CREATION DE LA BORDURE
		
		Vide vide=new Vide();
		for(int x=0;x<monde.tailleGrille;x++){
			for(int y=0;y<tailleGrille;y++){
				grille[x][y]=new ArrayList();	
				grille[x][y].add(vide);
			}
			
		}
		// 0.1 on enleve les vides en trop //
		//Attention il faudra par la suite que toute la surface jouable soit remplie !
		
		Entite objetBord=new Entite();
		for(int rx=10;rx<tailleGrille-10;rx++){
			for(int ry=10;ry<tailleGrille-10;ry++){
				
				
        		
        		if(!grille[rx][ry].isEmpty()){
        			
        			for(int i=0;i<grille[rx][ry].size();i++){
					
		 					
			 			try{
			 					
			 					
			 				objetBord = (Entite) grille[rx][ry].get(i);
		 					
		 					String strType ;			
							strType = (objetBord.getClass().getName());
							
							if(strType.compareTo("Vide")==0){
								grille[rx][ry].remove(objetBord);
							}
							
							
							
						}
						catch(NoSuchElementException exc){};
					}
				
				}
			
			}
		}
		///////////////////////////////////////////////////////
		
		
		//TEST VIDE
		//VraiVide vv=new VraiVide();
		//grille[28][52].add(vv);
		//grille[28][51].add(vv);
		
		
		////////////////////////////////////////////////////////////////////////////////
		//new ExtendedSol(grille,10,10,tailleGrille-21,tailleGrille-21,"./images/surfaces/herbe.gif",1);
		/////////////HERBE///////////////////////////////////////////////////
		Surface h1=new Surface(true,"./images/surfaces/herbe.gif",1,false);
		Surface h2=new Surface(true,"./images/surfaces/herbesombre.gif",1,false);
		Surface h3=new Surface(true,"./images/surfaces/ground0.gif",1,false);
		
		for(int rx=10;rx<tailleGrille-10;rx++){
			for(int ry=10;ry<tailleGrille-10;ry++){
        		
 				int rndm=(int)((Math.random()*100)+1);	
 				if(rndm<50){grille[rx][ry].add(h1);}
 				if(rndm>=50 && rndm<75){grille[rx][ry].add(h2);}
 				if(rndm>=75){grille[rx][ry].add(h3);}
 						
			}
		}
		
		
		new ExtendedSol(grille,17,20,0,5,"./images/surfaces/floor23.gif",2,true);
		
		new ExtendedSol(grille,17,27,11,9,"./images/surfaces/floor23.gif",2,true);
		
		new ExtendedSol(grille,16,16,4,2,"./images/surfaces/roomFloor12.gif",2,true);
		
		//route
		new ExtendedSol(grille,28,37,0,26,"./images/surfaces/f6.gif",1,false);
		
		new ExtendedSol(grille,32,47,9,15,"./images/surfaces/champA1.gif",1,false);
		
		
		for(int rx=32;rx<41;rx++){
			for(int ry=47;ry<62;ry++){
				
				if((int)((Math.random()*100)+1)<=5){
					grille[rx][ry].add(new Nourriture(false,"potiron","potiron","pumpkin","Comestible",true,"./images/comestible/potiron.gif"));
			
				}	
		
			}
		}
		
		
		
		new ExtendedSol(grille,17,34,8,0,"./images/surfaces/roomFloor23.gif",2,true);
		
		
		new Remplisseur(grille,null,null,null,"Sol",31,22,16,16,"./images/surfaces/floor33.gif",2,true);
		
		
		// 2.Les obstacles////////////////////////////
		
		new ExtendedWall(grille,"standardwall","Un mur","A wall",19,26,10,"h","./images/walls/roomWall33.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",29,27,10,"v","./images/walls/roomWall33.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",16,27,10,"v","./images/walls/roomWall33.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",17,37,10,"h","./images/walls/roomWall33.gif");
		
		new ExtendedWall(grille,"standardwall","Un mur","A wall",21,15,4,"v","./images/walls/roomWall33.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",18,19,1,"h","./images/walls/roomWall33.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",18,20,6,"v","./images/walls/roomWall33.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",18,15,2,"h","./images/walls/roomWall33.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",16,15,0,"h","./images/walls/roomWall33.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",15,15,4,"v","./images/walls/roomWall33.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",16,19,7,"v","./images/walls/wall21.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",17,31,7,"h","./images/walls/wall21.gif");
		new ExtendedWall(grille,"standardwall","Un mur","A wall",26,31,2,"h","./images/walls/wall21.gif");
		
		
		new Remplisseur(grille,"standardwall","Un mur","A wall","Wall",30,20,17,19,"./images/walls/roomWall11.gif",0,true);
		
		///RIVIERE
		new Remplisseur(grille,"water","eau","water","Water",10,56,79,0,"./images/surfaces/water1.gif",0,false);
		
		//PONT
		grille[28][55].add(new Passage(false,"pontbois","pont en bois","wood bridge","Passage",true,"./images/passage/pontB3.gif","./images/walls/rocks.gif"));
		grille[28][56].add(new Passage(false,"pontbois","pont en bois","wood bridge","Passage",true,"./images/passage/pontB2.gif","./images/walls/rocks.gif"));
		grille[28][57].add(new Passage(false,"pontbois","pont en bois","wood bridge","Passage",true,"./images/passage/pontB1.gif","./images/walls/rocks.gif"));
		
		
		///*******
		
		new Foreuse(grille,"Wall",29,29,1,0);
		new Foreuse(grille,"Wall",29,34,1,0);
		
		new Foreuse(grille,"Wall",31,29,2,0);
		new Foreuse(grille,"Wall",31,34,2,0);
		
		new Foreuse(grille,"Wall",33,23,0,9);
		new Foreuse(grille,"Wall",33,33,0,0);
		new Foreuse(grille,"Wall",34,29,2,0);
		
		new Foreuse(grille,"Wall",37,24,5,9);
		
		new Foreuse(grille,"Wall",39,22,0,1);
		
		new Foreuse(grille,"Wall",39,34,0,0);
		new Foreuse(grille,"Wall",38,35,2,1);
		new Foreuse(grille,"Wall",43,30,0,0);
		new Foreuse(grille,"Wall",44,29,2,2);
		
		
		grille[29][29].add(new Surface(true,"./images/surfaces/floor23.gif",2,true));
		
		grille[29][34].add(new Surface(true,"./images/surfaces/floor23.gif",2,true));
		
		
	
		grille[13][18].add(new Arbre(false,"mediumtree","Un Chene","An Oak","Obstacle",true,"./images/vegetation/t24.gif","./images/vegetation/tallTreeCasse.gif"));
		
		grille[25][19].add(new Arbre(false,"mediumtree","Un Chene","An Oak","Obstacle",true,"./images/vegetation/t22.gif","./images/vegetation/tallTreeCasse.gif"));
		
		grille[21][21].add(new Arbre(false,"mediumtree","Un Chene","An Oak","Obstacle",true,"./images/vegetation/t24.gif","./images/vegetation/tallTreeCasse.gif"));
		
		grille[20][24].add(new Arbre(false,"mediumtree","Un Chene","An Oak","Obstacle",true,"./images/vegetation/t22.gif","./images/vegetation/tallTreeCasse.gif"));
		
		//////////////////////////////////////////////
		///////////////////////////////////////////////////////
		for(int rx=12;rx<=24;rx++){
			for(int ry=40;ry<=87;ry++){
				
        		////ARBRES
        		if(((int)(Math.abs(Math.random()*100))+1)>95){
        			String ti=new String();
	        			String tiC=new String();
	        			
	        			
	        			ti="t"+((int)(Math.abs(Math.random()*39))+6)+".gif";
	        			tiC="tallTreeCasse.gif";
	        			
	        			/*
	        			int roll=((int)(Math.abs(Math.random()*100))+1);
	        			if(roll<25){
	        				ti="tallTree.gif";
	        				tiC="tallTreeCasse.gif";
	        			}
	        			else if(roll>=25 && roll<50){
	        				ti="arbuste.gif";
	        				tiC="arbusteCasse.gif";
	        			}
	        			else if(roll>=50 && roll<75){
	        				ti="sapin.gif";
	        				tiC="sapinCasse.gif";
	        			}
	        			else{
	        				ti="arbremort.gif";
	        				tiC="arbremortCasse.gif";
	        			}*/
	        			
	        			
	        			grille[rx][ry].add(new Arbre(false,"mediumtree","Un arbre","A tree","Obstacle",true,"./images/vegetation/"+ti,"./images/vegetation/"+tiC));
	        		}
        		
    		
    			
			}
		}
		
		for(int rx=27;rx<=87;rx++){
			for(int ry=64;ry<=87;ry++){
				
        		////ARBRES
        		if(((int)(Math.abs(Math.random()*100))+1)>95){
        			String ti=new String();
	        			String tiC=new String();
	        			
	        			/*
	        			int roll=((int)(Math.abs(Math.random()*100))+1);
	        			if(roll<25){
	        				ti="tallTree.gif";
	        				tiC="tallTreeCasse.gif";
	        			}
	        			else if(roll>=25 && roll<50){
	        				ti="arbuste.gif";
	        				tiC="arbusteCasse.gif";
	        			}
	        			else if(roll>=50 && roll<75){
	        				ti="sapin.gif";
	        				tiC="sapinCasse.gif";
	        			}
	        			else{
	        				ti="arbremort.gif";
	        				tiC="arbremortCasse.gif";
	        			}*/
	        			
	        			ti="t"+((int)(Math.abs(Math.random()*39))+6)+".gif";
	        			tiC="tallTreeCasse.gif";
	        			
	        			
	        			grille[rx][ry].add(new Arbre(false,"mediumtree","Un arbre","A tree","Obstacle",true,"./images/vegetation/"+ti,"./images/vegetation/"+tiC));
	        		}
        		
    		
    			
			}
		}
		
		for(int rx=48;rx<=87;rx++){
			for(int ry=11;ry<=62;ry++){
				
        		////ARBRES
        		if(((int)(Math.abs(Math.random()*100))+1)>95){
        			String ti=new String();
	        			String tiC=new String();
	        			
	        			ti="t"+((int)(Math.abs(Math.random()*39))+6)+".gif";
	        			tiC="tallTreeCasse.gif";
	        			
	        			/*
	        			int roll=((int)(Math.abs(Math.random()*100))+1);
	        			if(roll<25){
	        				ti="tallTree.gif";
	        				tiC="tallTreeCasse.gif";
	        			}
	        			else if(roll>=25 && roll<50){
	        				ti="arbuste.gif";
	        				tiC="arbusteCasse.gif";
	        			}
	        			else if(roll>=50 && roll<75){
	        				ti="sapin.gif";
	        				tiC="sapinCasse.gif";
	        			}
	        			else{
	        				ti="arbremort.gif";
	        				tiC="arbremortCasse.gif";
	        			}*/
	        			
	        			
	        			grille[rx][ry].add(new Arbre(false,"mediumtree","Un arbre","A tree","Obstacle",true,"./images/vegetation/"+ti,"./images/vegetation/"+tiC));
	        		}
        		
    		
    			
			}
		}
		
		    		
		
		// 3. les portes///////////////////////////
		grille[17][26].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"));
		
		grille[17][15].add(new Gate("Une porte","A door",false,50,false,false,"standarddoor",true,"./images/doors/door12.gif","./images/doors/openDoor12.gif","./images/walls/roomWall33.gif","./sons/door_open.wav","./sons/door_close.wav"));
		
		grille[17][19].add(new Gate("Une porte","A door",false,50,false,false,"standarddoor",true,"./images/doors/door12.gif","./images/doors/openDoor12.gif","./images/walls/roomWall33.gif","./sons/door_open.wav","./sons/door_close.wav"));
		
		grille[20][19].add(new Gate("Une fenetre","A window",false,20,false,false,"standardwindow",true,"./images/doors/roomWindow31.gif","./images/doors/roomWindow0.gif","./images/walls/roomWall33.gif","./sons/door_open.wav","./sons/door_close.wav"));
		
		
		
		grille[26][41].add(new Wall(false,"statue","statue","statue","Obstacle",true,"./images/deco/s3b.gif","./images/walls/rocks.gif"));
		
		grille[30][41].add(new Wall(false,"statue","statue","statue","Obstacle",true,"./images/deco/s3.gif","./images/walls/rocks.gif"));
		
		
		grille[34][41].add(new Wall(false,"colonne","colonne","column","Obstacle",true,"./images/special/pillar.gif","./images/walls/rocks.gif"));
		grille[38][41].add(new Wall(false,"colonne","colonne","column","Obstacle",true,"./images/special/pillar.gif","./images/walls/rocks.gif"));
		grille[42][41].add(new Wall(false,"colonne","colonne","column","Obstacle",true,"./images/special/pillar.gif","./images/walls/rocks.gif"));
		grille[46][41].add(new Wall(false,"colonne","colonne","column","Obstacle",true,"./images/special/pillar.gif","./images/walls/rocks.gif"));
				
		
		
		////////////////
		///////////////
		////Activables
		
		Gate ga0=new Gate("Une porte","A door",true,75,false,false,"standarddoor",false,"./images/doors/door0.gif","./images/doors/openDoor0.gif","./images/walls/wall21.gif","./sons/door_open.wav","./sons/door_close.wav");
		grille[25][31].add(ga0);
		ArrayList entitesCibleListB=new ArrayList();
		entitesCibleListB.add(ga0);
		grille[26][30].add(new Activable(26,30,entitesCibleListB,null,true,75,false,"levierPorte","Un levier","A lever","Activable",true,"./images/activable/levierON.gif","./images/activable/levierOFF.gif","./sons/get.wav"));
		
		
		Gate ga=new Gate("Une porte","A door",true,75,false,false,"standarddoor",true,"./images/doors/door12.gif","./images/doors/openDoor12.gif","./images/walls/roomWall33.gif","./sons/door_open.wav","./sons/door_close.wav");
		grille[28][37].add(ga);
		Gate ga2=new Gate("Une porte","A door",false,75,false,false,"standarddoor",true,"./images/doors/door33.gif","./images/doors/openDoor33.gif","./images/walls/roomWall33.gif","./sons/door_open.wav","./sons/door_close.wav");
		grille[30][29].add(ga2);
		Gate ga3=new Gate("Une porte","A door",true,75,true,false,"standarddoor",true,"./images/doors/door33.gif","./images/doors/openDoor33.gif","./images/walls/roomWall33.gif","./sons/door_open.wav","./sons/door_close.wav");
		grille[30][34].add(ga3);
		ArrayList entitesCibleListA=new ArrayList();
		entitesCibleListA.add(ga);
		entitesCibleListA.add(ga2);
		entitesCibleListA.add(ga3);
		grille[29][38].add(new Activable(29,38,entitesCibleListA,null,true,75,false,"levierPorte","Un levier","A lever","Activable",true,"./images/activable/levierON.gif","./images/activable/levierOFF.gif","./sons/get.wav"));
		
		
		
		
		Gate ga4=new Gate("Une porte","A door",false,500,false,false,"standarddoor",false,"./images/doors/door0.gif","./images/doors/openDoor0.gif","./images/walls/roomWall11.gif","./sons/door_open.wav","./sons/door_close.wav");
		grille[39][23].add(ga4);
		Gate ga5=new Gate("Une porte","A door",false,500,false,false,"standarddoor",false,"./images/doors/door0.gif","./images/doors/openDoor0.gif","./images/walls/roomWall11.gif","./sons/door_open.wav","./sons/door_close.wav");
		grille[39][34].add(ga5);
		Gate ga6=new Gate("Une porte","A door",true,500,false,false,"standarddoor",true,"./images/doors/door0.gif","./images/doors/openDoor0.gif","./images/walls/roomWall11.gif","./sons/door_open.wav","./sons/door_close.wav");
		grille[36][29].add(ga6);
		Gate ga7=new Gate("Une porte","A door",false,500,false,false,"standarddoor",false,"./images/doors/door0.gif","./images/doors/openDoor0.gif","./images/walls/roomWall11.gif","./sons/door_open.wav","./sons/door_close.wav");
		grille[43][30].add(ga7);
		
		ArrayList entitesCibleListC=new ArrayList();
		entitesCibleListC.add(ga4);
		entitesCibleListC.add(ga5);
		entitesCibleListC.add(ga6);
		entitesCibleListC.add(ga7);
		grille[40][29].add(new Activable(40,29,entitesCibleListC,null,true,75,false,"levierPorte","Un levier","A lever","Activable",true,"./images/activable/levierON.gif","./images/activable/levierOFF.gif","./sons/get.wav"));
		
		
		grille[36][41].add(new Activable(36,41,null,"+T0T-T2T+T0T39T82",true,0,false,"teleporteurFixe","Un teleporteur activable","A usable teleporter","Activable",true,"./images/activable/teleporteuractivable.gif","./images/activable/teleporteuractivable.gif","./sons/detect.wav"));
		grille[40][41].add(new Activable(40,41,null,"+T3T-T10T+T0T39T82",true,0,false,"teleporteurFixe","Un teleporteur activable","A usable teleporter","Activable",true,"./images/activable/teleporteuractivable.gif","./images/activable/teleporteuractivable.gif","./sons/detect.wav"));
		grille[44][41].add(new Activable(44,41,null,"+T0T+T0T+T1T39T22",true,0,false,"teleporteurFixe","Un teleporteur activable","A usable teleporter","Activable",true,"./images/activable/teleporteuractivable.gif","./images/activable/teleporteuractivable.gif","./sons/detect.wav"));
		grille[22][24].add(new Activable(22,24,null,"+T0T+T0T+T3T15T15",true,0,false,"teleporteurFixe","Un teleporteur activable","A usable teleporter","Activable",true,"./images/activable/teleporteuractivable.gif","./images/activable/teleporteuractivable.gif","./sons/detect.wav"));
		grille[27][24].add(new Activable(27,24,null,"+T0T+T0T-T1T36T25",true,0,false,"teleporteurFixe","Un teleporteur activable","A usable teleporter","Activable",true,"./images/activable/teleporteuractivable.gif","./images/activable/teleporteuractivable.gif","./sons/detect.wav"));
		
		
		
		
		// coffres//////////
		
		Contenant coffre1=new Contenant(cat,monde,false,true,false,50,false,false,"coffrestandard","Un coffre","A chest",true,"./images/contenant/coffrestandardferme.gif","./images/contenant/coffrestandardouvert.gif","./sons/oldedoor_open.wav","./sons/oldedoor_close.wav");
		grille[17][35].add(coffre1);
		Vector contenuCoffre1=new Vector();
		contenuCoffre1.add(new Nourriture(false,"mushroom","champignon vert","green mushroom","Comestible",true,"./images/comestible/champivert.gif"));
		contenuCoffre1.add(new Outil(false,"pioche","Vieille pioche","An old pick",0,"Objet",true,"./images/outils/pioche.gif"));
		contenuCoffre1.add(new Arme(false,"flail","Fleau","A flail",0,"Objet",true,"./images/weapons/flail.gif"));
		coffre1.setContenu(contenuCoffre1);
		
		
		Contenant coffre2=new Contenant(cat,monde,false,true,false,50,false,false,"coffrestandard","Un coffre etrange","A strange chest",true,"./images/contenant/coffrestandardferme.gif","./images/contenant/coffrestandardouvert.gif","./sons/oldedoor_open.wav","./sons/oldedoor_close.wav");
		grille[17][33].add(coffre2);
		Vector contenuCoffre2=new Vector();
		contenuCoffre2.add(new Piege(monde,false,10,300,true,75,false,"explosivetrap","Piege explosif","Exploding trap","Piege",true,"./images/pieges/piegeskull.gif","./sons/explosion.wav"));
		contenuCoffre2.add(new Boisson(false,"lesserhealingpotion","potion rubis","A red potion","Comestible",true,"./images/comestible/potionrouge.gif"));
		contenuCoffre2.add(new Nourriture(false,"ration","ration","ration","Comestible",true,"./images/comestible/ration1.gif"));
		coffre2.setContenu(contenuCoffre2);
		
		
		Contenant tableA=new Contenant(cat,monde,false,false,true,0,true,false,"alchemytable","Table Alchimie","Alchemy table",true,"./images/mobiliers/tableAlchimie.gif","./images/mobiliers/tableAlchimie.gif","./sons/door_open.wav","./sons/door_close.wav");
		Vector contenuTableA=new Vector();
		contenuTableA.add(new Piege(monde,false,2,300,true,75,false,"explosivetrap","Piege explosif","Exploding trap","Piege",true,"./images/pieges/piegeskull.gif","./sons/explosion.wav"));
		contenuTableA.add(new Boisson(false,"lesserhealingpotion","potion rubis","A red potion","Comestible",true,"./images/comestible/potionrouge.gif"));
		contenuTableA.add(new Boisson(false,"mediumhealingpotion","potion rouge","A red potion","Comestible",true,"./images/comestible/potionrouge.gif"));
		contenuTableA.add(new Boisson(false,"majorhealingpotion","potion cerise","A red potion","Comestible",true,"./images/comestible/potionrouge.gif"));
		contenuTableA.add(new Boisson(false,"lesserpoison","potion jaunatre","A yellow potion","Comestible",true,"./images/comestible/potionjaune.gif"));
		contenuTableA.add(new Boisson(false,"mediumpoison","potion marecageuse","A yellow potion","Comestible",true,"./images/comestible/potionjaune.gif"));
		contenuTableA.add(new Boisson(false,"majorpoison","potion jaune sale","A yellow potion","Comestible",true,"./images/comestible/potionjaune.gif"));
		contenuTableA.add(new Boisson(false,"speedpotion","potion violette petillante","A strange potion","Comestible",true,"./images/comestible/potionviolette.gif"));
		contenuTableA.add(new Boisson(false,"speedpotion","potion violette petillante","A strange potion","Comestible",true,"./images/comestible/potionviolette.gif"));
		contenuTableA.add(new Boisson(false,"slowpotion","potion rose","A pink potion","Comestible",true,"./images/comestible/potionrose.gif"));
		tableA.setContenu(contenuTableA);
		grille[20][16].add(tableA);
		
		
		
		// 4. les objets////////////////////////////
		grille[11][11].add(new Nourriture(false,"mushroom","champignon vert","green mushroom","Comestible",true,"./images/comestible/champivert.gif"));
		
		grille[20][25].add(new Nourriture(false,"mushroom","champignon vert","green mushroom","Comestible",true,"./images/comestible/champivert.gif"));
		
		grille[27][21].add(new Nourriture(false,"mushroom","champignon vert","green mushroom","Comestible",true,"./images/comestible/champivert.gif"));
		
	
		
		
		
		
		//grille[37][25].add(new Ecrit(false,"standardscroll","Un parchemin","A scroll","Ecrit",true,"./images/ecrits/scroll.gif","Une blague carambar","A stupid joke"));
		
		grille[32][42].add(new Ecrit(false,"standardpierretombale","Une pierre tombale","A tombstone","Ecrit",true,"./images/ecrits/pierretombale.gif","Ci-git Gary Gygax","Gary Gygax"));
	
		grille[29][52].add(new Ecrit(false,"pancarte","Un ecriteau","A sign","Ecrit",true,"./images/ecrits/grossepancarte.gif","Bienvenue dans CryptRL\nPrenez connaissance des raccourcis (shift ?)\nAu nord: une demeure abandonnee", "Welcome to CryptRL\nPlease read the shortcuts (shift ?)\nNorth: a house"));
		
		
		//MAGIC	
		
		//grille[28][54].add(new EcritMagique(false,"grimoire","Grimoire de trait de feu","Grimoire of FireBolt","EcritMagique",true,"./images/ecritsmagiques/grim1.gif",new Spell("firebolt","Trait de feu","FireBolt",1,"./sons/explosion2.wav","./images/sorts/firebolt.gif")));		
		
		
		
		
		
		
		
		
		////pieges
		//(boolean actifC,int complexiteC,boolean brok,String modeleC,String name,String typeObjetC,boolean visibleC,String tileStrC,String sndC){
		
		grille[17][34].add(new Piege(monde,false,4,300,true,75,false,"explosivetrap","Mine","Mine","Piege",false,"./images/pieges/piegeskull.gif","./sons/explosion.wav"));
		grille[18][33].add(new Piege(monde,false,0,5,true,110,false,"teleporttrap","Teleporteur","Teleporter","Piege",false,"./images/pieges/piegeteleport.gif","./sons/magic_teleport.wav"));
		
		grille[19][34].add(new Piege(monde,false,2,50,true,75,false,"explosivetrap","Mine","Mine","Piege",false,"./images/pieges/piegeskull.gif","./sons/explosion.wav"));
		//grille[19][33].add(new Piege(false,0,10,true,110,false,"teleporttrap","Teleporteur","Piege",false,"./images/pieges/piegeteleport.gif","./sons/magic_teleport.wav"));
		
		grille[21][34].add(new Piege(monde,false,2,50,true,75,false,"explosivetrap","Mine","Mine","Piege",false,"./images/pieges/piegeskull.gif","./sons/explosion.wav"));
		
		grille[23][36].add(new Piege(monde,false,0,75,true,75,false,"piketrap","Piege a pieux","Impaling trap","Piege",false,"./images/pieges/piketrap.gif","./sons/hit_pierce.wav"));
		//grille[21][35].add(new Piege(true,0,150,true,100000000,false,"trou","Un trou","Piege",false,"./images/pieges/trou.gif","./sons/fall_down_level.wav"));
		
		
		grille[23][34].add(new Piege(monde,false,2,20,true,75,false,"explosivetrap","Mine","Mine","Piege",false,"./images/pieges/piegeskull.gif","./sons/explosion.wav"));
		
		grille[25][34].add(new Piege(monde,false,6,20,true,75,false,"explosivetrap","Mine","Mine","Piege",false,"./images/pieges/piegeskull.gif","./sons/explosion.wav"));
		
		grille[27][34].add(new Ecrit(false,"pancarte","Un ecriteau","A sign","Ecrit",true,"./images/ecrits/pancarte1.gif","P.A.C","F.T"));
	
		
		//grille[35][29].add(new Piege(false,0,2,true,110,false,"teleporttrap","Teleporteur","Piege",false,"./images/pieges/piegeteleport.gif","./sons/magic_teleport.wav"));
		
		
		
		
		
		
		
		
		//test flipper/////////////////////////
		grille[12][12].add(new Piege(monde,false,0,300,true,200,false,"teleporttrap","Teleporteur","Teleport trap","Piege",false,"./images/pieges/piegeteleport.gif","./sons/teleport.wav"));
		grille[87][87].add(new Piege(monde,false,0,300,true,200,false,"teleporttrap","Teleporteur","Teleport trap","Piege",false,"./images/pieges/piegeteleport.gif","./sons/teleport.wav"));
		grille[12][87].add(new Piege(monde,false,0,300,true,200,false,"teleporttrap","Teleporteur","Teleport trap","Piege",false,"./images/pieges/piegeteleport.gif","./sons/teleport.wav"));
		grille[87][12].add(new Piege(monde,false,0,300,true,200,false,"teleporttrap","Teleporteur","Teleport trap","Piege",false,"./images/pieges/piegeteleport.gif","./sons/teleport.wav"));
		//////////////////////////////////////////////////
		
		
		//grille[28][40].add(new Piege(false,0,100,true,0,false,"trou","Un trou","A hole","Piege",false,"./images/pieges/trou.gif","./sons/fall_down_level.wav"));
		
		
		
		///////ESCALIERS////////////////
	
		grille[33][23].add(new Escalier(false,"standardstairUP","Un escalier vers le haut","Up stair","Escalier",true,"./images/escaliers/escalierup.gif"));
		
		grille[39][22].add(new Escalier(false,"standardstairDOWN","Un escalier vers le bas","Down stair","Escalier",true,"./images/escaliers/escalierdown.gif"));
				
				
				
		/////////////////////////////////////////////////
		
		/////////////////////////////////////////////:
		
		
		//grille[33][26].add(new Arme(false,"battleaxe","Hache de guerre","A battleaxe",0,"Objet",true,"./images/weapons/battleaxe.gif"));
		
		
		
		
		//grille[28][35].add(new Arme(false,"longsword","Epee longue etrange","A strange longsword",20,"Objet",true,"./images/weapons/longSword.gif"));
		
		grille[24][36].add(new Arme(false,"longsword","Epee longue rouillee","A longsword",0,"Objet",true,"./images/weapons/longSword.gif"));
		
		
		//grille[28][34].add(new Armure(false,"softleather","Armure de cuir souple classique","Soft leather armor",0,"Objet",true,"./images/armors/leatherArmor.gif"));
		
		grille[25][36].add(new Armure(false,"softleather","Armure de cuir","Soft leather armor",0,"Objet",true,"./images/armors/leatherArmor.gif"));
		
		//grille[35][26].add(new Armure(false,"hardleather","Armure de cuir bouilli","Hard leather armor",0,"Objet",true,"./images/armors/hardleather.gif"));
		
		//grille[36][26].add(new Armure(false,"mail","Cotte de mailles","Mail",0,"Objet",true,"./images/armors/mail.gif"));
		
		//grille[35][27].add(new Armure(false,"plate","Armure de plaques",0,"Objet",true,"./images/armors/plate.gif"));
		
		
		
		grille[20][30].add(new Outil(false,"pioche","Vieille pioche","A pick",0,"Objet",true,"./images/outils/pioche.gif"));
		
		grille[21][30].add(new Outil(false,"pelle","Une pelle","A shovel",0,"Objet",true,"./images/outils/pelle.gif"));
		
		
		grille[17][30].add(new Outil(false,"chandelier","Un chandelier","Candlestick",0,"Objet",true,"./images/outils/chandelier.gif"));
		
		grille[17][29].add(new Outil(false,"torche","Une torche","A torch",0,"Objet",true,"./images/outils/torche.gif"));
		
		grille[33][27].add(new Outil(false,"lanterne","Une lanterne","A lantern",0,"Objet",true,"./images/outils/lanterne.gif"));
		
		grille[26][36].add(new Outil(false,"pickingtools","Des outils de crochetage","Picking tools",0,"Objet",true,"./images/outils/pickingtools.gif"));
		
		grille[26][36].add(new Outil(false,"pickingtools","Outils de crochetage de qualite","Expert Picking tools",4,"Objet",true,"./images/outils/pickingtoolsgolden.gif"));
		
		
		grille[33][26].add(new Outil(false,"oilflask","Flasque d huile","Oil flask",0,"Objet",true,"./images/outils/oilflask.gif"));
			
	
		grille[24][23].add(new Boisson(false,"fountain","Fontaine","Fountain","Comestible",true,"./images/comestible/fountain.gif"));
	
	
	
		grille[30][53].add(new EcritMagique(30,53,false,"magicscroll","Parchemin de trait de feu","Scroll of firebolt","EcritMagique",true,"./images/ecritsmagiques/scroll1.gif",new Spell("firebolt","Trait de feu","Firebolt","./sons/magic_spell_casting.wav","./images/sorts/fire2.gif")));		
		grille[31][53].add(new EcritMagique(31,53,false,"grimoire","Grimoire de trait de feu","Spellbook of firebolt","EcritMagique",true,"./images/ecritsmagiques/grim8.gif",new Spell("firebolt","Trait de feu","Firebolt","./sons/magic_spell_casting.wav","./images/sorts/fire2.gif")));		
		
		
	
		//CREATURES
		
		UndeadCategory drakeDead=new UndeadCategory(false,"undeaddragon","Un dragon mort vivant","An undead dragon",true,"Creature",true,"./images/creatures/undead/undeaddragonTALL.gif","./images/creatures/bones.gif","./sons/demonlord.wav");
		//UndeadCategory drakeDead=new UndeadCategory(false,"undeaddragon","Un dragon mort vivant","An undead dragon",true,"Creature",true,"./images/creatures/undead/undeadDragonVERYBIG.gif","./images/creatures/bones.gif","./sons/demonlord.wav");
		
		drakeDead.setCooX(19);
		drakeDead.setCooY(32);
		grille[19][32].add(drakeDead);		
		
		
		
		
		
		UndeadCategory spectreVert1=new UndeadCategory(false,"lesser ghost","Mr Booo","Mr Booo",true,"Creature",true,"./images/creatures/undead/spectrevert.gif","./images/creatures/bones.gif","./sons/ghost.wav");
		spectreVert1.setCooX(12);
		spectreVert1.setCooY(28);
		grille[12][28].add(spectreVert1);	
		
		UndeadCategory spectreVert2=new UndeadCategory(false,"lesser ghost","Mr Booo2","Mr Booo2",true,"Creature",true,"./images/creatures/undead/spectrevert.gif","./images/creatures/bones.gif","./sons/ghost.wav");
		spectreVert2.setCooX(20);
		spectreVert2.setCooY(30);
		grille[20][30].add(spectreVert2);	
		
		
		
		UndeadCategory funkyskel1=new UndeadCategory(false,"lesser skeleton","Mr Nonos","Mr Nonos",false,"Creature",true,"./images/creatures/undead/funkysquelette.gif","./images/creatures/bones.gif","./sons/gravel.wav");
		funkyskel1.setCooX(21);
		funkyskel1.setCooY(28);
		grille[21][28].add(funkyskel1);
		
		
		UndeadCategory skel=new UndeadCategory(false,"lesser skeleton","Mr Bony","Mr Bony",false,"Creature",true,"./images/creatures/undead/funkysquelette.gif","./images/creatures/bones.gif","./sons/gravel.wav");
		skel.setCooX(21);
		skel.setCooY(29);
		grille[21][29].add(skel);
		
		UndeadCategory ske=new UndeadCategory(false,"lesser zombi","Mr Pourrissant","Mr Rotting",true,"Creature",true,"./images/creatures/undead/zombie.gif","./images/creatures/corpse.gif","./sons/zombi.wav");
		ske.setCooX(22);
		ske.setCooY(29);
		grille[22][29].add(ske);
		
		UndeadCategory sk=new UndeadCategory(false,"lesser zombi","Mr Brain!!!","Mr Brain!!!",true,"Creature",true,"./images/creatures/undead/zombie.gif","./images/creatures/corpse.gif","./sons/zombi2.wav");
		sk.setCooX(23);
		sk.setCooY(29);
		grille[23][29].add(sk);
		
		
		
		
		GoblinoidCategory orc1=new GoblinoidCategory(false,"lesser orc","CrocLeBo","CrocLeBo",true,"Creature",true,"./images/creatures/goblinoid/orc1.gif","./images/creatures/corpse.gif","./sons/monster_orcish_snarl.wav");
		orc1.setCooX(13);
		orc1.setCooY(20);
		grille[13][20].add(orc1);
		
		
		
		GoblinoidCategory orc2=new GoblinoidCategory(false,"lesser orc","Grumph","Grumph",true,"Creature",true,"./images/creatures/goblinoid/orc1.gif","./images/creatures/corpse.gif","./sons/monster_orcish_snarl.wav");
		orc2.setCooX(14);
		orc2.setCooY(20);
		grille[14][20].add(orc2);
		
		
		
		
		UndeadCategory funkyskel2=new UndeadCategory(true,"lesser skeleton","MEGADETH","MEGADETH",true,"Creature",true,"./images/creatures/undead/funkysquelette.gif","./images/creatures/bones.gif","./sons/gravel.wav");
		funkyskel2.setCooX(19);
		funkyskel2.setCooY(28);
		grille[19][28].add(funkyskel2);
		
		AnimalCategory w1=new AnimalCategory(false,"warg","Un warg","A warg",true,"Creature",true,"./images/creatures/animal/warg.gif","./images/creatures/corpse.gif","./sons/wolf.wav");
		w1.setCooX(39);
		w1.setCooY(35);
		grille[39][35].add(w1);
		
		
		AnimalCategory w2=new AnimalCategory(false,"warg","Un warg","A warg",true,"Creature",true,"./images/creatures/animal/warg.gif","./images/creatures/corpse.gif","./sons/wolf.wav");
		w2.setCooX(44);
		w2.setCooY(30);
		grille[44][30].add(w2);
		
		grille[23][32].add(new Arbre(false,"mediumtree","Un arbre","A tree","Obstacle",true,"./images/vegetation/t22.gif","./images/vegetation/arbremortCasse.gif"));
	    
		
	}
	
	
	///////////////////////////////////////////////////////////////////////////

	
	
		
}
