spartanboy56

Main

Jan 18th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.88 KB | None | 0 0
  1. package com.company;
  2.  
  3.  
  4.  
  5. import javax.swing.*;
  6. import java.util.*;
  7. import java.math.BigInteger;
  8. import java.security.SecureRandom;
  9. import java.util.stream.Collectors;
  10.  
  11.  
  12. /*
  13.  
  14.  
  15.  
  16.  
  17. */
  18. public class Main {
  19.  
  20.  
  21.  
  22. public static void main(String[] args) {
  23.  
  24.  
  25.  
  26. Map HiltpartsStrength = new HashMap();
  27. Map HiltID = new HashMap();
  28. Map DaggerBladepartsStrength = new HashMap();
  29. Map DaggerBladeID = new HashMap();
  30. Map DaggerBuffEffect = new HashMap();
  31. Map DaggerBuffID = new HashMap();
  32. Map SwordBladepartsStrength = new HashMap();
  33. Map SwordBladeID = new HashMap();
  34. Map SwordBuffEffect = new HashMap();
  35. Map SwordBuffID = new HashMap();
  36.  
  37.  
  38.  
  39.  
  40. // Map InventoryMap = new HashMap();
  41. ArrayList Inv1 = new ArrayList();
  42. ArrayList Inv2 = new ArrayList();
  43. ArrayList Inv3 = new ArrayList();
  44. ArrayList Inv4 = new ArrayList();
  45. ArrayList Inv5 = new ArrayList();
  46.  
  47. String[] InvName1 = new String[5];
  48. /* String[] InvName2 = new String[1];
  49. String[] InvName3 = new String[1];
  50. String[] InvName4 = new String[1];
  51. String[] InvName5 = new String[1];
  52. */
  53. //Maps for parts. ID-maps allows a random number generator to pick a part type. Strength/effect-maps give you the stats of the part.
  54. HiltpartsStrength.put("Slow", 2);
  55. HiltpartsStrength.put("Crawling", 1);
  56. HiltpartsStrength.put("Normal", 3);
  57. HiltpartsStrength.put("Quick", 4);
  58. HiltpartsStrength.put("Fast", 5);
  59.  
  60.  
  61. HiltID.put(1, "Crawling");
  62. HiltID.put(2, "Slow");
  63. HiltID.put(3, "Normal");
  64. HiltID.put(4, "Quick");
  65. HiltID.put(5, "Fast");
  66.  
  67. DaggerBladepartsStrength.put("Very sharp", 5);
  68. DaggerBladepartsStrength.put("Sharp", 4);
  69. DaggerBladepartsStrength.put("Prickly", 3);
  70. DaggerBladepartsStrength.put("Dull", 2);
  71. DaggerBladepartsStrength.put("Blunt", 1);
  72.  
  73. DaggerBladeID.put(5,"Very sharp");
  74. DaggerBladeID.put(4,"Sharp");
  75. DaggerBladeID.put(3,"Prickly");
  76. DaggerBladeID.put(2,"Dull");
  77. DaggerBladeID.put(1,"Blunt");
  78.  
  79. DaggerBuffEffect.put("Dex + 5", 5);
  80. DaggerBuffEffect.put("Dex + 4", 4);
  81. DaggerBuffEffect.put("Dex + 3", 3);
  82. DaggerBuffEffect.put("Dex + 2", 2);
  83. DaggerBuffEffect.put("Dex + 1", 1);
  84.  
  85. DaggerBuffID.put(5,"Dex + 5");
  86. DaggerBuffID.put(4,"Dex + 4");
  87. DaggerBuffID.put(3,"Dex + 3");
  88. DaggerBuffID.put(2,"Dex + 2");
  89. DaggerBuffID.put(1,"Dex + 1");
  90.  
  91. SwordBladepartsStrength.put("Very sharp", 5);
  92. SwordBladepartsStrength.put("Sharp", 4);
  93. SwordBladepartsStrength.put("Prickly", 3);
  94. SwordBladepartsStrength.put("Dull", 2);
  95. SwordBladepartsStrength.put("Blunt", 1);
  96.  
  97. SwordBladeID.put(5,"Very sharp");
  98. SwordBladeID.put(4,"Sharp");
  99. SwordBladeID.put(3,"Fine");
  100. SwordBladeID.put(2,"Dull");
  101. SwordBladeID.put(1,"Blunt");
  102.  
  103. SwordBuffEffect.put("Damage + 5", 5);
  104. SwordBuffEffect.put("Damage + 4", 4);
  105. SwordBuffEffect.put("Damage + 3", 3);
  106. SwordBuffEffect.put("Damage + 2", 2);
  107. SwordBuffEffect.put("Damage + 1", 1);
  108.  
  109. SwordBuffID.put(5,"Damage + 5");
  110. SwordBuffID.put(4,"Damage + 4");
  111. SwordBuffID.put(3,"Damage + 3");
  112. SwordBuffID.put(2,"Damage + 2");
  113. SwordBuffID.put(1,"Damage + 1");
  114.  
  115.  
  116.  
  117. //Keeps track of the parts for the weapon currently being made.
  118. int CurhiltID, CurbladeID, CurbuffID;
  119.  
  120. int cont = 0;
  121.  
  122.  
  123. String Dagger = "Dagger";
  124. String Sword = "Sword";
  125.  
  126. while(cont == 0) {
  127. int chestOpen = JOptionPane.showConfirmDialog(null,
  128. "Open the chest?",
  129. "Weapon gen ver 0.00001",
  130. JOptionPane.YES_OPTION);
  131.  
  132. if (chestOpen == 0) {
  133.  
  134. /*
  135. Randomly chooses between generating a sword or a dagger
  136. */
  137. int WeapChoice = Construct.randomWeaponChoice();
  138.  
  139. if (WeapChoice == 1){
  140.  
  141. System.out.println("Opening!");
  142.  
  143. CurhiltID = Construct.randomHiltGenID();
  144.  
  145. String Curhilt = (String) HiltID.get(CurhiltID);
  146.  
  147. CurbladeID = Construct.randomBladeGenID();
  148.  
  149. String Curblade = (String) DaggerBladeID.get(CurbladeID);
  150.  
  151. CurbuffID = Construct.randomBuffGenID();
  152.  
  153. String Curbuff = (String) DaggerBuffID.get(CurbuffID);
  154.  
  155. System.out.println("You received a " + Curhilt + " " + Curblade + " " + Dagger);
  156.  
  157. JOptionPane.showMessageDialog(null,
  158. "You received a " + Curhilt + " " + Curblade + " " + Dagger,
  159. "Weapon gen ver 0.00001",
  160. JOptionPane.WARNING_MESSAGE);
  161.  
  162. String newID = Construct.nextId();
  163.  
  164. //Gets the stats for the given part in integer form
  165. int CurhiltStrength = (Integer)HiltpartsStrength.get(Curhilt);
  166. int CurbladeStrength = (Integer)DaggerBladepartsStrength.get(Curblade);
  167. int CurbuffStrength = (Integer)DaggerBuffEffect.get(Curbuff);
  168.  
  169. // creates the new weapon
  170. Daggertemp newDagger = new Daggertemp(Curhilt,Curblade,Curbuff,CurhiltStrength,CurbladeStrength,CurbuffStrength,newID, Dagger);
  171.  
  172. // System.out.println(newDagger.toString());
  173.  
  174.  
  175.  
  176. String WeapStrang = newDagger.name.toString();
  177.  
  178. System.out.println("1" + WeapStrang);
  179. //Puts the new weapon in the inventory slot
  180. if(Inv1.size() < 1){
  181. Inv1.add(newDagger.name);
  182. Inv1.add(newDagger.damage);
  183. Inv1.add(newDagger.speed);
  184. Inv1.add(newDagger.buff);
  185. }
  186. else if(Inv2.size() < 1){
  187. Inv2.add(newDagger.name);
  188. Inv2.add(newDagger.damage);
  189. Inv2.add(newDagger.speed);
  190. Inv2.add(newDagger.buff);
  191. }
  192. else if(Inv3.size() < 1){
  193. Inv3.add(newDagger.name);
  194. Inv3.add(newDagger.damage);
  195. Inv3.add(newDagger.speed);
  196. Inv3.add(newDagger.buff);
  197. }
  198. else if(Inv4.size() < 1){
  199. Inv4.add(newDagger.name);
  200. Inv4.add(newDagger.damage);
  201. Inv4.add(newDagger.speed);
  202. Inv4.add(newDagger.buff);
  203. }
  204. else if(Inv5.size()< 1){
  205. Inv5.add(newDagger.name);
  206. Inv5.add(newDagger.damage);
  207. Inv5.add(newDagger.speed);
  208. Inv5.add(newDagger.buff);
  209. }
  210. else{
  211. System.out.println("Your inventory is full! You can no longer fit equipment into your pack.");
  212. }
  213.  
  214. //Adds the weapons name to a String Array
  215. if(InvName1.length < 1){
  216. InvName1[0] = WeapStrang;
  217. }
  218. else if(InvName1.length == 1){
  219. InvName1[1] = WeapStrang;
  220. System.out.println(WeapStrang);
  221. }
  222. else if(InvName1.length == 2){
  223. InvName1[2] = WeapStrang;
  224. System.out.println(WeapStrang);
  225. }
  226. else if(InvName1.length == 3){
  227. InvName1[3] = WeapStrang;
  228. System.out.println(WeapStrang);
  229. }
  230. else if(InvName1.length == 4){
  231. InvName1[4] = WeapStrang;
  232. System.out.println(WeapStrang);
  233. }
  234.  
  235. if (InvName1.length < 1) {
  236. InvName1[0] = "Empty";
  237. InvName1[1] = "Empty";
  238. InvName1[2] = "Empty";
  239. InvName1[3] = "Empty";
  240. InvName1[4] = "Empty";
  241. } else if (InvName1.length == 1) {
  242. InvName1[1] = "Empty";
  243. InvName1[2] = "Empty";
  244. InvName1[3] = "Empty";
  245. InvName1[4] = "Empty";
  246. } else if (InvName1.length == 2) {
  247. InvName1[2] = "Empty";
  248. InvName1[3] = "Empty";
  249. InvName1[4] = "Empty";
  250. } else if (InvName1.length == 3) {
  251. InvName1[3] = "Empty";
  252. InvName1[4] = "Empty";
  253. } else if (InvName1.length == 4) {
  254. InvName1[4] = "Empty";
  255.  
  256. }
  257.  
  258. System.out.println(InvName1[0]);
  259.  
  260.  
  261.  
  262. int Inspect = JOptionPane.showConfirmDialog(null,
  263. "Would you like to inspect your new weapon?",
  264. "Weapon gen ver 0.00001",
  265. JOptionPane.YES_OPTION);
  266.  
  267. if(Inspect == 0){
  268.  
  269. JOptionPane.showMessageDialog(null,
  270. "You have a " + newDagger.name + ". It has a speed stat of " + newDagger.speed +
  271. ", a damage stat of " + newDagger.damage + ", and a buff of " + newDagger.buff,
  272. "Weapon gen ver 0.00001",
  273. JOptionPane.WARNING_MESSAGE);
  274.  
  275. System.out.println("You have a " + newDagger.name + ". It has a speed stat of " + newDagger.speed + ", a damage stat of " + newDagger.damage + ", and the " + newDagger.buff + " buff");
  276. }}
  277. else if(WeapChoice == 2){
  278. System.out.println("Opening!");
  279.  
  280. CurhiltID = Construct.randomHiltGenID();
  281.  
  282. String Curhilt = (String) HiltID.get(CurhiltID);
  283.  
  284. CurbladeID = Construct.randomBladeGenID();
  285.  
  286. String Curblade = (String) SwordBladeID.get(CurbladeID);
  287.  
  288. CurbuffID = Construct.randomBuffGenID();
  289.  
  290. String Curbuff = (String) SwordBuffID.get(CurbuffID);
  291.  
  292. System.out.println("You received a " + Curhilt + " " + Curblade + Sword);
  293.  
  294. JOptionPane.showMessageDialog(null,
  295. "You received a " + Curhilt + " " + Curblade + " " + Dagger,
  296. "Weapon gen ver 0.00001",
  297. JOptionPane.WARNING_MESSAGE);
  298.  
  299. String newID = Construct.nextId();
  300.  
  301. //Gets the stats for the given part in integer form
  302. int CurhiltStrength = (Integer)HiltpartsStrength.get(Curhilt);
  303. int CurbladeStrength = (Integer)SwordBladepartsStrength.get(Curblade);
  304. int CurbuffStrength = (Integer)SwordBuffEffect.get(Curbuff);
  305.  
  306. // creates the new weapon
  307. Swordtemp newSword = new Swordtemp(Curhilt,Curblade,Curbuff,CurhiltStrength,CurbladeStrength,CurbuffStrength,newID, Sword);
  308.  
  309. System.out.println(newSword.toString());
  310.  
  311.  
  312. String WeapString = newSword.name.toString();
  313.  
  314.  
  315. //Puts the new weapon in the inventory slot
  316. if(Inv1.size() < 1){
  317. Inv1.add(newSword.name);
  318. Inv1.add(newSword.damage);
  319. Inv1.add(newSword.speed);
  320. Inv1.add(newSword.buff);
  321. }
  322. else if(Inv2.size() < 1){
  323. Inv2.add(newSword.name);
  324. Inv2.add(newSword.damage);
  325. Inv2.add(newSword.speed);
  326. Inv2.add(newSword.buff);
  327. }
  328. else if(Inv3.size() < 1){
  329. Inv3.add(newSword.name);
  330. Inv3.add(newSword.damage);
  331. Inv3.add(newSword.speed);
  332. Inv3.add(newSword.buff);
  333. }
  334. else if(Inv4.size() < 1){
  335. Inv4.add(newSword.name);
  336. Inv4.add(newSword.damage);
  337. Inv4.add(newSword.speed);
  338. Inv4.add(newSword.buff);
  339. }
  340. else if(Inv5.size() < 1){
  341. Inv5.add(newSword.name);
  342. Inv5.add(newSword.damage);
  343. Inv5.add(newSword.speed);
  344. Inv5.add(newSword.buff);
  345. }
  346. else{
  347. System.out.println("Your inventory is full! You can no longer fit equipment into your pack.");
  348. }
  349. if(InvName1.length < 1){
  350. InvName1[0] = WeapString;
  351. }
  352. else if(InvName1.length < 1){
  353. InvName1[0] = WeapString;
  354.  
  355. }
  356. else if(InvName1.length < 1){
  357. InvName1[0] = WeapString;
  358. }
  359. else if(InvName1.length < 1){
  360. InvName1[0] = WeapString;
  361. }
  362. else if(InvName1.length < 1){
  363. InvName1[0] = WeapString;
  364. }
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371. int Inspect = JOptionPane.showConfirmDialog(null,
  372. "Would you like to inspect your new weapon?",
  373. "Weapon gen ver 0.00001",
  374. JOptionPane.YES_OPTION);
  375.  
  376. if(Inspect == 0){
  377. System.out.println("You have a " + newSword.name + ". It has a speed stat of " + newSword.speed + ", a damage stat of " + newSword.damage + ", and the " + newSword.buff + " buff");
  378.  
  379. JOptionPane.showMessageDialog(null,
  380. "You received a " + newSword.name + ". It has a speed stat of " + newSword.speed +
  381. ", a damage stat of " + newSword.damage + ", and a buff of " + newSword.buff,
  382. "Weapon gen ver 0.00001",
  383. JOptionPane.WARNING_MESSAGE);
  384.  
  385. }}
  386. }else if (chestOpen == 1) {
  387. System.out.println("Goodbye!");
  388.  
  389. System.exit(0);
  390. }
  391.  
  392.  
  393. int CheckInv = JOptionPane.showConfirmDialog(null,
  394. "Would you like to see your inventory contents?",
  395. "Weapon gen ver 0.00001",
  396. JOptionPane.YES_OPTION);
  397.  
  398. /*
  399. String formatedInv1String = Inv1.toString()
  400. .replace(",", "")
  401. .replace("[", "")
  402. .replace("]", "")
  403. .replace(Inv1.get(1).toString(), "")
  404. .replace(Inv1.get(2).toString(), "")
  405. .replace(Inv1.get(3).toString(), "")
  406. .trim();
  407. String formatedInv2String = Inv2.toString()
  408. .replace(",", "")
  409. .replace("[", "")
  410. .replace("]", "")
  411. .replace(Inv2.get(1).toString(), "")
  412. .replace(Inv2.get(2).toString(), "")
  413. .replace(Inv2.get(3).toString(), "")
  414. .trim();
  415.  
  416. String formatedInv3String = Inv3.toString()
  417. .replace(",", "")
  418. .replace("[", "")
  419. .replace("]", "")
  420. .replace(Inv3.get(1).toString(), "")
  421. .replace(Inv3.get(2).toString(), "")
  422. .replace(Inv3.get(3).toString(), "")
  423. .trim();
  424.  
  425. String formatedInv4String = Inv4.toString()
  426. .replace(",", "")
  427. .replace("[", "")
  428. .replace("]", "")
  429. .replace(Inv4.get(1).toString(), "")
  430. .replace(Inv4.get(2).toString(), "")
  431. .replace(Inv4.get(3).toString(), "")
  432. .trim();
  433.  
  434. String formatedInv5String = Inv5.toString()
  435. .replace(",", "")
  436. .replace("[", "")
  437. .replace("]", "")
  438. .replace(Inv5.get(1).toString(), "")
  439. .replace(Inv5.get(2).toString(), "")
  440. .replace(Inv5.get(3).toString(), "")
  441. .trim();*/
  442.  
  443.  
  444.  
  445.  
  446.  
  447. System.out.println(InvName1[0] + "L" + InvName1[1]+ "L" + InvName1[2]+ "L" + InvName1[3] + "L" + InvName1[4]+ "L");
  448.  
  449. if(CheckInv == 0) {
  450.  
  451. //System.out.println("Your inventory contents are " + Inv1 + Inv2 + Inv3 + Inv4 + Inv5);
  452.  
  453.  
  454.  
  455.  
  456. /*
  457. String Weap1Name = InvName1.get(0);
  458. String Weap2Name = InvName2.get(0);
  459. String Weap3Name = InvName3.get(0);
  460. String Weap4Name = InvName4.get(0);
  461. String Weap5Name = InvName5.get(0);
  462. */
  463.  
  464. // System.out.println(Weap1Name + "L" + Weap2Name + "L" + Weap3Name + "L" + Weap4Name + "L" + Weap5Name + "L");
  465.  
  466.  
  467.  
  468. //String[] InvButtons = { InvName1[0], InvName2[0],InvName3[0],InvName4[0],InvName5[0], "Do not inspect"};
  469.  
  470. //Gives the ability to inspect one of the 5 items in your inventory
  471.  
  472. int InvCho = JOptionPane.showOptionDialog(null, "Click on a weapon to inspect it", "Weapons Gen. Ver. 0.00001",
  473. JOptionPane.WARNING_MESSAGE, 0 , null, InvName1, InvName1[4]);
  474.  
  475. while(InvCho != 5){
  476.  
  477. switch(InvCho){
  478. case 0:
  479. JOptionPane.showMessageDialog(null,
  480. "You weapon is a " + InvName1[0] + ". with a damage stat of " + Inv1.get(1) + ", a speed stat of " + Inv1.get(2) + ", and a buff of" + Inv1.get(3),
  481. "Weapon gen ver 0.00001",
  482. JOptionPane.WARNING_MESSAGE);
  483.  
  484. InvCho = JOptionPane.showOptionDialog(null, "Please choose a weapon to inspect", "Weapons Gen. Ver. 0.00001",
  485. JOptionPane.WARNING_MESSAGE, 0 , null, InvName1, InvName1[4]);
  486. break;
  487.  
  488. case 1:
  489. if(Inv2.size() > 1){
  490. JOptionPane.showMessageDialog(null,
  491. "You weapon is a " + InvName1[1] + ". with a damage stat of " + Inv2.get(1) + ", a speed stat of " + Inv2.get(2) + ", and a buff of" + Inv2.get(3) ,
  492. "Weapon gen ver 0.00001",
  493. JOptionPane.WARNING_MESSAGE);
  494.  
  495.  
  496.  
  497. }else{
  498. JOptionPane.showMessageDialog(null,
  499. "There is no weapon in that slot!",
  500. "Weapon gen ver 0.00001",
  501. JOptionPane.WARNING_MESSAGE);
  502. }
  503.  
  504.  
  505. InvCho = JOptionPane.showOptionDialog(null, "Please choose a weapon to inspect", "Weapons Gen. Ver. 0.00001",
  506. JOptionPane.WARNING_MESSAGE, 0 , null, InvName1, InvName1[4]);
  507. break;
  508.  
  509. case 2:
  510. if(Inv3.size() > 1){
  511. JOptionPane.showMessageDialog(null,
  512. "You weapon is a " + InvName1[2] + ". with a damage stat of " + Inv3.get(1) + ", a speed stat of " + Inv3.get(2) + ", and a buff of" + Inv3.get(3),
  513. "Weapon gen ver 0.00001",
  514. JOptionPane.WARNING_MESSAGE);
  515. }else{
  516. JOptionPane.showMessageDialog(null,
  517. "There is no weapon in that slot!",
  518. "Weapon gen ver 0.00001",
  519. JOptionPane.WARNING_MESSAGE);
  520. }
  521.  
  522.  
  523. InvCho = JOptionPane.showOptionDialog(null, "Please choose a weapon to inspect", "Weapons Gen. Ver. 0.00001",
  524. JOptionPane.WARNING_MESSAGE, 0 , null, InvName1, InvName1[4]);
  525. break;
  526.  
  527. case 3:
  528.  
  529. if(Inv4.size() > 1){
  530. JOptionPane.showMessageDialog(null,
  531. "You weapon is a " + InvName1[3] + ". with a damage stat of " + Inv4.get(1) + ", a speed stat of " + Inv4.get(2) + ", and a buff of" + Inv4.get(3),
  532. "Weapon gen ver 0.00001",
  533. JOptionPane.WARNING_MESSAGE);
  534. }else{
  535. JOptionPane.showMessageDialog(null,
  536. "There is no weapon in that slot!",
  537. "Weapon gen ver 0.00001",
  538. JOptionPane.WARNING_MESSAGE);
  539. }
  540.  
  541.  
  542. InvCho = JOptionPane.showOptionDialog(null, "Please choose a weapon to inspect", "Weapons Gen. Ver. 0.00001",
  543. JOptionPane.WARNING_MESSAGE, 0 , null, InvName1, InvName1[4]);
  544. break;
  545.  
  546. case 4:
  547. if(Inv5.size() > 1){
  548. JOptionPane.showMessageDialog(null,
  549. "You weapon is a " + InvName1[4] + ". with a damage stat of " + Inv5.get(1) + ", a speed stat of " + Inv5.get(2) + ", and a buff of" + Inv5.get(3),
  550. "Weapon gen ver 0.00001",
  551. JOptionPane.WARNING_MESSAGE);
  552. }else{
  553. JOptionPane.showMessageDialog(null,
  554. "There is no weapon in that slot!",
  555. "Weapon gen ver 0.00001",
  556. JOptionPane.WARNING_MESSAGE);
  557. }
  558.  
  559.  
  560.  
  561. InvCho = JOptionPane.showOptionDialog(null, "Please choose a weapon to inspect", "Weapons Gen. Ver. 0.00001",
  562. JOptionPane.WARNING_MESSAGE, 0 , null,InvName1, InvName1[4]);
  563. break;
  564. }}
  565.  
  566.  
  567.  
  568. cont = JOptionPane.showConfirmDialog(null,
  569. "Would you like to open another chest?",
  570. "Weapon gen ver 0.00001",
  571. JOptionPane.YES_OPTION);
  572.  
  573. if(cont == 1){
  574. System.exit(0);
  575. }
  576.  
  577. }
  578.  
  579.  
  580. }
  581.  
  582. }
  583. }
Advertisement
Add Comment
Please, Sign In to add comment