Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Game;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Random;
- import java.util.Scanner;
- public class Arena {
- int myBudget = 100000;
- int opponentBudget = 100000;
- String nameOfFirstTeam;
- String nameOfSecondTeam;
- Person knight = new Knight();
- Person paladin = new Paladin();
- Person peasant = new Peasant();
- Scanner sc = new Scanner(System.in);
- List<Person> allKinds = new ArrayList<>();
- List<Person> myPerson = new ArrayList<>();
- List<Person> opponentPerson = new ArrayList<>();
- public void getAllKinds(List<Person> personList) {
- for (int i = 0; i < personList.size(); i++) {
- System.out.println(personList.get(i).getName());
- }
- }
- void startGame() {
- System.out.println(" Welcome to The Game ");
- this.chooseYourName();
- this.chooseOpponentName();
- this.pickTeam(myPerson, myBudget, nameOfFirstTeam);
- System.out.println();
- this.pickTeam(opponentPerson, opponentBudget, nameOfSecondTeam);
- // this.attack(myPerson,opponentPerson);
- }
- void chooseYourName() {
- System.out.println("Choose first team name");
- String name = sc.nextLine();
- nameOfFirstTeam = name;
- }
- void chooseOpponentName() {
- System.out.println("Choose second team name");
- String name = sc.nextLine();
- nameOfSecondTeam = name;
- }
- void pickTeam(List<Person> person, int budget, String name) {
- System.out.println(name + " buy your army");
- while (budget >= 10000) {
- System.out.println("Your Budget : " + budget + "\n");
- System.out.println("peasant cost 10000");
- System.out.println("knight cost 25000");
- System.out.println("paladin cost 60000");
- String type = sc.nextLine();
- switch (type) {
- case "knight":
- if (budget >= ((Knight) knight).getCost()) {
- budget = budget - ((Knight) knight).getCost();
- person.add(knight);
- System.out.println("You bought Knight");
- } else
- System.out.println("You dont have enought money");
- break;
- case "paladin":
- if (budget >= ((Paladin) paladin).getCost()) {
- budget = budget - ((Paladin) paladin).getCost();
- person.add(paladin);
- System.out.println("You bought Paladin");
- } else
- System.out.println("You dont have enought money");
- break;
- case "peasant":
- if (budget >= ((Peasant) peasant).getCost()) {
- budget = budget - ((Peasant) peasant).getCost();
- person.add(peasant);
- System.out.println("You bought Peasant");
- } else
- System.out.println("You dont have enought money");
- break;
- default:
- System.out.println("there is no warrior such u typed");
- break;
- }
- System.out.println(name + " your army : ");
- for (Person army : person) {
- System.out.println(army.getName());
- }
- }
- }
- void attack(List<Person> attacker, List<Person> defender) {
- for (Person warrior : attacker) {
- if (defender.isEmpty())
- break;
- System.out.println("choose an enemy");
- this.getAllKinds(defender);
- int defIndex = sc.nextInt();
- Person defenders = defender.get(defIndex);
- int dmg = warrior.atack((Person) attacker);
- int defHp = defenders.takeDmg(dmg); //dunno
- System.out.println("Your deal : "+ dmg+" dmg");
- if (defHp<0)
- defender.remove(defIndex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement