import java.io.File; import java.io.FileNotFoundException; import java.net.URL; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.Scanner; public class Game { static Scanner user_input = new Scanner(System.in); int fightswon = 0; // List consumables = new ArrayList(); // List> equipments = new ArrayList>(); public Game() { /* // initialisatie van alle Items consumables.add(new Potion("Potion",50)); consumables.add(new Potion("Super_Potion",100)); consumables.add(new Potion("Hyper_Potion",200)); for (int i=0; i<5; i++) equipments.add(new ArrayList()); try { URL fileURL = getClass().getResource("data/equipments.txt"); File myfile = new File(fileURL.toURI()); Scanner scanner = new Scanner(myfile); while (scanner.hasNextLine()) { String[] split = scanner.nextLine().split(" "); if (split.length == 6) { equipments.get(Integer.parseInt(split[0])).add(new Equipment(split[1], Integer.parseInt(split[2]), Integer.parseInt(split[3]), Integer.parseInt(split[4]), EquipType.values()[Integer.parseInt(split[5])])); } } scanner.close(); } catch (FileNotFoundException e) { System.err.println("Error while reading equipment file!\n"); } */ } // * Geef als input de mogelijke invoerkeuzes en hun corresponderende beschrijving. // * Als returnwaarde krijg je de index (van de array) van het gekozen veldje static int make_choice(String[] choices, String[] descriptions) { while (true) { System.out.println("\nPlease type in one of the following commands:"); for (int i=0; i 0) { Item item; if (rand.nextInt(3)==0) { item = consumables.get(rand.nextInt(consumables.size())); } else { int index = Math.min(fightswon/2, equipments.size()-1); item = equipments.get(index).get(rand.nextInt(equipments.get(index).size())); } player.additem(item); System.out.println(item.name); } */ } public static void main(String[] in) { Game game = new Game(); System.out.println("Welcome to the Arena!\nPlease type in you name:"); Player player = new Player(Game.user_input.next()); // player.inventory.put(game.consumables.get(0), 3); gameloop: while (true) { // game loop String[] choices = {"F","I","Q"}; String[] desc = {"Start fight", "Open inventory", "Quit game"}; switch (Game.make_choice(choices, desc)) { case 0: Enemy adversary = new Enemy(3 + game.fightswon); Arena arena = new Arena(player, adversary); if (arena.fight()) { System.out.println("Congratulations! You won the battle!"); // game.rewards(player, 3); player.experience(adversary.expvalue()); player.hp = player.maxhp; game.fightswon++; System.out.println("\n\nGet ready for the next battle."); break; } else { System.out.println("You died in battle...\nGAME OVER\nYou survived for " + game.fightswon + " battles\n"); break gameloop; } case 1: // player.useitem(); break; case 2: break gameloop; } } System.out.println("Thank you for playing!"); } }