Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.69 KB | None | 0 0
  1. package group.project;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. import java.util.Random;
  7. import javax.swing.*;
  8.  
  9. public class GroupProject
  10. {
  11. JFrame window;
  12. Container con;
  13. JPanel titlePanel, startButtonPanel, mainTextPanel, choiceButtonPanel, playerPanel;
  14. JLabel titleLabel, hpLabel, hpLabelNumber, experienceLabel, experienceNumberLabel;
  15. JButton startButton, choice1, choice2, choice3, choice4;
  16. JTextArea mainTextArea;
  17.  
  18. Font titleFont = new Font("Comic Sans MS Bold", Font.PLAIN, 70);
  19. Font titleFontS = new Font("Comic Sans MS Bold", Font.PLAIN, 47);
  20. Font startFont = new Font("Impact", Font.PLAIN, 40);
  21. Font textFont = new Font ("Times New Roman Bold", Font.PLAIN, 20);
  22. Font textFontS = new Font ("Times New Roman Bold", Font.PLAIN, 15);
  23. Font buttonFont = new Font ("Times New Roman Bold", Font.PLAIN, 40);
  24. Font buttonFontS = new Font ("Times New Roman Bold", Font.PLAIN, 27);
  25. Font buttonFontES = new Font ("Times New Roman Bold", Font.PLAIN, 20);
  26.  
  27. int currentPlayerHP = 10;
  28. int totalPlayerHP = 10;
  29. int currentPlayerXP = 0;
  30. int totalPlayerXP = 25;
  31. int enemyPokemonNum1;
  32. int enemyPokemonNum2;
  33. int enemyPokemonNum3;
  34. int playerLevel = 1;
  35. int enemyPokemonMaxHP;
  36. int enemyPokemonCurrentHP;
  37. int battleNum;
  38.  
  39. String position;
  40. String pokemonType;
  41.  
  42. TitleScreenHandler titleHandler = new TitleScreenHandler();
  43. ChoiceHandler choiceHandler = new ChoiceHandler();
  44. Potion potionAmt = new Potion();
  45.  
  46. public GroupProject()
  47. {
  48. window = new JFrame();
  49. window.setSize(600, 800);
  50. window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  51. window.getContentPane().setBackground(Color.darkGray);
  52. window.setLayout(null);
  53. window.setVisible(true);
  54. con = window.getContentPane();
  55.  
  56. titlePanel = new JPanel();
  57. titlePanel.setBounds(50,75,500,100);
  58. titlePanel.setBackground(Color.darkGray);
  59. titleLabel = new JLabel("POKÉ ARENA");
  60. titleLabel.setForeground(Color.white);
  61. titleLabel.setFont(titleFont);
  62.  
  63. startButtonPanel = new JPanel();
  64. startButtonPanel.setBounds(150, 500, 300, 150);
  65. startButtonPanel.setBackground(Color.darkGray);
  66.  
  67. startButton = new JButton("START");
  68. startButton.setBackground(Color.darkGray);
  69. startButton.setForeground(Color.white);
  70. startButton.setFont(startFont);
  71. startButton.addActionListener(titleHandler);
  72. startButton.setFocusPainted(false);
  73.  
  74. titlePanel.add(titleLabel);
  75. startButtonPanel.add(startButton);
  76.  
  77. con.add(titlePanel);
  78. con.add(startButtonPanel);
  79. }
  80.  
  81. public void createScreen()
  82. {
  83. titlePanel.setVisible(false);
  84. startButtonPanel.setVisible(false);
  85.  
  86. mainTextPanel = new JPanel();
  87. mainTextPanel.setBounds(125,150,350,350);
  88. mainTextPanel.setBackground(Color.gray);
  89. mainTextPanel.setBorder(BorderFactory.createLineBorder(Color.black, 2, true));
  90. con.add(mainTextPanel);
  91.  
  92. mainTextArea = new JTextArea();
  93. mainTextArea.setBounds(100,100,300,325);
  94. mainTextArea.setBackground(Color.gray);
  95. mainTextArea.setForeground(Color.white);
  96. mainTextArea.setFont(textFontS);
  97. mainTextArea.setLineWrap(true);
  98. mainTextArea.setWrapStyleWord(true);
  99. mainTextArea.setEditable(false);
  100. mainTextPanel.add(mainTextArea);
  101.  
  102. choiceButtonPanel = new JPanel();
  103. choiceButtonPanel.setBounds(100, 500, 400, 200);
  104. choiceButtonPanel.setBackground(Color.darkGray);
  105. con.add(choiceButtonPanel);
  106.  
  107. choice1 = new JButton("Choice 1");
  108. choice1.setBackground(Color.darkGray);
  109. choice1.setForeground(Color.white);
  110. choice1.setFont(buttonFont);
  111. choice1.setPreferredSize(new Dimension(150,60));
  112. choiceButtonPanel.add(choice1);
  113. choice1.setFocusPainted(false);
  114. choice1.addActionListener(choiceHandler);
  115. choice1.setActionCommand("c1");
  116.  
  117. choice2 = new JButton("Choice 2");
  118. choice2.setBackground(Color.darkGray);
  119. choice2.setForeground(Color.white);
  120. choice2.setFont(buttonFontS);
  121. choice2.setPreferredSize(new Dimension(150,60));
  122. choiceButtonPanel.add(choice2);
  123. choice2.setFocusPainted(false);
  124. choice2.addActionListener(choiceHandler);
  125. choice2.setActionCommand("c2");
  126.  
  127. choice3 = new JButton("Choice 3");
  128. choice3.setBackground(Color.darkGray);
  129. choice3.setForeground(Color.white);
  130. choice3.setFont(buttonFont);
  131. choice3.setPreferredSize(new Dimension(150,60));
  132. choiceButtonPanel.add(choice3);
  133. choice3.setFocusPainted(false);
  134. choice3.addActionListener(choiceHandler);
  135. choice3.setActionCommand("c3");
  136.  
  137. playerPanel = new JPanel();
  138. playerPanel.setBounds(100,10,400,50);
  139. playerPanel.setBackground(Color.gray);
  140. playerPanel.setLayout(new GridLayout(1,4));
  141. playerPanel.setBorder(BorderFactory.createLineBorder(Color.black, 2, true));
  142. con.add(playerPanel);
  143.  
  144. hpLabel = new JLabel("HP: ");
  145. hpLabel.setHorizontalAlignment(SwingConstants.RIGHT);
  146. hpLabel.setFont(textFont);
  147. hpLabel.setForeground(Color.white);
  148. playerPanel.add(hpLabel);
  149.  
  150. hpLabelNumber = new JLabel();
  151. hpLabelNumber.setFont(textFont);
  152. hpLabelNumber.setForeground(Color.white);
  153. playerPanel.add(hpLabelNumber);
  154.  
  155. experienceLabel = new JLabel("EXP: ");
  156. experienceLabel.setHorizontalAlignment(SwingConstants.RIGHT);
  157. experienceLabel.setFont(textFont);
  158. experienceLabel.setForeground(Color.white);
  159. playerPanel.add(experienceLabel);
  160.  
  161. experienceNumberLabel = new JLabel();
  162. experienceNumberLabel.setFont(textFont);
  163. experienceNumberLabel.setForeground(Color.white);
  164. playerPanel.add(experienceNumberLabel);
  165.  
  166. playerSetup();
  167. openingCeremony();
  168. }
  169.  
  170. public void playerSetup()
  171. {
  172. experienceNumberLabel.setText(currentPlayerXP + "/" + totalPlayerXP);
  173. hpLabelNumber.setText(currentPlayerHP + "/" + totalPlayerHP);
  174. }
  175.  
  176. public void openingCeremony()
  177. {
  178. position = "openingCeremony";
  179.  
  180. mainTextArea.setText("You stand amongst your fellow rivals"
  181. + " waiting your turn to come to finally "
  182. + "beat these sorry excuses for men into the "
  183. + "ground! However... you don't techniqually "
  184. + "have a pokemon yet... BUT ALAS! They sell "
  185. + "some at the general store. AWAYYYY!\n\n"
  186. + "=================================\n"
  187. + "\"Hello sir, can you please choose your desired "
  188. + "pokemon to fight with?\"\n\n"
  189. + "What a wretched wench she is INDEED!\n"
  190. + "=================================\n\n"
  191. + "Well, which Pokemon do you DESIRE?");
  192.  
  193.  
  194. choice1.setText("Charmander");
  195. choice1.setFont(buttonFontES);
  196. choice2.setText("Bulbasaur");
  197. choice2.setFont(buttonFontES);
  198. choice3.setText("Squirtle");
  199. choice3.setFont(buttonFontES);
  200. }
  201.  
  202. public void charmanderChosen()
  203. {
  204. pokemonDecider();
  205. position = "charmanderChosen";
  206. pokemonType = "Charmander";
  207.  
  208. mainTextArea.setFont(titleFontS);
  209. mainTextArea.setText("Charmander\n"
  210. + " HAS\n"
  211. + " BEEN\n"
  212. + " CHOSEN!!!");
  213.  
  214.  
  215. choice1.setText("");
  216. choice1.setVisible(false);
  217. choice2.setText("");
  218. choice2.setVisible(false);
  219. choice3.setText("Continue...");
  220. choice3.setFont(buttonFontES);
  221. choice3.setVisible(true);
  222. }
  223.  
  224. public void bulbasaurChosen()
  225. {
  226. pokemonDecider();
  227. position = "bulbasaurChosen";
  228. pokemonType = "bulbasaur";
  229.  
  230. mainTextArea.setFont(titleFontS);
  231. mainTextArea.setText("BULBASAUR\n"
  232. + " HAS\n"
  233. + " BEEN\n"
  234. + " CHOSEN!!!");
  235.  
  236. choice1.setText("");
  237. choice1.setVisible(false);
  238. choice2.setText("");
  239. choice2.setVisible(false);
  240. choice3.setText("Continue...");
  241. choice3.setFont(buttonFontES);
  242. choice3.setVisible(true);
  243. }
  244.  
  245. public void squirtleChosen()
  246. {
  247. pokemonDecider();
  248. position = "squirtleChosen";
  249. pokemonType = "Squirtle";
  250.  
  251. mainTextArea.setFont(titleFontS);
  252. mainTextArea.setText("SQUIRTLE\n"
  253. + " HAS\n"
  254. + " BEEN\n"
  255. + " CHOSEN!!!");
  256.  
  257. choice1.setText("");
  258. choice1.setVisible(false);
  259. choice2.setText("");
  260. choice2.setVisible(false);
  261. choice3.setText("Continue...");
  262. choice3.setFont(buttonFontES);
  263. choice3.setVisible(true);
  264. }
  265.  
  266. public void pokemonDecider()
  267. {
  268. position = "pokemonDecider";
  269.  
  270. int[] enemy1 = {1,2,3};
  271. Random random1 = new Random();
  272.  
  273. int[] enemy2 = {1,2,3};
  274. Random random2 = new Random();
  275.  
  276. int[] enemy3 = {1,2,3};
  277. Random random3 = new Random();
  278.  
  279. enemyPokemonNum1 = random1.nextInt(enemy1.length);
  280. enemyPokemonNum2 = random2.nextInt(enemy2.length);
  281. enemyPokemonNum3 = random3.nextInt(enemy3.length);
  282. }
  283.  
  284. public void firstBattleMessage()
  285. {
  286. position = "firstBattleMessage";
  287. battleNum = 1;
  288.  
  289. String enemyPokemon;
  290.  
  291. switch (enemyPokemonNum1) {
  292. case 1:
  293. enemyPokemon = "Magikarp";
  294. enemyPokemonMaxHP = 10;
  295. enemyPokemonCurrentHP = enemyPokemonMaxHP; break;
  296. case 2:
  297. enemyPokemon = "Metapod";
  298. enemyPokemonMaxHP = 15;
  299. enemyPokemonCurrentHP = enemyPokemonMaxHP; break;
  300. default:
  301. enemyPokemon = "Slaking";
  302. enemyPokemonMaxHP = 15;
  303. enemyPokemonCurrentHP = enemyPokemonMaxHP; break;
  304. }
  305.  
  306. mainTextArea.setFont(textFontS);
  307. mainTextArea.setText(
  308. "=================================\n"
  309. + " BATTLE NUMBAH 1!\n"
  310. + "=================================\n"
  311. + "Your challenger brought forth " + enemyPokemon + "!\n"
  312. + "=================================\n\n\n\n");
  313.  
  314. choice1.setText("");
  315. choice1.setVisible(false);
  316. choice2.setText("");
  317. choice2.setVisible(false);
  318. choice3.setText("Continue...");
  319. choice3.setFont(buttonFontES);
  320. choice3.setVisible(true);
  321. }
  322.  
  323. public void firstBattle()
  324. {
  325. position = "firstBattle";
  326. String enemyPokemon;
  327. String pokemonAttack;
  328.  
  329. switch (enemyPokemonNum1) {
  330. case 1:
  331. enemyPokemon = "Magikarp";
  332. pokemonAttack = "Splash";
  333. break;
  334. case 2:
  335. enemyPokemon = "Metapod";
  336. pokemonAttack = "Harden";
  337. break;
  338. default:
  339. enemyPokemon = "Slaking";
  340. pokemonAttack = "Loaf Around";
  341. break;
  342. }
  343.  
  344. mainTextArea.setFont(textFontS);
  345. mainTextArea.setText(
  346. "=================================\n"
  347. + "Enemy " + enemyPokemon + " used " + pokemonAttack + "!!!\n\n"
  348. + "...... IT HAD NO EFFECT!\n\n"
  349. + "=================================\n"
  350. + "Your turn to fight back!!\n"
  351. + "=================================\n\n\n"
  352. + "... choose your option.");
  353.  
  354. choice1.setText("Attack");
  355. choice1.setVisible(true);
  356. choice1.setFont(buttonFontS);
  357. choice2.setText("Inventory");
  358. choice2.setFont(buttonFontES);
  359. choice2.setVisible(true);
  360. choice3.setText("Run");
  361. choice3.setFont(buttonFontS);
  362. choice3.setVisible(true);
  363. }
  364.  
  365. public void secondBattleMessage()
  366. {
  367. position = "secondBattleMessage";
  368. battleNum = 2;
  369.  
  370. String enemyPokemon;
  371.  
  372. switch (enemyPokemonNum2) {
  373. case 1:
  374. enemyPokemon = "Hitmonchan";
  375. enemyPokemonMaxHP = 26;
  376. enemyPokemonCurrentHP = enemyPokemonMaxHP;
  377. break;
  378. case 2:
  379. enemyPokemon = "Vaporeon";
  380. enemyPokemonMaxHP = 24;
  381. enemyPokemonCurrentHP = enemyPokemonMaxHP;
  382. break;
  383. default:
  384. enemyPokemon = "Tauros";
  385. enemyPokemonMaxHP = 30;
  386. enemyPokemonCurrentHP = enemyPokemonMaxHP;
  387. break;
  388. }
  389.  
  390. mainTextArea.setFont(textFontS);
  391. mainTextArea.setText(
  392. "\n"
  393. + "=================================\n"
  394. + " BATTLE NUMBAH 2!\n"
  395. + "=================================\n"
  396. + "Your challenger brought forth " + enemyPokemon + "!\n"
  397. + "=================================\n\n\n\n");
  398.  
  399. choice1.setText("");
  400. choice1.setVisible(false);
  401. choice2.setText("");
  402. choice2.setVisible(false);
  403. choice3.setText("Continue...");
  404. choice3.setFont(buttonFontES);
  405. choice3.setVisible(true);
  406. }
  407.  
  408. public void secondBattle()
  409. {
  410. position = "secondBattle";
  411.  
  412. String enemyPokemon;
  413. String pokemonAttack;
  414. int pokemonAttackNum;
  415.  
  416. switch (enemyPokemonNum2) {
  417. case 1:
  418. enemyPokemon = "Hitmonchan";
  419. pokemonAttack = "Low Kick";
  420. pokemonAttackNum = 5;
  421. break;
  422. case 2:
  423. enemyPokemon = "Vaporeon";
  424. pokemonAttack = "Ember";
  425. pokemonAttackNum = 4;
  426. break;
  427. default:
  428. enemyPokemon = "Tauros";
  429. pokemonAttack = "Tackle";
  430. pokemonAttackNum = 4;
  431. break;
  432. }
  433.  
  434. playerSetup();
  435.  
  436. mainTextArea.setFont(textFontS);
  437. mainTextArea.setText(
  438. "=================================\n\n\n"
  439. + "Time to D-D-D-D-D-DUUEELLL!!\n"
  440. + "=================================\n\n\n"
  441. + "... choose your option.");
  442.  
  443. choice1.setText("Attack");
  444. choice1.setVisible(true);
  445. choice1.setFont(buttonFontS);
  446. choice2.setText("Inventory");
  447. choice2.setFont(buttonFontES);
  448. choice2.setVisible(true);
  449. choice3.setText("Run");
  450. choice3.setFont(buttonFontS);
  451. choice3.setVisible(true);
  452. }
  453.  
  454. public void pokemonAttacks()
  455. {
  456. position = "pokemonAttacks";
  457.  
  458. if (playerLevel < 2)
  459. {
  460. mainTextArea.setText(
  461. "\n"
  462. + "=================================\n"
  463. + "So far you have but ONE attack!\n"
  464. + "CHOOSE WHICH ATTACK YOU WILL USE!!!\n"
  465. + "=================================\n\n"
  466. + "|--------------------------------------------|\n"
  467. + "| Tackle -- Just a teenie attack, |\n"
  468. + "| but good enough. |\n"
  469. + "|--------------------------------------------|\n");
  470.  
  471. choice1.setText("Tackle");
  472. choice1.setFont(buttonFontS);
  473. choice1.setVisible(true);
  474. choice2.setText("");
  475. choice2.setFont(buttonFontS);
  476. choice2.setVisible(false);
  477. choice3.setText("Back");
  478. choice3.setFont(buttonFontS);
  479. choice3.setVisible(true);
  480. }
  481.  
  482. else if (playerLevel >= 2 && playerLevel <= 3)
  483. {
  484. mainTextArea.setText(
  485. "\n"
  486. + "=================================\n"
  487. + "You now have TWOOOO attacks!\n"
  488. + "CHOOSE WHICH ATTACK YOU WILL USE!!!\n"
  489. + "=================================\n\n"
  490. + "|--------------------------------------------|\n"
  491. + "| Tackle -- Just a teenie attack, |\n"
  492. + "| but good enough. |\n"
  493. + "|--------------------------------------------|\n"
  494. + "| Quick Attack -- A bit stronger |\n"
  495. + "| but has a chance to miss. |\n"
  496. + "|--------------------------------------------|\n");
  497.  
  498. choice1.setText("Tackle");
  499. choice1.setFont(buttonFontS);
  500. choice1.setVisible(true);
  501. choice2.setText("Quick Attack");
  502. choice2.setFont(buttonFontES);
  503. choice2.setVisible(true);
  504. choice3.setText("Back");
  505. choice3.setFont(buttonFontS);
  506. choice3.setVisible(true);
  507. }
  508.  
  509. else
  510. {
  511. mainTextArea.setText(
  512. "\n"
  513. + "Player Level too high.");
  514. }
  515. }
  516.  
  517. public void tackleBattleMessage()
  518. {
  519. position = "tackleBattleMessage";
  520.  
  521. String enemyPokemon = "DEFAULT";
  522. String pokemonAttack = "DEFAULT";
  523. int pokemonAttackNum = 0;
  524.  
  525. if(battleNum == 1)
  526. {
  527. switch (enemyPokemonNum1) {
  528. case 1:
  529. enemyPokemon = "Magikarp"; break;
  530. case 2:
  531. enemyPokemon = "Metapod"; break;
  532. default:
  533. enemyPokemon = "Slaking"; break;
  534. }
  535. }
  536. else if(battleNum == 2)
  537. {
  538. switch (enemyPokemonNum2){
  539. case 1:
  540. enemyPokemon = "Hitmonchan";
  541. pokemonAttack = "Low Kick";
  542. pokemonAttackNum = 3; break;
  543. case 2:
  544. enemyPokemon = "Vaporeon";
  545. pokemonAttack = "Ember";
  546. pokemonAttackNum = 3; break;
  547. default:
  548. enemyPokemon = "Tauros";
  549. pokemonAttack = "Tackle";
  550. pokemonAttackNum = 2; break;
  551. }
  552. }
  553. else
  554. {
  555. switch (enemyPokemonNum3){
  556. case 1:
  557. enemyPokemon = "Onix";
  558. pokemonAttack = "Rock Smash"; break;
  559. case 2:
  560. enemyPokemon = "Mr. Mime";
  561. pokemonAttack = "Psychic"; break;
  562. default:
  563. enemyPokemon = "Pikachu";
  564. pokemonAttack = "Thunderbolt"; break;
  565. }
  566. }
  567.  
  568. enemyPokemonCurrentHP -= 5;
  569. currentPlayerHP = currentPlayerHP - pokemonAttackNum;
  570.  
  571. if (enemyPokemonCurrentHP > 0)
  572. {
  573. if (battleNum == 1)
  574. {
  575. mainTextArea.setText(
  576. "\n"
  577. + "=================================\n"
  578. + "Your tackle was VERY effective!\n"
  579. + "=================================\n"
  580. + "You dealt 5 damage to the enemy " + enemyPokemon + ".\n\n"
  581. + "Enemy " + enemyPokemon + " is now at " + enemyPokemonCurrentHP + "/" + enemyPokemonMaxHP + "HP\n"
  582. + "=================================\n");
  583. }
  584.  
  585.  
  586. else if (battleNum != 1)
  587. {
  588. mainTextArea.setText(
  589. "\n"
  590. + "=================================\n"
  591. + "Your tackle was VERY effective!\n"
  592. + "=================================\n"
  593. + "You dealt 5 damage to the enemy " + enemyPokemon + ".\n\n"
  594. + "Enemy " + enemyPokemon + " is now at " + enemyPokemonCurrentHP + "/" + enemyPokemonMaxHP + "HP\n"
  595. + "=================================\n"
  596. + "Enemy " + enemyPokemon + " used " + pokemonAttack + "!!!\n\n"
  597. + "OH NO! They did " + pokemonAttackNum + " damage to you!!!\n");
  598. }
  599. choice1.setText("Continue...");
  600. choice1.setFont(buttonFontES);
  601. choice1.setVisible(true);
  602. choice2.setText("");
  603. choice2.setVisible(false);
  604. choice3.setText("");
  605. choice3.setVisible(false);
  606. }
  607. else
  608. {
  609. mainTextArea.setText(
  610. "\n"
  611. + "=================================\n"
  612. + "You've KILLED the enemy " + enemyPokemon + "!!!\n"
  613. + "=================================\n\n"
  614. + "You've gained 25 Experience Points!\n"
  615. + "YEEAAHH!\n"
  616. + "=================================\n"
  617. + "You've ALSO gained 1 Small Potion!!!\n"
  618. + "OH BABY!!!\n"
  619. + "=================================\n");
  620.  
  621. currentPlayerXP = currentPlayerXP + 25;
  622.  
  623. potionAmt.setPotions(1);
  624.  
  625. playerSetup();
  626.  
  627. if (currentPlayerXP >= totalPlayerXP)
  628. {
  629. levelUp();
  630. }
  631.  
  632. choice1.setText("");
  633. choice1.setVisible(false);
  634. choice2.setText("Continue...");
  635. choice2.setFont(buttonFontES);
  636. choice2.setVisible(true);
  637. choice3.setText("");
  638. choice3.setVisible(false);
  639. }
  640. }
  641.  
  642. public void quickAttackBattleMessage()
  643. {
  644. position = "quickAttackBattleMessage";
  645.  
  646. int randNum;
  647. String enemyPokemon = "DEFAULT";
  648. String pokemonAttack = "DEFAULT";
  649. int pokemonAttackNum = 0;
  650.  
  651. int[] missChance = {1,2,3,4,5};
  652. Random rand = new Random();
  653. randNum = rand.nextInt(missChance.length);
  654.  
  655. if(battleNum == 1)
  656. {
  657. switch (enemyPokemonNum1) {
  658. case 1:
  659. enemyPokemon = "Magikarp"; break;
  660. case 2:
  661. enemyPokemon = "Metapod"; break;
  662. default:
  663. enemyPokemon = "Slaking"; break;
  664. }
  665. }
  666. else if(battleNum == 2)
  667. {
  668. switch (enemyPokemonNum2){
  669. case 1:
  670. enemyPokemon = "Hitmonchan";
  671. pokemonAttack = "Low Kick";
  672. pokemonAttackNum = 3; break;
  673. case 2:
  674. enemyPokemon = "Vaporeon";
  675. pokemonAttack = "Ember";
  676. pokemonAttackNum = 3; break;
  677. default:
  678. enemyPokemon = "Tauros";
  679. pokemonAttack = "Tackle";
  680. pokemonAttackNum = 2; break;
  681. }
  682. }
  683. else
  684. {
  685. switch (enemyPokemonNum3){
  686. case 1:
  687. enemyPokemon = "Onix";
  688. pokemonAttack = "Rock Smash"; break;
  689. case 2:
  690. enemyPokemon = "Mr. Mime";
  691. pokemonAttack = "Psychic"; break;
  692. default:
  693. enemyPokemon = "Pikachu";
  694. pokemonAttack = "Thunderbolt"; break;
  695. }
  696. }
  697.  
  698. currentPlayerHP = currentPlayerHP - pokemonAttackNum;
  699.  
  700. if (randNum != 3)
  701. {
  702. enemyPokemonCurrentHP -= 8;
  703.  
  704. if (enemyPokemonCurrentHP > 0)
  705. {
  706. if (battleNum == 1)
  707. {
  708. mainTextArea.setText(
  709. "\n"
  710. + "=================================\n"
  711. + "Your quick attack was VERY effective!\n"
  712. + "=================================\n"
  713. + "You dealt 8 damage to the enemy " + enemyPokemon + ".\n\n"
  714. + "Enemy " + enemyPokemon + " is now at " + enemyPokemonCurrentHP + "/" + enemyPokemonMaxHP + "HP\n"
  715. + "=================================\n");
  716. }
  717.  
  718.  
  719. else if (battleNum != 1)
  720. {
  721. mainTextArea.setText(
  722. "\n"
  723. + "=================================\n"
  724. + "Your quick attack was VERY effective!\n"
  725. + "=================================\n"
  726. + "You dealt 8 damage to the enemy " + enemyPokemon + ".\n\n"
  727. + "Enemy " + enemyPokemon + " is now at " + enemyPokemonCurrentHP + "/" + enemyPokemonMaxHP + "HP\n"
  728. + "=================================\n"
  729. + "Enemy " + enemyPokemon + " used " + pokemonAttack + "!!!\n\n"
  730. + "OH NO! They did " + pokemonAttackNum + " damage to you!!!\n");
  731. }
  732.  
  733. choice1.setText("Continue...");
  734. choice1.setFont(buttonFontES);
  735. choice1.setVisible(true);
  736. choice2.setText("");
  737. choice2.setVisible(false);
  738. choice3.setText("");
  739. choice3.setVisible(false);
  740. }
  741. else
  742. {
  743. mainTextArea.setText(
  744. "\n"
  745. + "=================================\n"
  746. + "You've KILLED the enemy " + enemyPokemon + "!!!\n"
  747. + "=================================\n\n"
  748. + "You've gained 25 Experience Points!\n"
  749. + "YEEAAHH!\n"
  750. + "=================================\n"
  751. + "You've ALSO gained 1 Small Potion!!!\n"
  752. + "OH BABY!!!\n"
  753. + "=================================\n");
  754.  
  755. currentPlayerXP = currentPlayerXP + 25;
  756. potionAmt.setPotions(1);
  757.  
  758. playerSetup();
  759.  
  760. choice1.setText("");
  761. choice1.setVisible(false);
  762. choice2.setText("Continue...");
  763. choice2.setFont(buttonFontES);
  764. choice2.setVisible(true);
  765. choice3.setText("");
  766. choice3.setVisible(false);
  767. }
  768. }
  769. else
  770. {
  771. if (battleNum == 1)
  772. {
  773. mainTextArea.setText("\n"
  774. + "=================================\n"
  775. + "OH NO!!!\n"
  776. + "YOU MISSED YOUR QUICK ATTACK!!\n"
  777. + "=================================\n\n\n"
  778. + "Better luck next time then. ;)");
  779. }
  780. else if (battleNum != 1)
  781. {
  782. mainTextArea.setText("\n"
  783. + "=================================\n"
  784. + "OH NO!!!\n"
  785. + "YOU MISSED YOUR QUICK ATTACK!!\n"
  786. + "=================================\n\n\n"
  787. + "Better luck next time then. ;)\n"
  788. + "=================================\n"
  789. + "Enemy " + enemyPokemon + " used " + pokemonAttack + "!!!\n\n"
  790. + "OH NO! They did " + pokemonAttackNum + " damage to you!!!\n");
  791. }
  792.  
  793. choice1.setText("");
  794. choice1.setVisible(false);
  795. choice2.setText("");
  796. choice2.setVisible(false);
  797. choice3.setText("Continue...");
  798. choice3.setFont(buttonFontES);
  799. choice3.setVisible(true);
  800. }
  801.  
  802. }
  803.  
  804. public void inventoryMenu()
  805. {
  806. position = "inventoryMenu";
  807.  
  808. int potion = potionAmt.getPotions();
  809.  
  810. if(potion > 0)
  811. {
  812. mainTextArea.setText("\n\n"
  813. + "You have " + potion + " Potions in your bag.\n"
  814. + "=================================\n"
  815. + "Each Potion heals for 10 HP\n\n"
  816. + "As you can see above, you are currently\n"
  817. + " at " + currentPlayerHP + " HP.\n"
  818. + "=================================\n\n"
  819. + "Would you like to use a potion?");
  820.  
  821. choice1.setText("");
  822. choice1.setVisible(false);
  823. choice2.setText("Yes");
  824. choice2.setFont(buttonFont);
  825. choice2.setVisible(true);
  826. choice3.setText("No");
  827. choice3.setFont(buttonFont);
  828. choice3.setVisible(true);
  829. }
  830. else
  831. {
  832. mainTextArea.setText(
  833. "\n\n\n\n"
  834. + "IT'S EMPTY YOU FOOOOOOLLLL!!!!!");
  835.  
  836. choice1.setText("Back");
  837. choice1.setFont(buttonFontS);
  838. choice2.setText("");
  839. choice2.setVisible(false);
  840. choice3.setText("");
  841. choice3.setVisible(false);
  842. }
  843. }
  844.  
  845. public void potionUsed()
  846. {
  847. potionAmt.setPotions(-1);
  848. currentPlayerHP = currentPlayerHP + 10;
  849.  
  850. if (currentPlayerHP > totalPlayerHP)
  851. {
  852. currentPlayerHP = totalPlayerHP;
  853. }
  854.  
  855. playerSetup();
  856.  
  857. mainTextArea.setText("\n\n"
  858. + "You used 1 potion and healed a maximum of 10 HP.\n"
  859. + "=================================\n"
  860. + "Your current health as you can see above is " + currentPlayerHP + " HP.\n");
  861.  
  862. choice1.setText("Continue...");
  863. choice1.setFont(buttonFontES);
  864. choice1.setVisible(true);
  865. choice2.setText("");
  866. choice2.setVisible(false);
  867. choice3.setText("");
  868. choice3.setVisible(false);
  869. }
  870.  
  871. public void runOption()
  872. {
  873. position = "runOption";
  874.  
  875. mainTextArea.setText(
  876. "\n\n\n\n"
  877. + "YOU THINK YOU CAN RUUNNN?!?! THINK AGAAIN\n\n"
  878. + "AAAAHAHAHAHAHAHAAAAAAA");
  879.  
  880. choice1.setText("Back");
  881. choice1.setFont(buttonFontS);
  882. choice2.setText("");
  883. choice2.setVisible(false);
  884. choice3.setText("");
  885. choice3.setVisible(false);
  886. }
  887.  
  888. public void levelUp()
  889. {
  890. position = "levelUp";
  891.  
  892. mainTextArea.setText("\n\n\n"
  893. + "YYYOOOOUUU LLLEEEEVVEEEEELLLEEEEDDDD UUUUUUUUUUUUUPPPPPPPPP!!!!!!!!!!!!!!!!!!\n"
  894. + "YYYYEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAHHHHHHHHH!!!!!\n"
  895. + "=================================\n\n"
  896. + "Level " + playerLevel + ": \n"
  897. + "HP Gained: 10\n"
  898. + "Current XP Reduced to: 0/50\n\n\n"
  899. + "...congrats ;D");
  900.  
  901. totalPlayerXP = 50;
  902. currentPlayerXP = 0;
  903. playerLevel = playerLevel + 1;
  904. totalPlayerHP = totalPlayerHP + 10;
  905. currentPlayerHP = totalPlayerHP;
  906.  
  907. playerSetup();
  908.  
  909. choice1.setText("");
  910. choice1.setVisible(false);
  911. choice2.setText("");
  912. choice2.setVisible(false);
  913. choice3.setText("Continue...");
  914. choice3.setFont(buttonFontES);
  915. choice3.setVisible(true);
  916. }
  917.  
  918. public class TitleScreenHandler implements ActionListener
  919. {
  920. @Override
  921. public void actionPerformed(ActionEvent e)
  922. {
  923. createScreen();
  924. }
  925. }
  926.  
  927. public class ChoiceHandler implements ActionListener
  928. {
  929. @Override
  930. public void actionPerformed(ActionEvent event)
  931. {
  932. String yourChoice = event.getActionCommand();
  933.  
  934. switch(position)
  935. {
  936. case "openingCeremony":
  937. switch(yourChoice)
  938. {
  939. case "c1": charmanderChosen(); break;
  940. case "c2": bulbasaurChosen(); break;
  941. case "c3": squirtleChosen(); break;
  942. }
  943. break;
  944. case "charmanderChosen":
  945. switch(yourChoice)
  946. {
  947. case "c3": firstBattleMessage(); break;
  948. }
  949. break;
  950. case "bulbasaurChosen":
  951. switch(yourChoice)
  952. {
  953. case "c3": firstBattleMessage(); break;
  954. }
  955. break;
  956. case "squirtleChosen":
  957. switch(yourChoice)
  958. {
  959. case "c3": firstBattleMessage(); break;
  960. }
  961. break;
  962. case "firstBattleMessage":
  963. switch(yourChoice)
  964. {
  965. case "c3": firstBattle(); break;
  966. }
  967. break;
  968. case "firstBattle":
  969. switch(yourChoice)
  970. {
  971. case "c1": pokemonAttacks(); break;
  972. case "c2": inventoryMenu(); break;
  973. case "c3": runOption(); break;
  974. }
  975. break;
  976. case "secondBattleMessage":
  977. switch(yourChoice)
  978. {
  979. case "c3": secondBattle(); break;
  980. }
  981. break;
  982. case "secondBattle":
  983. switch(yourChoice)
  984. {
  985. case "c1": pokemonAttacks(); break;
  986. case "c2": inventoryMenu(); break;
  987. case "c3": runOption();break;
  988. }
  989. break;
  990. case "levelUp":
  991. switch(yourChoice)
  992. {
  993. case "c3": secondBattleMessage(); break;
  994. }
  995. break;
  996. case "inventoryMenu":
  997. switch(yourChoice)
  998. {
  999. case "c1":
  1000. if (battleNum == 1)
  1001. {
  1002. firstBattle(); break;
  1003. }
  1004. else if (battleNum == 2)
  1005. {
  1006. secondBattle(); break;
  1007. }
  1008. else
  1009. {
  1010. break;
  1011. }
  1012. case "c2": potionUsed(); break;
  1013. case "c3":
  1014. if (battleNum == 1)
  1015. {
  1016. firstBattle(); break;
  1017. }
  1018. else if (battleNum == 2)
  1019. {
  1020. secondBattle(); break;
  1021. }
  1022. else
  1023. {
  1024. break;
  1025. }
  1026. }
  1027. break;
  1028. case "potionUsed":
  1029. switch(yourChoice)
  1030. {
  1031. case "c1":
  1032. if (battleNum == 1)
  1033. {
  1034. firstBattle(); break;
  1035. }
  1036. else if (battleNum == 2)
  1037. {
  1038. secondBattle(); break;
  1039. }
  1040. else
  1041. {
  1042. break;
  1043. }
  1044. }
  1045. break;
  1046. case "runOption":
  1047. switch(yourChoice)
  1048. {
  1049. case "c1": firstBattle(); break;
  1050. }
  1051. break;
  1052. case "pokemonAttacks":
  1053. switch(yourChoice)
  1054. {
  1055. case "c1": tackleBattleMessage(); break;
  1056. case "c2": quickAttackBattleMessage(); break;
  1057. case "c3":
  1058. if (battleNum == 1)
  1059. {
  1060. firstBattle(); break;
  1061. }
  1062. else if (battleNum == 2)
  1063. {
  1064. secondBattle(); break;
  1065. }
  1066. else
  1067. {
  1068. break;
  1069. }
  1070. }
  1071. break;
  1072. case "tackleBattleMessage":
  1073. switch(yourChoice)
  1074. {
  1075. case "c1":
  1076. if (battleNum == 1)
  1077. {
  1078. firstBattle(); break;
  1079. }
  1080. else if (battleNum == 2)
  1081. {
  1082. secondBattle(); break;
  1083. }
  1084. else
  1085. {
  1086. break;
  1087. }
  1088. case "c2":
  1089. if (battleNum == 1)
  1090. {
  1091. secondBattleMessage(); break;
  1092. }
  1093. else if (battleNum == 2)
  1094. {
  1095. break;
  1096. }
  1097. else
  1098. {
  1099. break;
  1100. }
  1101. }
  1102. break;
  1103. case "quickAttackBattleMessage":
  1104. switch(yourChoice)
  1105. {
  1106. case "c1":
  1107. if (battleNum == 1)
  1108. {
  1109. firstBattle(); break;
  1110. }
  1111. else if (battleNum == 2)
  1112. {
  1113. secondBattle(); break;
  1114. }
  1115. else
  1116. {
  1117. break;
  1118. }
  1119. case "c2":
  1120. if (battleNum == 1)
  1121. {
  1122. secondBattleMessage(); break;
  1123. }
  1124. else
  1125. {
  1126. break;
  1127. }
  1128. case "c3":
  1129. if (battleNum == 1)
  1130. {
  1131. firstBattle(); break;
  1132. }
  1133. else if (battleNum == 2)
  1134. {
  1135. secondBattle(); break;
  1136. }
  1137. else
  1138. {
  1139. break;
  1140. }
  1141. }
  1142. break;
  1143. }
  1144. }
  1145. }
  1146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement