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

public class Catalog{
	
	transient ArrayList bestiaire=new ArrayList();
	transient ArrayList piegesCatalogue=new ArrayList();
	transient ArrayList contenantsCatalogue=new ArrayList();
	transient ArrayList armesCatalogue=new ArrayList();
	transient ArrayList armuresCatalogue=new ArrayList();
	transient ArrayList outilsCatalogue=new ArrayList();
	transient ArrayList comestiblesCatalogue=new ArrayList();
	transient ArrayList ecritMagiqueCatalogue=new ArrayList();
	transient ArrayList sortCatalogue=new ArrayList();
	
	transient ArrayList imagesCat=new ArrayList();
	transient ArrayList imagesCatStr=new ArrayList();
	
	private transient Image imageTile;
	private transient Toolkit toolkit = Toolkit.getDefaultToolkit();
	
	Monde monde;
	
	public Catalog(Monde world){
		monde=world;
		
		creationBestiaire();
		creationPiegesCatalogue();
		creationContenantCatalogue();
		creationArmesCatalogue();
		creationArmuresCatalogue();
		creationOutilCatalogue();
		creationComestibleCatalogue();
		creationEcritMagiqueCatalogue();
		creationSortCatalogue();
		
	}	
	
	////////////////////////////////////////////////////////
	/////////////CATALOGUES/////////////////////////////////
	////////////////////////////////////////////////////////
	public void creationImagesCat(Monde wrld){
		imagesCat.clear();
		imagesCatStr.clear();
		
		//int indexIm=1;
		Entite objet;
		System.out.println("***********CREATION IMAGES***********");
		
		
		
		imagesCat.add(toolkit.getImage("./images/BUGALERT.gif"));
		imagesCatStr.add("./images/BUGALERT.gif");
		
		for(int x=0;x<wrld.tailleGrille;x++){
			for(int y=0;y<wrld.tailleGrille;y++){
				
				if(!wrld.grille[x][y].isEmpty()){
			
		 			for(int i=0;i<wrld.grille[x][y].size();i++){
					
			 			try{
			 					
			 				objet = (Entite)wrld.grille[x][y].get(i);		
		 				
							imageTile=toolkit.getImage(objet.getTileStr());
							
							if(!imagesCat.contains(imageTile)){
								imagesCat.add(imageTile);
								imagesCatStr.add(objet.getTileStr());
								
								//objet.indexImage=imagesCat.size()-1;
								//indexIm++;
							}
							/*
							else{
							 	objet.indexImage=imagesCat.indexOf(imageTile);
							}*/
							
							
							
						}
						catch(NoSuchElementException exc){};
					}
				}
					
			}
		}
		
		System.out.println("NbrImages= "+imagesCat.size());
		
		
	}
	
	////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////
	public void creationSortCatalogue(){
		sortCatalogue.clear();
		sortCatalogue.add(new Spell("invisibility","Invisibilite","Invisibility","./sons/magic_spell_casting.wav","./images/sorts/1.gif"));
		sortCatalogue.add(new Spell("customteleport","Teleportation Parametrable","Custom Teleportation","./sons/detect.wav","./images/sorts/teleport1.gif"));
		sortCatalogue.add(new Spell("passemuraille","Passe-Muraille","Ectoplasmic Consistency","./sons/gulp.wav","./images/sorts/4.gif"));
		sortCatalogue.add(new Spell("nightvision","Infravision","Infravision","./sons/magic_spell_casting.wav","./images/sorts/infravision.gif"));
		sortCatalogue.add(new Spell("rayonx","RayonX","X-Ray","./sons/magic_spell_casting.wav","./images/sorts/rayonX.gif"));
		sortCatalogue.add(new Spell("fly","Vol","Fly","./sons/magic_spell_casting.wav","./images/sorts/fly.gif"));
		sortCatalogue.add(new Spell("firebolt","Trait de feu","Firebolt","./sons/magic_spell_casting.wav","./images/sorts/fire2.gif"));
	
	}
	
	public void creationEcritMagiqueCatalogue(){
		ecritMagiqueCatalogue.clear();
		ecritMagiqueCatalogue.add(new EcritMagique(0,0,false,"magicscroll","Parchemin","Magic scroll","EcritMagique",true,new String(),new Spell("invisibility","Invisibilite","Invisibility","./sons/magic_spell_casting.wav","./images/sorts/1.gif")));
		ecritMagiqueCatalogue.add(new EcritMagique(0,0,false,"grimoire","Grimoire","Spellbook","EcritMagique",true,new String(),new Spell("invisibility","Invisibilite","Invisibility","./sons/magic_spell_casting.wav","./images/sorts/1.gif")));
	}
	
	
	
