Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve spelling, add win condition #108

Merged
merged 5 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/main/java/filereader/InventoryItemsStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hint/HintHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public HintHandler(BaseMap map, TextBox text){
invisibleTriggers = new ArrayList<Trigger>();

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
}


Expand Down
15 changes: 10 additions & 5 deletions src/main/java/main/CalculaChroniclesOfTheAlgorithmicKingdom.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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));
Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/map/BaseMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,8 @@ public int getWidth() {
public int getHeight() {
return height;
}

public boolean isWon() {
return false;
}
}
13 changes: 13 additions & 0 deletions src/main/java/map/FirstMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,17 @@ public void initMap(int givenWidth, int givenHeight) { //creates a box of "." of
mapData.add(row);
}
}


public boolean isWon() {
for (ArrayList<Character> row : mapData) {
for (char element : row) {
if (element != '.' && element != 'P' && element != '#') {

return false;
}
}
}
return true;
}
}
7 changes: 6 additions & 1 deletion src/main/java/parser/Parser.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
22 changes: 21 additions & 1 deletion src/main/java/ui/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Loading