diff --git a/json/original_data/npcs.json b/json/original_data/npcs.json index a86790f6..99cbce48 100644 --- a/json/original_data/npcs.json +++ b/json/original_data/npcs.json @@ -103,7 +103,7 @@ "rightHand": "hands" } ], - "intro": "Hey, rat. . . you dead??\n*You let out a groan...*\nWhat are you doing?!? Don't you know it's crazy to sleep so close to the recruits' camp? A guard will come down those stairs soon enough and catch you! You'll end up being drafted! You better come back in.\nBy the way, what's your name?", + "intro": "Hey, rat. . . you dead??\n*You let out a groan...*\nWhat are you doing?!? Don't you know it's crazy to sleep so close to the recruits' camp?\nA guard will come down those stairs soon enough and catch you! You'll end up being drafted! You better come back in.\nBy the way, what's your name?", "allies": [ "Sewer Rat" ], diff --git a/src/main/java/com/jadventure/game/CharacterNameController.java b/src/main/java/com/jadventure/game/CharacterNameController.java new file mode 100644 index 00000000..783f9824 --- /dev/null +++ b/src/main/java/com/jadventure/game/CharacterNameController.java @@ -0,0 +1,78 @@ +package com.jadventure.game; + +import com.jadventure.game.entities.Player; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.MenuItem; +import javafx.scene.control.TextField; +import javafx.scene.text.Text; +import javafx.stage.WindowEvent; + +public class CharacterNameController { + + // Reference to the main application. + private JAdventure jAdventure; + private Player player; + private Game game; + + public CharacterNameController() { + } + + @FXML + private MenuItem back; + @FXML + private MenuItem close; + @FXML + private MenuItem github; + @FXML + private Text intro; + @FXML + private TextField name; + @FXML + private Button create; + + @FXML + public void createCharacter() throws DeathException { + player.setName(name.getText()); + game.newGameStart(player); + jAdventure.loadWelcome(player, "new"); + } + + @FXML + public void goToMainMenu() { + jAdventure.loadMainMenu(); + } + + @FXML + public void goToGithub() { + // Goes to https://github.com/Progether/JAdventure + } + + @FXML + public void quitGame() throws Exception { + jAdventure.getPrimaryStage().fireEvent( + new WindowEvent(jAdventure.getPrimaryStage(), WindowEvent.WINDOW_CLOSE_REQUEST)); + } + + public void showIntro() { + intro.setText(player.getIntro()); + } + + /** + * Is called by the main application to give a reference back to itself. + * + * @param jAdventure + */ + public void setMainApp(JAdventure jAdventure) { + this.jAdventure = jAdventure; + } + + public void setPlayer(Player player) { + this.player = player; + showIntro(); + } + + public void setGame(Game game) { + this.game = game; + } +} diff --git a/src/main/java/com/jadventure/game/Client.java b/src/main/java/com/jadventure/game/Client.java index fa6b382a..a8952393 100644 --- a/src/main/java/com/jadventure/game/Client.java +++ b/src/main/java/com/jadventure/game/Client.java @@ -56,14 +56,14 @@ public Client(String serverName, int port) { } public void getInput() { - Scanner input; - try { - input = new Scanner(System.in); + //Scanner input; + try (Scanner input = new Scanner(System.in)) { + //input = new Scanner(System.in); String userInput = input.nextLine(); out.writeUTF(userInput); } catch (IOException e) { - e.printStackTrace(); - } + e.printStackTrace(); + } } } diff --git a/src/main/java/com/jadventure/game/Game.java b/src/main/java/com/jadventure/game/Game.java index 27e91685..64a6af4d 100644 --- a/src/main/java/com/jadventure/game/Game.java +++ b/src/main/java/com/jadventure/game/Game.java @@ -19,23 +19,23 @@ public class Game { public Monster monster; Player player = null; - public Game(Player player, String playerType) throws DeathException { - this.parser = new CommandParser(player); - this.player = player; - switch (playerType) { - case "new": - newGameStart(player); - break; - case "old": - QueueProvider.offer("Welcome back, " + player.getName() + "!"); - QueueProvider.offer(""); - player.getLocation().print(); - gamePrompt(player); - break; - default: - QueueProvider.offer("Invalid player type"); - break; - } + public Game(Player player, String playerType, JAdventure jAdventure) throws DeathException { + + this.parser = new CommandParser(player); + this.player = player; + switch (playerType) { + case "new": + jAdventure.loadCharacterName(player, this); + break; + case "old": + jAdventure.loadWelcome(player, "old"); + //player.getLocation().print(); + //gamePrompt(player); + break; + default: + QueueProvider.offer("Invalid player type"); + break; + } } /** @@ -44,6 +44,15 @@ public Game(Player player, String playerType) throws DeathException { * character and welcomes him / her. After that, it goes to the normal game prompt. */ public void newGameStart(Player player) throws DeathException { + LocationRepository locationRepo = GameBeans.getLocationRepository(player.getName()); + this.player.setLocation(locationRepo.getInitialLocation()); + player.save(); + //QueueProvider.offer("Welcome to Silliya, " + player.getName() + "."); + //player.getLocation().print(); + //gamePrompt(player); + } + + public void newGameStart_old(Player player) throws DeathException { QueueProvider.offer(player.getIntro()); String userInput = QueueProvider.take(); player.setName(userInput); diff --git a/src/main/java/com/jadventure/game/GameController.java b/src/main/java/com/jadventure/game/GameController.java new file mode 100644 index 00000000..6248419e --- /dev/null +++ b/src/main/java/com/jadventure/game/GameController.java @@ -0,0 +1,430 @@ +package com.jadventure.game; + +import java.util.List; +import java.util.Map; +import java.util.Random; +import com.jadventure.game.entities.Player; +import com.jadventure.game.items.ItemStack; +import com.jadventure.game.monsters.Monster; +import com.jadventure.game.monsters.MonsterFactory; +import com.jadventure.game.navigation.Direction; +import com.jadventure.game.navigation.ILocation; +import com.jadventure.game.navigation.LocationType; +import com.jadventure.game.repository.ItemRepository; +import javafx.fxml.FXML; +import javafx.geometry.HPos; +import javafx.geometry.NodeOrientation; +import javafx.scene.control.MenuItem; +import javafx.scene.control.ProgressBar; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.TilePane; +import javafx.scene.text.Text; +import javafx.stage.WindowEvent; + +public class GameController { + + // Reference to the main application. + private JAdventure jAdventure; + private Player player; + + public GameController() { + } + + @FXML + private MenuItem save; + @FXML + private MenuItem back; + @FXML + private MenuItem close; + @FXML + private MenuItem github; + @FXML + private Text locationTitle; + @FXML + private Text locationDesc; + @FXML + private ProgressBar health; + @FXML + private Text hpString; + @FXML + private ImageView up; + @FXML + private ImageView down; + @FXML + private ImageView north; + @FXML + private ImageView west; + @FXML + private ImageView south; + @FXML + private ImageView east; + @FXML + private TilePane minimap; + @FXML + private AnchorPane northTile; + @FXML + private AnchorPane westTile; + @FXML + private AnchorPane eastTile; + @FXML + private AnchorPane southTile; + @FXML + private AnchorPane middleTile; + @FXML + private ImageView playerImage; + @FXML + private ImageView stairsUp; + @FXML + private ImageView stairsDown; + @FXML + private ImageView itemMiddle; + @FXML + private ImageView monsterMiddle; + @FXML + private ImageView npcMiddle; + @FXML + private ImageView itemNorth; + @FXML + private ImageView monsterNorth; + @FXML + private ImageView npcNorth; + @FXML + private ImageView itemWest; + @FXML + private ImageView monsterWest; + @FXML + private ImageView npcWest; + @FXML + private ImageView itemEast; + @FXML + private ImageView monsterEast; + @FXML + private ImageView npcEast; + @FXML + private ImageView itemSouth; + @FXML + private ImageView monsterSouth; + @FXML + private ImageView npcSouth; + @FXML + private GridPane backpack; + + @FXML + void goUp() throws DeathException { + command_g("up"); + } + + @FXML + void goDown() throws DeathException { + command_g("down"); + } + + @FXML + void goEast() throws DeathException { + command_g("east"); + } + + @FXML + void goWest() throws DeathException { + command_g("west"); + } + + @FXML + void goNorth() throws DeathException { + command_g("north"); + } + + @FXML + void goSouth() throws DeathException { + command_g("south"); + } + + public void command_g(String arg) throws DeathException { + ILocation location = player.getLocation(); + try { + Direction direction = Direction.valueOf(arg.toUpperCase()); + Map exits = location.getExits(); + if (exits.containsKey(direction)) { + ILocation newLocation = exits.get(Direction.valueOf(arg.toUpperCase())); + if (!newLocation.getLocationType().equals(LocationType.WALL)) { + player.setLocation(newLocation); + if ("test".equals(player.getName())) { + QueueProvider.offer(player.getLocation().getCoordinate().toString()); + } + player.getLocation().print(); + Random random = new Random(); + if (player.getLocation().getMonsters().size() == 0) { + MonsterFactory monsterFactory = new MonsterFactory(); + int upperBound = random.nextInt(player.getLocation().getDangerRating() + 1); + for (int i = 0; i < upperBound; i++) { + Monster monster = monsterFactory.generateMonster(player); + player.getLocation().addMonster(monster); + } + } + if (player.getLocation().getItems().size() == 0) { + int chance = random.nextInt(100); + if (chance < 60) { + addItemToLocation(); + } + } + if (random.nextDouble() < 0.5) { + List monsters = player.getLocation().getMonsters(); + if (monsters.size() > 0) { + int posMonster = random.nextInt(monsters.size()); + String monster = monsters.get(posMonster).monsterType; + QueueProvider.offer("A " + monster + " is attacking you!"); + player.attack(monster); + } + } + } else { + QueueProvider.offer("You cannot walk through walls."); + } + } else { + QueueProvider.offer("The is no exit that way."); + } + } catch (IllegalArgumentException ex) { + QueueProvider.offer("That direction doesn't exist"); + } catch (NullPointerException ex) { + QueueProvider.offer("That direction doesn't exist"); + } finally { + jAdventure.loadGame(player); + } + } + + private void addItemToLocation() { + ItemRepository itemRepo = GameBeans.getItemRepository(); + if (player.getHealth() < player.getHealthMax()/3) { + player.getLocation().addItem(itemRepo.getRandomFood(player.getLevel())); + } else { + Random rand = new Random(); + int startIndex = rand.nextInt(3); + switch (startIndex) { + case 0: + player.getLocation().addItem(itemRepo.getRandomWeapon(player.getLevel())); + break; + case 1: + player.getLocation().addItem(itemRepo.getRandomFood(player.getLevel())); + break; + case 2: + player.getLocation().addItem(itemRepo.getRandomArmour(player.getLevel())); + break; + case 3: + player.getLocation().addItem(itemRepo.getRandomPotion(player.getLevel())); + break; + } + } + } + + public void loadState() { + loadCurrentLocation(); + loadHealthBar(); + loadMinimap(); + loadBackpack(); + } + + public void loadCurrentLocation() { + locationTitle.setText(player.getLocation().getTitle()); + locationDesc.setText(player.getLocation().getDescription()); + } + + public void loadHealthBar() { + int currentHealth = player.getHealth(); + int maxHealth = player.getHealthMax(); + double healthPercentage = (double) currentHealth / (double) maxHealth; + health.setProgress(healthPercentage); + hpString.setText(currentHealth + "/" + maxHealth); + } + + public void loadMinimap() { + loadPlayerImage(); + lookCurrentLocation(); + loadPossibleExits(); + } + + public void loadPlayerImage() { + String characterClass = ""; + if (player.getCurrentCharacterType().equals("Recruit")) { + characterClass = "hero_idle-l_300"; + playerImage.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT); + } else if (player.getCurrentCharacterType().equals("Sewer Rat")) { + characterClass = "Rat_Idle"; + playerImage.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT); + } + playerImage.setImage(new Image("/com/jadventure/game/images/" + characterClass + ".gif"));; + } + + public void loadPossibleExits() { + Map exits = player.getLocation().getExits(); + if ((exits.get(Direction.NORTH) != null) && !(exits.get(Direction.NORTH).getLocationType().equals(LocationType.WALL))) { + northTile.setStyle("-fx-background-color: saddlebrown;"); + } else { + northTile.setStyle("-fx-background-color: gray;"); + } + if ((exits.get(Direction.SOUTH) != null) && !(exits.get(Direction.SOUTH).getLocationType().equals(LocationType.WALL))) { + southTile.setStyle("-fx-background-color: saddlebrown;"); + } else { + southTile.setStyle("-fx-background-color: gray;"); + } + if ((exits.get(Direction.EAST) != null) && !(exits.get(Direction.EAST).getLocationType().equals(LocationType.WALL))) { + eastTile.setStyle("-fx-background-color: saddlebrown;"); + } else { + eastTile.setStyle("-fx-background-color: gray;"); + } + if ((exits.get(Direction.WEST) != null) && !(exits.get(Direction.WEST).getLocationType().equals(LocationType.WALL))) { + westTile.setStyle("-fx-background-color: saddlebrown;"); + } else { + westTile.setStyle("-fx-background-color: gray;"); + } + if (exits.get(Direction.UP) != null) { + stairsUp.setVisible(true); + } else { + stairsUp.setVisible(false); + } + if (exits.get(Direction.DOWN) != null) { + stairsDown.setVisible(true); + } else { + stairsDown.setVisible(false); + } + + for (Map.Entry entry : exits.entrySet()) { + Direction key = entry.getKey(); + ILocation value = entry.getValue(); + if (key.equals(Direction.NORTH)) { + if (!value.getItems().isEmpty()) { + itemNorth.setVisible(true); + } else { + itemNorth.setVisible(false); + } + if (!value.getMonsters().isEmpty()) { + monsterNorth.setVisible(true); + } else { + monsterNorth.setVisible(false); + } + if (!value.getNpcs().isEmpty()) { + npcNorth.setVisible(true); + } else { + npcNorth.setVisible(false); + } + } else if (key.equals(Direction.WEST)) { + if (!value.getItems().isEmpty()) { + itemWest.setVisible(true); + } else { + itemWest.setVisible(false); + } + if (!value.getMonsters().isEmpty()) { + monsterWest.setVisible(true); + } else { + monsterWest.setVisible(false); + } + if (!value.getNpcs().isEmpty()) { + npcWest.setVisible(true); + } else { + npcWest.setVisible(false); + } + } else if (key.equals(Direction.EAST)) { + if (!value.getItems().isEmpty()) { + itemEast.setVisible(true); + } else { + itemEast.setVisible(false); + } + if (!value.getMonsters().isEmpty()) { + monsterEast.setVisible(true); + } else { + monsterEast.setVisible(false); + } + if (!value.getNpcs().isEmpty()) { + npcEast.setVisible(true); + } else { + npcEast.setVisible(false); + } + } else if (key.equals(Direction.SOUTH)) { + if (!value.getItems().isEmpty()) { + itemSouth.setVisible(true); + } else { + itemSouth.setVisible(false); + } + if (!value.getMonsters().isEmpty()) { + monsterSouth.setVisible(true); + } else { + monsterSouth.setVisible(false); + } + if (!value.getNpcs().isEmpty()) { + npcSouth.setVisible(true); + } else { + npcSouth.setVisible(false); + } + } + } + } + + public void lookCurrentLocation() { + if (!player.getLocation().getItems().isEmpty()) { + itemMiddle.setVisible(true); + } else { + itemMiddle.setVisible(false); + } + if (!player.getLocation().getMonsters().isEmpty()) { + monsterMiddle.setVisible(true); + } else { + monsterMiddle.setVisible(false); + } + if (!player.getLocation().getNpcs().isEmpty()) { + npcMiddle.setVisible(true); + } else { + npcMiddle.setVisible(false); + } + } + + public void loadBackpack() { + List items = player.getStorage().getItemStack(); + if (!items.isEmpty()) { + for (int i=0; i() { + @Override + public void handle(WindowEvent e) { + close(e); + } + }); + this.primaryStage.setTitle("JAdventure"); + } catch(Exception e) { + e.printStackTrace(); + } + String[] args = getArguments(); logger.info("Starting JAdventure " + toString(args)); GameModeType mode = getGameMode(args); logger.debug("Starting in mode " + mode.name()); @@ -37,30 +68,30 @@ public static void main(String[] args) { new Client(serverName, port); } else if (GameModeType.SERVER == mode) { while (true) { - ServerSocket listener = null; + ServerSocket listener = null; try { listener = new ServerSocket(port); while (true) { Socket server = listener.accept(); - Runnable r = new MainMenu(server, mode); + Runnable r = new MainMenu(server, mode, this); new Thread(r).start(); } } catch (IOException c) { c.printStackTrace(); } finally { - try { - listener.close(); - } catch (IOException e) { - e.printStackTrace(); - } + try { + listener.close(); + } catch (IOException e) { + e.printStackTrace(); + } } } } else { QueueProvider.startMessenger(GameModeType.STAND_ALONE); - new MainMenu(); + new MainMenu(this).start(); } } - + private static GameModeType getGameMode(String[] args) { if (args == null || args.length == 0 || "".equals(args[0].trim())) { return GameModeType.STAND_ALONE; @@ -93,4 +124,204 @@ private static String toString(String[] args) { bldr.append(" ]"); return bldr.toString(); } + + /** + * Shows MainMenu scene + */ + public void loadMainMenu() { + try { + FXMLLoader loader = new FXMLLoader(); + loader.setLocation(JAdventure.class.getResource("/com/jadventure/game/view/MainMenu.fxml")); + root = (BorderPane) loader.load(); + Scene scene = new Scene(root); + primaryStage.setScene(scene); + setStageSize(); + primaryStage.show(); + MainMenuController controller = loader.getController(); + controller.setMainApp(this); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * Shows ProfileMenu scene + */ + public void loadProfileMenu() { + try { + FXMLLoader loader = new FXMLLoader(); + loader.setLocation(JAdventure.class.getResource("/com/jadventure/game/view/ProfileMenu.fxml")); + root = (BorderPane) loader.load(); + Scene scene = new Scene(root); + primaryStage.setScene(scene); + setStageSize(); + primaryStage.show(); + ProfileMenuController controller = loader.getController(); + controller.setMainApp(this); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * Shows NewClass scene + */ + public void loadNewClass() { + try { + FXMLLoader loader = new FXMLLoader(); + loader.setLocation(JAdventure.class.getResource("/com/jadventure/game/view/NewClass.fxml")); + root = (BorderPane) loader.load(); + Scene scene = new Scene(root); + primaryStage.setScene(scene); + setStageSize(); + primaryStage.show(); + NewClassController controller = loader.getController(); + controller.setMainApp(this); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * Shows CharacterName scene + * @param player + * @param game + */ + public void loadCharacterName(Player player, Game game) { + try { + FXMLLoader loader = new FXMLLoader(); + loader.setLocation(JAdventure.class.getResource("/com/jadventure/game/view/CharacterName.fxml")); + root = (BorderPane) loader.load(); + Scene scene = new Scene(root); + primaryStage.setScene(scene); + setStageSize(); + primaryStage.show(); + CharacterNameController controller = loader.getController(); + controller.setMainApp(this); + controller.setPlayer(player); + controller.setGame(game); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * Shows Welcome scene + * @param player + * @param type + * @param game + */ + public void loadWelcome(Player player, String type) { + try { + FXMLLoader loader = new FXMLLoader(); + loader.setLocation(JAdventure.class.getResource("/com/jadventure/game/view/Welcome.fxml")); + root = (BorderPane) loader.load(); + Scene scene = new Scene(root); + primaryStage.setScene(scene); + setStageSize(); + primaryStage.show(); + WelcomeController controller = loader.getController(); + controller.setMainApp(this); + controller.setPlayer(player); + controller.setType(type); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * Shows Game scene + */ + public void loadGame(Player player) { + try { + FXMLLoader loader = new FXMLLoader(); + loader.setLocation(JAdventure.class.getResource("/com/jadventure/game/view/Game.fxml")); + root = (BorderPane) loader.load(); + Scene scene = new Scene(root); + scene.getStylesheets().add(getClass().getResource("/com/jadventure/game/css/game.css").toExternalForm()); + primaryStage.setScene(scene); + setStageSize(); + primaryStage.show(); + GameController controller = loader.getController(); + controller.setMainApp(this); + controller.setPlayer(player); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void close(WindowEvent e) { + e.consume(); + ButtonType yes = new ButtonType("Yes"); + ButtonType cancel = new ButtonType("Cancel"); + Alert alert = new Alert(AlertType.CONFIRMATION, "", + yes, cancel); + alert.initOwner(getPrimaryStage()); + alert.setTitle("Quit"); + alert.setHeaderText("Are you sure you want to quit?"); + alert.setContentText("All unsaved progress will be lost."); + alert.setGraphic(null); + Optional clicked = alert.showAndWait(); + String selection = clicked.get().getText(); + if (selection.equals("Yes")) { + try { + Platform.exit(); + stop(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + public String[] getArguments() { + List params = getParameters().getRaw(); + if (params.size() > 0) { + String[] args = new String[params.size()]; + int index = 0; + for (String param : params) { + args[index] = param; + index++; + } + return args; + } else { + return new String[0]; + } + } + + public void setStageSize() { + // Sets height and width to match screen size + Rectangle2D bounds = Screen.getPrimary().getVisualBounds(); + primaryStage.setX(bounds.getMinX()); + primaryStage.setY(bounds.getMinY()); + primaryStage.setWidth(bounds.getWidth()); + primaryStage.setHeight(bounds.getHeight()); + } + + public Stage getPrimaryStage() { + return primaryStage; + } + + public void setPrimaryStage(Stage primaryStage) { + this.primaryStage = primaryStage; + } + + public BorderPane getRoot() { + return root; + } + + public void setRoot(BorderPane root) { + this.root = root; + } + + public static void main(String[] args) { + try { + launch(args); + } catch (Exception e) { + if (!e.toString().contains("MenuBarSkin")) { + e.printStackTrace(); + } else { + int i; + } + } + } } diff --git a/src/main/java/com/jadventure/game/MainMenuController.java b/src/main/java/com/jadventure/game/MainMenuController.java new file mode 100644 index 00000000..8b8bbfe8 --- /dev/null +++ b/src/main/java/com/jadventure/game/MainMenuController.java @@ -0,0 +1,56 @@ +package com.jadventure.game; + +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.MenuItem; +import javafx.stage.WindowEvent; + +public class MainMenuController { + + // Reference to the main application. + private JAdventure jAdventure; + + public MainMenuController() { + } + + @FXML + private MenuItem close; + @FXML + private MenuItem github; + @FXML + private Button start; + @FXML + private Button load; + @FXML + private Button quit; + + @FXML + public void startGame() throws DeathException { + jAdventure.loadNewClass(); + } + + @FXML + public void loadProfile() { + jAdventure.loadProfileMenu(); + } + + @FXML + public void goToGithub() { + // Goes to https://github.com/Progether/JAdventure + } + + @FXML + public void quitGame() throws Exception { + jAdventure.getPrimaryStage().fireEvent( + new WindowEvent(jAdventure.getPrimaryStage(), WindowEvent.WINDOW_CLOSE_REQUEST)); + } + + /** + * Is called by the main application to give a reference back to itself. + * + * @param jAdventure + */ + public void setMainApp(JAdventure jAdventure) { + this.jAdventure = jAdventure; + } +} diff --git a/src/main/java/com/jadventure/game/NewClassController.java b/src/main/java/com/jadventure/game/NewClassController.java new file mode 100644 index 00000000..9b2361e3 --- /dev/null +++ b/src/main/java/com/jadventure/game/NewClassController.java @@ -0,0 +1,64 @@ +package com.jadventure.game; + +import com.jadventure.game.entities.Player; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.MenuItem; +import javafx.stage.WindowEvent; + +public class NewClassController { + + // Reference to the main application. + private JAdventure jAdventure; + + public NewClassController() { + } + + @FXML + private MenuItem back; + @FXML + private MenuItem close; + @FXML + private MenuItem github; + @FXML + private Button recruit; + @FXML + private Button sewerRat; + + @FXML + public void newRecruit() throws DeathException { + Player player = Player.getInstance("recruit"); + new Game(player, "new", jAdventure); + } + + @FXML + public void newSewerRat() throws DeathException { + Player player = Player.getInstance("sewerrat"); + new Game(player, "new", jAdventure); + } + + @FXML + public void goToMainMenu() { + jAdventure.loadMainMenu(); + } + + @FXML + public void goToGithub() { + // Goes to https://github.com/Progether/JAdventure + } + + @FXML + public void quitGame() throws Exception { + jAdventure.getPrimaryStage().fireEvent( + new WindowEvent(jAdventure.getPrimaryStage(), WindowEvent.WINDOW_CLOSE_REQUEST)); + } + + /** + * Is called by the main application to give a reference back to itself. + * + * @param jAdventure + */ + public void setMainApp(JAdventure jAdventure) { + this.jAdventure = jAdventure; + } +} diff --git a/src/main/java/com/jadventure/game/ProfileMenuController.java b/src/main/java/com/jadventure/game/ProfileMenuController.java new file mode 100644 index 00000000..93fbe8cf --- /dev/null +++ b/src/main/java/com/jadventure/game/ProfileMenuController.java @@ -0,0 +1,144 @@ +package com.jadventure.game; + +import java.io.File; +import java.util.List; +import java.util.Optional; +import com.jadventure.game.entities.Player; +import com.jadventure.game.menus.MainMenu; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.control.Alert; +import javafx.scene.control.Button; +import javafx.scene.control.ButtonType; +import javafx.scene.control.MenuItem; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.ColumnConstraints; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Region; +import javafx.scene.layout.RowConstraints; +import javafx.scene.text.Font; +import javafx.scene.text.Text; +import javafx.stage.WindowEvent; + +public class ProfileMenuController { + + // Reference to the main application. + private JAdventure jAdventure; + + public ProfileMenuController() { + } + + @FXML + private MenuItem back; + @FXML + private MenuItem close; + @FXML + private MenuItem github; + @FXML + private Text exists; + @FXML + private GridPane profileGrid; + @FXML + private Button menu; + + @FXML + public void goToMainMenu() { + jAdventure.loadMainMenu(); + } + + @FXML + public void goToGithub() { + // Goes to https://github.com/Progether/JAdventure + } + + @FXML + public void quitGame() throws Exception { + jAdventure.getPrimaryStage().fireEvent( + new WindowEvent(jAdventure.getPrimaryStage(), WindowEvent.WINDOW_CLOSE_REQUEST)); + } + + public void loadProfiles() { + List profiles = MainMenu.listProfiles(); + if (profiles.size() == 0) { + exists.setText("There are no profiles to load. Please start a new game instead."); + } else { + for (int i=0; i() { + @Override + public void handle(MouseEvent e) { + ImageView img = (ImageView) e.getSource(); + int profileIndex = GridPane.getRowIndex(img); + Text profileNameT = (Text) profileGrid.getChildren().get(profileIndex * 3); + String profileName = profileNameT.getText(); + Player player = null; + player = Player.load(profileName); + try { + new Game(player, "old", jAdventure); + } catch (DeathException e1) { + e1.printStackTrace(); + } + } + }); + profileGrid.add(load, 1, i); + + ImageView del = new ImageView(new Image("/com/jadventure/game/images/delete.png")); + del.setOnMouseClicked(new EventHandler() { + @Override + public void handle(MouseEvent e) { + ImageView img = (ImageView) e.getSource(); + int profileIndex = GridPane.getRowIndex(img); + Text profileNameT = (Text) profileGrid.getChildren().get(profileIndex * 3); + String profileName = profileNameT.getText(); + + ButtonType yes = new ButtonType("Yes"); + ButtonType cancel = new ButtonType("Cancel"); + Alert alert = new Alert(AlertType.CONFIRMATION, + "", + yes, cancel); + alert.initOwner(jAdventure.getPrimaryStage()); + alert.setTitle("Delete profile"); + alert.setHeaderText("Are you sure you want to delete " + profileName + "?"); + alert.setContentText("The profile will be deleted permanently."); + alert.setGraphic(null); + Optional clicked = alert.showAndWait(); + String selection = clicked.get().getText(); + if (selection.equals("Yes")) { + File profile = new File("json/profiles/" + profileName); + boolean deleted = MainMenu.deleteDirectory(profile); + System.out.println(deleted); + } + jAdventure.loadProfileMenu(); + } + }); + profileGrid.add(del, 2, i); + + } + profileGrid.getRowConstraints().add(new RowConstraints(55, 55, Region.USE_COMPUTED_SIZE)); + profileGrid.getColumnConstraints().add(new ColumnConstraints(55, 55, Region.USE_COMPUTED_SIZE)); + profileGrid.setVgap(20); + profileGrid.setHgap(20); + profileGrid.setPadding(new Insets(50, 100, 0, 100)); + profileGrid.setAlignment(Pos.CENTER); + } + } + + /** + * Is called by the main application to give a reference back to itself. + * + * @param jAdventure + */ + public void setMainApp(JAdventure jAdventure) { + this.jAdventure = jAdventure; + loadProfiles(); + } +} diff --git a/src/main/java/com/jadventure/game/QueueProvider.java b/src/main/java/com/jadventure/game/QueueProvider.java index 9768ce8d..2129f153 100644 --- a/src/main/java/com/jadventure/game/QueueProvider.java +++ b/src/main/java/com/jadventure/game/QueueProvider.java @@ -94,15 +94,13 @@ public static String take() { message = "exit"; } } else { - Scanner input = null; - try { - input = new Scanner(System.in); + //Scanner input; + try (Scanner input = new Scanner(System.in)) { + //input = new Scanner(System.in); message = input.nextLine(); - } - catch (NoSuchElementException nsee) { + } catch (NoSuchElementException nsee) { nsee.printStackTrace(); - } - catch (IllegalStateException ise) { + } catch (IllegalStateException ise) { ise.printStackTrace(); } } diff --git a/src/main/java/com/jadventure/game/WelcomeController.java b/src/main/java/com/jadventure/game/WelcomeController.java new file mode 100644 index 00000000..665d00d4 --- /dev/null +++ b/src/main/java/com/jadventure/game/WelcomeController.java @@ -0,0 +1,77 @@ +package com.jadventure.game; + +import com.jadventure.game.entities.Player; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.MenuItem; +import javafx.scene.text.Text; +import javafx.stage.WindowEvent; + +public class WelcomeController { + + // Reference to the main application. + private JAdventure jAdventure; + private Player player; + private String type; + + public WelcomeController() { + } + + @FXML + private MenuItem back; + @FXML + private MenuItem close; + @FXML + private MenuItem github; + @FXML + private Text welcome; + @FXML + private Button cont; + + @FXML + public void play() { + jAdventure.loadGame(player); + } + + @FXML + public void goToMainMenu() { + jAdventure.loadMainMenu(); + } + + @FXML + public void goToGithub() { + // Goes to https://github.com/Progether/JAdventure + } + + @FXML + public void quitGame() throws Exception { + jAdventure.getPrimaryStage().fireEvent( + new WindowEvent(jAdventure.getPrimaryStage(), WindowEvent.WINDOW_CLOSE_REQUEST)); + } + + public void showWelcome() { + if (type.equals("new")) { + welcome.setText("Welcome to Silliya, " + player.getName() + "!"); + } else if (type.equals("old")) { + welcome.setText("Welcome back, " + player.getName() + "!"); + } + } + + /** + * Is called by the main application to give a reference back to itself. + * + * @param jAdventure + */ + public void setMainApp(JAdventure jAdventure) { + this.jAdventure = jAdventure; + } + + public void setPlayer(Player player) { + this.player = player; + } + + public void setType(String type) { + this.type = type; + showWelcome(); + } +} diff --git a/src/main/java/com/jadventure/game/conversation/ConversationManager.java b/src/main/java/com/jadventure/game/conversation/ConversationManager.java index c1bb57f0..8fcbbaff 100644 --- a/src/main/java/com/jadventure/game/conversation/ConversationManager.java +++ b/src/main/java/com/jadventure/game/conversation/ConversationManager.java @@ -16,7 +16,6 @@ import com.google.gson.JsonParser; import com.jadventure.game.repository.NpcRepository; -import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.Reader; @@ -64,7 +63,7 @@ public static ConversationManager getInstance() { private void load() { String fileName = "json/original_data/npcs.json"; JsonParser parser = new JsonParser(); - File f = new File(fileName); + //File f = new File(fileName); try { Reader reader = new FileReader(fileName); JsonObject json = parser.parse(reader).getAsJsonObject(); diff --git a/src/main/java/com/jadventure/game/conversation/Line.java b/src/main/java/com/jadventure/game/conversation/Line.java index 4acd82f5..8d68a1a9 100644 --- a/src/main/java/com/jadventure/game/conversation/Line.java +++ b/src/main/java/com/jadventure/game/conversation/Line.java @@ -1,6 +1,5 @@ package com.jadventure.game.conversation; -import com.jadventure.game.QueueProvider; import com.jadventure.game.entities.NPC; import com.jadventure.game.entities.Player; import com.jadventure.game.menus.Menus; diff --git a/src/main/java/com/jadventure/game/entities/NPC.java b/src/main/java/com/jadventure/game/entities/NPC.java index 25997ef1..4c75241d 100644 --- a/src/main/java/com/jadventure/game/entities/NPC.java +++ b/src/main/java/com/jadventure/game/entities/NPC.java @@ -1,20 +1,12 @@ package com.jadventure.game.entities; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.Reader; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Random; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import com.jadventure.game.QueueProvider; -import com.jadventure.game.items.Storage; /** * This class deals with Non Player Character (NPC) and all of their properties. diff --git a/src/main/java/com/jadventure/game/entities/Player.java b/src/main/java/com/jadventure/game/entities/Player.java index 73c4650b..6fa107f9 100644 --- a/src/main/java/com/jadventure/game/entities/Player.java +++ b/src/main/java/com/jadventure/game/entities/Player.java @@ -7,10 +7,6 @@ import java.io.IOException; import java.io.Reader; import java.io.Writer; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -25,8 +21,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.google.gson.JsonArray; -import com.google.gson.JsonPrimitive; import com.google.gson.reflect.TypeToken; import com.jadventure.game.DeathException; import com.jadventure.game.GameBeans; diff --git a/src/main/java/com/jadventure/game/menus/BattleMenu.java b/src/main/java/com/jadventure/game/menus/BattleMenu.java index b4169101..f2204e54 100644 --- a/src/main/java/com/jadventure/game/menus/BattleMenu.java +++ b/src/main/java/com/jadventure/game/menus/BattleMenu.java @@ -4,7 +4,6 @@ import com.jadventure.game.entities.Entity; import com.jadventure.game.entities.Player; import com.jadventure.game.entities.NPC; -import com.jadventure.game.monsters.Monster; import com.jadventure.game.QueueProvider; import com.jadventure.game.CharacterChange; import com.jadventure.game.items.ItemStack; diff --git a/src/main/java/com/jadventure/game/menus/ChooseClassMenu.java b/src/main/java/com/jadventure/game/menus/ChooseClassMenu.java deleted file mode 100644 index 20825b8c..00000000 --- a/src/main/java/com/jadventure/game/menus/ChooseClassMenu.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jadventure.game.menus; - -import com.jadventure.game.entities.Player; -import com.jadventure.game.DeathException; -import com.jadventure.game.Game; -import com.jadventure.game.QueueProvider; - -/** - * Called when creating a new Player - */ -public class ChooseClassMenu extends Menus { - - public ChooseClassMenu() throws DeathException { - this.menuItems.add(new MenuItem("Recruit", "A soldier newly enlisted to guard the city of Silliya")); - this.menuItems.add(new MenuItem("SewerRat", "A member of the underground of Silliya")); - - while(true) { - QueueProvider.offer("Choose a class to get started with:"); - MenuItem selectedItem = displayMenu(this.menuItems); - if(testOption(selectedItem)) { - break; - } - } - } - - private static boolean testOption(MenuItem m) throws DeathException { - String key = m.getKey(); - if(key.equals("recruit")) { - Player player = Player.getInstance("recruit"); - new Game(player, "new"); - return true; - } else if(key.equals("sewerrat")) { - Player player = Player.getInstance("sewerrat"); - new Game(player, "new"); - return true; - } else { - return false; - } - } -} diff --git a/src/main/java/com/jadventure/game/menus/MainMenu.java b/src/main/java/com/jadventure/game/menus/MainMenu.java index 53776f25..b255f6c8 100644 --- a/src/main/java/com/jadventure/game/menus/MainMenu.java +++ b/src/main/java/com/jadventure/game/menus/MainMenu.java @@ -2,13 +2,11 @@ import java.io.File; import java.net.Socket; - -import com.jadventure.game.DeathException; -import com.jadventure.game.Game; +import java.util.ArrayList; +import java.util.List; import com.jadventure.game.GameModeType; import com.jadventure.game.JAdventure; import com.jadventure.game.QueueProvider; -import com.jadventure.game.entities.Player; /** * The first menu displayed on user screen @@ -17,114 +15,28 @@ * start a new one, or exit to the terminal. */ public class MainMenu extends Menus implements Runnable { - - public MainMenu(Socket server, GameModeType mode){ + + private JAdventure jAdventure; + + public MainMenu(Socket server, GameModeType mode, JAdventure jAdventure){ + this.jAdventure = jAdventure; QueueProvider.startMessenger(mode, server); } - public MainMenu() { - start(); + public MainMenu(JAdventure jAdventure) { + this.jAdventure = jAdventure; } public void run() { start(); } - + public void start() { - menuItems.add(new MenuItem("Start", "Starts a new Game", "new")); - menuItems.add(new MenuItem("Load", "Loads an existing Game")); - menuItems.add(new MenuItem("Delete", "Deletes an existing Game")); - menuItems.add(new MenuItem("Exit", null, "quit")); - - boolean continuing = true; - do { - MenuItem selectedItem = displayMenu(menuItems); - try { - continuing = testOption(selectedItem); - } catch (DeathException e) { - if (e.getLocalisedMessage().equals("close")) { - continuing = false; - } - } - } while(continuing); - QueueProvider.offer("EXIT"); + jAdventure.loadMainMenu(); } - private static boolean testOption(MenuItem m) throws DeathException { - String key = m.getKey(); - switch (key){ - case "start": - new ChooseClassMenu(); - break; - case "load": - loadProfileFromMenu(); - break; - case "delete": - deleteProfileFromMenu(); - break; - case "exit": - QueueProvider.offer("Goodbye!"); - return false; - } - return true; - } - - private static void loadProfileFromMenu() throws DeathException { - String key; - if (isProfileDirEmpty()) { - QueueProvider.offer("\nThere are no profiles to load. Please start a new game instead."); - return; - } - Player player = null; - do { - listProfiles(); - QueueProvider.offer("\nSelect a profile to load. Type 'back' to go back."); - key = QueueProvider.take(); - if (key.equals("exit") || key.equals("back")) { - return; - } else if (Player.profileExists(key)) { - player = Player.load(key); - } else { - QueueProvider.offer("That user doesn't exist. Try again."); - } - } while (player == null); - new Game(player, "old"); - } - - private static void deleteProfileFromMenu() { - String key; - while (true) { - if (isProfileDirEmpty()) { - QueueProvider.offer("\nThere are no profiles to delete."); - return; - } - listProfiles(); - QueueProvider.offer("\nWhich profile do you want to delete? Type 'back' to go back."); - key = QueueProvider.take(); - if ((key.equals("exit") || key.equals("back"))) { - return; - } - if (Player.profileExists(key)) { - String profileName = key; - QueueProvider.offer("Are you sure you want to delete " + profileName + "? y/n"); - key = QueueProvider.take(); - if ((key.equals("exit") || key.equals("back"))) { - return; - } else if (key.equals("y")) { - File profile = new File("json/profiles/" + profileName); - deleteDirectory(profile); - QueueProvider.offer(profileName + " has been deleted."); - return; - } else { - QueueProvider.offer(profileName + " will NOT be deleted."); - } - } else { - QueueProvider.offer("That user doesn't exist. Try again."); - } - } - } - - private static boolean deleteDirectory(File directory) { + public static boolean deleteDirectory(File directory) { + System.out.println(directory); if(directory.exists()){ File[] files = directory.listFiles(); for (File file : files) { @@ -143,18 +55,22 @@ private static boolean isProfileDirEmpty() { return (numProfiles == 0); } - private static void listProfiles() { + public static List listProfiles() { if (isProfileDirEmpty()) { - QueueProvider.offer("No profiles found."); - return; - } - File file = new File("json/profiles"); - String[] profiles = file.list(); - QueueProvider.offer("Profiles:"); - for (String name : profiles) { - if (new File("json/profiles/" + name).isDirectory()) { - QueueProvider.offer(" " + name); + //QueueProvider.offer("No profiles found."); + return new ArrayList(); + } else { + File file = new File("json/profiles"); + String[] possibleProfiles = file.list(); + List profiles = new ArrayList(); + //QueueProvider.offer("Profiles:"); + for (String name : possibleProfiles) { + if (new File("json/profiles/" + name).isDirectory()) { + //QueueProvider.offer(" " + name); + profiles.add(name); + } } + return profiles; } } } diff --git a/src/main/java/com/jadventure/game/monsters/Bugbear.java b/src/main/java/com/jadventure/game/monsters/Bugbear.java index 4ca54423..ceb100ce 100644 --- a/src/main/java/com/jadventure/game/monsters/Bugbear.java +++ b/src/main/java/com/jadventure/game/monsters/Bugbear.java @@ -1,7 +1,5 @@ package com.jadventure.game.monsters; -import com.jadventure.game.items.ItemStack; - /* * A hybrid animal with the matching armour and high damage, but low health. */ diff --git a/src/main/java/com/jadventure/game/prompts/CommandCollection.java b/src/main/java/com/jadventure/game/prompts/CommandCollection.java index 3203cecb..0be1c562 100644 --- a/src/main/java/com/jadventure/game/prompts/CommandCollection.java +++ b/src/main/java/com/jadventure/game/prompts/CommandCollection.java @@ -22,7 +22,6 @@ import com.jadventure.game.navigation.LocationType; import com.jadventure.game.repository.ItemRepository; import com.jadventure.game.repository.LocationRepository; -import com.jadventure.game.DeathException; import com.jadventure.game.GameBeans; /** diff --git a/src/main/java/com/jadventure/game/repository/EncounteredNpcRepository.java b/src/main/java/com/jadventure/game/repository/EncounteredNpcRepository.java index 45201a5c..09ad9de0 100644 --- a/src/main/java/com/jadventure/game/repository/EncounteredNpcRepository.java +++ b/src/main/java/com/jadventure/game/repository/EncounteredNpcRepository.java @@ -3,13 +3,9 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.stream.JsonReader; -import com.jadventure.game.entities.NPC; - import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; -import java.util.HashMap; -import java.util.Map; public class EncounteredNpcRepository extends NpcRepository{ static String fileName; @@ -28,7 +24,7 @@ public static NpcRepository createRepo(String profileName) { } public static void addNpc(String profileName, String name, int health, String id) { - EncounteredNpcRepository repo = new EncounteredNpcRepository(); + //EncounteredNpcRepository repo = new EncounteredNpcRepository(); File repoFile = new File("json/profiles/" + profileName + "/encNpcs.json"); if (!repoFile.exists()) { throw new RuntimeException("Could not find NPC Repository"); diff --git a/src/main/java/com/jadventure/game/repository/LocationRepository.java b/src/main/java/com/jadventure/game/repository/LocationRepository.java index e83a6cc5..43811826 100644 --- a/src/main/java/com/jadventure/game/repository/LocationRepository.java +++ b/src/main/java/com/jadventure/game/repository/LocationRepository.java @@ -15,8 +15,6 @@ import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; import com.google.gson.Gson; -import com.jadventure.game.JAdventure; - import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.io.File; @@ -29,8 +27,6 @@ import java.util.HashMap; import java.util.Map; import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * This class loads the locations from the locations.json file on start. diff --git a/src/main/resources/com/jadventure/game/css/game.css b/src/main/resources/com/jadventure/game/css/game.css new file mode 100644 index 00000000..14dfa250 --- /dev/null +++ b/src/main/resources/com/jadventure/game/css/game.css @@ -0,0 +1,4 @@ +.health-bar { + -fx-box-border: red; + -fx-accent: red; +} diff --git a/src/main/resources/com/jadventure/game/images/Goblin_idle.gif b/src/main/resources/com/jadventure/game/images/Goblin_idle.gif new file mode 100755 index 00000000..ad3bb225 Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/Goblin_idle.gif differ diff --git a/src/main/resources/com/jadventure/game/images/JAdventure_logo.png b/src/main/resources/com/jadventure/game/images/JAdventure_logo.png new file mode 100644 index 00000000..cab95cf6 Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/JAdventure_logo.png differ diff --git a/src/main/resources/com/jadventure/game/images/Rat_Idle.gif b/src/main/resources/com/jadventure/game/images/Rat_Idle.gif new file mode 100755 index 00000000..bc8fd060 Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/Rat_Idle.gif differ diff --git a/src/main/resources/com/jadventure/game/images/cross.png b/src/main/resources/com/jadventure/game/images/cross.png new file mode 100755 index 00000000..e17c5eb5 Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/cross.png differ diff --git a/src/main/resources/com/jadventure/game/images/delete.png b/src/main/resources/com/jadventure/game/images/delete.png new file mode 100644 index 00000000..a6d4fe23 Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/delete.png differ diff --git a/src/main/resources/com/jadventure/game/images/down.png b/src/main/resources/com/jadventure/game/images/down.png new file mode 100755 index 00000000..2053fafc Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/down.png differ diff --git a/src/main/resources/com/jadventure/game/images/east.png b/src/main/resources/com/jadventure/game/images/east.png new file mode 100644 index 00000000..52f62631 Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/east.png differ diff --git a/src/main/resources/com/jadventure/game/images/hero_idle-l_300.gif b/src/main/resources/com/jadventure/game/images/hero_idle-l_300.gif new file mode 100644 index 00000000..ad18243a Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/hero_idle-l_300.gif differ diff --git a/src/main/resources/com/jadventure/game/images/item.png b/src/main/resources/com/jadventure/game/images/item.png new file mode 100755 index 00000000..c3c8256d Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/item.png differ diff --git a/src/main/resources/com/jadventure/game/images/load.png b/src/main/resources/com/jadventure/game/images/load.png new file mode 100644 index 00000000..487bc62b Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/load.png differ diff --git a/src/main/resources/com/jadventure/game/images/north.png b/src/main/resources/com/jadventure/game/images/north.png new file mode 100644 index 00000000..d5e29931 Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/north.png differ diff --git a/src/main/resources/com/jadventure/game/images/npc_idle.gif b/src/main/resources/com/jadventure/game/images/npc_idle.gif new file mode 100755 index 00000000..25d7c523 Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/npc_idle.gif differ diff --git a/src/main/resources/com/jadventure/game/images/send.png b/src/main/resources/com/jadventure/game/images/send.png new file mode 100644 index 00000000..645fbe27 Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/send.png differ diff --git a/src/main/resources/com/jadventure/game/images/south.png b/src/main/resources/com/jadventure/game/images/south.png new file mode 100644 index 00000000..5904f21d Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/south.png differ diff --git a/src/main/resources/com/jadventure/game/images/stairs_down.png b/src/main/resources/com/jadventure/game/images/stairs_down.png new file mode 100644 index 00000000..1573dd43 Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/stairs_down.png differ diff --git a/src/main/resources/com/jadventure/game/images/stairs_up.png b/src/main/resources/com/jadventure/game/images/stairs_up.png new file mode 100644 index 00000000..78870c27 Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/stairs_up.png differ diff --git a/src/main/resources/com/jadventure/game/images/up.png b/src/main/resources/com/jadventure/game/images/up.png new file mode 100755 index 00000000..23954c3a Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/up.png differ diff --git a/src/main/resources/com/jadventure/game/images/west.png b/src/main/resources/com/jadventure/game/images/west.png new file mode 100644 index 00000000..0f9549d1 Binary files /dev/null and b/src/main/resources/com/jadventure/game/images/west.png differ diff --git a/src/main/resources/com/jadventure/game/view/CharacterName.fxml b/src/main/resources/com/jadventure/game/view/CharacterName.fxml new file mode 100644 index 00000000..a6182f3a --- /dev/null +++ b/src/main/resources/com/jadventure/game/view/CharacterName.fxml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/src/main/resources/com/jadventure/game/view/Game.fxml b/src/main/resources/com/jadventure/game/view/Game.fxml new file mode 100644 index 00000000..9907b7c9 --- /dev/null +++ b/src/main/resources/com/jadventure/game/view/Game.fxml @@ -0,0 +1,391 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/src/main/resources/com/jadventure/game/view/MainMenu.fxml b/src/main/resources/com/jadventure/game/view/MainMenu.fxml new file mode 100644 index 00000000..fc61cd50 --- /dev/null +++ b/src/main/resources/com/jadventure/game/view/MainMenu.fxml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/src/main/resources/com/jadventure/game/view/NewClass.fxml b/src/main/resources/com/jadventure/game/view/NewClass.fxml new file mode 100644 index 00000000..671b8600 --- /dev/null +++ b/src/main/resources/com/jadventure/game/view/NewClass.fxml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/src/main/resources/com/jadventure/game/view/ProfileMenu.fxml b/src/main/resources/com/jadventure/game/view/ProfileMenu.fxml new file mode 100644 index 00000000..4ec66c76 --- /dev/null +++ b/src/main/resources/com/jadventure/game/view/ProfileMenu.fxml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
diff --git a/src/main/resources/com/jadventure/game/view/Welcome.fxml b/src/main/resources/com/jadventure/game/view/Welcome.fxml new file mode 100644 index 00000000..7fdb677b --- /dev/null +++ b/src/main/resources/com/jadventure/game/view/Welcome.fxml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+
diff --git a/src/test/java/com/jadventure/game/entities/EntityTest.java b/src/test/java/com/jadventure/game/entities/EntityTest.java index 49aa782f..3810cbc0 100644 --- a/src/test/java/com/jadventure/game/entities/EntityTest.java +++ b/src/test/java/com/jadventure/game/entities/EntityTest.java @@ -4,8 +4,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; - import java.util.Map; import org.junit.After; diff --git a/src/test/java/com/jadventure/game/entities/PlayerTest.java b/src/test/java/com/jadventure/game/entities/PlayerTest.java index 95051a33..239fa256 100644 --- a/src/test/java/com/jadventure/game/entities/PlayerTest.java +++ b/src/test/java/com/jadventure/game/entities/PlayerTest.java @@ -3,13 +3,6 @@ import com.jadventure.game.entities.Player; import org.junit.Test; -import org.junit.Before; - -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.io.File; -import java.io.IOException; - import static org.junit.Assert.assertEquals; public class PlayerTest { diff --git a/src/test/java/com/jadventure/game/monsters/MonsterFactoryTest.java b/src/test/java/com/jadventure/game/monsters/MonsterFactoryTest.java index a85be4eb..2ecab0e3 100644 --- a/src/test/java/com/jadventure/game/monsters/MonsterFactoryTest.java +++ b/src/test/java/com/jadventure/game/monsters/MonsterFactoryTest.java @@ -2,14 +2,11 @@ import static org.junit.Assert.*; -import java.security.PublicKey; - import org.junit.Before; import org.junit.Test; import com.jadventure.game.entities.Player; import com.jadventure.game.navigation.Coordinate; -import com.jadventure.game.navigation.ILocation; import com.jadventure.game.navigation.Location; import com.jadventure.game.navigation.LocationType; diff --git a/src/test/java/com/jadventure/game/monsters/MonsterTest.java b/src/test/java/com/jadventure/game/monsters/MonsterTest.java index 96da36d6..2e91906b 100644 --- a/src/test/java/com/jadventure/game/monsters/MonsterTest.java +++ b/src/test/java/com/jadventure/game/monsters/MonsterTest.java @@ -2,12 +2,6 @@ import static org.junit.Assert.*; -import java.util.Hashtable; - -import javax.naming.NamingException; -import javax.naming.spi.ObjectFactory; -import javax.naming.spi.ObjectFactoryBuilder; - import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/com/jadventure/game/prompts/CommandCollectionTest.java b/src/test/java/com/jadventure/game/prompts/CommandCollectionTest.java index 97927a31..f4185302 100644 --- a/src/test/java/com/jadventure/game/prompts/CommandCollectionTest.java +++ b/src/test/java/com/jadventure/game/prompts/CommandCollectionTest.java @@ -3,24 +3,16 @@ import static org.junit.Assert.*; import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; import java.io.PrintStream; -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.util.Collection; - import org.junit.After; import org.junit.Before; import org.junit.Test; -import com.google.gson.internal.bind.CollectionTypeAdapterFactory; import com.jadventure.game.DeathException; import com.jadventure.game.GameBeans; import com.jadventure.game.entities.Player; import com.jadventure.game.monsters.Troll; import com.jadventure.game.navigation.Coordinate; -import com.jadventure.game.navigation.Direction; import com.jadventure.game.navigation.Location; import com.jadventure.game.navigation.LocationType; import com.jadventure.game.repository.LocationRepository; diff --git a/src/test/java/com/jadventure/game/repository/ItemRepositoryTest.java b/src/test/java/com/jadventure/game/repository/ItemRepositoryTest.java index 10d52ed2..2edb5299 100644 --- a/src/test/java/com/jadventure/game/repository/ItemRepositoryTest.java +++ b/src/test/java/com/jadventure/game/repository/ItemRepositoryTest.java @@ -1,7 +1,6 @@ package com.jadventure.game.repository; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertNotNull; import java.io.IOException; @@ -10,7 +9,6 @@ import java.io.StringReader; import java.io.StringWriter; import java.io.Writer; -import java.util.HashMap; import java.util.Map; import java.util.TreeMap; diff --git a/src/test/java/com/jadventure/game/repository/LocationRepositoryTest.java b/src/test/java/com/jadventure/game/repository/LocationRepositoryTest.java index 6fd380dc..0bfac28e 100644 --- a/src/test/java/com/jadventure/game/repository/LocationRepositoryTest.java +++ b/src/test/java/com/jadventure/game/repository/LocationRepositoryTest.java @@ -1,8 +1,6 @@ package com.jadventure.game.repository; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import org.junit.Test; import org.junit.Before; @@ -10,7 +8,6 @@ import com.jadventure.game.navigation.ILocation; import com.jadventure.game.navigation.Location; import com.jadventure.game.navigation.LocationType; -import com.jadventure.game.GameBeans; public class LocationRepositoryTest { LocationRepository locationRepo;