Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org;
- import java.util.HashMap;
- import java.util.Random;
- import javax.swing.JFrame;
- import javax.swing.JRadioButton;
- public class Main extends javax.swing.JFrame {
- /** Creates new form Main */
- public Main() {
- initComponents();
- }
- Random generator = new Random();
- public String get(String[] array) {
- int rnd = generator.nextInt(array.length);
- return array[rnd];
- }
- public HashMap<JRadioButton, Integer> lvlNeeded = new HashMap<JRadioButton, Integer>();
- public HashMap<Integer, Integer> xpNeeded = new HashMap<Integer, Integer>();
- public HashMap<Integer, Integer> xpReq = new HashMap<Integer, Integer>();
- public int damage;
- int xp = 10;
- int lvl = xp / 10;
- public String Name = "unknown";
- public String[] oNames = {"Joeseph", "George", "Thomas", "Jerry", "Grant", "Mason"};
- public String oName = get(oNames);
- public boolean[] radioInUse = new boolean[10];
- //public int lvl = 1;
- public int Health = 100;
- public int oHealth = 100;
- public String HP = Integer.toString(Health);
- public String oHP = Integer.toString(oHealth);
- public boolean isPlayerTurn;
- public void displayError(String error, int w, int h) {
- jDialog1.setVisible(true);
- jDialog1.setSize(w, h);
- jLabel3.setText(error);
- }
- public void displayFrame(JFrame frame, int w, int h) {
- frame.setVisible(true);
- frame.setSize(w, h);
- }
- public void xpGive() {
- int xpToGive = damage;
- xp = xpToGive + xp;
- }
- public void reset() {
- HP = Integer.toString(Health);
- oHP = Integer.toString(oHealth);
- Name = jTextField1.getText();
- jLabel4.setText(Name);
- jLabel6.setText(HP);
- jLabel7.setText(oName);
- jLabel9.setText(oHP);
- lvlNeeded.put(jRadioButton1, 1);
- lvlNeeded.put(jRadioButton2, 2);
- lvlNeeded.put(jRadioButton3, 3);
- lvlNeeded.put(jRadioButton4, 4);
- lvlNeeded.put(jRadioButton5, 5);
- lvlNeeded.put(jRadioButton6, 6);
- lvlNeeded.put(jRadioButton7, 7);
- lvlNeeded.put(jRadioButton8, 8);
- lvlNeeded.put(jRadioButton9, 9);
- lvlNeeded.put(jRadioButton10, 10);
- try {
- lvl = xp / 10;
- } catch (Exception e) {
- }
- }
- public boolean canUseCurrentGun(JRadioButton jRadioButton) {
- if(lvl >= lvlNeeded.get(jRadioButton)) {
- return true;
- } else {
- return false;
- }
- }
- /* public void getlvl(int xp) {
- if(xpNeeded.get(xp) >= xpReq.get(xp)) {
- lvl = xpNeeded.get(xp);
- }
- } */
- //public boolean canUseCurrentGun2 = false;
- public void oTurn() {
- if (!isPlayerTurn) {
- damage = getDamage(1, 5);
- int Health2 = Health - damage;
- Health = Health2;
- reset();
- jTextArea1.append(oName + " dealt " + damage + " on " + Name + " leaving you with " + HP + " health.\n");
- //jTextArea1.setText(oName + " dealt " + damage + " on " + Name + " leaving you with " + HP + " health.");
- isPlayerTurn = true;
- } else {
- return;
- }
- }
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jFrame1 = new javax.swing.JFrame();
- jLabel4 = new javax.swing.JLabel();
- jLabel5 = new javax.swing.JLabel();
- jLabel6 = new javax.swing.JLabel();
- jButton5 = new javax.swing.JButton();
- jLabel7 = new javax.swing.JLabel();
- jLabel8 = new javax.swing.JLabel();
- jLabel9 = new javax.swing.JLabel();
- jScrollPane1 = new javax.swing.JScrollPane();
- jTextArea1 = new javax.swing.JTextArea();
- jDialog1 = new javax.swing.JDialog();
- jLabel3 = new javax.swing.JLabel();
- jFrame2 = new javax.swing.JFrame();
- jRadioButton1 = new javax.swing.JRadioButton();
- jRadioButton2 = new javax.swing.JRadioButton();
- jRadioButton3 = new javax.swing.JRadioButton();
- jRadioButton4 = new javax.swing.JRadioButton();
- jRadioButton5 = new javax.swing.JRadioButton();
- jRadioButton6 = new javax.swing.JRadioButton();
- jRadioButton7 = new javax.swing.JRadioButton();
- jRadioButton8 = new javax.swing.JRadioButton();
- jRadioButton9 = new javax.swing.JRadioButton();
- jRadioButton10 = new javax.swing.JRadioButton();
- jScrollPane2 = new javax.swing.JScrollPane();
- jTextArea2 = new javax.swing.JTextArea();
- jButton6 = new javax.swing.JButton();
- buttonGroup1 = new javax.swing.ButtonGroup();
- jFrame3 = new javax.swing.JFrame();
- jLabel10 = new javax.swing.JLabel();
- jLabel11 = new javax.swing.JLabel();
- jLabel12 = new javax.swing.JLabel();
- jFrame4 = new javax.swing.JFrame();
- jScrollPane3 = new javax.swing.JScrollPane();
- jTextArea3 = new javax.swing.JTextArea();
- jLabel1 = new javax.swing.JLabel();
- jButton1 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- jButton3 = new javax.swing.JButton();
- jButton4 = new javax.swing.JButton();
- jLabel2 = new javax.swing.JLabel();
- jTextField1 = new javax.swing.JTextField();
- jFrame1.setTitle("Single player ");
- jLabel4.setText("Couldn't find name");
- jLabel5.setText("Health:");
- jLabel6.setText("?");
- jButton5.setText("Attack");
- jButton5.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton5ActionPerformed(evt);
- }
- });
- jLabel7.setText("Couldn't generate name");
- jLabel8.setText("Health:");
- jLabel9.setText("?");
- jTextArea1.setColumns(20);
- jTextArea1.setRows(5);
- jScrollPane1.setViewportView(jTextArea1);
- javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
- jFrame1.getContentPane().setLayout(jFrame1Layout);
- jFrame1Layout.setHorizontalGroup(
- jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jFrame1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jFrame1Layout.createSequentialGroup()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 538, Short.MAX_VALUE)
- .addContainerGap())
- .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(jFrame1Layout.createSequentialGroup()
- .addGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(jFrame1Layout.createSequentialGroup()
- .addComponent(jLabel5)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel6)))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 268, Short.MAX_VALUE)
- .addGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel7)
- .addGroup(jFrame1Layout.createSequentialGroup()
- .addComponent(jLabel8)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel9)))
- .addContainerGap(18, Short.MAX_VALUE))))
- );
- jFrame1Layout.setVerticalGroup(
- jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jFrame1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel4)
- .addComponent(jLabel7))
- .addGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jFrame1Layout.createSequentialGroup()
- .addGap(2, 2, 2)
- .addGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel5)
- .addComponent(jLabel6)))
- .addGroup(jFrame1Layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel8)
- .addComponent(jLabel9))))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)
- .addContainerGap())
- );
- jDialog1.setTitle("Error!");
- jLabel3.setText("Unhandled error.");
- javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
- jDialog1.getContentPane().setLayout(jDialog1Layout);
- jDialog1Layout.setHorizontalGroup(
- jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jDialog1Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel3)
- .addContainerGap(308, Short.MAX_VALUE))
- );
- jDialog1Layout.setVerticalGroup(
- jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jDialog1Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel3)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- buttonGroup1.add(jRadioButton1);
- jRadioButton1.setText("Punch");
- jRadioButton1.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mouseEntered(java.awt.event.MouseEvent evt) {
- jRadioButton1MouseEntered(evt);
- }
- });
- jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jRadioButton1ActionPerformed(evt);
- }
- });
- buttonGroup1.add(jRadioButton2);
- jRadioButton2.setText("Kick");
- jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jRadioButton2ActionPerformed(evt);
- }
- });
- buttonGroup1.add(jRadioButton3);
- jRadioButton3.setText("Bat");
- jRadioButton3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jRadioButton3ActionPerformed(evt);
- }
- });
- buttonGroup1.add(jRadioButton4);
- jRadioButton4.setText("Knife");
- jRadioButton4.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jRadioButton4ActionPerformed(evt);
- }
- });
- buttonGroup1.add(jRadioButton5);
- jRadioButton5.setText("Machete");
- jRadioButton5.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jRadioButton5ActionPerformed(evt);
- }
- });
- buttonGroup1.add(jRadioButton6);
- jRadioButton6.setText("9mm Pistol");
- jRadioButton6.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jRadioButton6ActionPerformed(evt);
- }
- });
- buttonGroup1.add(jRadioButton7);
- jRadioButton7.setText(".45 Revolver");
- jRadioButton7.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jRadioButton7ActionPerformed(evt);
- }
- });
- buttonGroup1.add(jRadioButton8);
- jRadioButton8.setText("Glock");
- jRadioButton8.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jRadioButton8ActionPerformed(evt);
- }
- });
- buttonGroup1.add(jRadioButton9);
- jRadioButton9.setText("12 Guage");
- jRadioButton9.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jRadioButton9ActionPerformed(evt);
- }
- });
- buttonGroup1.add(jRadioButton10);
- jRadioButton10.setText("Uzi");
- jRadioButton10.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jRadioButton10ActionPerformed(evt);
- }
- });
- jTextArea2.setColumns(20);
- jTextArea2.setRows(5);
- jScrollPane2.setViewportView(jTextArea2);
- jButton6.setText("Confirm");
- jButton6.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton6ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout jFrame2Layout = new javax.swing.GroupLayout(jFrame2.getContentPane());
- jFrame2.getContentPane().setLayout(jFrame2Layout);
- jFrame2Layout.setHorizontalGroup(
- jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jFrame2Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jRadioButton3)
- .addComponent(jRadioButton4)
- .addComponent(jRadioButton2)
- .addComponent(jRadioButton5)
- .addComponent(jRadioButton1))
- .addGap(8, 8, 8)
- .addGroup(jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jRadioButton6)
- .addComponent(jRadioButton9)
- .addComponent(jRadioButton10)
- .addComponent(jRadioButton8)
- .addComponent(jRadioButton7))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
- .addGroup(jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addComponent(jButton6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING))
- .addContainerGap())
- );
- jFrame2Layout.setVerticalGroup(
- jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jFrame2Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jFrame2Layout.createSequentialGroup()
- .addGroup(jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jRadioButton1)
- .addComponent(jRadioButton6))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jRadioButton2)
- .addComponent(jRadioButton7))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jRadioButton3)
- .addComponent(jRadioButton8))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jRadioButton4)
- .addComponent(jRadioButton9))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jRadioButton5)
- .addComponent(jRadioButton10))))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton6)
- .addContainerGap(111, Short.MAX_VALUE))
- );
- jLabel10.setText("Name:");
- jLabel11.setText("Level:");
- jLabel12.setText("Experience:");
- javax.swing.GroupLayout jFrame3Layout = new javax.swing.GroupLayout(jFrame3.getContentPane());
- jFrame3.getContentPane().setLayout(jFrame3Layout);
- jFrame3Layout.setHorizontalGroup(
- jFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jFrame3Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel10)
- .addComponent(jLabel11)
- .addComponent(jLabel12))
- .addContainerGap(333, Short.MAX_VALUE))
- );
- jFrame3Layout.setVerticalGroup(
- jFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jFrame3Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel10)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel11)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel12)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- jTextArea3.setColumns(20);
- jTextArea3.setRows(5);
- jTextArea3.setText("Level 1: punch\nLevel 2: kick\nLevel 3: bat\nLevel 4: knife\nLevel 5: machete\nLevel 6: 9mm pistol\nLevel 7: .45 revolver\nLevel 8: \nLevel 9:\nLevel 10:");
- jScrollPane3.setViewportView(jTextArea3);
- javax.swing.GroupLayout jFrame4Layout = new javax.swing.GroupLayout(jFrame4.getContentPane());
- jFrame4.getContentPane().setLayout(jFrame4Layout);
- jFrame4Layout.setHorizontalGroup(
- jFrame4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jFrame4Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 326, Short.MAX_VALUE)
- .addContainerGap())
- );
- jFrame4Layout.setVerticalGroup(
- jFrame4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jFrame4Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
- .addContainerGap())
- );
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setTitle("ExtremeFighter #0.2");
- jLabel1.setText("Welcome to ExtremeFighter");
- jButton1.setText("Single Player");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jButton2.setText("Player Stats");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- jButton3.setText("Player Unlocks");
- jButton3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton3ActionPerformed(evt);
- }
- });
- jButton4.setText("Multiplayer");
- jLabel2.setText("Enter your name to continue: ");
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(128, 128, 128)
- .addComponent(jLabel1))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel1)
- .addGap(18, 18, 18)
- .addComponent(jButton1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton3)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton4)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap())
- );
- pack();
- }// </editor-fold>
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- Name = jTextField1.getText();
- String valid = "abcdefghijklmnopqrstuvwxyz1234567890";
- char[] validChars = valid.toLowerCase().toCharArray();
- char[] nameChars = Name.toLowerCase().toCharArray();
- boolean invalidName = false;
- for (int i = 0; i < nameChars.length; i++) {
- boolean invalid = true;
- for (int j = 0; j < validChars.length; j++) {
- if (nameChars[i] == validChars[j]) {
- if(Name.equals("")){
- invalid = true;
- }
- invalid = false;
- }
- }
- if (invalid) {
- invalidName = true;
- break;
- }
- }
- if (invalidName) {
- displayError("Invalid name!", 500, 100);
- } else {
- displayFrame(jFrame1, 558, 252);
- isPlayerTurn = true;
- reset();
- }
- }
- private void jRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {
- if (lvlNeeded.containsKey(jRadioButton3)) {
- int lvlNeed = lvlNeeded.get(jRadioButton3);
- if (lvl >= lvlNeed) {
- radioInUse[3] = true;
- if(canUseCurrentGun(jRadioButton3)) {
- canUseCurrentGun2 = true;
- }
- } else {
- int neededlvl = lvlNeeded.get(jRadioButton3);
- displayError("You need a lvl of " + neededlvl + ".", 500, 100);
- return;
- }
- } else {
- displayError("Could not find lvl needed.", 500, 50);
- }
- }
- private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
- if (isPlayerTurn) {
- displayFrame(jFrame2, 460, 266);
- } else {
- displayError("It is not your turn!", 500, 100);
- }
- }
- private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- if (lvlNeeded.containsKey(jRadioButton1)) {
- int lvlNeed = lvlNeeded.get(jRadioButton1);
- if (lvl >= lvlNeed) {
- radioInUse[1] = true;
- if(canUseCurrentGun(jRadioButton1)) {
- canUseCurrentGun2 = true;
- }
- } else {
- int neededlvl = lvlNeeded.get(jRadioButton1);
- displayError("You need a lvl of " + neededlvl + ".", 500, 100);
- return;
- }
- } else {
- displayError("Could not find lvl needed.", 500, 100);
- }
- }
- private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
- if (lvlNeeded.containsKey(jRadioButton2)) {
- int lvlNeed = lvlNeeded.get(jRadioButton2);
- if (lvl >= lvlNeed) {
- radioInUse[2] = true;
- if(canUseCurrentGun(jRadioButton2)) {
- canUseCurrentGun2 = true;
- }
- } else {
- int neededlvl = lvlNeeded.get(jRadioButton2);
- displayError("You need a lvl of " + neededlvl + ".", 500, 100);
- return;
- }
- } else {
- displayError("Could not find lvl needed.", 500, 100);
- }
- }
- private void jRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {
- if (lvlNeeded.containsKey(jRadioButton4)) {
- int lvlNeed = lvlNeeded.get(jRadioButton4);
- if (lvl >= lvlNeed) {
- radioInUse[4] = true;
- if(canUseCurrentGun(jRadioButton4)) {
- canUseCurrentGun2 = true;
- }
- } else {
- int neededlvl = lvlNeeded.get(jRadioButton4);
- displayError("You need a lvl of " + neededlvl + ".", 500, 100);
- return;
- }
- } else {
- displayError("Could not find lvl needed.", 500, 100);
- }
- }
- private void jRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {
- if (lvlNeeded.containsKey(jRadioButton5)) {
- int lvlNeed = lvlNeeded.get(jRadioButton5);
- if (lvl >= lvlNeed) {
- radioInUse[5] = true;
- if(canUseCurrentGun(jRadioButton5)) {
- canUseCurrentGun2 = true;
- }
- } else {
- int neededlvl = lvlNeeded.get(jRadioButton5);
- displayError("You need a lvl of " + neededlvl + ".", 500, 100);
- return;
- }
- } else {
- displayError("Could not find lvl needed.", 500, 100);
- }
- }
- private void jRadioButton6ActionPerformed(java.awt.event.ActionEvent evt) {
- if (lvlNeeded.containsKey(jRadioButton6)) {
- int lvlNeed = lvlNeeded.get(jRadioButton6);
- if (lvl >= lvlNeed) {
- radioInUse[6] = true;
- if(canUseCurrentGun(jRadioButton6)) {
- canUseCurrentGun2 = true;
- }
- } else {
- int neededlvl = lvlNeeded.get(jRadioButton6);
- displayError("You need a lvl of " + neededlvl + ".", 500, 100);
- return;
- }
- } else {
- displayError("Could not find lvl needed.", 500, 100);
- }
- }
- private void jRadioButton7ActionPerformed(java.awt.event.ActionEvent evt) {
- if (lvlNeeded.containsKey(jRadioButton7)) {
- int lvlNeed = lvlNeeded.get(jRadioButton7);
- if (lvl >= lvlNeed) {
- radioInUse[7] = true;
- if(canUseCurrentGun(jRadioButton7)) {
- canUseCurrentGun2 = true;
- }
- } else {
- int neededlvl = lvlNeeded.get(jRadioButton7);
- displayError("You need a lvl of " + neededlvl + ".", 500, 100);
- return;
- }
- } else {
- displayError("Could not find lvl needed.", 500, 100);
- }
- }
- private void jRadioButton8ActionPerformed(java.awt.event.ActionEvent evt) {
- if (lvlNeeded.containsKey(jRadioButton8)) {
- int lvlNeed = lvlNeeded.get(jRadioButton8);
- if (lvl >= lvlNeed) {
- radioInUse[8] = true;
- if(canUseCurrentGun(jRadioButton8)) {
- canUseCurrentGun2 = true;
- }
- } else {
- int neededlvl = lvlNeeded.get(jRadioButton8);
- displayError("You need a lvl of " + neededlvl + ".", 500, 100);
- return;
- }
- } else {
- displayError("Could not find lvl needed.", 500, 100);
- }
- }
- private void jRadioButton9ActionPerformed(java.awt.event.ActionEvent evt) {
- if (lvlNeeded.containsKey(jRadioButton9)) {
- int lvlNeed = lvlNeeded.get(jRadioButton9);
- if (lvl >= lvlNeed) {
- radioInUse[9] = true;
- if(canUseCurrentGun(jRadioButton9)) {
- canUseCurrentGun2 = true;
- }
- } else {
- int neededlvl = lvlNeeded.get(jRadioButton9);
- displayError("You need a lvl of " + neededlvl + ".", 500, 100);
- return;
- }
- } else {
- displayError("Could not find lvl needed.", 500, 100);
- }
- }
- private void jRadioButton10ActionPerformed(java.awt.event.ActionEvent evt) {
- if (lvlNeeded.containsKey(jRadioButton10)) {
- int lvlNeed = lvlNeeded.get(jRadioButton10);
- if (lvl >= lvlNeed) {
- radioInUse[10] = true;
- if(canUseCurrentGun(jRadioButton10)) {
- canUseCurrentGun2 = true;
- }
- } else {
- int neededlvl = lvlNeeded.get(jRadioButton10);
- displayError("You need a lvl of " + neededlvl + ".", 500, 100);
- return;
- }
- } else {
- displayError("Could not find lvl needed.", 500, 100);
- }
- }
- public int getDamage(int min, int max) {
- int random = min + (int) (Math.random() * max);
- return random;
- }
- private void jRadioButton1MouseEntered(java.awt.event.MouseEvent evt) {
- // TODO add your handling code here:
- }
- public boolean canUseCurrentGun2;
- private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
- if(canUseCurrentGun2) {
- if (radioInUse[1]) {
- jFrame2.setVisible(false);
- damage = getDamage(1, 5);
- int oHealth2 = oHealth - damage;
- oHealth = oHealth2;
- reset();
- jTextArea1.append(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health.\n");
- //jTextArea1.setText(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health");
- isPlayerTurn = false;
- oTurn();
- canUseCurrentGun2 = false;
- }
- else if (radioInUse[2]) {
- jFrame2.setVisible(false);
- damage = getDamage(3, 8);
- int oHealth2 = oHealth - damage;
- oHealth = oHealth2;
- reset();
- jTextArea1.append(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health.\n");
- //jTextArea1.setText(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health");
- isPlayerTurn = false;
- oTurn();
- canUseCurrentGun2 = false;
- }
- else if (radioInUse[3]) {
- jFrame2.setVisible(false);
- damage = getDamage(5, 15);
- int oHealth2 = oHealth - damage;
- oHealth = oHealth2;
- reset();
- jTextArea1.append(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health.\n");
- //jTextArea1.setText(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health");
- isPlayerTurn = false;
- oTurn();
- canUseCurrentGun2 = false;
- }
- else if (radioInUse[4]) {
- jFrame2.setVisible(false);
- damage = getDamage(10, 20);
- int oHealth2 = oHealth - damage;
- oHealth = oHealth2;
- reset();
- jTextArea1.append(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health.\n");
- //jTextArea1.setText(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health");
- isPlayerTurn = false;
- oTurn();
- canUseCurrentGun2 = false;
- }
- else if (radioInUse[5]) {
- jFrame2.setVisible(false);
- damage = getDamage(15, 25);
- int oHealth2 = oHealth - damage;
- oHealth = oHealth2;
- reset();
- jTextArea1.append(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health.\n");
- //jTextArea1.setText(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health");
- isPlayerTurn = false;
- oTurn();
- canUseCurrentGun2 = false;
- }
- else if (radioInUse[6]) {
- jFrame2.setVisible(false);
- damage = getDamage(10, 30);
- int oHealth2 = oHealth - damage;
- oHealth = oHealth2;
- reset();
- jTextArea1.append(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health.\n");
- //jTextArea1.setText(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health");
- isPlayerTurn = false;
- oTurn();
- canUseCurrentGun2 = false;
- }
- else if (radioInUse[7]) {
- jFrame2.setVisible(false);
- damage = getDamage(15, 40);
- int oHealth2 = oHealth - damage;
- oHealth = oHealth2;
- reset();
- jTextArea1.append(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health.\n");
- //jTextArea1.setText(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health");
- isPlayerTurn = false;
- oTurn();
- canUseCurrentGun2 = false;
- }
- else if (radioInUse[8]) {
- jFrame2.setVisible(false);
- damage = getDamage(20, 45);
- int oHealth2 = oHealth - damage;
- oHealth = oHealth2;
- reset();
- jTextArea1.append(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health.\n");
- //jTextArea1.setText(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health");
- isPlayerTurn = false;
- canUseCurrentGun2 = false;
- oTurn();
- }
- else if (radioInUse[9]) {
- jFrame2.setVisible(false);
- damage = getDamage(25, 50);
- int oHealth2 = oHealth - damage;
- oHealth = oHealth2;
- reset();
- jTextArea1.append(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health.\n");
- //jTextArea1.setText(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health");
- isPlayerTurn = false;
- oTurn();
- canUseCurrentGun2 = false;
- }
- else if(radioInUse[10]) {
- jFrame2.setVisible(false);
- damage = getDamage(30, 50);
- int oHealth2 = oHealth - damage;
- oHealth = oHealth2;
- reset();
- jTextArea1.append(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health.\n");
- //jTextArea1.setText(Name + " dealt " + damage + " on " + oName + " leaving him with " + oHP + " health");
- isPlayerTurn = false;
- canUseCurrentGun2 = false;
- oTurn();
- } else {
- displayError("You do not meet the requirements to use this weapon. 1 ", 500, 100);
- }
- } else {
- displayError("Error #2, you may need to re-select the attack option. ", 500, 100);
- }
- xpGive();
- }
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- displayFrame(jFrame3, 500, 200);
- Name = jTextField1.getText();
- jLabel10.setText("Name: " + Name);
- jLabel11.setText("lvl: " + lvl);
- jLabel12.setText("Experience: " + xp);
- } catch(Exception e) {
- //hehehhehehehheh
- }
- }
- private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
- displayFrame(jFrame4, 400, 300);
- jTextArea3.setEditable(false);
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Main().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.ButtonGroup buttonGroup1;
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JButton jButton4;
- private javax.swing.JButton jButton5;
- private javax.swing.JButton jButton6;
- private javax.swing.JDialog jDialog1;
- private javax.swing.JFrame jFrame1;
- private javax.swing.JFrame jFrame2;
- private javax.swing.JFrame jFrame3;
- private javax.swing.JFrame jFrame4;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel10;
- private javax.swing.JLabel jLabel11;
- private javax.swing.JLabel jLabel12;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabel5;
- private javax.swing.JLabel jLabel6;
- private javax.swing.JLabel jLabel7;
- private javax.swing.JLabel jLabel8;
- private javax.swing.JLabel jLabel9;
- private javax.swing.JRadioButton jRadioButton1;
- private javax.swing.JRadioButton jRadioButton10;
- private javax.swing.JRadioButton jRadioButton2;
- private javax.swing.JRadioButton jRadioButton3;
- private javax.swing.JRadioButton jRadioButton4;
- private javax.swing.JRadioButton jRadioButton5;
- private javax.swing.JRadioButton jRadioButton6;
- private javax.swing.JRadioButton jRadioButton7;
- private javax.swing.JRadioButton jRadioButton8;
- private javax.swing.JRadioButton jRadioButton9;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JScrollPane jScrollPane2;
- private javax.swing.JScrollPane jScrollPane3;
- private javax.swing.JTextArea jTextArea1;
- private javax.swing.JTextArea jTextArea2;
- private javax.swing.JTextArea jTextArea3;
- private javax.swing.JTextField jTextField1;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement