Guest User

Untitled

a guest
May 21st, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.68 KB | None | 0 0
  1. package hearthstone.deck.maker;
  2.  
  3. import java.io.*;
  4. import java.lang.*;
  5. import java.util.*;
  6.  
  7. public class HearthStoneDeckMaker {
  8.  
  9. static createfile save = new createfile();
  10.  
  11. public static double manaAVG = 5;
  12. public static int maxTaunt = 30;
  13. public static int maxSpell = 30;
  14. public static int maxMinions = 30;
  15. public static int minTaunt = 0;
  16. public static int minSpell = 0;
  17. public static int minMinions = 0;
  18. static Scanner input = new Scanner(System.in);
  19. public static int numberOfCards = 0;
  20. static Card[] card = new Card[9999];
  21. static int i;
  22. static int usedMinions = 0;
  23. static int usedSpells = 0;
  24. static int usedTaunts = 0;
  25. static String cls = "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn";
  26.  
  27. private static Scanner x;
  28.  
  29. public static void addcards(){
  30. for (i = numberOfCards; i <= numberOfCards; i++) {
  31. boolean DoneWithCard = false;
  32. while(DoneWithCard == false){
  33. card[i] = new Card();
  34. System.out.print("Name of Card >> ");
  35. card[i].setName(input.nextLine());
  36.  
  37. System.out.print(card[i].getName()+"'s Class >> ");
  38. card[i].setCharacter(input.nextLine());
  39. boolean isValid = false;
  40. String message = "";
  41. String cardtype = "";
  42. while(isValid == false){
  43. System.out.println(message +"Is " + card[i].getName() + " a minion or a spell >>");
  44. if(input.nextLine().equalsIgnoreCase("minion")){
  45. card[i].setIsMinion(true);
  46. isValid = true;
  47. cardtype = "minion";
  48. }
  49. else if(input.nextLine().equalsIgnoreCase("spell")){
  50. card[i].setIsSpell(true);
  51. isValid = true;
  52. cardtype = "spell";
  53. }
  54. else{
  55. message = "<INVALID ENTRY TRY AGAIN> ";
  56. }
  57. }
  58. String hastaunt = "";
  59. System.out.print("Does "+ card[i].getName() + " have Taunt (Y/N) >>");
  60. if(input.nextLine().equalsIgnoreCase("Y")) {
  61. card[i].setHasTaunt(true);
  62. hastaunt = "Does";
  63. }
  64. else{
  65. card[i].setHasTaunt(false);
  66. hastaunt = "Does not";
  67. }
  68. System.out.print("What is " +card[i].getName() +"'s mana cost >>");
  69. card[i].setMana(input.nextInt());
  70.  
  71. if(card[i].getIsSpell() == false){
  72. System.out.print("What is " +card[i].getName() +"'s health >>");
  73. card[i].setHealth(input.nextInt());
  74. }
  75. else{
  76. card[i].setHealth(0);
  77. }
  78.  
  79.  
  80. System.out.print("What is " +card[i].getName() +"'s damage >>");
  81. card[i].setDamage(input.nextInt());
  82.  
  83. System.out.println("would you like to add a desription (Y/N)");
  84. String ADesc = input.nextLine();
  85. if(input.nextLine().equalsIgnoreCase("y")){
  86. System.out.println("What is "+ card[i].getName() + "'s description >>");
  87. card[i].setDescription(input.nextLine());
  88. }
  89. else{
  90. System.out.println("Alright next");
  91. }
  92.  
  93. System.out.println(card[i].getName() + " is a(n) " + cardtype + " with " +card[i].getDamage() + ""
  94. + "/" + card[i].getHealth() + "nand " + hastaunt + " have taunt");
  95.  
  96. System.out.print("is this correct? (Y/N)");
  97. if(input.nextLine().equalsIgnoreCase("Y")){
  98. DoneWithCard = true;
  99. }
  100. else{
  101. DoneWithCard = false;
  102. }
  103.  
  104. }
  105. System.out.print("Do you want to enter another card? (Y/N)");
  106. if(input.nextLine().equalsIgnoreCase("n")){
  107. numberOfCards = i+1;
  108. save.OpenFile();
  109. save.addRecords();
  110. save.closeFile();
  111. numberOfCards++;
  112. parameters();
  113. }
  114. else{
  115. numberOfCards++;
  116.  
  117. }
  118.  
  119. }
  120. }
  121.  
  122. public static void setup(){
  123. int counter = 0;
  124. boolean add = false;
  125.  
  126. System.out.println("Current Cards >>");
  127.  
  128. openFile();
  129.  
  130.  
  131. }
  132.  
  133. public static void openFile(){
  134. try{
  135. x = new Scanner(new File("HearthCards.txt"));
  136. }
  137. catch(Exception e){
  138. System.out.println("Load Failure");
  139. }
  140.  
  141. readFile();
  142. }
  143.  
  144. public static void readFile(){
  145. Card[] cardie = new Card[numberOfCards];
  146. while(x.hasNext()){
  147. numberOfCards++;
  148. int a = 0;
  149. String name = x.next();
  150. String Character= x.next();
  151. int Health = Integer.parseInt(x.next());
  152. int Damage = Integer.parseInt(x.next());
  153. int Mana = Integer.parseInt(x.next());
  154. int TimesUsed = Integer.parseInt(x.next());
  155. boolean hasTaunt = Boolean.parseBoolean(x.next());
  156. boolean isMinion = Boolean.parseBoolean(x.next());
  157. boolean isSpell = Boolean.parseBoolean(x.next());
  158.  
  159. card[a].setName(name);
  160. card[a].setCharacter(Character);
  161. card[a].setHealth(Health);
  162. card[a].setDamage(Damage);
  163. card[a].setMana(Mana);
  164. card[a].setTimesUsed(0);
  165. card[a].setHasTaunt(hasTaunt);
  166. card[a].setIsMinion(isMinion);
  167. card[a].setIsSpell(isSpell);
  168. a++;
  169.  
  170.  
  171. }
  172. closeFile();
  173. }
  174.  
  175. public static void closeFile(){
  176. x.close();
  177. setupcont();
  178. }
  179.  
  180. public static void setupcont(){
  181.  
  182. for (int j = 0; j <= 30; j++) {
  183. String type = "oof";
  184. String taunts = "oofer";
  185. if(card[j].getIsMinion() == true){
  186. type = "minion";
  187. }
  188. else if(card[j].getIsSpell() == true){
  189. type = "spell";
  190. }
  191.  
  192. if(card[j].getHasTaunt() == true){
  193. taunts = "has";
  194. }
  195. else{
  196. taunts = "doesnt have";
  197. }
  198.  
  199. System.out.println(cls);
  200.  
  201. System.out.println(card[j].getName() + " >> " + card[j].getName() + " is a " + type + " that "+ taunts + " taunt");
  202.  
  203. }
  204.  
  205.  
  206. System.out.print("would you like to add any new Cards (Y/N)");
  207. if(input.nextLine().equalsIgnoreCase("y")){
  208. addcards();
  209. }
  210. else{
  211. makedeck();
  212. }
  213.  
  214.  
  215. }
  216.  
  217. public static void parameters(){
  218. System.out.print("Would you like to use default max and mins, or custom >> ");
  219. if(input.nextLine().equalsIgnoreCase("default")){
  220. makedeck();
  221. }
  222. else{
  223. System.out.print("What should the mana average be?");
  224. manaAVG = input.nextInt();
  225. System.out.println("What is the max taunt minions ?");
  226. maxTaunt = input.nextInt();
  227. System.out.print("What is max minions (1-30) >> ");
  228. maxMinions = input.nextInt();
  229. System.out.print("What is the max spells (1-30) >> ");
  230. maxSpell = input.nextInt();
  231. if(maxMinions + maxSpell < 30){
  232. System.out.println("<INVALID ENTRY TRY AGAIN> What is the max spells (1-30 >> ");
  233. maxSpell = input.nextInt();
  234. }
  235.  
  236. }
  237. }
  238.  
  239. public static void makedeck(){
  240. Card deck[] = new Card[30];
  241.  
  242. for(int a = 0; a <= 30; a++){
  243.  
  244. Random ran = new Random(i);
  245. int rand = ran.nextInt();
  246.  
  247. if(card[rand].getTimesUsed() <= 2){
  248. deck[a] = card[rand];
  249.  
  250. String hastaunt = "does not";
  251. if(card[rand].getHasTaunt() == true){
  252. hastaunt = "does";
  253. usedTaunts++;
  254. }
  255. String cardtype = "";
  256. if(card[rand].getIsMinion() == true && usedMinions < maxMinions){
  257. usedMinions++;
  258. cardtype = "minion";
  259. }
  260.  
  261.  
  262. System.out.println(deck[rand].getName() + " is a(n) " + cardtype + " with " +deck[rand].getDamage() + ""
  263. + "/" + deck[rand].getHealth() + "nand " + hastaunt + " have taunt");
  264. }
  265. }
  266. boolean isDone = false;
  267. Random ran = new Random(i);
  268. int rand = ran.nextInt();
  269.  
  270. boolean minMinDone = false;
  271. boolean maxMinDone = false;
  272. boolean minSpellDone = false;
  273. boolean maxSpellDone = false;
  274. boolean minTauntDone = false;
  275. boolean maxTauntDone = false;
  276. boolean correctClass = false;
  277.  
  278. System.out.println("What Class would you like to use");
  279. String usedClass = input.nextLine();
  280.  
  281. while(isDone == false){
  282. Random R = new Random(i);
  283. int Ran = R.nextInt();
  284.  
  285.  
  286. if(usedMinions < minMinions){
  287. Ran = R.nextInt();
  288. if(deck[Ran].getIsMinion() == false){
  289. int random = R.nextInt();
  290. if(card[random].getTimesUsed() <= 2){
  291. deck[Ran] = card[random];
  292. }
  293. }
  294. }
  295. else{
  296. minMinDone = true;
  297. }
  298.  
  299. if(usedMinions > maxMinions){
  300. Ran = R.nextInt();
  301. if(deck[Ran].getIsMinion() == true){
  302. int random = R.nextInt();
  303. deck[Ran] = card[random];
  304. if(card[random].getTimesUsed() <= 2){
  305. deck[Ran] = card[random];
  306. }
  307. }
  308. }
  309. else{
  310. maxMinDone = true;
  311. }
  312.  
  313. if(usedSpells < minSpell){
  314. Ran = R.nextInt();
  315. if(deck[Ran].getIsSpell() == false){
  316. int random = R.nextInt();
  317. if(card[random].getTimesUsed() <= 2){
  318. deck[Ran] = card[random];
  319. }
  320. }
  321. }
  322. else{
  323. minSpellDone = true;
  324. }
  325.  
  326. if(usedSpells > maxSpell){
  327. Ran = R.nextInt();
  328. if(deck[Ran].getIsMinion() == true){
  329. int random = R.nextInt();
  330. if(card[random].getTimesUsed() <= 2){
  331. deck[Ran] = card[random];
  332. }
  333. }
  334. }
  335. else{
  336. maxSpellDone = true;
  337. }
  338.  
  339. if(usedTaunts < minTaunt){
  340. Ran = R.nextInt();
  341. if(deck[Ran].getHasTaunt() == false){
  342. int random = R.nextInt();
  343. if(card[random].getTimesUsed() <= 2){
  344. deck[Ran] = card[random];
  345. card[Ran].setTimesUsed(card[Ran].getTimesUsed() + 1);
  346. }
  347. }
  348. }
  349. else{
  350. minTauntDone = true;
  351. }
  352.  
  353. if(usedTaunts > maxTaunt){
  354. Ran = R.nextInt();
  355. if(deck[Ran].getHasTaunt() == true){
  356. int random = R.nextInt();
  357. if(card[random].getTimesUsed() <= 2){
  358. deck[Ran] = card[random];
  359.  
  360. }
  361. }
  362. }
  363. else{
  364. maxTauntDone = true;
  365. }
  366.  
  367. correctClass = false;
  368. for (int j = 0; j <= 30; j++) {
  369. while(!deck[j].getCharacter().equalsIgnoreCase(usedClass)){
  370. int random = R.nextInt();
  371. if(card[random].getTimesUsed() <= 2 && card[random].getCharacter().equalsIgnoreCase(usedClass)){
  372. deck[j] = card[random];
  373. }
  374. }
  375.  
  376. }
  377. correctClass = true;
  378.  
  379. if(minMinDone == true && maxMinDone == true && minSpellDone == true && maxSpellDone == true && minTauntDone == true && maxTauntDone == true && correctClass == true){
  380. isDone = true;
  381. }
  382. else{
  383. isDone = false;
  384. }
  385.  
  386. }
  387.  
  388. for (int j = 0; j <= 30; j++) {
  389. String type = "oof";
  390. String taunts = "oofer";
  391. if(deck[j].getIsMinion() == true){
  392. type = "minion";
  393. }
  394. else if(deck[j].getIsSpell() == true){
  395. type = "spell";
  396. }
  397.  
  398. if(deck[j].getHasTaunt() == true){
  399. taunts = "has";
  400. }
  401. else{
  402. taunts = "doesnt have";
  403. }
  404.  
  405. System.out.println(cls);
  406.  
  407. if(!deck[j].getDescription().equals("")){
  408. System.out.println(deck[j].getName() + " >> " + deck[j].getName() + " is a " + type + " that "+ taunts + " taunt >>> nt" + deck[j].getDescription());
  409. }
  410. else{
  411. System.out.println(deck[j].getName() + " >> " + deck[j].getName() + " is a " + type + " that "+ taunts + " taunt");
  412. }
  413. }
  414.  
  415. }
  416.  
  417. public static void main(String[] args) {
  418. setup();
  419. }
  420.  
  421. }
  422.  
  423. package hearthstone.deck.maker;
  424.  
  425. public class Card {
  426.  
  427. private String Name;
  428. private String Class;
  429. private boolean HasTaunt;
  430. private int Mana;
  431. private int Damage;
  432. private int Health;
  433. private boolean isMinion = false;
  434. private boolean isSpell = false;
  435. private boolean isElemental = false;
  436. private int TimesUsed = 0;
  437. private String Description = " no description ";
  438.  
  439. public void setName(String name){
  440. Name = name;
  441. }
  442.  
  443. public String getName(){
  444. return Name;
  445. }
  446.  
  447. public void setCharacter(String a){
  448. Class = a;
  449. }
  450.  
  451. public String getCharacter(){
  452. return Class;
  453. }
  454.  
  455. public void setHasTaunt(boolean oof){
  456. HasTaunt = oof;
  457. }
  458.  
  459. public boolean getHasTaunt(){
  460. return HasTaunt;
  461. }
  462.  
  463. public void setMana(int b){
  464. Mana = b;
  465. }
  466.  
  467. public int getMana(){
  468. return Mana;
  469. }
  470.  
  471. public void setHealth(int c){
  472. Health = c;
  473. }
  474.  
  475. public int getHealth(){
  476. return Health;
  477. }
  478.  
  479. public void setDamage(int d){
  480. Damage = d;
  481. }
  482.  
  483. public int getDamage(){
  484. return Damage;
  485. }
  486.  
  487. public void setIsMinion(boolean e){
  488. isMinion = e;
  489. }
  490.  
  491. public boolean getIsMinion(){
  492. return isMinion;
  493. }
  494.  
  495. public void setIsSpell(boolean f){
  496. isSpell = f;
  497. }
  498.  
  499. public boolean getIsSpell(){
  500. return isSpell;
  501. }
  502.  
  503. public void setTimesUsed(int g){
  504. TimesUsed = g;
  505. }
  506.  
  507. public int getTimesUsed(){
  508. return TimesUsed;
  509. }
  510.  
  511. public String getDescription(){
  512. return Description;
  513. }
  514.  
  515. public void setDescription(String h){
  516. Description = h;
  517. }
  518.  
  519. public Card(){
  520.  
  521. }
  522. }
  523.  
  524. package hearthstone.deck.maker;
  525.  
  526. import java.io.*;
  527. import java.lang.*;
  528. import java.util.*;
  529.  
  530. public class createfile {
  531. int numCards = HearthStoneDeckMaker.numberOfCards;
  532. private Formatter x;
  533. public void OpenFile(){
  534. try{
  535. x = new Formatter("HearthCards.txt");
  536.  
  537. }
  538. catch(Exception e){
  539. System.out.println("Save Failed");
  540. }
  541. }
  542.  
  543. public void addRecords(){
  544.  
  545. for (int j = 0; j < HearthStoneDeckMaker.numberOfCards; j++) {
  546. x.format("%s %s %x %x %x %x %b %b %b %n", HearthStoneDeckMaker.card[j].getName(), HearthStoneDeckMaker.card[j].getCharacter(), HearthStoneDeckMaker.card[j].getHealth(), HearthStoneDeckMaker.card[j].getDamage(), HearthStoneDeckMaker.card[j].getMana(), HearthStoneDeckMaker.card[j].getTimesUsed(), HearthStoneDeckMaker.card[j].getHasTaunt(), HearthStoneDeckMaker.card[j].getIsMinion(), HearthStoneDeckMaker.card[j].getIsSpell());
  547. }
  548. }
  549.  
  550. public void closeFile(){
  551. x.close();
  552. }
  553.  
  554.  
  555. }
Add Comment
Please, Sign In to add comment