Skip to content

Commit

Permalink
Merge branch 'master' into fix_stored_map
Browse files Browse the repository at this point in the history
  • Loading branch information
BestDownLoader365 committed Mar 22, 2024
2 parents 7ff603c + e29ca6a commit 2cc1c85
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/main/java/command/fight/FightingCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public FightingCommand() {

@Override
public void execute() {

}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/command/fight/RunningCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public RunningCommand() {
@Override
public void execute(){
if(currentMap instanceof BattleInterface) {

textBox.setNextNarration("You decide to run and successfully got away");
}
}
}
4 changes: 3 additions & 1 deletion src/main/java/command/mapmove/InteractingCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ public InteractingCommand(){
@Override
public void execute() {
String entityInteractedWith = currentMap.handleInteract();
System.out.println(entityInteractedWith);
textBox.setNextNarration(entityInteractedWith + " appears in your path. What will you do?");
textBox.setNextInstruction("Will you [fight] or will you [run]?");
AMap battleMap;
switch (entityInteractedWith) {
case "@":
textBox.setNextDialogue("*the @ symbol stares at you menacingly*");
InteractableEntity monster = new Enemy(10, 10, 10);
battleMap = new BattleInterface(playerStatus, textBox, monster);
battleMap.initMap(30, 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void startGame() {

if (!(storedMaps.get(currentOn) instanceof FirstMap) && userCommand instanceof MapMoveCommand) {
System.out.println("Invalid Command");

} else if (userCommand.getCommandDescription().equals("FIGHT!")){
userCommand.execute(in);
} else {
Expand All @@ -61,6 +62,7 @@ public void startGame() {
if (!userCommand.getCommandDescription().equals("HelpMe!!")) {
ui.printPlayerStatus(playerStatus);
ui.printMap(storedMaps.get(currentOn));
ui.printTextBox(textBox);
}

}
Expand Down
48 changes: 44 additions & 4 deletions src/main/java/textbox/TextBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,55 @@
import map.AMap;

public class TextBox {
protected String nextMessage;
protected static String nextInstruction;
protected static String nextNarration;
protected static String nextDialogue;
protected static String nextError;
public void initTextBox(){
this.nextMessage = " ";
nextInstruction = "Type 'h' to get the help menu.";
nextDialogue = " ";
nextNarration = "Welcome to Calcula: Chronicles of the Algorithmic Kingdom";
nextError = "";
}
public void nextTextBoxBasedOnMapAndCommand(Command userCommand, AMap map){

}
public String getNextMessage(){
return nextMessage;

public void setNextInstruction(String message){
nextInstruction = message;
}
public void setNextNarration(String message){
nextNarration = message;
}

public void setNextDialogue(String message) {
nextDialogue = message;
}

public void setNextError(String message){
nextError = message;
}

public String getNextDialogue() {
return nextDialogue;
}

public String getNextInstruction() {
return nextInstruction;
}

public String getNextNarration() {
return nextNarration;
}

public String getNextError() {
return nextError;
}

public void clearAll(){
nextNarration = "";
nextInstruction = "";
nextDialogue = "";
nextError = "";
}
}
29 changes: 25 additions & 4 deletions src/main/java/ui/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,34 @@ public void printPlayerStatus(PlayerStatus statusBar) {


public void printTextBox(TextBox box) {
assert box.getNextDialogue() != null : "next dialogue is null";
assert box.getNextError() != null : "next error is null";
assert box.getNextInstruction() != null : "next instruction is null";
assert box.getNextNarration() != null : "next narration is null";


printDividingLine();
if (box.getNextMessage() != null) {
System.out.println(box.getNextMessage());
} else {
System.out.println(" ");
if (!box.getNextNarration().isEmpty()) {
System.out.println(box.getNextNarration());
System.out.println("\n");
}
if (!box.getNextDialogue().isEmpty()) {
System.out.println(box.getNextDialogue());
}
if (!box.getNextInstruction().isEmpty()) {
System.out.println(box.getNextInstruction());
}
if (!box.getNextError().isEmpty()) {
System.out.println(box.getNextError());
}
printDividingLine();
box.clearAll();
}

public void printTextbox(String message){ //for custom messages
printDividingLine();
System.out.println(message);
printDividingLine();
}
public void printMap(ArrayList<ArrayList<Character>> map) {
printDividingLine();
Expand Down

0 comments on commit 2cc1c85

Please sign in to comment.