Project #1 Choose Your Own Slightly Longer Adventure
Code
Name: Iaroslav Titov
Period: 7
Project Name: Adventure2
File Name: Adventure2.java
Date: 10/21/2015
import java.util.Scanner;
public class Adventure2
{
static String[][][] story = new String[4][3][3];
static String[][][][] answers = new String[4][3][3][4];
static void idLeftPath()
{
story[1][0][0] = "You turn left and soon arrive into an open ceiling room full of \n"+
"little dragons. They did not notice you yet. \n"+
"Would you \"shout\" to attract heir attention, or \n"+
"try to \"sneak\" unnoticed? ";
answers[1][0][0][1] = "shout";
answers[1][0][0][2] = "sneak";
story[1][1][0] = "Dragons immediately turn to face you. Although \n"+
"they are no more than a foot long, there are hundreds \n"+
"of them in the room, so shouting doesn't seen a good idea anymore.\n"+
"Would you try to \"soothe\" them with dried meat from your\n" +
"pack, or to \"run\" though their midst into the next room? ";
answers[1][1][0][1] = "soothe";
answers[1][1][0][2] = "run";
story[1][1][1] = "You fed the dragons everything edible from your pack.\n"+
"They seem to enjoy the food, so after they finished off the meal, \n"+
"dragons grab your clothes with their claws and carry you out of the room. \n"+
"Congrats, you escaped the Labyrinth!!! ";
story[1][1][2] = "You dash through the room with only a few scratches from dragons' claws.\n"+
"You run into the room and smash the door behind you. \n"+
"Inside the room, you see a large dragon waking up,\n"+
"which must be a parent of the little ones... \n"+
"The dragon attacks you and tears you apart.\n"+
"Unfortunately, you lost the game. Try one more time. ";
story[1][2][0] = "You slowly walk alongside the wall, but the dragons \n"+
"notice you and start to squeak on high tones. \n"+
"Suddenly, the opposite door is thrown open and a large full-grown \n"+
"dragon enters the room.\n" +
"Would you \"fight\" it to death with your sword or try to \"pet\" it? ";
answers[1][2][0][1] = "fight";
answers[1][2][0][2] = "pet";
story[1][2][1] = "You draw your sword and charge toward the beast, but\n"+
"unlike the infant dragons, this one can breathe fire.\n"+
"You are cooked in a couple seconds and dragons feast on your flesh.\n"+
"Unfortunately, you lost the game. Try one more time. ";
story[1][2][2] = "You raise empty hands up and try to approach the dragon \n"+
"in a friendly way, but Mama-dragon does not forgive those who \n"+
"disrupted peace of her offspring.\n"+
"The large dragon attacks you and tears you apart. \n"+
"Unfortunately, you lost the game. Try one more time. ";
}
static void idRightPath()
{
story[2][0][0] = "You turn right and soon arrive into a room, which feels\n"+
"extremely hot. You now see now what causes the heat. \n"+
"The opposite door is in purple flames, but behind ot you see the the blinks of light.\n"+
"Would you try to \"run\" through the flames or \"look\" for \n"+
"some other way out? ";
answers[2][0][0][1] = "run";
answers[2][0][0][2] = "look";
story[2][1][0] = "You run through the flames and your clothes catches fire.\n"+
"You manage to extinguish it, but you are heavily burned.\n"+
"You can see the exit now, but it is guarded by a giant hellhound.\n"+
"Would you try to \"sneak\" behind the sleeping dog or try to \"kill\" \n"+
"it in its sleep? ";
answers[2][1][0][1] = "sneak";
answers[2][1][0][2] = "kill";
story[2][1][1] = "You slowly creep toward the exit when the dog wakes up\n"+
"and attacks you.\n"+
"Before you draw your weapon, you are torn to pieces.\n"+
"Unfortunately, you lost the game. Try one more time. ";
story[2][1][2] = "You draw your weapon and creep toward the dog.\n"+
"The monster wakes up, but you are ready, so after\n"+
"a short struggle, you triumphantly kick the dead dog and exit the labyrinth.\n"+
"Congrats, you won the game!!! ";
story[2][2][0] = "You look around in search of anything that can help you.\n"+
"In the darkest corner you notice a fresh corpse, who seemed to bleed to death, clutching a pack.\n"+
"In the pack there is a little bag full of powder, labeled \"Extinguisher\" and.\n"+
"a big bloody chunk of meat.\n"+
"Would you take the \"powder\" and leave the meat, or take \"both\"? ";
answers[2][2][0][1] = "powder";
answers[2][2][0][2] = "both";
story[2][2][1] = "You throw the powder into the flames and it disappears with a loud pop.\n"+
"Behind the door is a hellhound monster, who guards the exit from the labyrinth.\n"+
"It growls and gazes at you, scared by the loud pop.\n"+
"You attack the confused monster, kill it, and finally exit the labyrinth.\n"+
"Congrats, you won the game!!! ";
story[2][2][2] = "You throw the powder into the flames and it disappears with a loud pop.\n"+
"Behind the door is a hellhound monster, who guards the exit from the labyrinth.\n"+
"It senses the meat in your pack, charges at you, and, before you can draw your\n"+
"weapon, tears you into pieces.\n"+
"Unfortunately, you lost the game. Try one more time. ";
}
static void idStraightPath()
{
story[3][0][0] = "You paddle forward for a long time before you asee a musty room.\n"+
"You hear muffled voices, which appear to be quite human. \n" +
"Would you \"enter\" the room openly or \"listen\" at the door? ";
answers[3][0][0][1] = "enter";
answers[3][0][0][2] = "listen";
story[3][1][0] = "You are glad to hear humans in this labyrinth, so you \n"+
"burst into the room and only then see the horrors of it: \n" +
"the room contains an altar of some dark god, to whom four \n" +
"priests who gathered around are sacrificing a sheep just right now. \n" +
"Near you there is a stand with an ancient skull on it.\n"+
"Would you \"charge\" at the priests, or \"grab\" the skull? ";
answers[3][1][0][1] = "charge";
answers[3][1][0][2] = "grab";
story[3][1][1] = "You charge at the priests and manage to kill one of them before others \n"+
"realize your presence. While you fight with one of them, the remaining two \n" +
"weave some dark spell that controls your mind. \n" +
"You cannot resist, while the priests lay you on the altar and sacrifice. \n" +
"Unfortunately, you lost the game. Try one more time.";
story[3][1][2] = "You grab the ancient skull and hold it over your head, like you \n"+
"want to break it. Priests are horrified by this idea, due to \n" +
"the skull being a very important artifact. \n" +
"Priests let you go unharrmed in exchange for their artifact.\n" +
"You run toward the light and soon exit the labyrinth.\n" +
"Congrats, you won the game!!! ";
story[3][2][0] = "You listen to the voices in the room and realize that \n"+
"people in the room are dark priests. From their conversation \n"+
"you realize that they are going to sacrifice a sheep and then \n"+
"go into some kind of trance. \n"+
"Would you \"wait\" till they go into the trance or \"attack\" and save the sheep? ";
answers[3][2][0][1] = "wait";
answers[3][2][0][2] = "attack";
story[3][2][1] = "You wait while the priests sacrifice the sheep, pray to their dark god \n"+
"and go to into trance. Once they did, you come into the room and slay them \n" +
"all, for they are the most wretched creatures. \n" +
"The way out is now open, so you hastily exit the labyrinth.\n" +
"Congrats, you won the game!!! ";
story[3][2][2] = "Bursting into the room, you attack the priests and manage to kill two of them\n" +
"before others realize your presence. While you fight with one of them, the \n"+
"remaining one weaves some dark spell that controls your mind. \n" +
"You cannot resist, while the priests lay you on the altar and sacrifice. \n" +
"Unfortunately, you lost the game. Try one more time.";
}
public static void main(String[] args)
{
int choice[] = {0,0,0};
Scanner keyboard = new Scanner(System.in);
int yourWay[] = {0,0,0};
String response = "none";
story[0][0][0] = "Welcome to the Iarik's Labyrinth Adventure!!!\n"+
"You are a hero that enters the Labyrinth of Fate! \n" +
"At first, you follow a single path with no branches, but \n"+
"after a few hours arrive at a fork. You can go \"left\", \n"+
"from where you hear weird noises, \"right\", which you feel \n"+
"is way warmer than the other paths, or keep going \"straight\". \n"+
"Where would you go? ";
answers[0][0][0][1] = "left";
answers[0][0][0][2] = "right";
answers[0][0][0][3] = "straight";
idLeftPath();
idRightPath();
idStraightPath();
try
{
System.out.println();
System.out.print(story[yourWay[0]][yourWay[1]][yourWay[2]]);
for (int i = 0; i < 3; i++)
{
response = keyboard.next();
if (response.equals(answers[yourWay[0]][yourWay[1]][yourWay[2]][1])) yourWay[i] = 1;
else if (response.equals(answers[yourWay[0]][yourWay[1]][yourWay[2]][2])) yourWay[i] = 2;
else if (response.equals(answers[yourWay[0]][yourWay[1]][yourWay[2]][3])) yourWay[i] = 3;
else throw new Exception("WRONG INPUT");
System.out.println();
System.out.print(story[yourWay[0]][yourWay[1]][yourWay[2]]);
}
}
catch (Exception e)
{
System.out.println("WRONG INPUT!!! RESTART ADVENTURE!!!");
}
System.out.println();
}
}
Picture of the output