	public void creationBestiaire(){
		bestiaire.clear();
		bestiaire.add(new UndeadCategory(false,"lesser skeleton","Un squelette","A skeleton",true,"Creature",true,"./images/creatures/undead/funkysquelette.gif","./images/creatures/bones.gif","./sons/gravel.wav"));
		bestiaire.add(new UndeadCategory(false,"lesser zombi","Un zombi","A zombi",true,"Creature",true,"./images/creatures/undead/zombie.gif","./images/creatures/corpse.gif","./sons/zombi.wav"));
		bestiaire.add(new UndeadCategory(false,"lesser ghost","Un spectre","A ghost",true,"Creature",true,"./images/creatures/undead/spectrevert.gif","./images/creatures/bones.gif","./sons/ghost.wav"));
		bestiaire.add(new UndeadCategory(false,"undeaddragon","Un dragon mort vivant","An undead dragon",true,"Creature",true,"./images/creatures/undead/undeaddragon.gif","./images/creatures/bones.gif","./sons/demonlord.wav"));
		bestiaire.add(new UndeadCategory(false,"mummy","Une momie","A mummy",true,"Creature",true,"./images/creatures/undead/mummy.gif","./images/creatures/bones.gif","./sons/mummy.wav"));
		
		
		bestiaire.add(new GoblinoidCategory(false,"lesser orc","Un orc","An orc",true,"Creature",true,"./images/creatures/goblinoid/orc1.gif","./images/creatures/corpse.gif","./sons/monster_orcish_snarl.wav"));
		bestiaire.add(new GoblinoidCategory(false,"gobelin","Un gobelin","A goblin",true,"Creature",true,"./images/creatures/goblinoid/orc2.gif","./images/creatures/corpse.gif","./sons/goblin.wav"));
		
		bestiaire.add(new CritterCategory(false,"bat","Une chauve souris","A bat",true,"Creature",true,"./images/creatures/critter/bat.gif","./images/creatures/corpse.gif","./sons/rats.wav"));
		bestiaire.add(new CritterCategory(false,"bug","Un cafard geant","A giant bug",true,"Creature",true,"./images/creatures/critter/cafard.gif","./images/creatures/corpse.gif","./sons/insect.wav"));
		bestiaire.add(new CritterCategory(false,"rat","Un rat","A rat",true,"Creature",true,"./images/creatures/critter/rat2.gif","./images/creatures/corpse.gif","./sons/rats.wav"));
		bestiaire.add(new CritterCategory(false,"giantbat","Une chauve souris geante","A giant bat",true,"Creature",true,"./images/creatures/critter/giantbat.gif","./images/creatures/corpse.gif","./sons/bat.wav"));
		bestiaire.add(new CritterCategory(false,"escargotgeant","Un escargot geant","A giant snail",true,"Creature",true,"./images/creatures/critter/escargot.gif","./images/creatures/corpse.gif","./sons/slime.wav"));
		
		
		
		
		bestiaire.add(new DragonCategory(false,"dragonancientgreen","Un dragon vert ancien","An old green dragon",true,"Creature",true,"./images/creatures/dragon/d10.gif","./images/creatures/corpse.gif","./sons/demonlord.wav"));
		bestiaire.add(new DragonCategory(false,"dragonancientblack","Un dragon noir ancien","An old black dragon",true,"Creature",true,"./images/creatures/dragon/d4.gif","./images/creatures/corpse.gif","./sons/demonlord.wav"));
		bestiaire.add(new DragonCategory(false,"dragonancientlordred","Un seigneur dragon rouge","An old red dragon lord",true,"Creature",true,"./images/creatures/dragon/d1.gif","./images/creatures/corpse.gif","./sons/demonlord.wav"));
		bestiaire.add(new DragonCategory(false,"dragonancientred","Un dragon rouge ancient","An old red dragon",true,"Creature",true,"./images/creatures/dragon/d5.gif","./images/creatures/corpse.gif","./sons/demonlord.wav"));
		
		
		bestiaire.add(new AnimalCategory(false,"evilfrog","Une grenouille geante","A giant frog",true,"Creature",true,"./images/creatures/animal/evilfrog.gif","./images/creatures/corpse.gif","./sons/frog.wav"));
		bestiaire.add(new AnimalCategory(false,"wolf","Un loup","A wolf",true,"Creature",true,"./images/creatures/animal/wolf.gif","./images/creatures/corpse.gif","./sons/wolf.wav"));
		bestiaire.add(new AnimalCategory(false,"warg","Un warg","A warg",true,"Creature",true,"./images/creatures/animal/warg.gif","./images/creatures/corpse.gif","./sons/wolf.wav"));
		
		bestiaire.add(new CthulianCategory(false,"tentaclesphere","Une chose tentaculaire","A tentacles thing",true,"Creature",true,"./images/creatures/cthulian/tentaclesphere.gif","./images/creatures/corpse.gif","./sons/scorpion.wav"));
		bestiaire.add(new CthulianCategory(false,"stellarlarva","Une larve stellaire","A stellar larva",true,"Creature",true,"./images/creatures/cthulian/stellarlarva.gif","./images/creatures/corpse.gif","./sons/stormend.wav"));
		
		bestiaire.add(new DemonCategory(false,"balrog","Un balrog","A balrog",true,"Creature",true,"./images/creatures/demon/balrog.gif","./images/creatures/corpse.gif","./sons/balrog.wav"));
		
		bestiaire.add(new ElementalCategory(false,"smallwaterelemental","Un elementaire d eau","A water elemental",true,"Creature",true,"./images/creatures/elemental/waterelemental.gif","./images/creatures/corpse.gif","./sons/waterel.wav"));
				
		
	}
	
