/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Frames;

import java.util.ArrayList;
import javax.swing.JOptionPane;

/**
 *
 * @author Daniel
 */
public class Bosque extends javax.swing.JFrame {

    private boolean estado;
    private int contar;
    private String nombre;
    private int indicador;
    private int turnos;
    ArrayList<String> datos = new ArrayList<String>();
    /**
     * Creates new form Bosque
     */
    public Bosque() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        acemila = new javax.swing.JLabel();
        afilo = new javax.swing.JLabel();
        agave = new javax.swing.JLabel();
        ajaraca = new javax.swing.JLabel();
        alcatifa = new javax.swing.JLabel();
        amanal = new javax.swing.JLabel();
        ave = new javax.swing.JLabel();
        bajel = new javax.swing.JLabel();
        cabana = new javax.swing.JLabel();
        guardabosques = new javax.swing.JLabel();
        panda = new javax.swing.JLabel();
        tronco = new javax.swing.JLabel();
        arrebol = new javax.swing.JLabel();
        canasta = new javax.swing.JLabel();
        caperuza = new javax.swing.JLabel();
        cortaarbol = new javax.swing.JLabel();
        espuela = new javax.swing.JLabel();
        hongo = new javax.swing.JLabel();
        jarron = new javax.swing.JLabel();
        lena = new javax.swing.JLabel();
        lobo = new javax.swing.JLabel();
        rapa = new javax.swing.JLabel();
        servillana = new javax.swing.JLabel();
        tink = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });
        getContentPane().setLayout(null);

        jButton1.setBackground(new java.awt.Color(51, 102, 0));
        jButton1.setText("jButton1");
        getContentPane().add(jButton1);
        jButton1.setBounds(240, 373, 230, 30);

        jButton2.setBackground(new java.awt.Color(0, 102, 0));
        jButton2.setText("<--");
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
        });
        getContentPane().add(jButton2);
        jButton2.setBounds(670, 0, 51, 23);

        acemila.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/acemila.png"))); // NOI18N
        acemila.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                acemilaMouseClicked(evt);
            }
        });
        getContentPane().add(acemila);
        acemila.setBounds(510, 290, 120, 110);

        afilo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/afilo.png"))); // NOI18N
        afilo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                afiloMouseClicked(evt);
            }
        });
        getContentPane().add(afilo);
        afilo.setBounds(70, 220, 100, 200);

        agave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/agave.png"))); // NOI18N
        agave.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                agaveMouseClicked(evt);
            }
        });
        getContentPane().add(agave);
        agave.setBounds(640, 190, 80, 120);

        ajaraca.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/ajaraca.png"))); // NOI18N
        ajaraca.setText("jLabel5");
        ajaraca.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ajaracaMouseClicked(evt);
            }
        });
        getContentPane().add(ajaraca);
        ajaraca.setBounds(10, 0, 110, 60);

        alcatifa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/alcatifa.png"))); // NOI18N
        alcatifa.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                alcatifaMouseClicked(evt);
            }
        });
        getContentPane().add(alcatifa);
        alcatifa.setBounds(150, 360, 89, 50);

        amanal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/amanal.png"))); // NOI18N
        amanal.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                amanalMouseClicked(evt);
            }
        });
        getContentPane().add(amanal);
        amanal.setBounds(560, 30, 100, 100);

        ave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/ave.png"))); // NOI18N
        getContentPane().add(ave);
        ave.setBounds(220, 30, 70, 40);

        bajel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/bajel.png"))); // NOI18N
        bajel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                bajelMouseClicked(evt);
            }
        });
        getContentPane().add(bajel);
        bajel.setBounds(260, 320, 80, 40);

        cabana.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/cabaña.png"))); // NOI18N
        getContentPane().add(cabana);
        cabana.setBounds(600, 160, 119, 50);

        guardabosques.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/guardabosques.png"))); // NOI18N
        getContentPane().add(guardabosques);
        guardabosques.setBounds(500, 140, 104, 160);

        panda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/panda.png"))); // NOI18N
        getContentPane().add(panda);
        panda.setBounds(420, 230, 100, 110);

        tronco.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/troncos.png"))); // NOI18N
        tronco.setText("3");
        getContentPane().add(tronco);
        tronco.setBounds(310, 240, 70, 50);

        arrebol.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/arrebol.png"))); // NOI18N
        arrebol.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                arrebolMouseClicked(evt);
            }
        });
        getContentPane().add(arrebol);
        arrebol.setBounds(310, 10, 119, 80);

        canasta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/canasta.png"))); // NOI18N
        getContentPane().add(canasta);
        canasta.setBounds(360, 280, 63, 80);

        caperuza.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/caperuza.png"))); // NOI18N
        getContentPane().add(caperuza);
        caperuza.setBounds(160, 200, 81, 140);

        cortaarbol.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/cortaarbol.png"))); // NOI18N
        getContentPane().add(cortaarbol);
        cortaarbol.setBounds(630, 330, 90, 70);

        espuela.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/espuela.png"))); // NOI18N
        espuela.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                espuelaMouseClicked(evt);
            }
        });
        getContentPane().add(espuela);
        espuela.setBounds(480, 360, 54, 40);

        hongo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/hongos.png"))); // NOI18N
        getContentPane().add(hongo);
        hongo.setBounds(600, 250, 60, 60);

        jarron.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/jarron.png"))); // NOI18N
        getContentPane().add(jarron);
        jarron.setBounds(20, 330, 48, 60);

        lena.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/leña.png"))); // NOI18N
        getContentPane().add(lena);
        lena.setBounds(420, 60, 100, 190);

        lobo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/lobo.png"))); // NOI18N
        getContentPane().add(lobo);
        lobo.setBounds(260, 140, 90, 90);

        rapa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/rapa.png"))); // NOI18N
        rapa.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                rapaMouseClicked(evt);
            }
        });
        getContentPane().add(rapa);
        rapa.setBounds(50, 100, 59, 91);

        servillana.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/servillana.png"))); // NOI18N
        servillana.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                servillanaMouseClicked(evt);
            }
        });
        getContentPane().add(servillana);
        servillana.setBounds(130, 180, 70, 39);

        tink.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/tink.png"))); // NOI18N
        getContentPane().add(tink);
        tink.setBounds(140, 40, 50, 80);

        jButton3.setBackground(new java.awt.Color(255, 102, 102));
        jButton3.setText("Iniciar Juego");
        jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton3MouseClicked(evt);
            }
        });
        getContentPane().add(jButton3);
        jButton3.setBounds(280, 190, 170, 23);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bosque/bosque.jpg"))); // NOI18N
        getContentPane().add(jLabel1);
        jLabel1.setBounds(0, 0, 730, 410);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
        Niveles ni = new Niveles();
        ni.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton2MouseClicked

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        estado = false;
        Inicio();
    }//GEN-LAST:event_formWindowOpened

    private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseClicked
        estado = true;
        Inicio();
        jButton3.setVisible(false);
        datos.add("Arrebal");
        datos.add("Acemila");
        datos.add("Afilo");
        datos.add("Agave");
        datos.add("Ajaraca");
        datos.add("Alcatifa");
        datos.add("Amanal");
        datos.add("Bajel");
        datos.add("Espuela");
        datos.add("Rapa");
        datos.add("Servillana");
        
        indicador = 1;
        jButton1.setText(datos.get(indicador));
        turnos=0;
     
    
    }//GEN-LAST:event_jButton3MouseClicked

    private void arrebolMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_arrebolMouseClicked
        if (jButton1.getText().equals("Arrebol")) {
            arrebol.setVisible(false);
            nombre = "Arrebol";
            CleanBoton();
            contar += 1;
          indicador += 1;
            jButton1.setText(datos.get(indicador));
        }else{
            
    turnos++;
    
            if(turnos==4){
              JOptionPane.showMessageDialog(null, "Perdite el nivel hiciste mas intentos de los debidos", "Perdiendo",JOptionPane.INFORMATION_MESSAGE);
            this.dispose();
            }
        }
    }//GEN-LAST:event_arrebolMouseClicked

    private void acemilaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_acemilaMouseClicked
        if (jButton1.getText().equals("Acemila")) {
            acemila.setVisible(false);
            nombre = "Acemila";
            CleanBoton();
            contar += 1;
            indicador += 1;
            jButton1.setText(datos.get(indicador));
        }
    }//GEN-LAST:event_acemilaMouseClicked

    private void afiloMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_afiloMouseClicked
        if (jButton1.getText().equals("Afilo")) {
            afilo.setVisible(false);
            nombre = "Afilo";
            CleanBoton();
            contar += 1;
             indicador += 1;
            jButton1.setText(datos.get(indicador));
        }
    }//GEN-LAST:event_afiloMouseClicked

    private void agaveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_agaveMouseClicked
        if (jButton1.getText().equals("Agave")) {
            agave.setVisible(false);
            nombre = "Agave";
            CleanBoton();
            contar += 1;
                indicador += 1;
            jButton1.setText(datos.get(indicador));
        }
    }//GEN-LAST:event_agaveMouseClicked

    private void ajaracaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ajaracaMouseClicked
        if (jButton1.getText().equals("Ajaraca")) {
            ajaraca.setVisible(false);
            nombre = "Ajaraca";
            CleanBoton();
            contar += 1;
     indicador += 1;
            jButton1.setText(datos.get(indicador));
        }
    }//GEN-LAST:event_ajaracaMouseClicked

    private void alcatifaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_alcatifaMouseClicked
        if (jButton1.getText().equals("Alcatifa")) {
            alcatifa.setVisible(false);
            nombre = "Alcatifa";
            CleanBoton();
            contar += 1;
            indicador += 1;
            jButton1.setText(datos.get(indicador));
        }
    }//GEN-LAST:event_alcatifaMouseClicked

    private void amanalMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_amanalMouseClicked
        if (jButton1.getText().equals("Amanal")) {
            amanal.setVisible(false);
            nombre = "Amanal";
            CleanBoton();
            contar += 1;
            indicador += 1;
            jButton1.setText(datos.get(indicador));
        }
    }//GEN-LAST:event_amanalMouseClicked

    private void bajelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_bajelMouseClicked
        if (jButton1.getText().equals("Bajel")) {
            bajel.setVisible(false);
            nombre = "Bajel";
            CleanBoton();
            contar += 1;
             indicador += 1;
            jButton1.setText(datos.get(indicador));
        }
    }//GEN-LAST:event_bajelMouseClicked

    private void espuelaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_espuelaMouseClicked
        if (jButton1.getText().equals("Espuela")) {
            espuela.setVisible(false);
            nombre = "Espuela";
            CleanBoton();
            contar += 1;
             indicador += 1;
            jButton1.setText(datos.get(indicador));
        }
    }//GEN-LAST:event_espuelaMouseClicked

    private void rapaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_rapaMouseClicked
        if (jButton1.getText().equals("Rapa")) {
            rapa.setVisible(false);
            nombre = "Rapa";
            CleanBoton();
            contar += 1;
             indicador += 1;
            jButton1.setText(datos.get(indicador));
        }
    }//GEN-LAST:event_rapaMouseClicked

    private void servillanaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_servillanaMouseClicked
        if (jButton1.getText().equals("Servillana")) {
            servillana.setVisible(false);
            nombre = "Servillana";
            CleanBoton();
            contar += 1;
             indicador += 1;
            jButton1.setText(datos.get(indicador));
        }
    }//GEN-LAST:event_servillanaMouseClicked

    public void CleanBoton() {
        
        if (jButton1.getText().equals(nombre)) {
            jButton1.setText("Acemila");
        }
        if (jButton1.getText().equals(nombre)) {
            jButton1.setText("Afilo");
        }
        if (jButton1.getText().equals(nombre)) {
            jButton1.setText("Agave");
        }
        if (jButton1.getText().equals(nombre)) {
            jButton1.setText("Ajaraca");
        }
        if (jButton1.getText().equals(nombre)) {
            jButton1.setText("Alcatifa");
        }
        if (jButton1.getText().equals(nombre)) {
            jButton1.setText("Amanal");
        }
        if (jButton1.getText().equals(nombre)) {
            jButton1.setText("Bajel");
        }
        if (jButton1.getText().equals(nombre)) {
            jButton1.setText("Espuela");
        }
        if (jButton1.getText().equals(nombre)) {
            jButton1.setText("Rapa");
        }
        if (jButton1.getText().equals(nombre)) {
            jButton1.setText("Servillana");
        }
    }

    public void CalculoNombre() {

        if (contar == 1) {
                nombre = "Acemila";
            }
            if (contar == 2) {
                nombre = "Afilo";
            }
            if (contar == 3) {
                nombre = "Agave";
            }
            if (contar == 4) {
                nombre = "Ajaraca";
            }
            if (contar == 5) {
                nombre = "Alcatifa";
            }
            if (contar == 6) {
                nombre = "Amanal";
            }
            if (contar == 7) {
                nombre = "Bajel";
            }
            if (contar == 8) {
                nombre = "Espuela";
            }
            if (contar == 9) {
                nombre = "Rapa";
            }
            if (contar == 10) {
                nombre = "Servillana";
            }
            if (contar == 11) {
                nombre = "";
        }
    }

    
    public void CalcularSiguiente() {
        if (jButton1.getText().equals(" ")) {
            jButton1.setText(nombre);
        }
    }



    private void Inicio() {
        acemila.setVisible(estado);
        afilo.setVisible(estado);
        agave.setVisible(estado);
        ajaraca.setVisible(estado);
        alcatifa.setVisible(estado);
        amanal.setVisible(estado);
        arrebol.setVisible(estado);
        ave.setVisible(estado);
        bajel.setVisible(estado);
        cabana.setVisible(estado);
        canasta.setVisible(estado);
        caperuza.setVisible(estado);
        cortaarbol.setVisible(estado);
        espuela.setVisible(estado);
        hongo.setVisible(estado);
        jarron.setVisible(estado);
        lena.setVisible(estado);
        lobo.setVisible(estado);
        rapa.setVisible(estado);
        servillana.setVisible(estado);
        tink.setVisible(estado);
        guardabosques.setVisible(estado);
        panda.setVisible(estado);
        lena.setVisible(estado);
        jButton1.setVisible(estado);

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Bosque.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Bosque.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Bosque.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Bosque.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Bosque().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel acemila;
    private javax.swing.JLabel afilo;
    private javax.swing.JLabel agave;
    private javax.swing.JLabel ajaraca;
    private javax.swing.JLabel alcatifa;
    private javax.swing.JLabel amanal;
    private javax.swing.JLabel arrebol;
    private javax.swing.JLabel ave;
    private javax.swing.JLabel bajel;
    private javax.swing.JLabel cabana;
    private javax.swing.JLabel canasta;
    private javax.swing.JLabel caperuza;
    private javax.swing.JLabel cortaarbol;
    private javax.swing.JLabel espuela;
    private javax.swing.JLabel guardabosques;
    private javax.swing.JLabel hongo;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jarron;
    private javax.swing.JLabel lena;
    private javax.swing.JLabel lobo;
    private javax.swing.JLabel panda;
    private javax.swing.JLabel rapa;
    private javax.swing.JLabel servillana;
    private javax.swing.JLabel tink;
    private javax.swing.JLabel tronco;
    // End of variables declaration//GEN-END:variables
}
