Created
February 5, 2019 15:40
-
-
Save andreybleme/95441ec039fbf9591f57b71054f3eabe to your computer and use it in GitHub Desktop.
andreybleme.com | Regactoring RPG Game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void runGame() { | |
System.out.print(ANSI_CYAN + " WELCOME TO RPG GAME " + ANSI_RESET); | |
menuLoop: while (true) { | |
System.out.print("\n\nType the number of an option below to continue: "); | |
System.out.print(ANSI_BLUE + "\n 1" + ANSI_RESET +" New Game"); | |
System.out.print(ANSI_BLUE + "\n 2" + ANSI_RESET +" Load Game"); | |
System.out.print(ANSI_BLUE + "\n 9" + ANSI_RESET +" Exit"); | |
System.out.print(ANSI_BLUE + "\n\n > " + ANSI_RESET); | |
Integer option = in.nextInt(); | |
switch (option) { | |
case NEW_GAME: | |
System.out.print("\nType here the name of your new Character"); | |
System.out.print(ANSI_BLUE + "\n\n > " + ANSI_RESET); | |
in.nextLine(); | |
String name = in.nextLine(); | |
command = new NewGameCommand(name); | |
command.execute(); | |
break; | |
case LOAD_GAME: | |
command = new LoadGameCommand(null); | |
command.execute(); | |
break; | |
case EXIT_GAME: | |
break menuLoop; | |
default: | |
System.out.print(ANSI_RED + "\nYou typed an invalid option." + ANSI_RESET); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment