Skip to content

Commit

Permalink
Merge pull request #19 from nscherer30/dev
Browse files Browse the repository at this point in the history
v2.2 Release
  • Loading branch information
nickordoodle authored Feb 16, 2021
2 parents e6ae266 + 1b03f50 commit a6227f8
Show file tree
Hide file tree
Showing 71 changed files with 697 additions and 542 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
##############################
.mtj.tmp/


*.war
*.ear
*.nar
Expand Down Expand Up @@ -42,4 +41,5 @@ gradle-app.setting
.idea_modules/
*.iml
*.ipr
*.iws
*.iws
/out/
Binary file added RPS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added four-colored-door-room.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gameOver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lizardKey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed out/production/LizardKey/org/lizard/Actions.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Board.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Combat.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Command.class
Binary file not shown.
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Directions.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Enemy.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Event.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Funsies.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Game.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Item.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Lock.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Main.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/MapView.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/MyJFrame.class
Binary file not shown.
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Player.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Room.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/Story.class
Binary file not shown.
Binary file removed out/production/LizardKey/org/lizard/TextParser.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed out/test/test/org/lizard/CheatCodeTest.class
Binary file not shown.
Binary file removed out/test/test/org/lizard/RoomTest.class
Binary file not shown.
Binary file removed out/test/test/org/lizard/user/PrompterTest.class
Binary file not shown.
Binary file added person.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 59 additions & 60 deletions src/org/lizard/Actions.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public String execute(Command command) {
GameDictionary.Noun noun;
GameDictionary.Noun targetNoun = null;
Integer verb;
if (command.isAmbiguous()) {
return disambiguate(command);
}
// if (command.isAmbiguous()) {
// return disambiguate(command);
// }
verb = command.getVerb();
noun = command.getNoun() == null ? null : command.getNoun()[0];

Expand Down Expand Up @@ -74,7 +74,7 @@ public String execute(Command command) {
case 99:
return bossAvailable("west", noun);
case 1000:
return Story.howToPlayInGame();
return board.howToPlayInGame();
case 2424:
return demonUnleashed();
}
Expand Down Expand Up @@ -107,11 +107,11 @@ private String move(GameDictionary.Noun direction) {
private String grab(GameDictionary.Noun noun) {

if (noun == null) {
return ("That doesn't exist");
return ("You don't see anything like that.");
} else if (!noun.isGrabable()) {
return ("You can't even grab a " + noun.getName());
return ("You cannot take " + noun.getName() + ".");
} else if (player.getInventory().has(noun)) {
return "You already have that in your inventory";
return "You already have " + noun.getName() + " in your inventory.";
} else {
//get current room
Room currentRoom = board.getCurrentRoom();
Expand Down Expand Up @@ -161,7 +161,7 @@ public String use(GameDictionary.Noun noun, GameDictionary.Noun targetNoun) {

public String unlockExit(String direction, GameDictionary.Noun noun) {
if (!player.getInventory().has(noun)) {
return "You don't have that on your person";
return "You don't have a " + noun.getName() + ".";
}
Lock lock = board.getCurrentRoom().getLock(direction);
if (lock != null && lock.getNoun().equals(noun)) {
Expand Down Expand Up @@ -248,48 +248,48 @@ public String drop(GameDictionary.Noun noun) {

}

private String disambiguate(Command command) {
GameDictionary.Noun[] noun = command.getNoun();
GameDictionary.Noun[] targetNoun = command.getTargetNoun();

Set<GameDictionary.Noun> availableNouns = new HashSet<>(player.getInventory().getItems());
availableNouns.addAll(board.getCurrentRoom().getItems());

Set<GameDictionary.Noun> nounSet = new HashSet<>(Arrays.asList(noun));

nounSet.retainAll(availableNouns);

if (nounSet.size() == 1) {
noun = new GameDictionary.Noun[]{nounSet.iterator().next()};
} else if (nounSet.size() > 1) {
Iterator<GameDictionary.Noun> iterator = nounSet.iterator();
return frame.decision(new ArrayList<>(nounSet), command);

} else {
noun = null;
}

if (targetNoun != null) {
System.out.println(Arrays.toString(targetNoun));
Set<GameDictionary.Noun> targetNounSet = new HashSet<>(Arrays.asList(targetNoun));
targetNounSet.retainAll(availableNouns);

if (targetNounSet.size() == 1) {
targetNoun = new GameDictionary.Noun[]{targetNounSet.iterator().next()};
} else if (targetNounSet.size() > 1) {
Iterator<GameDictionary.Noun> iterator = targetNounSet.iterator();
return frame.decision(new ArrayList<>(targetNounSet), command);
}

}

if (targetNoun != null && targetNoun.length == 1) {
return execute(new Command(command.getVerb(), noun, targetNoun));
} else {
return execute(new Command(command.getVerb(), noun));
}

}
// private String disambiguate(Command command) {
// GameDictionary.Noun[] noun = command.getNoun();
// GameDictionary.Noun[] targetNoun = command.getTargetNoun();
//
// Set<GameDictionary.Noun> availableNouns = new HashSet<>(player.getInventory().getItems());
// availableNouns.addAll(board.getCurrentRoom().getItems());
//
// Set<GameDictionary.Noun> nounSet = new HashSet<>(Arrays.asList(noun));
//
// nounSet.retainAll(availableNouns);
//
// if (nounSet.size() == 1) {
// noun = new GameDictionary.Noun[]{nounSet.iterator().next()};
// } else if (nounSet.size() > 1) {
// Iterator<GameDictionary.Noun> iterator = nounSet.iterator();
// return frame.decision(new ArrayList<>(nounSet), command);
//
// } else {
// noun = null;
// }
//
// if (targetNoun != null) {
// System.out.println(Arrays.toString(targetNoun));
// Set<GameDictionary.Noun> targetNounSet = new HashSet<>(Arrays.asList(targetNoun));
// targetNounSet.retainAll(availableNouns);
//
// if (targetNounSet.size() == 1) {
// targetNoun = new GameDictionary.Noun[]{targetNounSet.iterator().next()};
// } else if (targetNounSet.size() > 1) {
// Iterator<GameDictionary.Noun> iterator = targetNounSet.iterator();
// return frame.decision(new ArrayList<>(targetNounSet), command);
// }
//
// }
//
// if (targetNoun != null && targetNoun.length == 1) {
// return execute(new Command(command.getVerb(), noun, targetNoun));
// } else {
// return execute(new Command(command.getVerb(), noun));
// }
//
// }

// Unleashes the demon/enemy and places the demon
// in the whisperingPassage room
Expand Down Expand Up @@ -322,18 +322,18 @@ static class CheatCode {
// in the game and gives them to player
// NOTE this does not give the player
// the lizard key
static String givePlayerAllKeysBesidesLizardKey(Player.Inventory inv, final Board board){
static String givePlayerAllKeysBesidesLizardKey(Player.Inventory inv, final Board board) {
// Check for negative case and handle
if(inv == null || board == null){
if (inv == null || board == null) {
return "Oops! Cheat code get all keys besides lizard key did not work!";
}
Map<String, Item> allItems = board.getAllItems();
// Iterate over the map entries
for (Map.Entry<String,Item> item : allItems.entrySet()){
for (Map.Entry<String, Item> item : allItems.entrySet()) {
Item currItem = item.getValue();
// Check if the item is a key but not the winning key
if(currItem.getName().contains("key")
&& !currItem.getName().equals("lizard key")){
if (currItem.getName().contains("key")
&& !currItem.getName().equals("lizard key")) {
// Add to the player's inventory
inv.add(currItem);
}
Expand All @@ -343,22 +343,22 @@ static String givePlayerAllKeysBesidesLizardKey(Player.Inventory inv, final Boar
" of the keys in the game!!!";
}

static String givePlayerSpecificItem(GameDictionary.Noun requestedItem, Player.Inventory inv, final Board board){
static String givePlayerSpecificItem(GameDictionary.Noun requestedItem, Player.Inventory inv, final Board board) {

try {
// Get the name of the item
String itemName = requestedItem.getName();
Map<String, Item> allItems = board.getAllItems();
// Iterate over the map entries
for (Map.Entry<String,Item> item : allItems.entrySet()){
for (Map.Entry<String, Item> item : allItems.entrySet()) {
String currItemName = item.getValue().getName();
// Check if it is the requested item
if(currItemName.contains(itemName)){
if (currItemName.contains(itemName)) {
// Add to the player's inventory
inv.add(item.getValue());
}
}
} catch (NullPointerException e){
} catch (NullPointerException e) {
return "Oops! Cheat code get " + requestedItem + " item did not work! Try" +
" cheatcodeget <item>";
}
Expand All @@ -367,7 +367,6 @@ static String givePlayerSpecificItem(GameDictionary.Noun requestedItem, Player.I
}



}

}
75 changes: 73 additions & 2 deletions src/org/lizard/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Board() {
addToVisitedRooms("keyRoom");
}

public Map<String, Item> getAllItems(){
public Map<String, Item> getAllItems() {
return this.allItems;
}

Expand Down Expand Up @@ -179,7 +179,7 @@ public String changeCurrentRoom(String direction) {
if (exits.containsKey(direction)) {
currentRoom = exits.get(direction);
addToVisitedRooms(currentRoom.getName());
return ("You have entered the " + currentRoom.getName() + "\n" + currentRoom.getRoomDescription());
return ("You have entered the " + currentRoom.getName() + "\n\n" + currentRoom.getRoomDescription());

} else {
return ("That is not an exit.");
Expand Down Expand Up @@ -330,6 +330,77 @@ private void addLocksToRooms() {
}
}
}

String howToPlayInGame() {
return """
HOW TO PLAY:\s
Look for clues, and don't be afraid to explore!
To perform an action, type your command in the text box and hit enter.
Examples of possible commands are:\s
'rules' - to see instructions.
'go east' - to travel east.
'go north' - to travel north.
'examine room' - to see items and doors in current room.
'examine locked chest' - to examine the locked chest (locked chest can be substituted for any item in your current room).
'inventory' - to see items in your inventory.
'grab knife' - to grab a knife (substitute knife for item you wish to pick up).
'drop knife' - to drop a knife (substitute knife for item you wish to drop from your inventory).
'use skeleton key on east' - some doors or items may be locked. Using the proper key/item on the proper item or direction will\s""";

}

static String howToPlay() {
return "\n" + "\n" + "\n" + "\n" + "\n" + "\n" +
"How to Play: \n" +
"\n" +
"Look for clues, and don't be afraid to explore!\n" +
"To perform an action, type your command in the text box and hit enter.\n" +
"\n" +
"Examples of possible commands are: \n" +
"\n" +
"'rules' - to see instructions.\n" +
"\n" +
"'go east' - to travel east.\n" +
"\n" +
"'go north' - to travel north.\n" +
"\n" +
"'examine room' - to see items and doors in current room.\n" +
"\n" +
"'examine locked chest' - to examine the locked chest (locked chest can be substituted for any item in your current room).\n" +
"\n" +
"'inventory' - to see items in your inventory.\n" +
"\n" +
"'grab knife' - to grab a knife (substitute knife for item you wish to pick up).\n" +
"\n" +
"'drop knife' - to drop a knife (substitute knife for item you wish to drop from your inventory).\n" +
"\n" +
"'use skeleton key on east' - some doors or items may be locked. Using the proper key/item on the proper item or direction will ";

}

String introduction() {
return """
Like a dream, your thoughts carry you to an unknown universe. Four bare walls keep you as a prisoner to an overly bright room with no windows. Shelves with millions of keys in varying sizes, shapes, and colors line the floors like passageways to doors around you.
What lies behind each door is unknown to you, but your options are limited, for this is no dream, and you are not imagining what you are seeing. The keys you touch are as real as the keys to your home. The floor you stand on is as hard as the surface beneath your bed.
Like many others before you, you have become a pet to a man named Copernicus Rex Verwirrtheit Theodore, locksmith, creator of worlds, and master of confusion. With no two worlds being the same, Mister Theodore has created each maze uniquely odd and fantastically tumultuous for every mouse searching for its cheese.
It is up to you to find the way out of this prison, for if you do not, you will forever be in an endless loop of rooms that lead to other rooms,the final and single exit a mystery never to be given away freely.""";

}
}


6 changes: 6 additions & 0 deletions src/org/lizard/GameDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static GameDictionary getGameDictionary() {
private void setVerbs() {
verbs.put("grab", 1);
verbs.put("take", 1);
verbs.put("get", 1);
verbs.put("go", 2);
verbs.put("move", 2);
verbs.put("look", 3);
Expand Down Expand Up @@ -191,5 +192,10 @@ public void addKnownWord(Noun noun, String word) {
}
}

public static void main(String[] args) {
for (String s : gameDictionary.verbs.keySet()) {
System.out.println(s);
}
}

}
Loading

0 comments on commit a6227f8

Please sign in to comment.