added notebook reading

This commit is contained in:
Luca Carnegie
2019-05-31 23:50:24 -04:00
parent ff32ca6ab5
commit 23f0535a0a
6 changed files with 55 additions and 18 deletions

View File

@@ -222,10 +222,6 @@ class Game {
System.out.print(currentRoom.longDescription());
System.out.println(currentRoom.itemString());
System.out.println(currentRoom.exitString());
player.addToInventory(new Lockpick());
player.addToInventory(new Key());
player.addToInventory(new Crowbar());
player.addToInventory(new Batteringram());
boolean finished = false;
while (!finished) {
if (currentCombat != null) {
@@ -296,7 +292,7 @@ class Game {
}
if(hasKey) {
player.removeFromInventory(new Key());
System.out.println("With great force, you turn the key in the keyhole and the door unclocks! However, the key broke in the keyhole.");
System.out.println("With great force, you turn the key in the keyhole and the door unlocks! However, the key breaks in the keyhole and is now unusable.");
}
if(!nextRoom.getBoarded())
break;
@@ -449,6 +445,24 @@ class Game {
case "scream":
System.out.println("Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhh!");
break;
case "read":
if(currentRoom.containsNotebook()) {
for(Item i : currentRoom.getItems()) {
if(i.equals(new Notebook())) {
System.out.println("In elegant cursive, the page reads:\n" + ((Notebook)i).getHint());
}
}
}else if(player.getInventory().contains(new Notebook())) {
for(Item i : player.getInventory()) {
if(i.equals(new Notebook())) {
System.out.println("In elegant cursive, the page reads:\n" + ((Notebook)i).getHint());
}
}
}else {
System.out.println("Read what?");
}
break;
case "take":
boolean hasAll = false;
for (String a : command.getOtherWords()) {

View File

@@ -1,8 +1,13 @@
package com.bayviewglen.zork.Items;
public class Notebook extends Item{
private String hint;
public Notebook(){
super(15, "Notebook", "A book filled with diagrams and descriptions, belonging to Henry Pellatt", false, 50, 1);
hint = "Fire escape plan for Casa Loma:\n1. Acquire key to front door\n2. Make battering ram from point, cylinder, and base\n3. Use both to force front door open.\n4. P.S. Don't forget Shaving Cream!";
}
public String getHint() {
return hint;
}
}

View File

@@ -255,5 +255,13 @@ class Room {
riddler = null;
}
public boolean containsNotebook() {
for(Item i : this.getItems()) {
if(i.equals(new Notebook()))
return true;
}
return false;
}
}