Advertisement
Guest User

ConLasChangeCards

a guest
Oct 18th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.27 KB | None | 0 0
  1. package nana;
  2.  
  3. public class Java_Deck{
  4.  
  5. // Name of the player (remains empty for tostring method unless indicated)
  6. private String player_name;
  7. // What team the player is in
  8. private String team;
  9. // Name of the card, self explanatory
  10. private String name_of_card;
  11. // Common, Uncommon, Rare, Legendary
  12. private String type_of_card;
  13. // Name of deck, we have freedom to put what we want here
  14. private String deck_name;
  15. // Elixir of card (idk why we need to have this, we don't even use this tbh)
  16. private double elixir;
  17. // health points of the CURRENT card
  18. private double health_points;
  19. // Damage of the CURRENT card
  20. private double damage;
  21. // Total hitpoints, initialized as zero
  22. private double t_hp = 0;
  23. // Total damage, initialized as zero
  24. private double t_dam = 0;
  25. // Card count, used for average calculation
  26. private double card_count = 1;
  27. // isHealth boolean used for type of toString method
  28. private boolean isHealth = false;
  29.  
  30. //This is for the changing the deck by changing two cards
  31.  
  32.  
  33. // Constructor, DONT TOUCH THIS UNLESS YOU HAVE TO
  34. public Java_Deck(String deck_namel, String p_name, String t, String n, String ty, double eli, double he, double dam){
  35. deck_name = deck_namel;
  36. player_name = p_name;
  37. team = t;
  38. name_of_card = n;
  39. type_of_card = ty;
  40. elixir = eli;
  41. health_points = he;
  42. damage = dam;
  43. t_hp = he;
  44. t_dam = dam;
  45. }
  46. // Method to add card given parameters
  47. void addCard(String new_name, String new_type, double new_health, double new_elixir, double new_damage){
  48. name_of_card = new_name;
  49. type_of_card = new_type;
  50. t_hp = t_hp + new_health;
  51. t_dam = t_dam + new_damage;
  52. health_points = new_health;
  53. damage = new_damage;
  54. card_count += 1;
  55.  
  56. }
  57.  
  58. // Print Health and Damage methods, don't touch this
  59. String printHealth(){
  60. return " The average health of " + deck_name + " is: " + (t_hp/card_count);
  61. }
  62. String printDamage(){
  63. return " The average damage of " + deck_name + " is: " + (t_dam/card_count);
  64. }
  65.  
  66. //Extra credit, since we don't really need current card health and damage, might as well add this for some extra points :)
  67. String recent_card_stats(Java_Deck deck){
  68. return ("The most recent added card has the following stats: " + health_points + " hit points, " + damage + " damage, and " + elixir + " elixir points." + "/n" + "The name of the card is " + name_of_card + " and it is of " + type_of_card + " rarity.");
  69. }
  70.  
  71. // What deck Colton will play, based on the decks given in the parameter (Yes, there are better ways to do this, but spaguetti code will do the job)
  72. void Colton_choice(String player_namel, String team_name, Java_Deck deck1, Java_Deck deck2, Java_Deck deck3, Java_Deck deck4){
  73. if (deck1.t_hp > deck2.t_hp && deck1.t_hp > deck3.t_hp && deck1.t_hp >deck4.t_hp){
  74. deck1.player_name = player_namel;
  75. deck1.team = team_name;
  76. deck1.isHealth = true;
  77.  
  78. }
  79. else if (deck2.t_hp > deck3.t_hp && deck2.t_hp > deck4.t_hp){
  80. deck2.player_name = player_namel;
  81. deck2.team = team_name;
  82. deck2.isHealth = true;
  83. }
  84. else if (deck3.t_hp > deck4.t_hp){
  85. deck3.player_name = player_namel;
  86. deck3.team = team_name;
  87. deck3.isHealth = true;
  88. }
  89. else{
  90. deck4.player_name = player_namel;
  91. deck4.team = team_name;
  92. deck4.isHealth = true;
  93. }
  94.  
  95. }
  96.  
  97. // Same as the method before, but this time for player Cuchii (what a weird name)
  98. void Cuchii_choice(String player_namel,String team_name, Java_Deck deck1, Java_Deck deck2, Java_Deck deck3, Java_Deck deck4){
  99. if (deck1.t_dam > deck2.t_dam && deck1.t_dam > deck3.t_dam && deck1.t_dam >deck4.t_dam){
  100. deck1.player_name = player_namel;
  101. deck1.team = team_name;
  102. deck1.isHealth = false;
  103. }
  104. else if (deck2.t_dam > deck3.t_dam && deck2.t_dam > deck4.t_dam){
  105. deck2.player_name = player_namel;
  106. deck2.team = team_name;
  107. deck2.isHealth = false;
  108. }
  109. else if (deck3.t_dam > deck4.t_dam){
  110. deck3.player_name = player_namel;
  111. deck3.team = team_name;
  112. deck3.isHealth = false;
  113. }
  114. else{
  115. deck4.player_name = player_namel;
  116. deck4.team = team_name;
  117. deck4.isHealth = false;
  118. }
  119. }
  120.  
  121. //Method for changing the cards in the deck (or rather, subtracting)
  122. void changeCards(int oldhel, int olddmg, int oldhel2, int olddmg2)
  123. {
  124. t_hp -= oldhel;
  125. t_hp -= oldhel2;
  126. t_dam -= olddmg;
  127. t_dam -= olddmg2;
  128. }
  129.  
  130. // toString method (PLEASE DO NOT TOUCH THIS UNLESS YOU ABSOLUTELY NEED TO)
  131. public String toString() {
  132. if (player_name != ""){
  133. if (isHealth == true){
  134. return "Player " + player_name + " in team " + team + " playing will choose in the CRL " + deck_name + " with a hit point average of " + (t_hp/card_count);
  135. }
  136. else{
  137. return "Player " + player_name + " in team " + team + " will choose in the CRL " + deck_name + " with a damage average of " + (t_dam/card_count);
  138. }
  139. }
  140. else{
  141. return deck_name + " with a hit point average of " + (t_hp/card_count) + " and a damage average of " + (t_dam/card_count) + " will not be played by any player in the CRL.";
  142. }
  143.  
  144.  
  145.  
  146. }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement