Merge branch 'master' of https://github.com/jslightham/Zork
Conflicts: src/com/bayviewglen/zork/Game.java
This commit is contained in:
@@ -1,4 +1,10 @@
|
|||||||
Enemy Name: Henry Pellatt
|
Enemy Name: Henry Pellatt
|
||||||
Description: The owner of the Castle
|
Description: The owner of the Castle
|
||||||
Starting Room: Circle Room
|
Starting Room: Apple Hallway
|
||||||
Damage Given: 25
|
Damage Given: 25
|
||||||
|
Loot: Crowbar
|
||||||
|
Enemy Name: Lady Pellatt
|
||||||
|
Description: The wife to the owner of the Castle
|
||||||
|
Starting Room: Lady Pellatt's Bedroom
|
||||||
|
Damage Given: 25
|
||||||
|
Loot: Crowbar
|
||||||
@@ -146,7 +146,7 @@ Room name: Evergreen Bedroom
|
|||||||
Room Description: Oh look! Another bedroom! How exciting! This one's walls are even green this time.<br>Cool!
|
Room Description: Oh look! Another bedroom! How exciting! This one's walls are even green this time.<br>Cool!
|
||||||
Locked: false
|
Locked: false
|
||||||
Boarded: false
|
Boarded: false
|
||||||
Items:
|
Items:Sword
|
||||||
Riddler:
|
Riddler:
|
||||||
Exit Rooms: N-Silver Stairs (2nd Floor), W-Aspen Bedroom
|
Exit Rooms: N-Silver Stairs (2nd Floor), W-Aspen Bedroom
|
||||||
|
|
||||||
|
|||||||
@@ -46,10 +46,12 @@ absorb, eat
|
|||||||
drink, eat
|
drink, eat
|
||||||
i, inventory
|
i, inventory
|
||||||
henry, henrypellatt
|
henry, henrypellatt
|
||||||
pellatt, henrypellatt
|
lady, ladypellatt
|
||||||
shaving, shavingcream
|
shaving, shavingcream
|
||||||
cream, shavingcream
|
cream, shavingcream
|
||||||
water, waterbottle
|
water, waterbottle
|
||||||
bottle, waterbottle
|
bottle, waterbottle
|
||||||
warm, warmbread
|
warm, warmbread
|
||||||
bread, warmbread
|
bread, warmbread
|
||||||
|
battering, batteringram
|
||||||
|
ram, batteringram
|
||||||
@@ -62,4 +62,7 @@ henrypellatt, enemy
|
|||||||
riddler, friend
|
riddler, friend
|
||||||
clock, item
|
clock, item
|
||||||
keyboard, item
|
keyboard, item
|
||||||
lightbulb, item
|
lightbulb, item
|
||||||
|
craft, verb
|
||||||
|
batteringram, item
|
||||||
|
ladypellatt, enemy
|
||||||
@@ -7,6 +7,7 @@ public class Enemy extends Entity{
|
|||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
private String room;
|
private String room;
|
||||||
|
private String loot;
|
||||||
private boolean blinded;
|
private boolean blinded;
|
||||||
|
|
||||||
public Enemy(){
|
public Enemy(){
|
||||||
@@ -54,4 +55,10 @@ public class Enemy extends Entity{
|
|||||||
public void setBlinded(boolean blinded) {
|
public void setBlinded(boolean blinded) {
|
||||||
this.blinded = blinded;
|
this.blinded = blinded;
|
||||||
}
|
}
|
||||||
|
public void setLoot(String loot) {
|
||||||
|
this.loot = loot;
|
||||||
|
}
|
||||||
|
public String getLoot() {
|
||||||
|
return loot;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,6 @@ class Game {
|
|||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
masterEnemyMap.put(e, e.getRoom());
|
|
||||||
enemyScanner.close();
|
enemyScanner.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,15 +276,18 @@ class Game {
|
|||||||
if (command.hasDirection() && hasLockPick) {
|
if (command.hasDirection() && hasLockPick) {
|
||||||
Room nextRoom = currentRoom.nextRoom(command.getDirection());
|
Room nextRoom = currentRoom.nextRoom(command.getDirection());
|
||||||
try {
|
try {
|
||||||
if (nextRoom.getLocked()) {
|
if(nextRoom.getLocked()) {
|
||||||
nextRoom.setLocked(false);
|
nextRoom.setLocked(false);
|
||||||
player.removeFromInventory(new Lockpick());
|
player.removeFromInventory(new Lockpick());
|
||||||
System.out.println(
|
System.out.println("After a little bit of picking, a click is heard and the door opens slightly!");
|
||||||
"After a little bit of picking, a click is heard and the door opens slightly!");
|
if(!nextRoom.getBoarded())
|
||||||
} else {
|
break;
|
||||||
System.out.println("That door is already unlocked!");
|
}else{
|
||||||
}
|
System.out.println("That door is already unlocked!");
|
||||||
} catch (Exception e) {
|
if(!nextRoom.getBoarded())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}catch(Exception e) {
|
||||||
System.out.println("There is no door there!");
|
System.out.println("There is no door there!");
|
||||||
}
|
}
|
||||||
} else if (!command.hasDirection()) {
|
} else if (!command.hasDirection()) {
|
||||||
@@ -317,7 +319,7 @@ class Game {
|
|||||||
} else if (!command.hasDirection()) {
|
} else if (!command.hasDirection()) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
System.out.println("What do you want to unboard the door with?");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "go":
|
case "go":
|
||||||
@@ -563,6 +565,51 @@ class Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "craft":
|
||||||
|
if(command.hasItem()) {
|
||||||
|
Class<?> clazz;
|
||||||
|
CraftableItem object;
|
||||||
|
try {
|
||||||
|
clazz = Class.forName("com.bayviewglen.zork.Items." + command.getItem().substring(0, 1).toUpperCase().trim() + command.getItem().substring(1).trim());
|
||||||
|
Constructor<?> ctor = clazz.getConstructor();
|
||||||
|
object = (CraftableItem) ctor.newInstance();
|
||||||
|
if(object.isCraftable()) {
|
||||||
|
boolean playerHasItems = true;
|
||||||
|
boolean hasItem = false;
|
||||||
|
for(Item i : object.getMaterials()) {
|
||||||
|
hasItem = false;
|
||||||
|
for(Item pi : player.getInventory()) {
|
||||||
|
if(i.equals(pi)) {
|
||||||
|
hasItem = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(playerHasItems) {
|
||||||
|
playerHasItems = hasItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(playerHasItems) {
|
||||||
|
if(player.addToInventory(object)) {
|
||||||
|
for(Item i : object.getMaterials()) {
|
||||||
|
player.removeFromInventory(i);
|
||||||
|
}
|
||||||
|
System.out.println("You have crafted a " + object.getName());
|
||||||
|
}else {
|
||||||
|
System.out.println("You cannot carry any more!");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
System.out.println("You do not have the nessecary parts to make a " + object.getName() + "!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
System.out.println("You cannot make that item!");
|
||||||
|
}
|
||||||
|
}catch(Exception e) {
|
||||||
|
System.out.println("You cannot make that item!");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
System.out.println("Craft what?");
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/com/bayviewglen/zork/Items/Batteringram.java
Normal file
10
src/com/bayviewglen/zork/Items/Batteringram.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package com.bayviewglen.zork.Items;
|
||||||
|
|
||||||
|
public class Batteringram extends CraftableItem{
|
||||||
|
public Batteringram() {
|
||||||
|
super(99, "Battering Ram", "Description", false, 1, 1);
|
||||||
|
super.addMaterial(new Base());
|
||||||
|
super.addMaterial(new Cylinder());
|
||||||
|
super.addMaterial(new Point());
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/com/bayviewglen/zork/Items/CraftableItem.java
Normal file
20
src/com/bayviewglen/zork/Items/CraftableItem.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package com.bayviewglen.zork.Items;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class CraftableItem extends Item{
|
||||||
|
private ArrayList<Item> materials;
|
||||||
|
public CraftableItem(int id, String name, String description, boolean isConsumable, int health, int weight) {
|
||||||
|
super(id, name, description, isConsumable, health, weight);
|
||||||
|
materials = new ArrayList<Item>();
|
||||||
|
}
|
||||||
|
public boolean isCraftable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public void addMaterial(Item item) {
|
||||||
|
materials.add(item);
|
||||||
|
}
|
||||||
|
public ArrayList<Item> getMaterials(){
|
||||||
|
return materials;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -67,5 +67,7 @@ public class Item {
|
|||||||
public int getDamage() {
|
public int getDamage() {
|
||||||
return this.damage;
|
return this.damage;
|
||||||
}
|
}
|
||||||
|
public boolean isCraftable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user