/**
*Programme cree par The Clusters
*Classe BoutonCarte du jeu "Chkoba"
* Classe qui rend les carte cliquable
*@author The Clusters
*@version 1.0
**/

package chkoba;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import chkoba.*;
import java.util.*;

/**
*	Classe CarteRamassage
*/

public class CarteRamassage extends JFrame
{
	private ArrayList<ICarte> list;
	private ICarte cart;
	
	public CarteRamassage()
	{
		try
		{
			list=new ArrayList<ICarte>();
			list.add(new CarteImpl());
		}
		catch ( Exception e)
		{
			System.out.println("A pris ==> Carte ramassage");
		}
	}
		
	public CarteRamassage(ArrayList<ICarte> ramassage,String s)
	{
		setTitle(s);
		setSize((10+ramassage.size()*89),183);
		setLocation(600,0);
		setLayout(null);
		Color c = new Color(0,200,0);
		setBackground(c);
		
		list=new ArrayList<ICarte>(ramassage);
		ArrayList<BoutonCarte> aBcRammas = new ArrayList<BoutonCarte> ();
		int x=0;
		for (int i = 0;i!=ramassage.size();i++)
		{
			try{System.out.println(ramassage.get(i).affiche());}catch(Exception e){}
			aBcRammas.add(new BoutonCarte(ramassage.get(i)));
			aBcRammas.get(i).setBounds(x, 0, 89, 148);
			aBcRammas.get(i).setVisible(true);
			add(aBcRammas.get(i));
			x+=89;
		}
		setVisible(true);
	}
	
	public CarteRamassage(ICarte ca,ArrayList<ICarte> ramassage,String s)
	{
		setTitle(s);
		setSize((89+10+ramassage.size()*89),183);
		setLocation(600,0);
		JPanel contenant = new JPanel();
		contenant.setLayout(null);
		contenant.setOpaque(true);
		Color c = new Color(0,200,0);
		contenant.setBackground(c);
		list=new ArrayList<ICarte>(ramassage);
		ArrayList<BoutonCarte> aBcRammas = new ArrayList<BoutonCarte> ();
		int x=0;
		int dec=0;
		aBcRammas.add(new BoutonCarte(ca));
		aBcRammas.get(0).setBounds(x + dec, 0, 89, 148);
		aBcRammas.get(0).setVisible(true);
		contenant.add(aBcRammas.get(0));
		x+=89;
		int comp=0;
		for (int i = 1;i!=ramassage.size()+1;i++)
		{
			aBcRammas.add(new BoutonCarte(ramassage.get(comp)));
			aBcRammas.get(i).setBounds(x + dec, 0, 89, 148);
			aBcRammas.get(i).setVisible(true);
			contenant.add(aBcRammas.get(i));
			x+=89;
			comp++;
		}
		add(contenant);
		setVisible(true);
	}
	
	public CarteRamassage(ICarte ca,ICarte main,String s)
	{
		setTitle(s);
		setSize((10+2*89),183);
		setLocation(600,0);
		JPanel contenant = new JPanel();
		contenant.setLayout(null);
		contenant.setOpaque(true);
		Color c = new Color(0,200,0);
		contenant.setBackground(c);
		cart=main;
		ArrayList<BoutonCarte> aBcRammas = new ArrayList<BoutonCarte> ();
		int x=0;
		int dec=0;
		aBcRammas.add(new BoutonCarte(ca));
		aBcRammas.get(0).setBounds(x + dec, 0, 89, 148);
		aBcRammas.get(0).setVisible(true);
		contenant.add(aBcRammas.get(0));
		x+=89;
		aBcRammas.add(new BoutonCarte(main));
		aBcRammas.get(1).setBounds(x + dec, 0, 89, 148);
		aBcRammas.get(1).setVisible(true);
		contenant.add(aBcRammas.get(1));
		x+=89;
		add(contenant);
		setVisible(true);
	}
	
	public CarteRamassage(ICarte ca,ICarte main,ArrayList<ICarte> ramassage,String s)
	{
		setTitle(s);
		setSize((10+(2+ramassage.size())*89),183);
		setLocation(600,0);
		JPanel contenant = new JPanel();
		contenant.setLayout(null);
		contenant.setOpaque(true);
		Color c = new Color(0,200,0);
		contenant.setBackground(c);
		list=new ArrayList<ICarte>(ramassage);
		ArrayList<BoutonCarte> aBcRammas = new ArrayList<BoutonCarte> ();
		int x=0;
		int dec=0;
		
		aBcRammas.add(new BoutonCarte(ca));
		aBcRammas.get(0).setBounds(x + dec, 0, 89, 148);
		aBcRammas.get(0).setVisible(true);
		contenant.add(aBcRammas.get(0));
		x+=89;
		
		aBcRammas.add(new BoutonCarte(main));
		aBcRammas.get(1).setBounds(x + dec, 0, 89, 148);
		aBcRammas.get(1).setVisible(true);
		contenant.add(aBcRammas.get(1));
		x+=89;
		int comp=0;
		for (int i = 2;i!=ramassage.size()+2;i++)
		{
			
			aBcRammas.add(new BoutonCarte(ramassage.get(comp)));
			aBcRammas.get(i).setBounds(x + dec, 0, 89, 148);
			aBcRammas.get(i).setVisible(true);
			contenant.add(aBcRammas.get(i));
			x+=89;
			comp++;
		}
		add(contenant);
		setVisible(true);
	}
	
	public ArrayList<ICarte> getPlis() { return list; }
	
	public void attendre()
	{
		try
		{
			Thread.sleep( 3000 );
		}
		catch(Exception e){}
			setVisible(false);
	}
}