diff --git a/src/main/java/filereader/InventoryItemsStorage.java b/src/main/java/filereader/InventoryItemsStorage.java index d25d9d5caa..a9e6b96a35 100644 --- a/src/main/java/filereader/InventoryItemsStorage.java +++ b/src/main/java/filereader/InventoryItemsStorage.java @@ -2,9 +2,7 @@ import inventoryitems.Consumable; import inventoryitems.Item; -import inventoryitems.ShopItem; import map.PlayerInventory; - import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; diff --git a/src/main/java/hint/HintHandler.java b/src/main/java/hint/HintHandler.java index f6c8c57104..fa8d6f670d 100644 --- a/src/main/java/hint/HintHandler.java +++ b/src/main/java/hint/HintHandler.java @@ -17,7 +17,7 @@ public HintHandler(BaseMap map, TextBox text){ invisibleTriggers = new ArrayList(); addTrigger(0, 1, 3, 2, "You should visit the shop sometime. The owner sells many" + - "useful items for your journey"); //add all triggers in the map here + " useful items for your journey"); //add all triggers in the map here } diff --git a/src/main/java/main/CalculaChroniclesOfTheAlgorithmicKingdom.java b/src/main/java/main/CalculaChroniclesOfTheAlgorithmicKingdom.java index 65ddffa44e..cb07bc3ba5 100644 --- a/src/main/java/main/CalculaChroniclesOfTheAlgorithmicKingdom.java +++ b/src/main/java/main/CalculaChroniclesOfTheAlgorithmicKingdom.java @@ -34,11 +34,11 @@ public class CalculaChroniclesOfTheAlgorithmicKingdom { public static final int START_DAMAGE = 5; public static final PlayerInventory PLAYER_INVENTORY = new PlayerInventory(); - public static void main(String[] args) { + public static void main(String[] args) throws InterruptedException { new CalculaChroniclesOfTheAlgorithmicKingdom().startGame(); } - public void startGame() { + public void startGame() throws InterruptedException { Scanner in = new Scanner(System.in); InventoryItemsStorage inventoryItemsStorage = new InventoryItemsStorage(); @@ -84,8 +84,9 @@ public void startGame() { storedMaps.add(map); mapIndex.put(FIRST_MAP_IDENTITY, storedMaps.size() - 1); currentMap = mapIndex.get(FIRST_MAP_IDENTITY); - - + + + long startTime = System.currentTimeMillis(); // start speed run timer assert playerStatus != null; ui.printPlayerStatus(playerStatus); ui.printMap(storedMaps.get(currentMap)); @@ -103,7 +104,11 @@ public void startGame() { printMessageUnderMap(userCommand, ui, playerStatus, textBox); saveAllGameFile(mapStorage, playerStatusStorage, playerStatus, userCommand, inventoryItemsStorage); - } while (!userCommand.getCommandDescription().equals("TIRED")); + if (storedMaps.get(mapIndex.get(FIRST_MAP_IDENTITY)).isWon()){ + ui.printWinMessage(playerStatus, startTime); + break; + } + } while (!userCommand.getCommandDescription().equals("TIRED") ); } private static void saveAllGameFile(MapStorage mapStorage, PlayerStatusStorage playerStatusStorage, diff --git a/src/main/java/map/BaseMap.java b/src/main/java/map/BaseMap.java index b02b17588d..ccba3d35f7 100644 --- a/src/main/java/map/BaseMap.java +++ b/src/main/java/map/BaseMap.java @@ -238,4 +238,8 @@ public int getWidth() { public int getHeight() { return height; } + + public boolean isWon() { + return false; + } } diff --git a/src/main/java/map/FirstMap.java b/src/main/java/map/FirstMap.java index 6c696a8664..ea45450478 100644 --- a/src/main/java/map/FirstMap.java +++ b/src/main/java/map/FirstMap.java @@ -36,4 +36,17 @@ public void initMap(int givenWidth, int givenHeight) { //creates a box of "." of mapData.add(row); } } + + + public boolean isWon() { + for (ArrayList row : mapData) { + for (char element : row) { + if (element != '.' && element != 'P' && element != '#') { + + return false; + } + } + } + return true; + } } diff --git a/src/main/java/parser/Parser.java b/src/main/java/parser/Parser.java index 0f3c7fc84d..ad7241d374 100644 --- a/src/main/java/parser/Parser.java +++ b/src/main/java/parser/Parser.java @@ -1,6 +1,11 @@ package parser; -import command.*; +import command.Command; +import command.HelpCommand; +import command.CommandType; +import command.ResetCommand; +import command.ErrorCommand; +import command.QuitCommand; import command.fight.FightingCommand; import command.fight.RunningCommand; import command.inventory.OpenInventoryCommand; diff --git a/src/main/java/ui/Ui.java b/src/main/java/ui/Ui.java index bf7090027c..2c139dfe77 100644 --- a/src/main/java/ui/Ui.java +++ b/src/main/java/ui/Ui.java @@ -223,11 +223,31 @@ public void printDeathMessage(){ System.out.println(" \\_/ (_______)(_______) (______/ \\_______/(_______/(______/ "); } + + public void printWinMessage(PlayerStatus player, long startTime) throws InterruptedException { + System.out.println(" __ __ ______ __ __ __ __ ______ __ __ \n" + + "| \\ / \\ / \\ | \\ | \\ | \\ _ | \\| \\| \\ | \\\n" + + " \\$$\\ / $$| $$$$$$\\| $$ | $$ | $$ / \\ | $$ \\$$$$$$| $$\\ | $$\n" + + " \\$$\\/ $$ | $$ | $$| $$ | $$ | $$/ $\\| $$ | $$ | $$$\\| $$\n" + + " \\$$ $$ | $$ | $$| $$ | $$ | $$ $$$\\ $$ | $$ | $$$$\\ $$\n" + + " \\$$$$ | $$ | $$| $$ | $$ | $$ $$\\$$\\$$ | $$ | $$\\$$ $$\n" + + " | $$ | $$__/ $$| $$__/ $$ | $$$$ \\$$$$ _| $$_ | $$ \\$$$$\n" + + " | $$ \\$$ $$ \\$$ $$ | $$$ \\$$$| $$ \\| $$ \\$$$\n" + + " \\$$ \\$$$$$$ \\$$$$$$ \\$$ \\$$ \\$$$$$$ \\$$ \\$$\n" + + " "); + Thread.sleep(3000); + System.out.println("You Completed the game with $" + player.getPlayerMoney() + " remaining and a total" + + " of " + player.getPlayerExp() + " exp!!"); + System.out.println("You completed this run in " + ((System.currentTimeMillis() - startTime) / 1000) + "s!"); + Thread.sleep(3000); + System.out.println("Thank you for playing!!!"); + } + public void insertOutOfBoundsMessage(TextBox box){ box.setNextNarration("You ran straight into a wall"); } public void insertObjectObstructionMessage(TextBox box){ - System.out.println();box.setNextNarration("Something appears to be blocking your way"); + box.setNextNarration("Something appears to be blocking your way"); } }