	public void creationPiegesCatalogue(){
		piegesCatalogue.clear();
		piegesCatalogue.add(new Piege(monde,true,0,0,true,0,false,"explosivetrap","Mine","Exploding trap","Piege",false,"./images/pieges/piegeskull.gif","./sons/explosion.wav"));
		piegesCatalogue.add(new Piege(monde,true,0,0,true,0,false,"teleporttrap","Teleporteur","Teleport trap","Piege",false,"./images/pieges/piegeteleport.gif","./sons/teleport.wav"));
		piegesCatalogue.add(new Piege(monde,true,0,0,true,0,false,"piketrap","Piege a pieux","Impaling trap","Piege",false,"./images/pieges/piketrap.gif","./sons/hit_pierce.wav"));
		piegesCatalogue.add(new Piege(monde,true,0,0,true,0,false,"trou","Un trou","A hole","Piege",false,"./images/pieges/trou.gif","./sons/fall_down_level.wav"));
		
		
	}
	
	public void creationContenantCatalogue(){
		contenantsCatalogue.clear();
		contenantsCatalogue.add(new Contenant(this,monde,true,true,false,0,false,false,"coffrestandard","Un coffre","A chest",true,"./images/contenant/coffrestandardferme.gif","./images/contenant/coffrestandardouvert.gif","./sons/oldedoor_open.wav","./sons/oldedoor_close.wav"));
		contenantsCatalogue.add(new Contenant(this,monde,true,false,true,0,true,false,"alchemytable","Table Alchimie","An Alchemy table",true,"./images/mobiliers/tableAlchimie.gif","./images/mobiliers/tableAlchimie.gif","./sons/door_open.wav","./sons/door_close.wav"));
		
	}
	
	public void creationArmesCatalogue(){
		armesCatalogue.clear();
		armesCatalogue.add(new Arme(false,"longsword","Une epee longue","Longsword",0,"Objet",true,"./images/weapons/longSword.gif"));
		armesCatalogue.add(new Arme(false,"dagger","Une dague","Dagger",0,"Objet",true,"./images/weapons/tinydagger.gif"));
		armesCatalogue.add(new Arme(false,"battleaxe","Hache de guerre","Battleaxe",0,"Objet",true,"./images/weapons/battleaxe.gif"));
		armesCatalogue.add(new Arme(false,"flail","Fleau","Flail",0,"Objet",true,"./images/weapons/flail.gif"));
		armesCatalogue.add(new Arme(false,"warhammer","Marteau de guerre","Warhammer",0,"Objet",true,"./images/weapons/hammer.gif"));
		armesCatalogue.add(new Arme(false,"mace","Masse d arme","Mace",0,"Objet",true,"./images/weapons/mace.gif"));
		armesCatalogue.add(new Arme(false,"polearm","Arme d hast","Polearm",0,"Objet",true,"./images/weapons/polearm.gif"));
		armesCatalogue.add(new Arme(false,"quarterstaff","Baton","Quarterstaff",0,"Objet",true,"./images/weapons/quarterstaff.gif"));
		armesCatalogue.add(new Arme(false,"shortaxe","Hache courte","Shortaxe",0,"Objet",true,"./images/weapons/shortaxe.gif"));
		armesCatalogue.add(new Arme(false,"shortsword","Epee courte","Shortsword",0,"Objet",true,"./images/weapons/shortsword.gif"));
	}
	
