From 9dede87f7ffffa10399d072ee5c3b0ee2dc0ef89 Mon Sep 17 00:00:00 2001 From: Luca Carnegie <41924665+lcarnegie@users.noreply.github.com> Date: Mon, 27 May 2019 14:40:58 -0400 Subject: [PATCH] fixed welcome message --- data/enemies.dat | 4 +-- src/com/bayviewglen/zork/Game.java | 44 +++++++++++++++++++----------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/data/enemies.dat b/data/enemies.dat index dd529da..10c9960 100644 --- a/data/enemies.dat +++ b/data/enemies.dat @@ -1,4 +1,4 @@ -Enemy Name: Henry Pelatt -Description: A guy +Enemy Name: Henry Pellatt +Description: The owner of the Castle. Starting Room: Circle Room Damage Given: 25 \ No newline at end of file diff --git a/src/com/bayviewglen/zork/Game.java b/src/com/bayviewglen/zork/Game.java index 2fa92fe..7d1488d 100644 --- a/src/com/bayviewglen/zork/Game.java +++ b/src/com/bayviewglen/zork/Game.java @@ -154,18 +154,40 @@ class Game { parser = new Parser(); player = new Player(); } + + /** + * Print out the opening message for the player. + */ + private boolean printWelcome() { + Scanner in = new Scanner(System.in); + boolean isNotValid = true; + System.out.println("Welcome to ESCAPE CASA LOMA!\n-----"); + System.out.println("A new, fresh take on the escape-room,\nby Johnathon, Luca, Victoria and Evan "); + System.out.println("Type \"play\" to play the game. If you wish to close the game at any time, type \"quit\"."); + while(isNotValid) { + System.out.print("> "); + String i = in.nextLine(); + if(i.toLowerCase().equals("play")) { + return true; + }else if(i.toLowerCase().equals("quit")) { + return false; + } + System.out.println("That is not a valid response. Type \"play\" to play the game. If you wish to close the game, type \"quit\"."); + } + return false; + + + } /** * Main play routine. Loops until end of play. */ public void play() { - printWelcome(); + if(printWelcome()) { // Enter the main command loop. Here we repeatedly read commands and // execute them until the game is over. - Scanner in = new Scanner(System.in); - if(in.nextLine().equals("play")){ - System.out.println("\nType 'help' if you need help, consult the wiki \non GitHub if you are confused and enjoy the game!\n"); - System.out.println("\n\nEscape Casa Loma: A text-based escape game"); + System.out.println("\nType 'help' if you need help, consult the wiki \non GitHub if you are confused and enjoy the game!\n"); + System.out.println("\n\nEscape Casa Loma: A text-based adventure game"); System.out.println("---------------------\n"); System.out.print(currentRoom.longDescription()); System.out.println(currentRoom.exitString()); @@ -175,19 +197,9 @@ class Game { finished = processCommand(command); } } - - System.out.println("Thank you for playing. Good bye."); + System.out.println("Thank you for playing. Goodbye!"); } - /** - * Print out the opening message for the player. - */ - private void printWelcome() { - System.out.println("Welcome to ESCAPE CASA LOMA!\n-----"); - System.out.println("A new, fresh take on the escape-room,\nby Johnathon, Luca, Victoria and Evan "); - System.out.println("Type \"play\" to play the game. If you want to close the game at any time, type \"quit\"."); - System.out.print("> "); - } /** * Given a command, process (that is: execute) the command. If this command