Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Game
- {
- private static boolean fromAdmin = false;
- public static void main(String args[])
- {
- SOP("Welcome to RPG V1, please choose an option from the list below.");
- delayOneSecond();
- SOP("1. Start the game");
- SOP("2. Quit the game (Already?)");
- SOP("3. Administrator Account");
- initialMenu(fromAdmin);
- }
- public static void initialMenu(boolean fromAdmin)
- {
- if(fromAdmin)
- {
- SOP("1. Start the game");
- SOP("2. Quit the game (Already?)");
- SOP("3. Administrator Account");
- }
- Scanner myScan = new Scanner(System.in);
- int choice = myScan.nextInt();
- switch(choice)
- {
- case 1:
- basicInfo();
- break;
- case 2:
- return;
- case 3:
- admin(fromAdmin);
- }
- }
- public static void admin(boolean fromAdmin)
- {
- fromAdmin = true;
- boolean goodUser = false;
- String password;
- Scanner admin = new Scanner(System.in);
- System.out.println("Admin Login");
- System.out.println("Username: ");
- String username = admin.next();
- if(username.compareTo("advil0") == 0)
- {
- goodUser = true;
- }
- else
- {
- goodUser = false;
- }
- if(goodUser)
- {
- System.out.println("Password: ");
- password = admin.next();
- }
- else
- {
- return;
- }
- if(password.compareTo("herman") == 0)
- {
- }
- else
- {
- return;
- }
- SOP("Admin Menu");
- SOP("1. Return to game menu");
- SOP("2. Quit");
- int adminChoice = admin.nextInt();
- switch(adminChoice)
- {
- case 1:
- initialMenu(fromAdmin);
- break;
- case 2:
- fastQuit();
- }
- delayThreeSeconds();
- fastQuit();
- }
- public static void basicInfo()
- {
- boolean goodInfo = false;
- Scanner myScan2 = new Scanner(System.in);
- SOP("Please choose a name for your character");
- String name = myScan2.next();
- SOP("How old is your character?");
- int age = myScan2.nextInt();
- while(!goodInfo)
- {
- SOP("Are you a male or female?");
- String sex = myScan2.next();
- if( sex.compareTo("male") == 0 | sex.compareTo("Male") == 0 )
- {
- goodInfo = true;
- startGame();
- }
- if( sex.compareTo("female") == 0 | sex.compareTo("Female") == 0 )
- {
- goodInfo = true;
- startGame();
- }
- else
- {
- SOP("You can only enter male or female, try again.");
- delayOneSecond();
- goodInfo = false;
- }
- }
- }
- public static void startGame()
- {
- ArrayList al = new ArrayList();
- SOP("You have recieved your first item!");
- delayOneSecond();
- SOP("*A baseball bat appears out of nowhere, you pick it up");
- delayOneSecond();
- SOP("Gained 1 (Baseball Bat)");
- al.add("Baseball Bat");
- delayOneSecond();
- SOP( "Current inventory: " + al );
- gameMenu();
- }
- public static void gameMenu()
- {
- Scanner gameMenu = new Scanner(System.in);
- boolean done = false;
- int charLevel = 1;
- int health = 100;
- int xp = 0;
- if(done)
- {
- SOP("Test");
- }
- ArrayList al = new ArrayList();
- al.add("Baseball Bat");
- while(!done)
- {
- if( xp > 20 )
- {
- charLevel++;
- SOP("You have gained a level!");
- }
- SOP("Choose an option.");
- SOP("1. Attack a monster");
- SOP("2. Sleep and restore Health");
- SOP("3. Go to the general store to buy items");
- SOP("4. Quit game");
- SOP("5. Save Game");
- SOP("6. Save and Quit");
- int menu = gameMenu.nextInt();
- switch(menu)
- {
- case 1:
- attackMonster(health,xp);
- break;
- case 2:
- sleep(health);
- break;
- case 3:
- generalStore(al);
- break;
- case 4:
- quitGame();
- case 5:
- saveGame();
- break;
- case 6:
- saveAndQuit();
- case 7:
- fastQuit();
- }
- if( charLevel == 10 )
- {
- done = true;
- }
- }
- }
- public static void saveAndQuit()
- {
- saveGame();
- quitGame();
- }
- public static void saveGame()
- {
- SOP("Saving...");
- delayThreeSeconds();
- boolean success = true;
- if(success)
- {
- SOP("Save successful!");
- }
- if(!success)
- {
- SOP("Save unsuccessful, try again later.");
- }
- delayOneSecond();
- return;
- }
- public static void quitGame()
- {
- SOP("Quitting...");
- delayOneSecond();
- System.exit(0);
- }
- public static void fastQuit()
- {
- SOP("Fast quitting...");
- delayOneSecond();
- System.exit(0);
- }
- public static void generalStore(ArrayList al)
- {
- Scanner itemBuyer = new Scanner(System.in);
- SOP("What would you like to buy?");
- SOP("1. Giant Running Weaboo");
- int item = itemBuyer.nextInt();
- switch(item)
- {
- case 1:
- giantRunningWeaboo();
- break;
- default:
- SOP("Please choose a valid choice");
- break;
- }
- return;
- }
- public static void giantRunningWeaboo()
- {
- SOP("A great choice!");
- SOP("You have chosen the Giant Running Weaboo");
- delayOneSecond();
- SOP("Are you sure you want to purchase this item?");
- delayOneSecond();
- confirmPurchase();
- return;
- }
- public static void confirmPurchase()
- {
- boolean pass = false;
- Scanner confirm = new Scanner(System.in);
- while(!pass)
- {
- SOP("Yes or No");
- String answer = confirm.next();
- if(answer.compareTo("Yes") == 0 | answer.compareTo("yes") == 0)
- {
- SOP("Congratulations!");
- delayOneSecond();
- SOP("This item has been added to your inventory!");
- delayTwoSeconds();
- pass = true;
- }
- if(answer.compareTo("No") == 0 | answer.compareTo("no") == 0)
- {
- SOP("Sorry for the bother");
- delayOneSecond();
- pass = true;
- }
- else
- {
- SOP("Make a valid choice please");
- }
- }
- return;
- }
- public static void attackMonster(int health, int xp)
- {
- SOP("You have encountered a wild pig!");
- delayOneSecond();
- SOP("You hit it for 5 hitpoints");
- delayOneSecond();
- SOP("The pig lunges at you and hits for 20!");
- health = health - 20;
- delayOneSecond();
- SOP("You hit the pig for 5 more points and it dies!");
- delayOneSecond();
- SOP("You gained 5xp!");
- xp = xp + 5;
- delayOneSecond();
- SOP( "Current XP: " + xp );
- delayOneSecond();
- return;
- }
- public static void delayOneSecond()
- {
- try {
- Thread.sleep(1000L);
- }
- catch (Exception e) {}
- }
- public static void delayThreeSeconds()
- {
- try {
- Thread.sleep(3000L);
- }
- catch (Exception e) {}
- }
- public static void delayTwoSeconds()
- {
- try {
- Thread.sleep(2000L);
- }
- catch (Exception e) {}
- }
- public static void delayFiveSeconds()
- {
- try {
- Thread.sleep(5000L);
- }
- catch (Exception e) {}
- }
- public static int sleep(int health)
- {
- SOP("You walk into your house, lay down on the bed and get a good nights rest.");
- health = 100;
- return health;
- }
- public static void SOP(String s)
- {
- System.out.println(s);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement