Merge branch 'master' of https://github.com/jslightham/Zork
This commit is contained in:
@@ -62,6 +62,9 @@ class Game {
|
||||
// Read the locked state
|
||||
boolean locked = Boolean.parseBoolean(roomScanner.nextLine().split(":")[1].replaceAll("<br>", "\n").trim());
|
||||
room.setLocked(locked);
|
||||
// Read the boarded state
|
||||
boolean boarded = Boolean.parseBoolean(roomScanner.nextLine().split(":")[1].replaceAll("<br>", "\n").trim());
|
||||
room.setBoarded(boarded);
|
||||
// Read the Items
|
||||
String items = roomScanner.nextLine();
|
||||
try {
|
||||
@@ -279,6 +282,31 @@ class Game {
|
||||
System.out.println("In what direction do you want to go in?");
|
||||
}else {
|
||||
System.out.println("What do you want to open the door with?");
|
||||
}
|
||||
boolean hasCrowbar = false;
|
||||
for(int i =0; i<player.getInventory().size(); i++) {
|
||||
if(player.getInventory().get(i).equals(new Crowbar())) {
|
||||
hasCrowbar = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(command.hasDirection() && hasCrowbar) {
|
||||
Room nextRoom = currentRoom.nextRoom(command.getDirection());
|
||||
try {
|
||||
if(nextRoom.getBoarded()) {
|
||||
nextRoom.setBoarded(false);
|
||||
player.removeFromInventory(new Crowbar());
|
||||
System.out.println("With great effort, you pry the boards off the door with the crowbar! However, it breaks and is no longer useable.");
|
||||
}else{
|
||||
System.out.println("That door is already unlocked!");
|
||||
}
|
||||
}catch(Exception e) {
|
||||
System.out.println("There is no door there!");
|
||||
}
|
||||
}else if(!command.hasDirection()){
|
||||
|
||||
}else {
|
||||
|
||||
}
|
||||
break;
|
||||
case "go": case "n": case "s": case "e": case "w": case "north": case "south": case "west": case "east": case "up": case "down": case "d": case "u":
|
||||
@@ -517,8 +545,11 @@ class Game {
|
||||
Room nextRoom = currentRoom.nextRoom(direction);
|
||||
if (nextRoom == null)
|
||||
System.out.println("There is no door!");
|
||||
else if(nextRoom.getLocked() && nextRoom.getBoarded()) {
|
||||
System.out.println("The door is locked and boarded shut. You need to find a key and crowbar to open it.");
|
||||
}
|
||||
else if(nextRoom.getLocked()) {
|
||||
System.out.println("The door is locked. You need to find a key to open it.");
|
||||
System.out.println("The door is locked. You need a key to open it.");
|
||||
}
|
||||
else {
|
||||
currentRoom = nextRoom;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.bayviewglen.zork.Items;
|
||||
public class Base extends Item{
|
||||
|
||||
public Base(){
|
||||
super(5, "Base", "A base for an ancient battering ram", false, 100, 1);
|
||||
super(5, "Base", "A base for an ancient battering ram", false, 100, 30);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
9
src/com/bayviewglen/zork/Items/Clock.java
Normal file
9
src/com/bayviewglen/zork/Items/Clock.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.bayviewglen.zork.Items;
|
||||
|
||||
public class Clock extends Item{
|
||||
|
||||
public Clock() {
|
||||
super(34, "Clock", "An antique clock that is no longer working is propped up against the wall", false, 20, 10);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.bayviewglen.zork.Items;
|
||||
public class Cylinder extends Item{
|
||||
|
||||
public Cylinder(){
|
||||
super(6, "Cylinder", "A part of a battering ram meant to lay on the base and have a point attatched to the end", false, 100, 1);
|
||||
super(6, "Cylinder", "A part of a battering ram meant to lay on the base and have a point attatched to the end", false, 100, 30);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
9
src/com/bayviewglen/zork/Items/Keyboard.java
Normal file
9
src/com/bayviewglen/zork/Items/Keyboard.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.bayviewglen.zork.Items;
|
||||
|
||||
public class Keyboard extends Item{
|
||||
|
||||
public Keyboard() {
|
||||
super(36, "Keyboard", "An unplugged keyboard for a desktop computer is neatly placed by a wall", false, 20, 10);
|
||||
}
|
||||
|
||||
}
|
||||
9
src/com/bayviewglen/zork/Items/Lightbulb.java
Normal file
9
src/com/bayviewglen/zork/Items/Lightbulb.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.bayviewglen.zork.Items;
|
||||
|
||||
public class Lightbulb extends Item{
|
||||
|
||||
public Lightbulb() {
|
||||
super(35, "Lightbulb", "An incandescent light bulb rolls around on the floor", false, 20, 5);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.bayviewglen.zork.Items;
|
||||
public class Point extends Item{
|
||||
|
||||
public Point() {
|
||||
super(7, "Point", "A part of the battering ram that is attatched to the cylinder and smashes the door", false, 100, 1);
|
||||
super(7, "Point", "A part of the battering ram that is attatched to the cylinder and smashes the door", false, 100, 30);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.bayviewglen.zork.Items;
|
||||
public class Sword extends Item{
|
||||
|
||||
public Sword(){
|
||||
super(33, "Sword", "A steel, double-edged sword which seems to have been sharpened recently", 20, 20);
|
||||
super(33, "Sword", "A steel, double-edged sword which seems to have been sharpened recently", 50, 30);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class Room {
|
||||
private ArrayList<Item> items;
|
||||
private Riddler riddler;
|
||||
private boolean locked;
|
||||
private boolean boarded;
|
||||
|
||||
/**
|
||||
* Create a room described "description". Initially, it has no exits.
|
||||
@@ -51,10 +52,16 @@ class Room {
|
||||
public void setLocked(boolean b) {
|
||||
locked = b;
|
||||
}
|
||||
public void setBoarded(boolean b) {
|
||||
boarded = b;
|
||||
}
|
||||
|
||||
public boolean getLocked() {
|
||||
return locked;
|
||||
}
|
||||
public boolean getBoarded() {
|
||||
return boarded;
|
||||
}
|
||||
|
||||
public void setExit(char direction, Room r) throws Exception {
|
||||
String dir = "";
|
||||
|
||||
Reference in New Issue
Block a user