package Globales;
import villa1.*;
import Globales.*;
import Personajes.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

/*
 * InicioPartida.java
 *
 * Created on 27-ago-2009, 17:22:06
 */

/**
 *
 * @author Xabier
 */
public class InicioPartida extends Inicio {

    /** Creates new form InicioPartida */
    public InicioPartida() {
        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() {

        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        btnElfo = new javax.swing.JButton();
        btnSoldado = new javax.swing.JButton();
        btnLadron = new javax.swing.JButton();
        btnMago = new javax.swing.JButton();
        btnModificar = new javax.swing.JButton();
        labelElfo = new javax.swing.JLabel();
        txtMotePersonaje = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        labelMago = new javax.swing.JLabel();
        labelLadron = new javax.swing.JLabel();
        labelOrco = new javax.swing.JLabel();
        btnOrco = new javax.swing.JButton();
        labelSoldado = new javax.swing.JLabel();
        labelModificar = new javax.swing.JLabel();
        labelPass = new javax.swing.JLabel();
        txtPass = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Nueva Partida - Elección Personaje");

        jLabel2.setText("Escribe un mote para tu personaje:");

        btnElfo.setText("Elfo");
        btnElfo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnElfoActionPerformed(evt);
            }
        });

        btnSoldado.setLabel("Soldado");
        btnSoldado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSoldadoActionPerformed(evt);
            }
        });

        btnLadron.setText("Ladron");
        btnLadron.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLadronActionPerformed(evt);
            }
        });

        btnMago.setText("Mago");
        btnMago.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMagoActionPerformed(evt);
            }
        });

        btnModificar.setText("Modificar");
        btnModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarActionPerformed(evt);
            }
        });

        labelElfo.setText("HP 25.  PP = 5.  Ataque: 9.   Defensa: 12.  Agilidad: 4.   Suerte: 4");

        txtMotePersonaje.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtMotePersonaje.setText("Personaje");
        txtMotePersonaje.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                txtMotePersonajeMouseClicked(evt);
            }
        });
        txtMotePersonaje.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtMotePersonajeActionPerformed(evt);
            }
        });

        jLabel3.setText("Ahora, elije un tipo de personaje para empezar la aventura.");

        labelMago.setText("HP 20.  PP = 5.  Ataque: 15.  Defensa: 7.   Agilidad: 2.   Suerte: 6");

        labelLadron.setText("HP 40.  PP = 5.  Ataque: 9.   Defensa: 8.   Agilidad: 7.   Suerte: 2");

        labelOrco.setText("HP 50.  PP = 5.  Ataque: 9.   Defensa: 5.   Agilidad: 4.   Suerte: 6");

        btnOrco.setLabel("Orco");
        btnOrco.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOrcoActionPerformed(evt);
            }
        });

        labelSoldado.setText("HP 30.  PP = 5.  Ataque: 11.  Defensa: 8.   Agilidad: 4.   Suerte: 5");

        labelModificar.setText("Personaje Editable. Crea un personaje a tu medida.");

        labelPass.setText("Contraseña para tu patida guardada:");

        txtPass.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtPass.setText("1234");
        txtPass.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                txtPassMouseClicked(evt);
            }
        });
        txtPass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtPassActionPerformed(evt);
            }
        });
        txtPass.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtPassKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(51, 51, 51)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(btnLadron, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(btnOrco, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(btnMago, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(btnModificar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(btnElfo, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE))
                                .addComponent(btnSoldado, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(labelElfo)
                                .addComponent(labelMago)
                                .addComponent(labelOrco)
                                .addComponent(labelLadron)
                                .addComponent(labelSoldado)
                                .addComponent(labelModificar))
                            .addGap(48, 48, 48))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel2)
                                .addComponent(labelPass))
                            .addGap(22, 22, 22)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(txtPass)
                                .addComponent(txtMotePersonaje, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE))
                            .addGap(128, 128, 128)))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtMotePersonaje, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelPass)
                    .addComponent(txtPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(btnElfo)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnMago)
                            .addComponent(labelMago)))
                    .addComponent(labelElfo))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnLadron)
                    .addComponent(labelLadron))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnOrco)
                    .addComponent(labelOrco))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSoldado)
                    .addComponent(labelSoldado))
                .addGap(32, 32, 32)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnModificar)
                    .addComponent(labelModificar)))
        );

        btnElfo.getAccessibleContext().setAccessibleName("btnElfo");
        btnSoldado.getAccessibleContext().setAccessibleName("btnSoldado");
        btnLadron.getAccessibleContext().setAccessibleName("btnLadron");
        btnMago.getAccessibleContext().setAccessibleName("btnMago");
        btnModificar.getAccessibleContext().setAccessibleName("btnModificar");
        txtMotePersonaje.getAccessibleContext().setAccessibleName("txtMotePersonaje"); // NOI18N
        btnOrco.getAccessibleContext().setAccessibleName("btnOrco");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(41, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(32, Short.MAX_VALUE))
        );

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

    private void btnElfoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnElfoActionPerformed
        String mote = txtMotePersonaje.getText();
        Elfo elf = new Elfo(25,5,9,12,4,4,mote);
        pers = elf;
        String pass = txtPass.getText();
        pass.replaceAll(" ", "");
        pers.pass = Integer.parseInt(pass);
        this.hide();
        new villa1.NMenu().setVisible(true);
    }//GEN-LAST:event_btnElfoActionPerformed

    private void btnMagoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMagoActionPerformed
        String mote = txtMotePersonaje.getText();
        Mago mag = new Mago(20,5,15,7,2,6,mote);
        pers = mag;
        this.hide();
        new villa1.NMenu().setVisible(true);// TODO add your handling code here:
    }//GEN-LAST:event_btnMagoActionPerformed

    private void btnLadronActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLadronActionPerformed
        String mote = txtMotePersonaje.getText();
        Ladron lad = new Ladron(40,5,9,8,7,2,mote);//
        pers = lad;
        this.hide();
        new villa1.NMenu().setVisible(true);// TODO add your handling code here:
    }//GEN-LAST:event_btnLadronActionPerformed

    private void btnOrcoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOrcoActionPerformed
        String mote = txtMotePersonaje.getText();
        Orco orc = new Orco(50,5,9,5,4,6,mote);//
        pers = orc;
        this.hide();
        new villa1.NMenu().setVisible(true);// TODO add your handling code here:
    }//GEN-LAST:event_btnOrcoActionPerformed

    private void btnSoldadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSoldadoActionPerformed
        String mote = txtMotePersonaje.getText();
        Soldado sold = new Soldado(30,5,11,8,4,5,mote);//
        pers = sold;
        this.hide();
        new villa1.NMenu().setVisible(true);// TODO add your handling code here:
    }//GEN-LAST:event_btnSoldadoActionPerformed

    private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed
        this.hide();
        new ModPers().setVisible(true);// TODO add your handling code here:
    }//GEN-LAST:event_btnModificarActionPerformed

    private void txtMotePersonajeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtMotePersonajeActionPerformed

    }//GEN-LAST:event_txtMotePersonajeActionPerformed

    private void txtMotePersonajeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtMotePersonajeMouseClicked
 txtMotePersonaje.setText(null);
    }//GEN-LAST:event_txtMotePersonajeMouseClicked

    private void txtPassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPassActionPerformed
