From ba18bed404bc0714873643f6eae0d93f45637898 Mon Sep 17 00:00:00 2001 From: Luca Carnegie <41924665+lcarnegie@users.noreply.github.com> Date: Thu, 23 May 2019 13:59:29 -0400 Subject: [PATCH] Made a title screen and fixed help command --- data/words.dat | 4 ++-- src/com/bayviewglen/zork/Game.java | 34 ++++++++++++++++++------------ src/com/bayviewglen/zork/Zork.java | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/data/words.dat b/data/words.dat index 4f9020e..7027dc2 100644 --- a/data/words.dat +++ b/data/words.dat @@ -32,7 +32,6 @@ book, item socks, item painting, item inventory, verb -i, verb notebook, item shaving cream, item toothbrush, item @@ -46,4 +45,5 @@ chocolate, item warm bread, item clothes, item sword, item -blanket, item \ No newline at end of file +blanket, item +die, verb \ No newline at end of file diff --git a/src/com/bayviewglen/zork/Game.java b/src/com/bayviewglen/zork/Game.java index 7ce839b..c6792e0 100644 --- a/src/com/bayviewglen/zork/Game.java +++ b/src/com/bayviewglen/zork/Game.java @@ -130,12 +130,19 @@ class Game { printWelcome(); // Enter the main command loop. Here we repeatedly read commands and // execute them until the game is over. - - boolean finished = false; - while (!finished) { - Command command = parser.getCommand(); - finished = processCommand(command); + 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("---------------------\n"); + System.out.println(currentRoom.longDescription()); + boolean finished = false; + while (!finished) { + Command command = parser.getCommand(); + finished = processCommand(command); + } } + System.out.println("Thank you for playing. Good bye."); } @@ -145,9 +152,8 @@ class Game { 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("\nType 'help' if you need help, consult the wiki \non GitHub if you are confused and enjoy the game!"); - System.out.println("\n---------------------\n"); - System.out.println(currentRoom.longDescription()); + System.out.println("Type \"play\" to play the game. If you want to close the game at any time, type \"quit\"."); + System.out.print(">"); } /** @@ -173,6 +179,9 @@ class Game { break; case "quit": return true; + case "die": + System.out.println("If you insist... \n Poof! You're gone. You're out of the castle now, but now a new, grand new adventure begins..."); + return true; case "eat": System.out.println("Do you really think you should be eating at a time like this?"); break; @@ -232,7 +241,7 @@ class Game { System.out.print(itemsP); System.out.println(); }else { - System.out.println("You are empty handed."); + System.out.println("You have nothing on you. Try and find some items."); } break; case "open": @@ -261,10 +270,7 @@ class Game { * message and a list of the command words. */ private void printHelp() { - System.out.println("You are lost. You are alone. You wander"); - System.out.println("around at Monash Uni, Peninsula Campus."); - System.out.println(); - System.out.println("Your command words are:"); + System.out.println("Here's what you can do:"); parser.showCommands(); } @@ -284,7 +290,7 @@ class Game { if (nextRoom == null) System.out.println("There is no door!"); else if(nextRoom.getLocked()) { - System.out.println("The door is locked!"); + System.out.println("The door is locked. You need to find a key to open it."); } else { currentRoom = nextRoom; diff --git a/src/com/bayviewglen/zork/Zork.java b/src/com/bayviewglen/zork/Zork.java index 646914d..1ec0f82 100644 --- a/src/com/bayviewglen/zork/Zork.java +++ b/src/com/bayviewglen/zork/Zork.java @@ -1,4 +1,4 @@ -package com.bayviewglen.zork; + package com.bayviewglen.zork; public class Zork { public static void main(String[] args) {