Merge branch 'master' of https://github.com/jslightham/Zork/
Conflicts: data/rooms.dat
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
Room name: Circle Room
|
||||
Room Description: You are in the circular room. The windows to the west are bolted shut and curtains cover them.<br>To the east, a hallway. A scroll hangs on the north wall. Writing is visible.
|
||||
Items:Lockpick,Cylinder,Base,Point
|
||||
Locked: false
|
||||
Items:Lockpick
|
||||
Exit Rooms: W-Apple Hallway
|
||||
Room name: Apple Hallway
|
||||
Room Description: You are in an empty hallway. Many closed doors surround you. To the west is the Circle Room and north is the Porcupine Stairs. The door to the stairs is locked. There is no key to the door.
|
||||
Locked: true
|
||||
Items:
|
||||
Exit Rooms: E-Circle Room, N-Porcupine Stairs (3rd Floor)
|
||||
Room name: Porcupine Stairs (3rd Floor)
|
||||
|
||||
@@ -33,3 +33,17 @@ socks, item
|
||||
painting, item
|
||||
inventory, verb
|
||||
i, verb
|
||||
notebook, item
|
||||
shaving cream, item
|
||||
toothbrush, item
|
||||
toothpaste, item
|
||||
milk, item
|
||||
cheese, item
|
||||
yogurt, item
|
||||
chips, item
|
||||
granola bars, item
|
||||
chocolate, item
|
||||
warm bread, item
|
||||
clothes, item
|
||||
sword, item
|
||||
blanket, item
|
||||
5
src/com/bayviewglen/zork/Entities/Enemy.java
Normal file
5
src/com/bayviewglen/zork/Entities/Enemy.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package com.bayviewglen.zork.Entities;
|
||||
|
||||
public class Enemy {
|
||||
|
||||
}
|
||||
@@ -54,6 +54,9 @@ class Game {
|
||||
// Read the Description
|
||||
String roomDescription = roomScanner.nextLine();
|
||||
room.setDescription(roomDescription.split(":")[1].replaceAll("<br>", "\n").trim());
|
||||
// Read the Description
|
||||
boolean locked = Boolean.parseBoolean(roomScanner.nextLine());
|
||||
room.setLocked(locked);
|
||||
// Read the Items
|
||||
String items = roomScanner.nextLine();
|
||||
try {
|
||||
@@ -232,7 +235,20 @@ class Game {
|
||||
System.out.println("You are empty handed.");
|
||||
}
|
||||
break;
|
||||
|
||||
case "open":
|
||||
boolean hasLockpick = false;
|
||||
for(int i =0; i<player.getInventory().size(); i++) {
|
||||
if(player.getInventory().get(i).equals(new Lockpick())) {
|
||||
hasLockpick = true;
|
||||
player.removeFromInventory(new Lockpick());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(command.hasDirection()) {
|
||||
Room nextRoom = currentRoom.nextRoom(command.getDirection());
|
||||
nextRoom.setLocked(false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -267,6 +283,9 @@ class Game {
|
||||
Room nextRoom = currentRoom.nextRoom(direction);
|
||||
if (nextRoom == null)
|
||||
System.out.println("There is no door!");
|
||||
else if(nextRoom.getLocked()) {
|
||||
System.out.println("The door is locked!");
|
||||
}
|
||||
else {
|
||||
currentRoom = nextRoom;
|
||||
System.out.println(currentRoom.longDescription());
|
||||
|
||||
8
src/com/bayviewglen/zork/Items/Notebook.java
Normal file
8
src/com/bayviewglen/zork/Items/Notebook.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.bayviewglen.zork.Items;
|
||||
public class Notebook extends Item{
|
||||
|
||||
public Notebook(){
|
||||
super(15, "Notebook", "A book filled with diagrams and descriptions, belonging to Henry Pellatt", false, 50, 1);
|
||||
}
|
||||
|
||||
}
|
||||
8
src/com/bayviewglen/zork/Items/ShavingCream.java
Normal file
8
src/com/bayviewglen/zork/Items/ShavingCream.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.bayviewglen.zork.Items;
|
||||
public class ShavingCream extends Item{
|
||||
|
||||
public ShavingCream(){
|
||||
super(16, "Shaving Cream", "A can of shaving cream with foam still around the edge of the nozzle", false, 10, 1);
|
||||
}
|
||||
|
||||
}
|
||||
7
src/com/bayviewglen/zork/Items/Toothbrush.java
Normal file
7
src/com/bayviewglen/zork/Items/Toothbrush.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.bayviewglen.zork.Items;
|
||||
public class Toothbrush extends Item{
|
||||
|
||||
public Toothbrush(){
|
||||
super(17, "Toothbrush", "A light blue manual toothbrush stained with missing bristles after continual use", false, 5, 1);
|
||||
}
|
||||
}
|
||||
8
src/com/bayviewglen/zork/Items/Toothpaste.java
Normal file
8
src/com/bayviewglen/zork/Items/Toothpaste.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.bayviewglen.zork.Items;
|
||||
public class Toothpaste extends Item{
|
||||
|
||||
public Toothpaste(){
|
||||
super(18, "Toothpaste", "A half used tube of toothpaste crumpled up with little care", false, 10, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ class Room {
|
||||
private String description;
|
||||
private HashMap<String, Room> exits; // stores exits of this room.
|
||||
private ArrayList<Item> items;
|
||||
private boolean locked;
|
||||
|
||||
/**
|
||||
* Create a room described "description". Initially, it has no exits.
|
||||
@@ -45,6 +46,14 @@ class Room {
|
||||
items = new ArrayList<Item>();
|
||||
}
|
||||
|
||||
public void setLocked(boolean b) {
|
||||
locked = b;
|
||||
}
|
||||
|
||||
public boolean getLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public void setExit(char direction, Room r) throws Exception {
|
||||
String dir = "";
|
||||
switch (direction) {
|
||||
|
||||
Reference in New Issue
Block a user