txtPass.addKeyListener(new KeyAdapter()
{ @Override
public void keyTyped(KeyEvent e)
{
char caracter = e.getKeyChar();
if(((caracter < '0') || (caracter > '9')) && (caracter != KeyEvent.VK_BACK_SPACE))
e.consume();
}
});     // TODO add your handling code here:
    }//GEN-LAST:event_txtPassActionPerformed

    private void txtPassMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtPassMouseClicked
txtPass.addKeyListener(new KeyAdapter()
{ @Override
public void keyTyped(KeyEvent e)
{
char caracter = e.getKeyChar();
if(((caracter < '0') || (caracter > '9')) && (caracter != KeyEvent.VK_BACK_SPACE))
e.consume();
}
});        // TODO add your handling code here:
    }//GEN-LAST:event_txtPassMouseClicked

    private void txtPassKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPassKeyPressed
txtPass.addKeyListener(new KeyAdapter()
{ @Override
public void keyTyped(KeyEvent e)
{
char caracter = e.getKeyChar();
if(((caracter < '0') || (caracter > '9')) && (caracter != KeyEvent.VK_BACK_SPACE))
e.consume();
}
});         // TODO add your handling code here:
    }//GEN-LAST:event_txtPassKeyPressed

    /**
    * @param args the command line arguments
    */
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnElfo;
    private javax.swing.JButton btnLadron;
    private javax.swing.JButton btnMago;
    private javax.swing.JButton btnModificar;
    private javax.swing.JButton btnOrco;
    private javax.swing.JButton btnSoldado;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel labelElfo;
    private javax.swing.JLabel labelLadron;
    private javax.swing.JLabel labelMago;
    private javax.swing.JLabel labelModificar;
    private javax.swing.JLabel labelOrco;
    private javax.swing.JLabel labelPass;
    private javax.swing.JLabel labelSoldado;
    private javax.swing.JTextField txtMotePersonaje;
    private javax.swing.JTextField txtPass;
    // End of variables declaration//GEN-END:variables

}
