Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.20 KB | None | 0 0
  1. import java.io.*;
  2. public class TestCharacter {
  3. public static void main (String args[])throws IOException{//main method
  4.  
  5. {
  6. Dice dice = new Dice();
  7. Character ch1 = new Character();
  8. Character ch2 = new Character();
  9.  
  10. int S1 =ch1.getStrength();
  11. int D1 =ch1.getDexterity();
  12. int I1 =ch1.getIntelligence();
  13. int Mx1=ch1.getMaxLife1();
  14. int CL1=Mx1;
  15. int A1 =ch1.getAttack1();
  16. int HL1 =ch1.getheal1();
  17. int S2 =ch1.getStrength2();
  18. int D2 =ch1.getDexterity2();
  19. int I2 =ch1.getIntelligence2();
  20. int Mx2=ch1.getMaxLife1();
  21. int CL2=Mx2;
  22. int A2=ch1.getAttack2();
  23. int HL2 =ch1.getheal2();
  24. int x,y;
  25. int Dm1 = 0;
  26. int Dm2 =0;
  27. int ctr=1;
  28.  
  29.  
  30.  
  31.  
  32.  
  33. System.out.println(ch1.getName() + " " + "MaxLife is" + Mx1);
  34. System.out.println(ch2.getName1() + " " + "MaxLife is" + Mx2);
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. //Attributes of player 1
  46. System.out.println("JOE's Attributes:");
  47.  
  48. System.out.println(ch1.getName() + "Strength is" + " " + S1);
  49. System.out.println("Dexterity is" + " " + D1);
  50. System.out.println("Intelligence is" + " " + I1);
  51.  
  52. System.out.println(" ");
  53. //Attributes of plaeer 2
  54. System.out.println("BOB's Attributes:");
  55.  
  56. System.out.println(ch2.getName1() + "Strength is" + " " + S2);
  57. System.out.println("Dexterity is" + " " + D2);
  58. System.out.println("Intelligence is" + " " + I2);
  59.  
  60. ///////////////////////////////////////////////////////////////////////////
  61.  
  62. //Start of the battle
  63. System.out.println(" ");
  64. System.out.println("BATTLE COMMENCE");
  65. System.out.println(" ");
  66.  
  67. //////////////////////////////////////////////////////////////////////////
  68. do
  69. {
  70.  
  71. //Battle starts and counter increases by 1 each round
  72. System.out.println(" ");
  73. System.out.println("BATTLE" +"__" + ctr);
  74. System.out.println(" ");
  75.  
  76.  
  77. if(Dm1 > 0 || Dm2>0){
  78. {//player 1 attacks player 2 with random roll of dice times 4
  79. System.out.println("JOE Attack:");
  80.  
  81. System.out.println( ch1.getName() + " Attacks " + ch2.getName1());
  82. System.out.println("Attacks:" + (x= A1 + dice.roll2()));
  83. System.out.println(ch2.getName1()+ "'s CL:" + Dm2);
  84. System.out.println(" ");
  85. CL2=CL2 - x;
  86. Dm2=CL2;
  87. //player 1 attacks player 2 with random roll of dice times 4
  88. System.out.println("BOB Attack:");
  89.  
  90. System.out.println( ch2.getName1() + " Attacks " + ch1.getName());
  91. System.out.println("Attacks:" + (y= A2 + dice.roll1() ));
  92. System.out.println(ch1.getName()+ "'s CL:" + Dm1);
  93. System.out.println(" ");
  94. CL1=CL1 - y;
  95. Dm1=CL1;
  96. }
  97. }
  98. else{
  99. {//player 1 attacks player 2 with random roll of dice times 4
  100. System.out.println("BOB Attack:");
  101.  
  102. System.out.println( ch2.getName1() + " Attacks " + ch1.getName());
  103. System.out.println("Attacks:" + (y= A2 + dice.roll1() ));
  104. System.out.println(ch1.getName()+ "'s CL:" + Dm1);
  105. System.out.println(" ");
  106. CL1=CL1 - y;
  107. Dm1=CL1;
  108. //player 1 attacks player 2 with random roll of dice times 4
  109. System.out.println("JOE Attack:");
  110.  
  111.  
  112. System.out.println( ch1.getName() + " Attacks " + ch2.getName1());
  113. System.out.println("Attacks:" + (x= A1 + dice.roll2()));
  114. System.out.println(ch2.getName1()+ "'s CL:" + Dm2);
  115. System.out.println(" ");
  116. CL2=CL2 - x;
  117. Dm2=CL2;
  118. }}
  119. ctr++;
  120. System.out.println("BATTLE" +"__" +ctr);
  121.  
  122. }while(CL2 > 1 & CL1 >1);
  123.  
  124. /////////////////////////////////////////////////////////////////////////
  125. int R = dice.roll1();
  126. if(R >2)
  127. {
  128. if(Dm1 < Mx1 || CL1 > 0)
  129. {
  130. Dm1 = CL1 + HL1;
  131.  
  132. if(Dm1 > Mx1){
  133. Dm1 = CL1;
  134. System.out.println("Joe Heals_" + HL1);
  135. System.out.println("Joe's Health is_" + Dm1);
  136. }
  137. else
  138. {
  139. if(CL1 > 0)
  140. {
  141. System.out.println("Joe Heals" + HL1);
  142. System.out.println("Joe's Health is" + Dm1);
  143. }
  144. }
  145. }
  146. }
  147. /////////////////////////////////////////////////////////////////////////
  148. int W = dice.roll1();
  149. if(W >2)
  150. {
  151. if(Dm2 < Mx2 || CL2 > 0)
  152. {
  153. Dm2 = CL2 + HL2;
  154.  
  155. if(Dm2 > Mx2){
  156. Dm2 = CL2;
  157. System.out.println("Joe Heals_" + HL2);
  158. System.out.println("Joe's Health is_" + Dm2);
  159. }
  160. else
  161. {
  162. if(CL2 > 0)
  163. {
  164. System.out.println("Joe Heals" + HL2);
  165. System.out.println("Joe's Health is" + Dm2);
  166. }
  167. }
  168. }
  169. }
  170.  
  171. ////////////////////////////////////////////////////////////////////////////
  172.  
  173. if(CL1 == CL2)
  174. {
  175. System.out.println("____DRAW!?!?!?!?!_____");
  176. }
  177. if(CL1 > CL2 )
  178. {
  179. System.out.println("____JOE KICKED BUTT(wins)!!!!!_____");
  180. }
  181. if(CL2 > CL1 )
  182. {
  183. System.out.println("____BOB KICKED BUTT (wins)!!!!!_____");
  184. }
  185.  
  186.  
  187.  
  188.  
  189. }
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199. }
  200.  
  201.  
  202.  
  203. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement