Luninariel

Monsters - Main

Dec 6th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. Entity a = new Human();
  2. Entity b = new Human();
  3. Human c = new Human();
  4. Human d = new Human(0.80);
  5. Entity f = new Warrior();
  6. Warrior g = new Warrior();
  7. Warrior h = new Warrior();
  8. Ninja j = new Ninja();
  9. assassinVine k = new assassinVine();
  10. Daisy l =new Daisy();
  11. Owl m = new Owl();
  12. pineTree n = new pineTree();
  13. rabbitOfCaerbannog o = new rabbitOfCaerbannog();
  14. Plant p = new Plant();
  15.  
  16. ArrayList<Entity> creatures = new ArrayList<Entity>();
  17. creatures.add(a);
  18. creatures.add(b);
  19. creatures.add(c);
  20. creatures.add(d);
  21. creatures.add(f);
  22. creatures.add(g);
  23. creatures.add(h);
  24. creatures.add(j);
  25. creatures.add(k);
  26. creatures.add(l);
  27. creatures.add(m);
  28. creatures.add(n);
  29. creatures.add(o);
  30. creatures.add(p);
  31. creatures.add(new Warrior());
  32. creatures.add(new Human());
  33. creatures.add(new Human(0.95));
  34. creatures.add(new Human(100.0));
  35.  
  36. System.out.println(Attack.isNight());
  37.  
  38. //Run a match between Warrior and Tree.
  39. Entity warriorTree = match(f,p);
  40. if(warriorTree == null)
  41. System.out.println("It's a draw!");
  42. else
  43. System.out.println(warriorTree + " is the winner");
  44.  
  45.  
  46. //Run a match between vine and Daisy.
  47. Entity vineDaisy = match(k,l);
  48. if(vineDaisy == null)
  49. System.out.println("It's a draw!");
  50. else
  51. System.out.println(vineDaisy + " is the winner");
  52.  
  53.  
  54. //Run a match between Rabbit & Owl.
  55. Entity rabbitowl = match(o,m);
  56. if(rabbitowl == null)
  57. System.out.println("It's a draw!");
  58. else
  59. System.out.println(rabbitowl + " is the winner");
  60.  
  61. //Match between Ninja and pineTree
  62. Entity ninjapineTree = match(j,n);
  63. if(ninjapineTree == null)
  64. System.out.println("It's a draw!");
  65. else
  66. System.out.println(ninjapineTree + " is the winner");
  67.  
  68.  
  69. //Run a match between two humans.
  70. Entity winner = match(b,c);
  71. if(winner == null)
  72. System.out.println("It's a draw!");
  73. else
  74. System.out.println(winner + " is the winner");
  75.  
  76. //Run a match between two entities.
  77. Entity twoEntityfight = match(a,f);
  78. if(twoEntityfight == null)
  79. System.out.println("It's a draw!");
  80. else
  81. System.out.println(twoEntityfight + " is the winner");
  82.  
  83. //Run a match between two Warriors.
  84. Entity twoWarriorfight = match(g,h);
  85. if(twoWarriorfight == null)
  86. System.out.println("It's a draw!");
  87. else
  88. System.out.println(twoWarriorfight + " is the winner");
  89.  
  90. //Run a match between a Human and a Warrior
  91. Entity humanWarrior = match(c,g);
  92. if(humanWarrior == null)
  93. System.out.println("It's a draw!");
  94. else
  95. System.out.println(humanWarrior + " is the winner");
  96.  
  97. //Run a match between an Entity and a Warrior
  98. Entity entityWarrior = match(a,h);
  99. if(entityWarrior == null)
  100. System.out.println("It's a draw!");
  101. else
  102. System.out.println(entityWarrior + " is the winner");
  103.  
  104. System.out.println("\uD83C\uDF84\uD83C\uDF84\uD83C\uDF84");
  105. }
  106.  
  107. public static <T> void print(ArrayList<T> list){
  108. System.out.printf("\n------------------ %d items\n", list.size());
  109. for(T t : list){
  110. System.out.println(t);
  111. }
  112. }
  113.  
  114. /**
  115. * This runs a set of rounds until at least one player is dead.
  116. *
  117. * After the rounds are completed the winner is printed
  118. *
  119. * In the postmortem both players are printed.
  120. *
  121. * @param a One player
  122. * @param b A second player
  123. * @return The Winner object, in all it's bloody glory
  124. */
  125.  
  126. public static Entity match(Entity a, Entity b){
  127. int round = 1;
  128. while(round <= 10 && !a.isDead() && !b.isDead()){
  129. System.out.printf("\nRound %2d %s VS %s\n", round, a, b);
  130. Attack.round(a,b,round);
  131. round++;
  132. }
  133.  
  134. //Find the winner, if any
  135. Entity winner = null;
  136. if(a.isDead() && !b.isDead())
  137. winner = b;
  138. else if(!a.isDead() && b.isDead())
  139. winner = a;
  140.  
  141. System.out.println("Postmortem: ");
  142. System.out.printf("%s %s\n", a.isDead()?"\uD83D\uDC80":"\uD83D\uDE03", a);
  143. System.out.printf("%s %s\n", b.isDead()?"\uD83D\uDC80":"\uD83D\uDE03", b);
  144.  
  145. return winner;
  146. }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment