Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package group.project;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.util.Random;
- import javax.swing.*;
- public class GroupProject
- {
- JFrame window;
- Container con;
- JPanel titlePanel, startButtonPanel, mainTextPanel, choiceButtonPanel, playerPanel;
- JLabel titleLabel, hpLabel, hpLabelNumber, experienceLabel, experienceNumberLabel;
- JButton startButton, choice1, choice2, choice3, choice4;
- JTextArea mainTextArea;
- Font titleFont = new Font("Comic Sans MS Bold", Font.PLAIN, 70);
- Font titleFontS = new Font("Comic Sans MS Bold", Font.PLAIN, 47);
- Font startFont = new Font("Impact", Font.PLAIN, 40);
- Font textFont = new Font ("Times New Roman Bold", Font.PLAIN, 20);
- Font textFontS = new Font ("Times New Roman Bold", Font.PLAIN, 15);
- Font buttonFont = new Font ("Times New Roman Bold", Font.PLAIN, 40);
- Font buttonFontS = new Font ("Times New Roman Bold", Font.PLAIN, 27);
- Font buttonFontES = new Font ("Times New Roman Bold", Font.PLAIN, 20);
- int currentPlayerHP = 10;
- int totalPlayerHP = 10;
- int currentPlayerXP = 0;
- int totalPlayerXP = 25;
- int enemyPokemonNum1;
- int enemyPokemonNum2;
- int enemyPokemonNum3;
- int playerLevel = 1;
- int enemyPokemonMaxHP;
- int enemyPokemonCurrentHP;
- int battleNum;
- String position;
- String pokemonType;
- TitleScreenHandler titleHandler = new TitleScreenHandler();
- ChoiceHandler choiceHandler = new ChoiceHandler();
- Potion potionAmt = new Potion();
- public GroupProject()
- {
- window = new JFrame();
- window.setSize(600, 800);
- window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- window.getContentPane().setBackground(Color.darkGray);
- window.setLayout(null);
- window.setVisible(true);
- con = window.getContentPane();
- titlePanel = new JPanel();
- titlePanel.setBounds(50,75,500,100);
- titlePanel.setBackground(Color.darkGray);
- titleLabel = new JLabel("POKÉ ARENA");
- titleLabel.setForeground(Color.white);
- titleLabel.setFont(titleFont);
- startButtonPanel = new JPanel();
- startButtonPanel.setBounds(150, 500, 300, 150);
- startButtonPanel.setBackground(Color.darkGray);
- startButton = new JButton("START");
- startButton.setBackground(Color.darkGray);
- startButton.setForeground(Color.white);
- startButton.setFont(startFont);
- startButton.addActionListener(titleHandler);
- startButton.setFocusPainted(false);
- titlePanel.add(titleLabel);
- startButtonPanel.add(startButton);
- con.add(titlePanel);
- con.add(startButtonPanel);
- }
- public void createScreen()
- {
- titlePanel.setVisible(false);
- startButtonPanel.setVisible(false);
- mainTextPanel = new JPanel();
- mainTextPanel.setBounds(125,150,350,350);
- mainTextPanel.setBackground(Color.gray);
- mainTextPanel.setBorder(BorderFactory.createLineBorder(Color.black, 2, true));
- con.add(mainTextPanel);
- mainTextArea = new JTextArea();
- mainTextArea.setBounds(100,100,300,325);
- mainTextArea.setBackground(Color.gray);
- mainTextArea.setForeground(Color.white);
- mainTextArea.setFont(textFontS);
- mainTextArea.setLineWrap(true);
- mainTextArea.setWrapStyleWord(true);
- mainTextArea.setEditable(false);
- mainTextPanel.add(mainTextArea);
- choiceButtonPanel = new JPanel();
- choiceButtonPanel.setBounds(100, 500, 400, 200);
- choiceButtonPanel.setBackground(Color.darkGray);
- con.add(choiceButtonPanel);
- choice1 = new JButton("Choice 1");
- choice1.setBackground(Color.darkGray);
- choice1.setForeground(Color.white);
- choice1.setFont(buttonFont);
- choice1.setPreferredSize(new Dimension(150,60));
- choiceButtonPanel.add(choice1);
- choice1.setFocusPainted(false);
- choice1.addActionListener(choiceHandler);
- choice1.setActionCommand("c1");
- choice2 = new JButton("Choice 2");
- choice2.setBackground(Color.darkGray);
- choice2.setForeground(Color.white);
- choice2.setFont(buttonFontS);
- choice2.setPreferredSize(new Dimension(150,60));
- choiceButtonPanel.add(choice2);
- choice2.setFocusPainted(false);
- choice2.addActionListener(choiceHandler);
- choice2.setActionCommand("c2");
- choice3 = new JButton("Choice 3");
- choice3.setBackground(Color.darkGray);
- choice3.setForeground(Color.white);
- choice3.setFont(buttonFont);
- choice3.setPreferredSize(new Dimension(150,60));
- choiceButtonPanel.add(choice3);
- choice3.setFocusPainted(false);
- choice3.addActionListener(choiceHandler);
- choice3.setActionCommand("c3");
- playerPanel = new JPanel();
- playerPanel.setBounds(100,10,400,50);
- playerPanel.setBackground(Color.gray);
- playerPanel.setLayout(new GridLayout(1,4));
- playerPanel.setBorder(BorderFactory.createLineBorder(Color.black, 2, true));
- con.add(playerPanel);
- hpLabel = new JLabel("HP: ");
- hpLabel.setHorizontalAlignment(SwingConstants.RIGHT);
- hpLabel.setFont(textFont);
- hpLabel.setForeground(Color.white);
- playerPanel.add(hpLabel);
- hpLabelNumber = new JLabel();
- hpLabelNumber.setFont(textFont);
- hpLabelNumber.setForeground(Color.white);
- playerPanel.add(hpLabelNumber);
- experienceLabel = new JLabel("EXP: ");
- experienceLabel.setHorizontalAlignment(SwingConstants.RIGHT);
- experienceLabel.setFont(textFont);
- experienceLabel.setForeground(Color.white);
- playerPanel.add(experienceLabel);
- experienceNumberLabel = new JLabel();
- experienceNumberLabel.setFont(textFont);
- experienceNumberLabel.setForeground(Color.white);
- playerPanel.add(experienceNumberLabel);
- playerSetup();
- openingCeremony();
- }
- public void playerSetup()
- {
- experienceNumberLabel.setText(currentPlayerXP + "/" + totalPlayerXP);
- hpLabelNumber.setText(currentPlayerHP + "/" + totalPlayerHP);
- }
- public void openingCeremony()
- {
- position = "openingCeremony";
- mainTextArea.setText("You stand amongst your fellow rivals"
- + " waiting your turn to come to finally "
- + "beat these sorry excuses for men into the "
- + "ground! However... you don't techniqually "
- + "have a pokemon yet... BUT ALAS! They sell "
- + "some at the general store. AWAYYYY!\n\n"
- + "=================================\n"
- + "\"Hello sir, can you please choose your desired "
- + "pokemon to fight with?\"\n\n"
- + "What a wretched wench she is INDEED!\n"
- + "=================================\n\n"
- + "Well, which Pokemon do you DESIRE?");
- choice1.setText("Charmander");
- choice1.setFont(buttonFontES);
- choice2.setText("Bulbasaur");
- choice2.setFont(buttonFontES);
- choice3.setText("Squirtle");
- choice3.setFont(buttonFontES);
- }
- public void charmanderChosen()
- {
- pokemonDecider();
- position = "charmanderChosen";
- pokemonType = "Charmander";
- mainTextArea.setFont(titleFontS);
- mainTextArea.setText("Charmander\n"
- + " HAS\n"
- + " BEEN\n"
- + " CHOSEN!!!");
- choice1.setText("");
- choice1.setVisible(false);
- choice2.setText("");
- choice2.setVisible(false);
- choice3.setText("Continue...");
- choice3.setFont(buttonFontES);
- choice3.setVisible(true);
- }
- public void bulbasaurChosen()
- {
- pokemonDecider();
- position = "bulbasaurChosen";
- pokemonType = "bulbasaur";
- mainTextArea.setFont(titleFontS);
- mainTextArea.setText("BULBASAUR\n"
- + " HAS\n"
- + " BEEN\n"
- + " CHOSEN!!!");
- choice1.setText("");
- choice1.setVisible(false);
- choice2.setText("");
- choice2.setVisible(false);
- choice3.setText("Continue...");
- choice3.setFont(buttonFontES);
- choice3.setVisible(true);
- }
- public void squirtleChosen()
- {
- pokemonDecider();
- position = "squirtleChosen";
- pokemonType = "Squirtle";
- mainTextArea.setFont(titleFontS);
- mainTextArea.setText("SQUIRTLE\n"
- + " HAS\n"
- + " BEEN\n"
- + " CHOSEN!!!");
- choice1.setText("");
- choice1.setVisible(false);
- choice2.setText("");
- choice2.setVisible(false);
- choice3.setText("Continue...");
- choice3.setFont(buttonFontES);
- choice3.setVisible(true);
- }
- public void pokemonDecider()
- {
- position = "pokemonDecider";
- int[] enemy1 = {1,2,3};
- Random random1 = new Random();
- int[] enemy2 = {1,2,3};
- Random random2 = new Random();
- int[] enemy3 = {1,2,3};
- Random random3 = new Random();
- enemyPokemonNum1 = random1.nextInt(enemy1.length);
- enemyPokemonNum2 = random2.nextInt(enemy2.length);
- enemyPokemonNum3 = random3.nextInt(enemy3.length);
- }
- public void firstBattleMessage()
- {
- position = "firstBattleMessage";
- battleNum = 1;
- String enemyPokemon;
- switch (enemyPokemonNum1) {
- case 1:
- enemyPokemon = "Magikarp";
- enemyPokemonMaxHP = 10;
- enemyPokemonCurrentHP = enemyPokemonMaxHP; break;
- case 2:
- enemyPokemon = "Metapod";
- enemyPokemonMaxHP = 15;
- enemyPokemonCurrentHP = enemyPokemonMaxHP; break;
- default:
- enemyPokemon = "Slaking";
- enemyPokemonMaxHP = 15;
- enemyPokemonCurrentHP = enemyPokemonMaxHP; break;
- }
- mainTextArea.setFont(textFontS);
- mainTextArea.setText(
- "=================================\n"
- + " BATTLE NUMBAH 1!\n"
- + "=================================\n"
- + "Your challenger brought forth " + enemyPokemon + "!\n"
- + "=================================\n\n\n\n");
- choice1.setText("");
- choice1.setVisible(false);
- choice2.setText("");
- choice2.setVisible(false);
- choice3.setText("Continue...");
- choice3.setFont(buttonFontES);
- choice3.setVisible(true);
- }
- public void firstBattle()
- {
- position = "firstBattle";
- String enemyPokemon;
- String pokemonAttack;
- switch (enemyPokemonNum1) {
- case 1:
- enemyPokemon = "Magikarp";
- pokemonAttack = "Splash";
- break;
- case 2:
- enemyPokemon = "Metapod";
- pokemonAttack = "Harden";
- break;
- default:
- enemyPokemon = "Slaking";
- pokemonAttack = "Loaf Around";
- break;
- }
- mainTextArea.setFont(textFontS);
- mainTextArea.setText(
- "=================================\n"
- + "Enemy " + enemyPokemon + " used " + pokemonAttack + "!!!\n\n"
- + "...... IT HAD NO EFFECT!\n\n"
- + "=================================\n"
- + "Your turn to fight back!!\n"
- + "=================================\n\n\n"
- + "... choose your option.");
- choice1.setText("Attack");
- choice1.setVisible(true);
- choice1.setFont(buttonFontS);
- choice2.setText("Inventory");
- choice2.setFont(buttonFontES);
- choice2.setVisible(true);
- choice3.setText("Run");
- choice3.setFont(buttonFontS);
- choice3.setVisible(true);
- }
- public void secondBattleMessage()
- {
- position = "secondBattleMessage";
- battleNum = 2;
- String enemyPokemon;
- switch (enemyPokemonNum2) {
- case 1:
- enemyPokemon = "Hitmonchan";
- enemyPokemonMaxHP = 26;
- enemyPokemonCurrentHP = enemyPokemonMaxHP;
- break;
- case 2:
- enemyPokemon = "Vaporeon";
- enemyPokemonMaxHP = 24;
- enemyPokemonCurrentHP = enemyPokemonMaxHP;
- break;
- default:
- enemyPokemon = "Tauros";
- enemyPokemonMaxHP = 30;
- enemyPokemonCurrentHP = enemyPokemonMaxHP;
- break;
- }
- mainTextArea.setFont(textFontS);
- mainTextArea.setText(
- "\n"
- + "=================================\n"
- + " BATTLE NUMBAH 2!\n"
- + "=================================\n"
- + "Your challenger brought forth " + enemyPokemon + "!\n"
- + "=================================\n\n\n\n");
- choice1.setText("");
- choice1.setVisible(false);
- choice2.setText("");
- choice2.setVisible(false);
- choice3.setText("Continue...");
- choice3.setFont(buttonFontES);
- choice3.setVisible(true);
- }
- public void secondBattle()
- {
- position = "secondBattle";
- String enemyPokemon;
- String pokemonAttack;
- int pokemonAttackNum;
- switch (enemyPokemonNum2) {
- case 1:
- enemyPokemon = "Hitmonchan";
- pokemonAttack = "Low Kick";
- pokemonAttackNum = 5;
- break;
- case 2:
- enemyPokemon = "Vaporeon";
- pokemonAttack = "Ember";
- pokemonAttackNum = 4;
- break;
- default:
- enemyPokemon = "Tauros";
- pokemonAttack = "Tackle";
- pokemonAttackNum = 4;
- break;
- }
- playerSetup();
- mainTextArea.setFont(textFontS);
- mainTextArea.setText(
- "=================================\n\n\n"
- + "Time to D-D-D-D-D-DUUEELLL!!\n"
- + "=================================\n\n\n"
- + "... choose your option.");
- choice1.setText("Attack");
- choice1.setVisible(true);
- choice1.setFont(buttonFontS);
- choice2.setText("Inventory");
- choice2.setFont(buttonFontES);
- choice2.setVisible(true);
- choice3.setText("Run");
- choice3.setFont(buttonFontS);
- choice3.setVisible(true);
- }
- public void pokemonAttacks()
- {
- position = "pokemonAttacks";
- if (playerLevel < 2)
- {
- mainTextArea.setText(
- "\n"
- + "=================================\n"
- + "So far you have but ONE attack!\n"
- + "CHOOSE WHICH ATTACK YOU WILL USE!!!\n"
- + "=================================\n\n"
- + "|--------------------------------------------|\n"
- + "| Tackle -- Just a teenie attack, |\n"
- + "| but good enough. |\n"
- + "|--------------------------------------------|\n");
- choice1.setText("Tackle");
- choice1.setFont(buttonFontS);
- choice1.setVisible(true);
- choice2.setText("");
- choice2.setFont(buttonFontS);
- choice2.setVisible(false);
- choice3.setText("Back");
- choice3.setFont(buttonFontS);
- choice3.setVisible(true);
- }
- else if (playerLevel >= 2 && playerLevel <= 3)
- {
- mainTextArea.setText(
- "\n"
- + "=================================\n"
- + "You now have TWOOOO attacks!\n"
- + "CHOOSE WHICH ATTACK YOU WILL USE!!!\n"
- + "=================================\n\n"
- + "|--------------------------------------------|\n"
- + "| Tackle -- Just a teenie attack, |\n"
- + "| but good enough. |\n"
- + "|--------------------------------------------|\n"
- + "| Quick Attack -- A bit stronger |\n"
- + "| but has a chance to miss. |\n"
- + "|--------------------------------------------|\n");
- choice1.setText("Tackle");
- choice1.setFont(buttonFontS);
- choice1.setVisible(true);
- choice2.setText("Quick Attack");
- choice2.setFont(buttonFontES);
- choice2.setVisible(true);
- choice3.setText("Back");
- choice3.setFont(buttonFontS);
- choice3.setVisible(true);
- }
- else
- {
- mainTextArea.setText(
- "\n"
- + "Player Level too high.");
- }
- }
- public void tackleBattleMessage()
- {
- position = "tackleBattleMessage";
- String enemyPokemon = "DEFAULT";
- String pokemonAttack = "DEFAULT";
- int pokemonAttackNum = 0;
- if(battleNum == 1)
- {
- switch (enemyPokemonNum1) {
- case 1:
- enemyPokemon = "Magikarp"; break;
- case 2:
- enemyPokemon = "Metapod"; break;
- default:
- enemyPokemon = "Slaking"; break;
- }
- }
- else if(battleNum == 2)
- {
- switch (enemyPokemonNum2){
- case 1:
- enemyPokemon = "Hitmonchan";
- pokemonAttack = "Low Kick";
- pokemonAttackNum = 3; break;
- case 2:
- enemyPokemon = "Vaporeon";
- pokemonAttack = "Ember";
- pokemonAttackNum = 3; break;
- default:
- enemyPokemon = "Tauros";
- pokemonAttack = "Tackle";
- pokemonAttackNum = 2; break;
- }
- }
- else
- {
- switch (enemyPokemonNum3){
- case 1:
- enemyPokemon = "Onix";
- pokemonAttack = "Rock Smash"; break;
- case 2:
- enemyPokemon = "Mr. Mime";
- pokemonAttack = "Psychic"; break;
- default:
- enemyPokemon = "Pikachu";
- pokemonAttack = "Thunderbolt"; break;
- }
- }
- enemyPokemonCurrentHP -= 5;
- currentPlayerHP = currentPlayerHP - pokemonAttackNum;
- if (enemyPokemonCurrentHP > 0)
- {
- if (battleNum == 1)
- {
- mainTextArea.setText(
- "\n"
- + "=================================\n"
- + "Your tackle was VERY effective!\n"
- + "=================================\n"
- + "You dealt 5 damage to the enemy " + enemyPokemon + ".\n\n"
- + "Enemy " + enemyPokemon + " is now at " + enemyPokemonCurrentHP + "/" + enemyPokemonMaxHP + "HP\n"
- + "=================================\n");
- }
- else if (battleNum != 1)
- {
- mainTextArea.setText(
- "\n"
- + "=================================\n"
- + "Your tackle was VERY effective!\n"
- + "=================================\n"
- + "You dealt 5 damage to the enemy " + enemyPokemon + ".\n\n"
- + "Enemy " + enemyPokemon + " is now at " + enemyPokemonCurrentHP + "/" + enemyPokemonMaxHP + "HP\n"
- + "=================================\n"
- + "Enemy " + enemyPokemon + " used " + pokemonAttack + "!!!\n\n"
- + "OH NO! They did " + pokemonAttackNum + " damage to you!!!\n");
- }
- choice1.setText("Continue...");
- choice1.setFont(buttonFontES);
- choice1.setVisible(true);
- choice2.setText("");
- choice2.setVisible(false);
- choice3.setText("");
- choice3.setVisible(false);
- }
- else
- {
- mainTextArea.setText(
- "\n"
- + "=================================\n"
- + "You've KILLED the enemy " + enemyPokemon + "!!!\n"
- + "=================================\n\n"
- + "You've gained 25 Experience Points!\n"
- + "YEEAAHH!\n"
- + "=================================\n"
- + "You've ALSO gained 1 Small Potion!!!\n"
- + "OH BABY!!!\n"
- + "=================================\n");
- currentPlayerXP = currentPlayerXP + 25;
- potionAmt.setPotions(1);
- playerSetup();
- if (currentPlayerXP >= totalPlayerXP)
- {
- levelUp();
- }
- choice1.setText("");
- choice1.setVisible(false);
- choice2.setText("Continue...");
- choice2.setFont(buttonFontES);
- choice2.setVisible(true);
- choice3.setText("");
- choice3.setVisible(false);
- }
- }
- public void quickAttackBattleMessage()
- {
- position = "quickAttackBattleMessage";
- int randNum;
- String enemyPokemon = "DEFAULT";
- String pokemonAttack = "DEFAULT";
- int pokemonAttackNum = 0;
- int[] missChance = {1,2,3,4,5};
- Random rand = new Random();
- randNum = rand.nextInt(missChance.length);
- if(battleNum == 1)
- {
- switch (enemyPokemonNum1) {
- case 1:
- enemyPokemon = "Magikarp"; break;
- case 2:
- enemyPokemon = "Metapod"; break;
- default:
- enemyPokemon = "Slaking"; break;
- }
- }
- else if(battleNum == 2)
- {
- switch (enemyPokemonNum2){
- case 1:
- enemyPokemon = "Hitmonchan";
- pokemonAttack = "Low Kick";
- pokemonAttackNum = 3; break;
- case 2:
- enemyPokemon = "Vaporeon";
- pokemonAttack = "Ember";
- pokemonAttackNum = 3; break;
- default:
- enemyPokemon = "Tauros";
- pokemonAttack = "Tackle";
- pokemonAttackNum = 2; break;
- }
- }
- else
- {
- switch (enemyPokemonNum3){
- case 1:
- enemyPokemon = "Onix";
- pokemonAttack = "Rock Smash"; break;
- case 2:
- enemyPokemon = "Mr. Mime";
- pokemonAttack = "Psychic"; break;
- default:
- enemyPokemon = "Pikachu";
- pokemonAttack = "Thunderbolt"; break;
- }
- }
- currentPlayerHP = currentPlayerHP - pokemonAttackNum;
- if (randNum != 3)
- {
- enemyPokemonCurrentHP -= 8;
- if (enemyPokemonCurrentHP > 0)
- {
- if (battleNum == 1)
- {
- mainTextArea.setText(
- "\n"
- + "=================================\n"
- + "Your quick attack was VERY effective!\n"
- + "=================================\n"
- + "You dealt 8 damage to the enemy " + enemyPokemon + ".\n\n"
- + "Enemy " + enemyPokemon + " is now at " + enemyPokemonCurrentHP + "/" + enemyPokemonMaxHP + "HP\n"
- + "=================================\n");
- }
- else if (battleNum != 1)
- {
- mainTextArea.setText(
- "\n"
- + "=================================\n"
- + "Your quick attack was VERY effective!\n"
- + "=================================\n"
- + "You dealt 8 damage to the enemy " + enemyPokemon + ".\n\n"
- + "Enemy " + enemyPokemon + " is now at " + enemyPokemonCurrentHP + "/" + enemyPokemonMaxHP + "HP\n"
- + "=================================\n"
- + "Enemy " + enemyPokemon + " used " + pokemonAttack + "!!!\n\n"
- + "OH NO! They did " + pokemonAttackNum + " damage to you!!!\n");
- }
- choice1.setText("Continue...");
- choice1.setFont(buttonFontES);
- choice1.setVisible(true);
- choice2.setText("");
- choice2.setVisible(false);
- choice3.setText("");
- choice3.setVisible(false);
- }
- else
- {
- mainTextArea.setText(
- "\n"
- + "=================================\n"
- + "You've KILLED the enemy " + enemyPokemon + "!!!\n"
- + "=================================\n\n"
- + "You've gained 25 Experience Points!\n"
- + "YEEAAHH!\n"
- + "=================================\n"
- + "You've ALSO gained 1 Small Potion!!!\n"
- + "OH BABY!!!\n"
- + "=================================\n");
- currentPlayerXP = currentPlayerXP + 25;
- potionAmt.setPotions(1);
- playerSetup();
- choice1.setText("");
- choice1.setVisible(false);
- choice2.setText("Continue...");
- choice2.setFont(buttonFontES);
- choice2.setVisible(true);
- choice3.setText("");
- choice3.setVisible(false);
- }
- }
- else
- {
- if (battleNum == 1)
- {
- mainTextArea.setText("\n"
- + "=================================\n"
- + "OH NO!!!\n"
- + "YOU MISSED YOUR QUICK ATTACK!!\n"
- + "=================================\n\n\n"
- + "Better luck next time then. ;)");
- }
- else if (battleNum != 1)
- {
- mainTextArea.setText("\n"
- + "=================================\n"
- + "OH NO!!!\n"
- + "YOU MISSED YOUR QUICK ATTACK!!\n"
- + "=================================\n\n\n"
- + "Better luck next time then. ;)\n"
- + "=================================\n"
- + "Enemy " + enemyPokemon + " used " + pokemonAttack + "!!!\n\n"
- + "OH NO! They did " + pokemonAttackNum + " damage to you!!!\n");
- }
- choice1.setText("");
- choice1.setVisible(false);
- choice2.setText("");
- choice2.setVisible(false);
- choice3.setText("Continue...");
- choice3.setFont(buttonFontES);
- choice3.setVisible(true);
- }
- }
- public void inventoryMenu()
- {
- position = "inventoryMenu";
- int potion = potionAmt.getPotions();
- if(potion > 0)
- {
- mainTextArea.setText("\n\n"
- + "You have " + potion + " Potions in your bag.\n"
- + "=================================\n"
- + "Each Potion heals for 10 HP\n\n"
- + "As you can see above, you are currently\n"
- + " at " + currentPlayerHP + " HP.\n"
- + "=================================\n\n"
- + "Would you like to use a potion?");
- choice1.setText("");
- choice1.setVisible(false);
- choice2.setText("Yes");
- choice2.setFont(buttonFont);
- choice2.setVisible(true);
- choice3.setText("No");
- choice3.setFont(buttonFont);
- choice3.setVisible(true);
- }
- else
- {
- mainTextArea.setText(
- "\n\n\n\n"
- + "IT'S EMPTY YOU FOOOOOOLLLL!!!!!");
- choice1.setText("Back");
- choice1.setFont(buttonFontS);
- choice2.setText("");
- choice2.setVisible(false);
- choice3.setText("");
- choice3.setVisible(false);
- }
- }
- public void potionUsed()
- {
- potionAmt.setPotions(-1);
- currentPlayerHP = currentPlayerHP + 10;
- if (currentPlayerHP > totalPlayerHP)
- {
- currentPlayerHP = totalPlayerHP;
- }
- playerSetup();
- mainTextArea.setText("\n\n"
- + "You used 1 potion and healed a maximum of 10 HP.\n"
- + "=================================\n"
- + "Your current health as you can see above is " + currentPlayerHP + " HP.\n");
- choice1.setText("Continue...");
- choice1.setFont(buttonFontES);
- choice1.setVisible(true);
- choice2.setText("");
- choice2.setVisible(false);
- choice3.setText("");
- choice3.setVisible(false);
- }
- public void runOption()
- {
- position = "runOption";
- mainTextArea.setText(
- "\n\n\n\n"
- + "YOU THINK YOU CAN RUUNNN?!?! THINK AGAAIN\n\n"
- + "AAAAHAHAHAHAHAHAAAAAAA");
- choice1.setText("Back");
- choice1.setFont(buttonFontS);
- choice2.setText("");
- choice2.setVisible(false);
- choice3.setText("");
- choice3.setVisible(false);
- }
- public void levelUp()
- {
- position = "levelUp";
- mainTextArea.setText("\n\n\n"
- + "YYYOOOOUUU LLLEEEEVVEEEEELLLEEEEDDDD UUUUUUUUUUUUUPPPPPPPPP!!!!!!!!!!!!!!!!!!\n"
- + "YYYYEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAHHHHHHHHH!!!!!\n"
- + "=================================\n\n"
- + "Level " + playerLevel + ": \n"
- + "HP Gained: 10\n"
- + "Current XP Reduced to: 0/50\n\n\n"
- + "...congrats ;D");
- totalPlayerXP = 50;
- currentPlayerXP = 0;
- playerLevel = playerLevel + 1;
- totalPlayerHP = totalPlayerHP + 10;
- currentPlayerHP = totalPlayerHP;
- playerSetup();
- choice1.setText("");
- choice1.setVisible(false);
- choice2.setText("");
- choice2.setVisible(false);
- choice3.setText("Continue...");
- choice3.setFont(buttonFontES);
- choice3.setVisible(true);
- }
- public class TitleScreenHandler implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- createScreen();
- }
- }
- public class ChoiceHandler implements ActionListener
- {
- @Override
- public void actionPerformed(ActionEvent event)
- {
- String yourChoice = event.getActionCommand();
- switch(position)
- {
- case "openingCeremony":
- switch(yourChoice)
- {
- case "c1": charmanderChosen(); break;
- case "c2": bulbasaurChosen(); break;
- case "c3": squirtleChosen(); break;
- }
- break;
- case "charmanderChosen":
- switch(yourChoice)
- {
- case "c3": firstBattleMessage(); break;
- }
- break;
- case "bulbasaurChosen":
- switch(yourChoice)
- {
- case "c3": firstBattleMessage(); break;
- }
- break;
- case "squirtleChosen":
- switch(yourChoice)
- {
- case "c3": firstBattleMessage(); break;
- }
- break;
- case "firstBattleMessage":
- switch(yourChoice)
- {
- case "c3": firstBattle(); break;
- }
- break;
- case "firstBattle":
- switch(yourChoice)
- {
- case "c1": pokemonAttacks(); break;
- case "c2": inventoryMenu(); break;
- case "c3": runOption(); break;
- }
- break;
- case "secondBattleMessage":
- switch(yourChoice)
- {
- case "c3": secondBattle(); break;
- }
- break;
- case "secondBattle":
- switch(yourChoice)
- {
- case "c1": pokemonAttacks(); break;
- case "c2": inventoryMenu(); break;
- case "c3": runOption();break;
- }
- break;
- case "levelUp":
- switch(yourChoice)
- {
- case "c3": secondBattleMessage(); break;
- }
- break;
- case "inventoryMenu":
- switch(yourChoice)
- {
- case "c1":
- if (battleNum == 1)
- {
- firstBattle(); break;
- }
- else if (battleNum == 2)
- {
- secondBattle(); break;
- }
- else
- {
- break;
- }
- case "c2": potionUsed(); break;
- case "c3":
- if (battleNum == 1)
- {
- firstBattle(); break;
- }
- else if (battleNum == 2)
- {
- secondBattle(); break;
- }
- else
- {
- break;
- }
- }
- break;
- case "potionUsed":
- switch(yourChoice)
- {
- case "c1":
- if (battleNum == 1)
- {
- firstBattle(); break;
- }
- else if (battleNum == 2)
- {
- secondBattle(); break;
- }
- else
- {
- break;
- }
- }
- break;
- case "runOption":
- switch(yourChoice)
- {
- case "c1": firstBattle(); break;
- }
- break;
- case "pokemonAttacks":
- switch(yourChoice)
- {
- case "c1": tackleBattleMessage(); break;
- case "c2": quickAttackBattleMessage(); break;
- case "c3":
- if (battleNum == 1)
- {
- firstBattle(); break;
- }
- else if (battleNum == 2)
- {
- secondBattle(); break;
- }
- else
- {
- break;
- }
- }
- break;
- case "tackleBattleMessage":
- switch(yourChoice)
- {
- case "c1":
- if (battleNum == 1)
- {
- firstBattle(); break;
- }
- else if (battleNum == 2)
- {
- secondBattle(); break;
- }
- else
- {
- break;
- }
- case "c2":
- if (battleNum == 1)
- {
- secondBattleMessage(); break;
- }
- else if (battleNum == 2)
- {
- break;
- }
- else
- {
- break;
- }
- }
- break;
- case "quickAttackBattleMessage":
- switch(yourChoice)
- {
- case "c1":
- if (battleNum == 1)
- {
- firstBattle(); break;
- }
- else if (battleNum == 2)
- {
- secondBattle(); break;
- }
- else
- {
- break;
- }
- case "c2":
- if (battleNum == 1)
- {
- secondBattleMessage(); break;
- }
- else
- {
- break;
- }
- case "c3":
- if (battleNum == 1)
- {
- firstBattle(); break;
- }
- else if (battleNum == 2)
- {
- secondBattle(); break;
- }
- else
- {
- break;
- }
- }
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement