riddles are done!
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
Room name: Circle Room
|
Room name: Circle Room
|
||||||
Room Description: You are in a circular room. The windows to the east are covered with boards that let in just enough light to see. You spot a man in a tailored suit.
|
Room Description: You are in a circular room. The windows to the east are covered with boards that<br> let in just enough light to see. You spot a man in a tailored suit.
|
||||||
Locked: false
|
Locked: false
|
||||||
Boarded: false
|
Boarded: false
|
||||||
Items:Lockpick,Milk
|
Items:Lockpick,Milk
|
||||||
Riddler: "I can help you in your quest<comma> but only if you answer my riddle.", "Who is never hungry during Christmas?", "The turkey because he is always stuffed", ShavingCream
|
Riddler: "Hello there. My name is Kevin and I am Sir Pellatt's butler. I understand that my master<comma><br>Sir Pellatt has wrongfully imprisoned you. If you answer my riddle<comma> I can give you something to<br>help you with your escape - nothing comes for free you know!", "What goes moo?", "Cows", ShavingCream
|
||||||
Exit Rooms: W-Apple Hallway
|
Exit Rooms: W-Apple Hallway
|
||||||
|
|
||||||
Room name: Apple Hallway
|
Room name: Apple Hallway
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ mop, item
|
|||||||
bucket, item
|
bucket, item
|
||||||
towels, item
|
towels, item
|
||||||
henrypellatt, enemy
|
henrypellatt, enemy
|
||||||
|
riddler, friend
|
||||||
clock, item
|
clock, item
|
||||||
keyboard, item
|
keyboard, item
|
||||||
lightbulb, item
|
lightbulb, item
|
||||||
@@ -40,15 +40,10 @@ public class Player extends Entity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void eat() {
|
public void eat() {
|
||||||
// TODO Do we want health or hunger?
|
|
||||||
health+=5;
|
health+=5;
|
||||||
hunger+=5;
|
|
||||||
if(health > 100.0) {
|
if(health > 100.0) {
|
||||||
health = 100.0;
|
health = 100.0;
|
||||||
}
|
}
|
||||||
if(hunger > 100.0) {
|
|
||||||
hunger = 100.0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,5 +21,9 @@ public class Riddler extends Entity {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Item getPrize() {
|
||||||
|
return prize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,9 +83,9 @@ class Game {
|
|||||||
int comma1 = riddlerInfo.indexOf(",");
|
int comma1 = riddlerInfo.indexOf(",");
|
||||||
int comma2 = riddlerInfo.indexOf(",", riddlerInfo.indexOf(",") + 1);
|
int comma2 = riddlerInfo.indexOf(",", riddlerInfo.indexOf(",") + 1);
|
||||||
int comma3 = riddlerInfo.indexOf(",", comma2 +1);
|
int comma3 = riddlerInfo.indexOf(",", comma2 +1);
|
||||||
String message = riddlerInfo.substring(1, comma1 - 1).replaceAll("<comma>", ",");
|
String message = riddlerInfo.substring(1, comma1 - 1).replaceAll("<comma>", ",").replaceAll("<br>", "\n");
|
||||||
String question = riddlerInfo.substring(comma1 + 3, comma2 - 1).replaceAll("<comma>", ",");
|
String question = riddlerInfo.substring(comma1 + 3, comma2 - 1).replaceAll("<comma>", ",").replaceAll("<br>", "\n");
|
||||||
String answer = riddlerInfo.substring(comma2 + 3, riddlerInfo.length() - 1).replaceAll("<comma>", ",");
|
String answer = riddlerInfo.substring(comma2 + 3, comma3 - 1).replaceAll("<comma>", ",").replaceAll("<br>", "\n");
|
||||||
Riddle riddleObj = new Riddle(question, answer);
|
Riddle riddleObj = new Riddle(question, answer);
|
||||||
String item = riddlerInfo.substring(comma3 + 2, riddlerInfo.length());
|
String item = riddlerInfo.substring(comma3 + 2, riddlerInfo.length());
|
||||||
// Initializes prize object
|
// Initializes prize object
|
||||||
@@ -375,10 +375,19 @@ class Game {
|
|||||||
String message = currentRoom.getRiddler().getMessage();
|
String message = currentRoom.getRiddler().getMessage();
|
||||||
String riddle = currentRoom.getRiddler().getRiddle().getQuestion();
|
String riddle = currentRoom.getRiddler().getRiddle().getQuestion();
|
||||||
String answer = currentRoom.getRiddler().getRiddle().getAnswer();
|
String answer = currentRoom.getRiddler().getRiddle().getAnswer();
|
||||||
System.out.println(message + "\n" + riddle + "\nWhat is your answer?:");
|
System.out.println(message + "\n\nHere's my riddle: " + riddle);
|
||||||
|
System.out.print("Enter your guess here: ");
|
||||||
String guess = rScanner.nextLine();
|
String guess = rScanner.nextLine();
|
||||||
if(guess.toLowerCase().equals(answer.toLowerCase())) {
|
if(guess.toLowerCase().equals(answer.toLowerCase())) {
|
||||||
System.out.println("Good Job!");
|
Item prize = currentRoom.getRiddler().getPrize();
|
||||||
|
String prizeName = prize.getName();
|
||||||
|
System.out.println("Congratulations! You solved my riddle! As your reward, you get a " + prizeName + "!");
|
||||||
|
if(player.addToInventory(prize)) {
|
||||||
|
player.addToInventory(prize);
|
||||||
|
System.out.println("A " + prizeName + " has been added to your inventory.");
|
||||||
|
}else {
|
||||||
|
System.out.println("Sorry, you can't carry any more ");
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
System.out.println("Sorry, that isn't the answer. Think about it, then try again.");
|
System.out.println("Sorry, that isn't the answer. Think about it, then try again.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user