From 26f24b02b7047d0cf5e6019782f641e5b9082d28 Mon Sep 17 00:00:00 2001 From: B1G-SAM <54065426+B1G-SAM@users.noreply.github.com> Date: Fri, 12 Apr 2024 23:16:25 +0800 Subject: [PATCH 1/2] Remove Timer in Ui --- .../java/main/CalculaChroniclesOfTheAlgorithmicKingdom.java | 5 ++--- src/main/java/ui/Ui.java | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/main/CalculaChroniclesOfTheAlgorithmicKingdom.java b/src/main/java/main/CalculaChroniclesOfTheAlgorithmicKingdom.java index cb07bc3ba5..df8d8d97c2 100644 --- a/src/main/java/main/CalculaChroniclesOfTheAlgorithmicKingdom.java +++ b/src/main/java/main/CalculaChroniclesOfTheAlgorithmicKingdom.java @@ -85,8 +85,7 @@ public void startGame() throws InterruptedException { 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)); @@ -105,7 +104,7 @@ public void startGame() throws InterruptedException { printMessageUnderMap(userCommand, ui, playerStatus, textBox); saveAllGameFile(mapStorage, playerStatusStorage, playerStatus, userCommand, inventoryItemsStorage); if (storedMaps.get(mapIndex.get(FIRST_MAP_IDENTITY)).isWon()){ - ui.printWinMessage(playerStatus, startTime); + ui.printWinMessage(playerStatus); break; } } while (!userCommand.getCommandDescription().equals("TIRED") ); diff --git a/src/main/java/ui/Ui.java b/src/main/java/ui/Ui.java index 2c139dfe77..d3a7734426 100644 --- a/src/main/java/ui/Ui.java +++ b/src/main/java/ui/Ui.java @@ -224,7 +224,7 @@ public void printDeathMessage(){ } - public void printWinMessage(PlayerStatus player, long startTime) throws InterruptedException { + public void printWinMessage(PlayerStatus player) throws InterruptedException { System.out.println(" __ __ ______ __ __ __ __ ______ __ __ \n" + "| \\ / \\ / \\ | \\ | \\ | \\ _ | \\| \\| \\ | \\\n" + " \\$$\\ / $$| $$$$$$\\| $$ | $$ | $$ / \\ | $$ \\$$$$$$| $$\\ | $$\n" + @@ -238,7 +238,6 @@ public void printWinMessage(PlayerStatus player, long startTime) throws Interrup 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!!!"); } From 1fdde5bea813e14df54d3ae774089304565ba102 Mon Sep 17 00:00:00 2001 From: B1G-SAM <54065426+B1G-SAM@users.noreply.github.com> Date: Sat, 13 Apr 2024 00:07:37 +0800 Subject: [PATCH 2/2] Add death reset and adjust UG --- docs/UserGuide.md | 67 ++++++++++++++++--- .../java/command/fight/FightingCommand.java | 3 + .../map/BattleInterface/BattleInterface.java | 1 - 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index ed2cc8bd8e..8be47e7522 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -16,7 +16,17 @@ math wizard. ### The Map This game displays the character's position on a 2D grid, the player is denoted by a `P` -and the other interactable entities are denoted by other symbols. +and the other interactable entities are denoted by other symbols. The entities on the map are randomly generated in each +play through of the game. + +### The Player +At all times, the player's health, money and exp is displayed at the top of the screen. Dropping the player's health +to 0 will cause the player to die and the game is over. + +### The Text Box +At all times, on the bottom part of the screen, a text box will be visible and it will be visible. The text box informs +the player of narrations from the narrator, dialogue from the entities, general instructions from the user interface and +also error messages when they occur. ### Movement Traversing the map is similar to many common computer games. We use the "WASD" system such that @@ -24,6 +34,13 @@ entering `w` to the program shifts the player up by 1 space, entering `a` shifts entering `s` shifts the player down 1 space and lastly, entering `d` shifts the player to the right by 1 space. This movement can only take place when the 2D grid map is visible. +Additionally, should the player wish to move more than 1 space at a time, the player can modify the directional commands +by adding a number in this manner. + +E.g `d 10` + +The above command moves the player rightwards by 10 spaces. + ### Interacting @@ -55,14 +72,40 @@ questions wrong repeatedly will deplete the player's health and once the player' the game is over. However, depleting the enemy's health to 0 will result in a victory and the player is rewarded with some gold and exp before returning the player to the main map. + +### Items + +There are various consumables the player can acquire throughout the game. The items are consumable items, meaning the +item can be only used once before it is destroyed. There are 2 general types of items, the healing item and the damage +item. Healing items will recover the player's health, if the player's health is already maxed out at +100hp(health points), the healing item will OVER-HEAl and increase the player's health past the initial 100hp. Damage +items will empower the player's next attack to do increased damage on a successful hit. + +### Shop + +Items are purchasable at the shop denoted by a '#' on the map. Interacting with the shop causes the player to enter the +shop. Just like the enemies, the player must enter `fight` to browse the shop's items. After entering the shop, buy an +item by entering the index of the item and the item will automatically be purchased and transferred to the Inventory. +The purchase will only go through if the player has enough money. To exit the shop, the player enters `exit`. + +### Inventory + +The inventory of the player can only be accessed when the player is not currently interacting with an entity. To bring +up the inventory the player enters `i`. To use an item the player enters the keyword `use` followed by the index of the +item. + +E.g `use 1` + +To close the inventory, the player enters `close`. + ### Hints -Sometimes, hints are scattered throughout the map such that some text will display just below the map to help the player, -hints are entirely passive and no user input is required for the hints to trigger. +Sometimes, hints are scattered throughout the map such that some text will display just below the map to help the +player, hints are entirely passive and no user input is required for the hints to trigger. ### Quit -Enter `q`to quit the game. +Enter `q`to quit the game. The game is automatically saved. ### Help @@ -74,9 +117,11 @@ If you need a refresher on the controls, entering either `h` or `help` will brin Our program can save map when you are playing the game. Also, it will save the player status and your inventory items -### Inventory +### Reset + +Should a reset be necessary, the player can completely wipe the current progress of the game and regenerate a new game +at ANY POINT IN THE GAME by entering `reset`. -In our map, there is always a shop. In the shop, you can buy things and use them to battle with the monster! @@ -84,9 +129,9 @@ In our map, there is always a shop. In the shop, you can buy things and use them ## FAQ -**Q**: How do I transfer my data to another computer? +**Q**: -**A**: {your answer here} +**A**: ## Command Summary @@ -96,4 +141,8 @@ In our map, there is always a shop. In the shop, you can buy things and use them `h` to print help menu `run` to escape the battle interface `fight` to commence a fight - all math questions have integer answers. +`i` to bring up inventory +`close` to leave inventory +`exit` to leave the shop +`reset` to reset the entire game and start a new game. + All math questions have integer answers. diff --git a/src/main/java/command/fight/FightingCommand.java b/src/main/java/command/fight/FightingCommand.java index 5680aeb260..79257ee371 100644 --- a/src/main/java/command/fight/FightingCommand.java +++ b/src/main/java/command/fight/FightingCommand.java @@ -1,5 +1,6 @@ package command.fight; import command.Command; +import command.ResetCommand; import map.BaseMap; import map.ShopMap; @@ -31,6 +32,8 @@ public void execute(Scanner in) { currentMapForCommand.handleLootingByPlayer(); } else if (currentMapForCommand.getPlayerDeath()) { currentMapForCommand.handleDeath(); + Command deathReset = new ResetCommand(); + deathReset.execute(playerStatus); } } diff --git a/src/main/java/map/BattleInterface/BattleInterface.java b/src/main/java/map/BattleInterface/BattleInterface.java index 719219a56b..91cd488aa2 100644 --- a/src/main/java/map/BattleInterface/BattleInterface.java +++ b/src/main/java/map/BattleInterface/BattleInterface.java @@ -117,7 +117,6 @@ public boolean getPlayerDeath() { public void handleDeath(){ Ui ui = new Ui(); ui.printDeathMessage(); - System.exit(0); } public PlayerStatus getCurrentPlayer() {