Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. package Game;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.Random;
  6. import java.util.Scanner;
  7.  
  8.  
  9. public class Arena {
  10.  
  11. int myBudget = 100000;
  12. int opponentBudget = 100000;
  13. String nameOfFirstTeam;
  14. String nameOfSecondTeam;
  15. Person knight = new Knight();
  16. Person paladin = new Paladin();
  17. Person peasant = new Peasant();
  18. Scanner sc = new Scanner(System.in);
  19. List<Person> allKinds = new ArrayList<>();
  20. List<Person> myPerson = new ArrayList<>();
  21. List<Person> opponentPerson = new ArrayList<>();
  22.  
  23. public void getAllKinds(List<Person> personList) {
  24.  
  25. for (int i = 0; i < personList.size(); i++) {
  26. System.out.println(personList.get(i).getName());
  27. }
  28.  
  29. }
  30.  
  31. void startGame() {
  32. System.out.println(" Welcome to The Game ");
  33. this.chooseYourName();
  34. this.chooseOpponentName();
  35. this.pickTeam(myPerson, myBudget, nameOfFirstTeam);
  36. System.out.println();
  37. this.pickTeam(opponentPerson, opponentBudget, nameOfSecondTeam);
  38. // this.attack(myPerson,opponentPerson);
  39. }
  40.  
  41. void chooseYourName() {
  42. System.out.println("Choose first team name");
  43. String name = sc.nextLine();
  44. nameOfFirstTeam = name;
  45. }
  46.  
  47. void chooseOpponentName() {
  48. System.out.println("Choose second team name");
  49. String name = sc.nextLine();
  50. nameOfSecondTeam = name;
  51. }
  52.  
  53. void pickTeam(List<Person> person, int budget, String name) {
  54. System.out.println(name + " buy your army");
  55. while (budget >= 10000) {
  56. System.out.println("Your Budget : " + budget + "\n");
  57. System.out.println("peasant cost 10000");
  58. System.out.println("knight cost 25000");
  59. System.out.println("paladin cost 60000");
  60.  
  61. String type = sc.nextLine();
  62. switch (type) {
  63. case "knight":
  64. if (budget >= ((Knight) knight).getCost()) {
  65. budget = budget - ((Knight) knight).getCost();
  66. person.add(knight);
  67. System.out.println("You bought Knight");
  68. } else
  69. System.out.println("You dont have enought money");
  70. break;
  71. case "paladin":
  72. if (budget >= ((Paladin) paladin).getCost()) {
  73. budget = budget - ((Paladin) paladin).getCost();
  74. person.add(paladin);
  75. System.out.println("You bought Paladin");
  76. } else
  77. System.out.println("You dont have enought money");
  78.  
  79. break;
  80. case "peasant":
  81. if (budget >= ((Peasant) peasant).getCost()) {
  82. budget = budget - ((Peasant) peasant).getCost();
  83. person.add(peasant);
  84. System.out.println("You bought Peasant");
  85. } else
  86. System.out.println("You dont have enought money");
  87.  
  88. break;
  89. default:
  90. System.out.println("there is no warrior such u typed");
  91. break;
  92. }
  93. System.out.println(name + " your army : ");
  94. for (Person army : person) {
  95. System.out.println(army.getName());
  96. }
  97. }
  98. }
  99.  
  100. void attack(List<Person> attacker, List<Person> defender) {
  101. for (Person warrior : attacker) {
  102. if (defender.isEmpty())
  103. break;
  104. System.out.println("choose an enemy");
  105. this.getAllKinds(defender);
  106. int defIndex = sc.nextInt();
  107. Person defenders = defender.get(defIndex);
  108. int dmg = warrior.atack((Person) attacker);
  109. int defHp = defenders.takeDmg(dmg); //dunno
  110. System.out.println("Your deal : "+ dmg+" dmg");
  111. if (defHp<0)
  112. defender.remove(defIndex);
  113. }
  114. }
  115.  
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement