package Globales;
import villa1.*;
/**
 *
 * @author Xabier
 */
public class UsObjBat extends Inicio {

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

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        labelUsObj = new javax.swing.JLabel();
        labelObj1 = new javax.swing.JLabel();
        labelObj2 = new javax.swing.JLabel();
        btnUsarObj1 = new javax.swing.JButton();
        btnUsarObj2 = new javax.swing.JButton();
        txtResultado = new javax.swing.JTextField();
        btnAtras = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("RpG Java - Utilizar Objetos");

        labelUsObj.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        labelUsObj.setText(". Utilizar Objetos .");

        labelObj1.setText("Pociones: "+pers.contObj1);

        labelObj2.setText("Superpociones: "+pers.contObj2);

        btnUsarObj1.setText("Usar");
        btnUsarObj1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUsarObj1ActionPerformed(evt);
            }
        });

        btnUsarObj2.setText("Usar");
        btnUsarObj2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUsarObj2ActionPerformed(evt);
            }
        });

        txtResultado.setEditable(false);
        txtResultado.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        txtResultado.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        btnAtras.setText("Atras");
        btnAtras.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAtrasActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(txtResultado, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addContainerGap(213, Short.MAX_VALUE)
                        .addComponent(btnAtras))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(labelUsObj)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel3Layout.createSequentialGroup()
                                    .addComponent(labelObj2)
                                    .addGap(18, 18, 18)
                                    .addComponent(btnUsarObj2))
                                .addGroup(jPanel3Layout.createSequentialGroup()
                                    .addComponent(labelObj1)
                                    .addGap(18, 18, 18)
                                    .addComponent(btnUsarObj1))))))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(labelUsObj)
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelObj1)
                    .addComponent(btnUsarObj1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelObj2)
                    .addComponent(btnUsarObj2))
                .addGap(171, 171, 171)
                .addComponent(txtResultado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnAtras)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("tab3", jPanel3);
        jTabbedPane1.addTab("Bolsa", jPanel3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 287, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1)
                .addContainerGap())
        );

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

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

    private void btnUsarObj2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUsarObj2ActionPerformed
        if (pers.hp == pers.hp_max){
            txtResultado.setText("Tu HP está al máximo");
        }
        if (pers.contObj2 >= 1){
            pers.hp = pers.hp + 50;
            if (pers.hp > pers.hp_max){
                pers.hp = pers.hp_max;
            }
            pers.contObj2 = pers.contObj2 - 1;
            labelObj2.setText("Pociones: "+pers.contObj1);
            txtResultado.setText("Superpoción usada correctamente. HP: "+pers.hp+"/"+pers.hp_max);
        } else {
            txtResultado.setText("No tienes superpociones para poder usar");
        }        // TODO add your handling code here:
}//GEN-LAST:event_btnUsarObj2ActionPerformed

    private void btnUsarObj1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUsarObj1ActionPerformed
        if (pers.hp == pers.hp_max){
            txtResultado.setText("Tu HP está al máximo");
        }
        if (pers.contObj1 >= 1){
            pers.hp = pers.hp + 20;
            if (pers.hp > pers.hp_max){
                pers.hp = pers.hp_max;
            }
            pers.contObj1 = pers.contObj1 - 1;
            labelObj1.setText("Pociones: "+pers.contObj1);
            txtResultado.setText("Poción usada correctamente. HP: "+pers.hp+"/"+pers.hp_max);
        } else {
            txtResultado.setText("No tienes pociones para poder usar");
        }
        // TODO add your handling code here:
}//GEN-LAST:event_btnUsarObj1ActionPerformed

    /**
    * @param args the command line arguments
    */
   

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAtras;
    private javax.swing.JButton btnUsarObj1;
    private javax.swing.JButton btnUsarObj2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel labelObj1;
    private javax.swing.JLabel labelObj2;
    private javax.swing.JLabel labelUsObj;
    private javax.swing.JTextField txtResultado;
    // End of variables declaration//GEN-END:variables

}