	public void creationArmuresCatalogue(){
		armuresCatalogue.clear();
		armuresCatalogue.add(new Armure(false,"softleather","Armure de cuir","Soft leather armor",0,"Objet",true,"./images/armors/leatherArmor.gif"));
		armuresCatalogue.add(new Armure(false,"hardleather","Armure de cuir bouilli","Hard leather armor",0,"Objet",true,"./images/armors/hardleather.gif"));
		armuresCatalogue.add(new Armure(false,"mail","Cotte de mailles","Mail armor",0,"Objet",true,"./images/armors/mail.gif"));
		armuresCatalogue.add(new Armure(false,"plate","Armure de plaques","Plate Armor",0,"Objet",true,"./images/armors/plate.gif"));
	}
	
	
	public void creationOutilCatalogue(){
		outilsCatalogue.clear();
		outilsCatalogue.add(new Outil(false,"pickingtools","Outils de crochetage","Picking tools",0,"Objet",true,"./images/outils/pickingtools.gif"));
		outilsCatalogue.add(new Outil(false,"pioche","Pioche","Pick",0,"Objet",true,"./images/outils/pioche.gif"));
		outilsCatalogue.add(new Outil(false,"chandelier","Un chandelier","Candlestick",0,"Objet",true,"./images/outils/chandelier.gif"));
		outilsCatalogue.add(new Outil(false,"torche","Une torche","Torch",0,"Objet",true,"./images/outils/torche.gif"));
		outilsCatalogue.add(new Outil(false,"lanterne","Une lanterne","Lantern",0,"Objet",true,"./images/outils/lanterne.gif"));
		outilsCatalogue.add(new Outil(false,"oilflask","Flasque d huile","Oil flask",0,"Objet",true,"./images/outils/oilflask.gif"));
		outilsCatalogue.add(new Outil(false,"pelle","Une pelle","Shovel",0,"Objet",true,"./images/outils/pelle.gif"));
		
		
	}
	
	public void creationComestibleCatalogue(){
		comestiblesCatalogue.clear();
		comestiblesCatalogue.add(new Nourriture(false,"mushroom","champignon","mushroom","Comestible",true,"./images/comestible/champivert.gif"));
		comestiblesCatalogue.add(new Nourriture(false,"ration","ration","ration","Comestible",true,"./images/comestible/ration1.gif"));
		comestiblesCatalogue.add(new Nourriture(false,"potiron","potiron","pumpkin","Comestible",true,"./images/comestible/potiron.gif"));
		
		
		comestiblesCatalogue.add(new Boisson(false,"lesserhealingpotion","potion","potion","Comestible",true,"./images/comestible/potionrouge.gif"));
		comestiblesCatalogue.add(new Boisson(false,"mediumhealingpotion","potion","potion","Comestible",true,"./images/comestible/potionrouge.gif"));
		comestiblesCatalogue.add(new Boisson(false,"majorhealingpotion","potion","potion","Comestible",true,"./images/comestible/potionrouge.gif"));
		comestiblesCatalogue.add(new Boisson(false,"lesserpoison","potion","potion","Comestible",true,"./images/comestible/potionjaune.gif"));
		comestiblesCatalogue.add(new Boisson(false,"mediumpoison","potion","potion","Comestible",true,"./images/comestible/potionjaune.gif"));
		comestiblesCatalogue.add(new Boisson(false,"majorpoison","potion","potion","Comestible",true,"./images/comestible/potionjaune.gif"));
		comestiblesCatalogue.add(new Boisson(false,"speedpotion","potion","potion","Comestible",true,"./images/comestible/potionviolette.gif"));
		comestiblesCatalogue.add(new Boisson(false,"slowpotion","potion","potion","Comestible",true,"./images/comestible/potionrose.gif"));
		comestiblesCatalogue.add(new Boisson(false,"fountain","Fontaine","Fountain","Comestible",true,"./images/comestible/fountain.gif"));
	
	}
	
}