import java.util.*; //used to make imput work
class Text_Game_Kit
{
//main method, where the game takes place
public static void main(String args[])
{
//Declaring everything
//position as a Y cordinate
int POSY = 0;
//position as an X cordinate
int POSX = 0;
//Placeholder for input
String input = "";
//The First Chest is not open
boolean Chest1 = false;
String Chest1OPCL = " closed"; // the first chest is closed. This is to enhance the text.
//Is there an enemy?
boolean enemy = false;
String enemyname = ""; //Type of enemy. i.e. Skeleton, Zombie, etc.
// boolean to see if the game is done
boolean done = false;
//if the game is not done, keep running
while (!done)
{
//quickly check if the game is done. if it is, break everything
if (done)
{
break;
}
//these are commands. try to see how they work. all commands must be lowercase.
//Movement Outputs: tells the user what the character sees
if (POSX==0&&POSY==0) //If you are at the starting position: 0,0. You see a chest from here. Reach it by saying "move up" 3 times.
{
System.out.println("You wake up in a poorly lit room. You see a" + Chest1OPCL + " chest 3 steps to the north");
}
else if (POSX==0&&POSY==3) //You have just moved up 3 times. you can open the chest by saing "open"
{
System.out.println("There is a" + Chest1OPCL + " chest in front of you.");
}
//Danger Commands: tells the user other information besides the Movement Outputs
if (enemy)
{
System.out.println("You are being attacked by a" + enemyname + ".");
}
//Get the input
input=in();
//handle the input. This includs all do able commands. typing help will list them. typing help and then a command will describe it. The only changing here should be to add commands
//Moving Commands
if (input==("up"))
{
POSY++; //move up
}
else if (input==("down"))
{
POSY--; //go down
}
else if (input==("left"))
{
POSX--; //move left
}
else if (input==("right"))
{
POSX++; //move right
}
//opening commands: deals with: is there a chest, is it open, and what happens
else if (input==("open"))
{
if (POSX==0&&POSY==3&&!Chest1) //if the chest isnt open and you are at 0,3: the place where chest1 is.
{
System.out.println("You open the chest and find a sword. You hear the rattling of bones behind you.");
enemy=true;
enemyname=" Skeleton";
Chest1=true;
Chest1OPCL="n open"; //now text thinks its open
// you open the chest and are now being attacked by a skeleton. use "attack" to kill it.
}
// you can insert more chests here, you must use else if
//if there is no chest
else
{
System.out.println("You see nothing to open!");
}
}
//Attacking Command
else if (input=="attack")
{
if (enemy)
{
System.out.println("You attack a" + enemyname + ". It falls rather easily.");
//Staging. this is rather difficult because the attack command dosent know what you just attacked.
if (enemyname == " Skeleton")
{
done=true; //in this short kit, killing the skeleton is the end. however, you can use anything here. if you want, you can make this progress, or have another enemy pop up, a door open, etc. if you need help here, just ask. I understand its a bit vague.
}
}
else
{
System.out.println("You find nothing to attack, so you swing at the air for good measure");
}
}
//help, and any variants. Add more if you make new commands
else if (input=="help")
{
System.out.println("Commands are: up, down, left, right, open, help, and attack. Say help with a command after it to see more information"); //make sure to put any added here.
}
//indepth command help
else if (input=="help up")
{
System.out.println("This makes you move fowdard");
}
else if (input=="help down")
{
System.out.println("This makes you move backwards");
}
else if (input=="help left")
{
System.out.println("This makes you move left");
}
else if (input=="help right")
{
System.out.println("This makes you move right.");
}
else if (input=="help open")
{
System.out.println("This opens a chest, if there is one.");
}
else if (input=="help attack")
{
System.out.println("This attacks an enemy, if there is one.");
}
else if (input=="help help")
{
System.out.println("You IQ must me in the double digits");
}
//The end of the command cycle. all other commands must be above this
else
{
System.out.println("That is not a command. Try using help to find more commands.");
}
}
//end of the loop. only goes here when the game is done
System.out.println("Congradulations! You've won!");
}
//This method gets input
public static String in()
{
Scanner scan=new Scanner(System.in);
String word = "Temp";
word=scan.next();
return word;
}
}