Advertisement
Guest User

java 11

a guest
Dec 3rd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 29.43 KB | None | 0 0
  1. package de.unistuttgart.iaas.pse.ex04.p2;
  2.  
  3.  
  4. import java.util.Scanner;
  5. import java.text.DecimalFormat;
  6. import java.text.SimpleDateFormat;
  7. import java.util.Calendar;
  8. import java.util.Random;
  9.  
  10.  
  11.   public class Game {
  12.    
  13.     public static String one;
  14.     public static String menuTD = "=========================================";
  15.     public static String menuVoid = "|                                       |";
  16.     public static String menuRL = "=                                        =";
  17.     public static String playerLive;
  18.     private static int[] playerStats;
  19.     private static int[] playerItems;
  20.     private static int[] gameValues;
  21.     private static int[] playerLevels;
  22.     private static int[] itemStatus;
  23.     private static double[] gameValuesDb;
  24.     public static String travelId;
  25.     public static String adminAccess;
  26.  
  27.     public static int switchB = 0;
  28.     public static long startTime = System.currentTimeMillis();
  29.    
  30.  
  31.    
  32.  
  33.    
  34.   public static void gameStart() {
  35.      
  36.       playerItems();
  37.       playerStats();
  38.       gameValues();
  39.       travelMethod();
  40.       playerLive();
  41.       playerLevels();
  42.       itemStatus();
  43.  
  44.      
  45.     try{
  46.       Thread.sleep(2000);
  47.       System.out.print("RAM: ");
  48.       Thread.sleep(1000);
  49.       System.out.println("OK");
  50.       Thread.sleep(2000);
  51.       System.out.print("CPU: ");
  52.       Thread.sleep(1000);
  53.       System.out.println("OK");
  54.       Thread.sleep(3000);
  55.       System.out.println("©2017 Vincenzo Pisano [Pre-Alpha 0.2]");
  56.       loginScreen();
  57.     }
  58.     catch(Exception e){}
  59.   }
  60.  
  61.  
  62.   public static void loginScreen() {
  63.    
  64.     System.out.println("\n\n\n" + menuTD);
  65.     System.out.println("|               Game Demo               |");
  66.     System.out.println(menuTD);
  67.     System.out.println("|                 Login                 |");
  68.     System.out.println("|                                       |");
  69.     System.out.println("|1|         Enter Player Name           |");  
  70.     System.out.println(menuTD);
  71.    
  72.     System.out.print("\n\nEnter an option:  ");
  73.     Scanner loginScreenScan = new Scanner(System.in);
  74.     int loginScreenInput;
  75.     loginScreenInput = loginScreenScan.nextInt();
  76.    
  77.      
  78.    
  79.    
  80.     if(loginScreenInput == 1){
  81.      
  82.      
  83.       System.out.println("\n\n" + menuTD);
  84.       System.out.println("=           Enter Player Name           =");
  85.       System.out.println(menuTD);
  86.       System.out.print("\nEnter name:  ");
  87.      
  88.       Scanner user = new Scanner(System.in);
  89.       one = user.nextLine();
  90.    
  91.      
  92.      
  93.       int countDigits = 0;
  94.       for(int i = 0; i < one.length(); i++) {
  95.         countDigits++;
  96.       }
  97.      
  98.       if(countDigits > 3) {
  99.         mainMenu();
  100.        
  101.       } else {
  102.         System.err.println("Minimum Player Name length: 4\n\n\n");
  103.         loginScreen();
  104.       }
  105.      
  106.      
  107.      
  108.     } else {
  109.       System.err.println("Invalid input.");
  110.       loginScreen();
  111.     }
  112.    
  113.   }
  114.  
  115.   private static void playerLive() {
  116.       if(playerStats[1] > 0) {
  117.           playerLive = "ALIVE";
  118.       } else {
  119.           playerLive = "DEAD!";
  120.       }
  121.      
  122.   }
  123.  
  124.   private static void playerStats() {
  125.     playerStats = new int[4];
  126.    
  127.     playerStats[0] = 800; //Player Gold
  128.     playerStats[1] = 100; //Player HP
  129.     playerStats[2] = 100; //Player MaxHP
  130.     playerStats[3] = 0; //Player Level
  131.  
  132.   }
  133.  
  134.   private static void playerItems() {
  135.     playerItems = new int[4];
  136.    
  137.     playerItems[0] = 2; //Quick travel Tokens
  138.     playerItems[1] = 0; //small health potion
  139.     playerItems[2] = 0; //Bike 0 = not owned; 1 = owned
  140.     playerItems[3] = 5; //Founder's Crate
  141.    
  142.   }
  143.  
  144.   private static void gameValues() {
  145.     gameValues = new int[3];
  146.    
  147.     gameValues[0] = 0; //Times travelled to the shop
  148.     gameValues[1] = 12; //Time needed to travel to the shop
  149.     gameValues[2] = 1; //Bicicle durability
  150.    
  151.    
  152.     gameValuesDb = new double[1];
  153.    
  154.     gameValuesDb[0] = 20.0;
  155.   }
  156.  
  157.   private static void travelMethod() {
  158.     travelId = "Walking";
  159.   }
  160.  
  161.   private static void itemStatus() {
  162.       itemStatus = new int[1];
  163.      
  164.       itemStatus[0] = 0; //Bicicle equipped? 0 = no; 1 = yes
  165.   }
  166.  
  167.   private static void playerLevels() {
  168.       //XP PROGRESS
  169.       playerLevels = new int[9];
  170.      
  171.       playerLevels[0] = 0; //Current XP
  172.       playerLevels[1] = 10;
  173.       playerLevels[2] = 25;
  174.       playerLevels[3] = 50;
  175.       playerLevels[4] = 75;
  176.       playerLevels[5] = 100;
  177.       playerLevels[6] = 125;
  178.       playerLevels[7] = 175;
  179.       playerLevels[8] = 225;
  180.   }
  181.  
  182.   public static void mainMenu() {
  183.      
  184.       if(gameValues[2] == 0 && switchB == 0) {
  185.           gameValuesDb[0] = gameValuesDb[0] * 1.5;
  186.           playerItems[2] = 0;
  187.           switchB++;
  188.       }
  189.      
  190.       int currentXpProgress = 0;
  191.      
  192.       if(playerLevels[0] < playerLevels[1]) {
  193.           currentXpProgress = playerLevels[1];
  194.           playerStats[3] = 0;
  195.       }
  196.      
  197.       if(playerLevels[0] < playerLevels[2] && playerLevels[0] >= playerLevels[1]) {
  198.           currentXpProgress = playerLevels[2];
  199.           playerStats[3] = 1;
  200.       }
  201.       if(playerLevels[0] < playerLevels[3] && playerLevels[0] >= playerLevels[2]) {
  202.           currentXpProgress = playerLevels[3];
  203.           playerStats[3] = 2;
  204.       }
  205.       if(playerLevels[0] < playerLevels[4] && playerLevels[0] >= playerLevels[3]) {
  206.           currentXpProgress = playerLevels[4];
  207.           playerStats[3] = 3;
  208.       }
  209.       if(playerLevels[0] < playerLevels[5] && playerLevels[0] >= playerLevels[4]) {
  210.           currentXpProgress = playerLevels[5];
  211.           playerStats[3] = 4;
  212.       }
  213.       if(playerLevels[0] < playerLevels[6] && playerLevels[0] >= playerLevels[5]) {
  214.           currentXpProgress = playerLevels[6];
  215.           playerStats[3] = 5;
  216.       }
  217.       if(playerLevels[0] < playerLevels[7] && playerLevels[0] >= playerLevels[6]) {
  218.           currentXpProgress = playerLevels[7];
  219.           playerStats[3] = 6;
  220.       }
  221.       if(playerLevels[0] < playerLevels[8] && playerLevels[0] >= playerLevels[7]) {
  222.           currentXpProgress = playerLevels[8];
  223.           playerStats[3] = 7;
  224.       }
  225.      
  226.      
  227.      
  228.       if(playerLevels[0] >= playerLevels[8]) {
  229.           playerLevels[0] = playerLevels[8];
  230.           currentXpProgress = playerLevels[8];
  231.           playerStats[3] = 8;
  232.       }
  233.      
  234.      
  235.       DecimalFormat df = new DecimalFormat("#.#");
  236.      
  237.       if(playerStats[1] > 0) {
  238.           playerLive = "ALIVE";
  239.       } else {
  240.           playerLive = "DEAD!";
  241.       }
  242.    
  243.     String playerNameCaps = one.toUpperCase();
  244.    
  245.     Calendar cal = Calendar.getInstance();
  246.     SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
  247.    
  248.     System.out.println("\n\n");
  249.     System.out.println(menuTD);
  250.     System.out.println("| [Time  "+ sdf.format(cal.getTime()) +"]                   " + playerLive + " |");
  251.     System.out.println(menuTD);
  252.     System.out.println("| Player: " + playerNameCaps);
  253.     System.out.println("|                    ");
  254.     System.out.println("| Gold: " + playerStats[0]);
  255.     System.out.println("| HP: " + playerStats[1] + "/" + playerStats[2]);
  256.     System.out.println("| Level: " + playerStats[3] + " (" + playerLevels[0] + "/" + currentXpProgress + " EXP)");
  257.     System.out.println(menuTD);
  258.     System.out.println("|                Tavern                 |");
  259.     System.out.println(menuTD);
  260.     System.out.println("|1|           Shop (" + df.format(gameValuesDb[0]) + "sec)       ");
  261.     System.out.println("|2|            Inventory                |");
  262.     System.out.println("|3|            Statistics               |");
  263.     System.out.println(menuTD);
  264.     System.out.print("\n\nEnter an option:  ");
  265.    
  266.    
  267.     Scanner menu = new Scanner(System.in);
  268.     int menuInput;
  269.     menuInput = menu.nextInt();
  270.    
  271.     if(menuInput == 1) {
  272.       System.out.flush();
  273.       shopWalk();
  274.      
  275.     }
  276.    
  277.     if(menuInput == 2) {
  278.         inventory();
  279.     }
  280.  
  281.     if(menuInput == 3) {
  282.         statistics();
  283.     }
  284.    
  285.     if(menuInput == 0) {
  286.         adminPannel();
  287.     }
  288.  
  289.  
  290.   }
  291.  
  292.   public static void shopWalk() {
  293.     if(playerItems[2] == 1) {
  294.         travelId = "Bike";
  295.     }
  296.    
  297.     DecimalFormat df = new DecimalFormat("#.#");
  298.    
  299.     System.out.println("\n");
  300.     System.out.println(menuTD);
  301.     System.out.println("|                  Shop                 |");
  302.     System.out.println(menuTD);
  303.     System.out.println("| You are currently walking to the shop |");
  304.     System.out.println("|            Duration: " + df.format(gameValuesDb[0]) + "sec          ");
  305.     System.out.println(menuTD);
  306.    
  307.     if(playerItems[0] == 0){
  308.       gameValues[0] += 1;
  309.       double i;
  310.       try {
  311.         for(i = gameValuesDb[0]; i > -1; i--){
  312.           System.out.print((int)i + "•");
  313.           System.out.flush();
  314.           Thread.sleep(1000);
  315.      
  316.             if(i <= 1){
  317.                 if(playerItems[2] == 1) {
  318.                     gameValues[2] = gameValues[2] - 1;
  319.                 }
  320.               shop();
  321.             }
  322.         }
  323.       } catch(Exception e) {  }
  324.     }
  325.    
  326.     if(playerItems[0] > 0){
  327.       System.out.println("| Tokens left: " + playerItems[0] + "                        |");
  328.       System.out.println("| You are traveling by: " + travelId);
  329.       System.out.println(menuTD);
  330.       System.out.println("Do you want to use your Quick Travel Token?");
  331.       System.out.print("[Y/N]    ");
  332.      
  333.       Scanner scan = new Scanner(System.in);
  334.       String input = scan.nextLine();
  335.      
  336.       String temp = "Y";
  337.       if(input.equals(temp)){
  338.         gameValues[0] += 1;
  339.         changeToken();
  340.         scan.close();
  341.        
  342.       } else {
  343.         gameValues[0] += 1;
  344.        
  345.         double i;
  346.         try {
  347.         for(i = gameValuesDb[0]; i > -1; i--){
  348.           System.out.print((int)i + "•");
  349.           System.out.flush();
  350.           Thread.sleep(1000);
  351.      
  352.             if(i <= 0.99){
  353.                 if(playerItems[2] == 1) {
  354.                     gameValues[2] = gameValues[2] - 1;
  355.                 }
  356.                 shop();
  357.                 scan.close();
  358.                
  359.             }
  360.            
  361.         }
  362.       } catch(Exception e) {  }
  363.        
  364.       }
  365.      
  366.     }
  367.   }
  368.  
  369.   public static void changeToken() {
  370.      playerItems[0] -= 1;
  371.      shop();
  372.   }
  373.  
  374.   public static void shop() {
  375.    
  376.     System.out.println("\n\n" + menuTD);
  377.     System.out.println("|                  Shop                 |");
  378.     System.out.println(menuTD);
  379.     System.out.println("| Gold:  " + playerStats[0] + "                            ");
  380.     System.out.println("| Level: " + playerStats[3] + "                              |");
  381.     System.out.println(menuTD);
  382.     System.out.println("|             Purchase Items            |");
  383.     System.out.println(menuVoid);
  384.     System.out.println("|1|         Health Potion [25G]         |");
  385.     System.out.println(menuTD);
  386.     System.out.println("|            Purchase Vehicles          |");
  387.     System.out.println(menuVoid);
  388.     System.out.println("|2|             Bike [300G]             |");
  389.     System.out.println("|3|             Motorcycle              |");
  390.     System.out.println("|4|             Small Plane             |");
  391.     System.out.println(menuTD);
  392.     System.out.println("|0|                Exit                 |");
  393.     System.out.println(menuTD);
  394.    
  395.     System.out.print("\n\nEnter an option:  ");
  396.     Scanner shopInput = new Scanner(System.in);
  397.     int shopInputInt = shopInput.nextInt();
  398.    
  399.     if(shopInputInt == 1) {
  400.       System.out.println(menuTD);
  401.       System.out.println("|           Shop (Health Potion)        |");
  402.       System.out.println(menuTD);
  403.       System.out.println("| Health regeneration: 10HP             |");
  404.       System.out.println("| Durability: 1                         |");
  405.       System.out.println(menuTD);
  406.       System.out.println("|0|                Exit                 |");
  407.       System.out.println(menuTD);
  408.  
  409.       System.out.print("Enter the amount of potions you want to buy: ");
  410.      
  411.       Scanner potion = new Scanner(System.in);
  412.       int potionAmount = potion.nextInt();
  413.       if(potionAmount == 0) {
  414.           shop();
  415.           potion.close();
  416.       }
  417.       int priceFinal = potionAmount * 25;
  418.      
  419.       if(priceFinal <= playerStats[0]) {
  420.         playerStats[0] = playerStats[0] - priceFinal;
  421.         playerItems[1] += potionAmount;
  422.         System.out.println("ok");
  423.         shop();
  424.       }
  425.       if(priceFinal > playerStats[0]) {
  426.         System.err.println("Come back later when you have more gold!");
  427.         shop();
  428.       }
  429.    
  430.         shopInput.close();
  431.     }
  432.     if(shopInputInt == 2) {
  433.       System.out.println(menuTD);
  434.       System.out.println("|               Shop (Bike)             |");
  435.       System.out.println(menuTD);
  436.       System.out.println("| Requirements:                         |");
  437.       System.out.println("| Level: 5                              |");
  438.       System.out.println("| Cost:  300 Gold                       |");
  439.       System.out.println(menuTD);
  440.       System.out.println("| Speed: 1.5                            |");
  441.       System.out.println("| Durability: 20                        |");
  442.       System.out.println(menuTD);
  443.       System.out.println("|1|              Purchase               |");
  444.       System.out.println("|0|                Exit                 |");
  445.       System.out.println(menuTD);
  446.      
  447.       Scanner shopBike = new Scanner(System.in);
  448.       int bikePurchase = shopBike.nextInt();
  449.       if(bikePurchase == 0) {
  450.           shop();
  451.           shopBike.close();
  452.       }
  453.       if(bikePurchase == 1) {
  454.           if(playerStats[0] < 300) {
  455.               System.err.println("Come back later when you have more gold!");
  456.               shop();
  457.           }
  458.           if(playerStats[0] >= 300) {
  459.               playerStats[0] = playerStats[0] - 300;
  460.               playerItems[2] = 1;
  461.               gameValues[2] = 1;
  462.               switchB = 0;
  463.              
  464.                
  465.               shop();
  466.              
  467.           }
  468.       }
  469.     }
  470.     else {
  471.      
  472.       mainMenu();
  473.      
  474.     }
  475.   }
  476.  
  477.   public static void inventory() {
  478.       String equip = "";
  479.       if(itemStatus[0] == 0) {
  480.           equip = "[not equipped]";
  481.       } else {
  482.           equip = "[equipped]";
  483.       }
  484.       String bike = "";
  485.       if(playerItems[2] == 0) {
  486.           bike = "no                           ";
  487.       }
  488.       if(playerItems[2] == 1 && itemStatus[0] == 0) {
  489.           bike = "yes (" + gameValues[2] + "/20)" + equip + "     ";
  490.       }
  491.       if(playerItems[2] == 1 && itemStatus[0] == 1) {
  492.           bike = "yes (" + gameValues[2] + "/20)" + equip + "         ";
  493.       }
  494.       System.out.println("\n" + menuTD);
  495.       System.out.println("|               Inventory               |");
  496.       System.out.println(menuTD);
  497.       System.out.println("| |  Items:                             |");
  498.       System.out.println("|1|  Tokens: " + playerItems[0] + "                          |");
  499.       System.out.println("|2|  Health Potions: " + playerItems[1] + "                  |");
  500.       System.out.println(menuTD);
  501.       System.out.println("| |  Vehicles:                          |");
  502.       System.out.println("|3|  Bike: " + bike + "|");
  503.       System.out.println(menuTD);
  504.       System.out.println("| |  Lootcrates:                        |");
  505.       System.out.println("|4|  Founder's Crate: " + playerItems[3] + "                 |");
  506.       System.out.println(menuTD);
  507.       System.out.println("|0|               Exit                  |");
  508.       System.out.println(menuTD);
  509.      
  510.       System.out.print("\n\nEnter an option:  ");
  511.       Scanner inventoryInput = new Scanner(System.in);
  512.         int inventoryInputInt = inventoryInput.nextInt();
  513.        
  514.        
  515.         if(inventoryInputInt == 3) {
  516.             if(playerItems[2] == 1 && gameValues[2] > 0) {
  517.                 gameValuesDb[0] = gameValuesDb[0] / 1.5;
  518.                 if(itemStatus[0] == 0) {
  519.                     itemStatus[0] = 1;
  520.                 } else {
  521.                     itemStatus[0] = 0;
  522.                 }
  523.                
  524.             }
  525.             inventory();
  526.         }
  527.         if(inventoryInputInt == 4) {
  528.             System.out.println("\n" + menuTD);
  529.             System.out.println("|           Inventory (Tokens)          |");
  530.             System.out.println(menuTD);
  531.             System.out.println("| |      Founder's Crate left: " + playerItems[3] + "        |");
  532.             System.out.println("| |                                     |");
  533.             System.out.println("| |The Founder's Crate, one of the very |");
  534.             System.out.println("| |first starter rewards to be found.   |");
  535.             System.out.println(menuTD);
  536.             System.out.println("| |Durability: 1        Craftable: false|");
  537.             System.out.println(menuTD);
  538.             System.out.println("|1|            Open Crate               |");
  539.             System.out.println("|0|               Exit                  |");
  540.             System.out.println(menuTD);
  541.            
  542.             System.out.print("\n\nEnter an option:  ");
  543.             int inventoryInputDescription4Int = inventoryInput.nextInt();
  544.            
  545.             if(inventoryInputDescription4Int == 0) {
  546.                 inventory();
  547.                 inventoryInput.close();
  548.             }
  549.             if(inventoryInputDescription4Int == 1) {
  550.                
  551.                 if(playerItems[3] == 0) {
  552.                     System.err.println("You don't own this many Founder's Crates!");
  553.                     inventory();
  554.                 }
  555.                 if(playerItems[3] >= 1) {
  556.                     playerItems[3] = playerItems[3] - 1;
  557.                    
  558.                     Random rand = new Random();
  559.                     int random = rand.nextInt(3);
  560.                    
  561.                     if(random == 0) {
  562.                         System.out.println("\nYou recieved nothing");
  563.                         inventory();
  564.                     }
  565.                     if(random == 1) {
  566.                         Random randHealth = new Random();
  567.                         int randomHealth = randHealth.nextInt(3) + 1;
  568.                         playerItems[1] = playerItems[1] + randomHealth;
  569.                         if(randomHealth == 1) {
  570.                             System.out.println("\nYou recieved " + randomHealth + " health Potion");
  571.                             inventory();
  572.                         }
  573.                         if(randomHealth > 1) {
  574.                             System.out.println("\nYou recieved " + randomHealth + " health Potions");
  575.                             inventory();
  576.                         }
  577.                     }
  578.                     if(random > 1) {
  579.                         Random randHealth2 = new Random();
  580.                         int randomHealth2 = randHealth2.nextInt(3) + 1;
  581.                         playerItems[1] = playerItems[1] + randomHealth2;
  582.                        
  583.                         Random randToken = new Random();
  584.                         int randomToken = randToken.nextInt(2) + 1;
  585.                         playerItems[0] = playerItems[0] + randomToken;
  586.                        
  587.                         if(randomHealth2 == 1 && randomToken > 1) {
  588.                             System.out.println("\nYou recieved " + randomHealth2 + " health Potion and " + randomToken + " Tokens");
  589.                             inventory();
  590.                         }
  591.                         if(randomHealth2 == 1 && randomToken == 1) {
  592.                             System.out.println("\nYou recieved " + randomHealth2 + " health Potion and " + randomToken + " Token");
  593.                             inventory();
  594.                         }
  595.                         if(randomHealth2 > 1 && randomToken > 1) {
  596.                             System.out.println("\nYou recieved " + randomHealth2 + " health Potions and " + randomToken + " Tokens");
  597.                             inventory();
  598.                         }
  599.                         if(randomHealth2 > 1 && randomToken == 1) {
  600.                             System.out.println("\nYou recieved " + randomHealth2 + " health Potions and " + randomToken + " Token");
  601.                             inventory();
  602.                         }
  603.                        
  604.                     }
  605.                    
  606.                 }
  607.             }
  608.            
  609.         }
  610.         if(inventoryInputInt == 1) {
  611.             System.out.println("\n" + menuTD);
  612.             System.out.println("|           Inventory (Tokens)          |");
  613.             System.out.println(menuTD);
  614.             System.out.println("| |Tokens enable fast travel to the     |");
  615.             System.out.println("| |shop.                                |");
  616.             System.out.println(menuTD);
  617.             System.out.println("| |Durability: 1        Craftable: false|");
  618.             System.out.println(menuTD);
  619.             System.out.println("|0|               Exit                  |");
  620.             System.out.println(menuTD);
  621.  
  622.            
  623.             System.out.print("\n\nEnter an option:  ");
  624.            
  625.             int inventoryInputDescription1Int = inventoryInput.nextInt();
  626.             if(inventoryInputDescription1Int == 0) {
  627.                 inventory();
  628.                 inventoryInput.close();
  629.             }
  630.             inventoryInput.close();
  631.         }
  632.         if(inventoryInputInt == 2) {
  633.           System.out.println("\n" + menuTD);
  634.           System.out.println("|       Inventory (Health Potion)       |");
  635.           System.out.println(menuTD);
  636.           System.out.println("| |Health regeneration: 10HP            |");
  637.           System.out.println("| |Health potions left: " + playerItems[1] +"               |");
  638.           System.out.println(menuVoid);
  639.           System.out.println("| |Durability: 1         Craftable: true|");
  640.           System.out.println(menuTD);
  641.           System.out.println("|1|           Use Potions               |");
  642.           System.out.println("|0|               Exit                  |");
  643.           System.out.println(menuTD);
  644.          
  645.          
  646.           System.out.print("\n\nEnter an option:  ");
  647.             int inventoryInputDescription2Int = inventoryInput.nextInt();
  648.             if(inventoryInputDescription2Int == 0) {
  649.                 inventory();
  650.                 inventoryInput.close();
  651.             }
  652.             if(inventoryInputDescription2Int == 1) {
  653.                 System.out.print("Enter how many Health Potions you want to use: ");
  654.          
  655.                 Scanner potionInput = new Scanner(System.in);
  656.                 int potionAmount = potionInput.nextInt();
  657.          
  658.                 if(potionAmount > playerItems[1]) {
  659.                     System.err.println("You don't own this many Health Potions!");
  660.                     inventory();
  661.                 }
  662.                 if(potionAmount <= playerItems[1]) {
  663.                     playerItems[1] = playerItems[1] - potionAmount;
  664.                    
  665.                     if(playerStats[1] < 100) {
  666.                         playerStats[1] += (10 * potionAmount);
  667.                         inventory();
  668.                     }
  669.                     if(playerStats[1] == 100) {
  670.                         System.err.println("\nYour HP is already full!");
  671.                         playerItems[1] = playerItems[1] + potionAmount;
  672.                         inventory();
  673.                     }
  674.                     if(playerStats[1] > playerStats[2]) {
  675.                         playerStats[1] = playerStats[2];
  676.                         inventory();
  677.                     }
  678.                     if(playerStats[1] <= playerStats[2]) {
  679.                         inventory();
  680.                     }
  681.                 }
  682.             }
  683.         }
  684.         else {
  685.          
  686.           mainMenu();
  687.          
  688.         }
  689.   }
  690.  
  691.  
  692.  
  693.  
  694.   public static void statistics() {
  695.       long elapsedTime = System.currentTimeMillis() - startTime;
  696.       long elapsedSeconds = elapsedTime / 1000;
  697.       long secondsDisplay = elapsedSeconds % 60;      
  698.       long elapsedMinutes = elapsedSeconds / 60;
  699.  
  700.       String str = secondsDisplay < 10 ? "0" + secondsDisplay : "" + secondsDisplay;
  701.      
  702.       System.out.println("\n" + menuTD);
  703.       System.out.println("|               Statistics              |");
  704.       System.out.println(menuTD);
  705.       System.out.println("|Playtime:  " + elapsedMinutes + ":" + str + " Minutes                |");
  706.       System.out.println(menuVoid);
  707.       System.out.println("|Times travelled to the shop:  " + gameValues[0] + "        |");
  708.       System.out.println(menuTD);
  709.       System.out.println("|0|               Exit                  |");
  710.       System.out.println(menuTD);
  711.      
  712.       System.out.print("\n\nEnter an option:  ");
  713.         Scanner statisticsInput = new Scanner(System.in);
  714.         int statisticsInputInt = statisticsInput.nextInt();
  715.        
  716.         if(statisticsInputInt == 0) {
  717.             mainMenu();
  718.             statisticsInput.close();
  719.         }
  720.   }
  721.  
  722.   private static void adminPannel() {
  723.       adminAccess = "betterberich";
  724.       System.out.print("\n\nPassword:  ");
  725.       Scanner passwordInput = new Scanner(System.in);
  726.       String password = passwordInput.nextLine();
  727.      
  728.       if(password.equals(adminAccess)) {
  729.           System.out.println("\n\n");
  730.           System.out.println(menuTD);
  731.           System.out.println("|              Admin Pannel             |");
  732.           System.out.println(menuTD);
  733.           System.out.println("|1|              Add Gold               |");
  734.           System.out.println("|2|               Add XP                |");
  735.           System.out.println("|3|              Change HP              |");
  736.           System.out.println("|4|            Change MaxHP             |");
  737.           System.out.println("|5|            Change Level             |");
  738.           System.out.println("|6|            System Value             |");
  739.           System.out.println(menuTD);
  740.           System.out.println("|0|               Exit                  |");
  741.           System.out.println(menuTD);
  742.          
  743.           System.out.print("\n\nEnter an option:  ");
  744.             Scanner adminPannel = new Scanner(System.in);
  745.             int adminPannelInt = adminPannel.nextInt();
  746.              
  747.             if(adminPannelInt == 0) {
  748.               mainMenu();
  749.               adminPannel.close();
  750.               passwordInput.close();
  751.             }
  752.             if(adminPannelInt == 1) {
  753.                 System.out.println(menuTD);
  754.                 System.out.println("|              Admin Pannel             |");
  755.                 System.out.println(menuTD);
  756.                 System.out.println("| | Enter a value to add Gold           |");
  757.                 System.out.println(menuTD);
  758.                
  759.                 System.out.print("\nGold to add:  ");
  760.                     Scanner goldAdd = new Scanner(System.in);
  761.                     int goldAddInt = goldAdd.nextInt();
  762.                    
  763.                     playerStats[0] += goldAddInt;
  764.                    
  765.                     if(playerStats[0] < 0) {
  766.                         playerStats[0] = 0;
  767.                        
  768.                     }
  769.                     mainMenu();
  770.                     goldAdd.close();
  771.                
  772.             }
  773.             if(adminPannelInt == 2) {
  774.                 System.out.println(menuTD);
  775.                 System.out.println("|              Admin Pannel             |");
  776.                 System.out.println(menuTD);
  777.                 System.out.println("| | Enter a value to add to your XP     |");
  778.                 System.out.println(menuTD);
  779.                 System.out.print("\nChange XP to:  ");
  780.                     Scanner changeXP = new Scanner(System.in);
  781.                     int changeXPInt = changeXP.nextInt();
  782.                    
  783.                     playerLevels[0] += changeXPInt;
  784.                     if(playerLevels[0] < 0) {
  785.                         playerLevels[0] = 0;
  786.                        
  787.                        
  788.                     }
  789.                     mainMenu();
  790.                     changeXP.close();
  791.  
  792.             }
  793.            
  794.             if(adminPannelInt == 3) {
  795.                 System.out.println(menuTD);
  796.                 System.out.println("|              Admin Pannel             |");
  797.                 System.out.println(menuTD);
  798.                 System.out.println("| | Enter a value to change your HP     |");
  799.                 System.out.println(menuTD);
  800.                
  801.                 System.out.print("\nSet HP to:  ");
  802.                     Scanner changeHP = new Scanner(System.in);
  803.                     int changeHPInt = changeHP.nextInt();
  804.                
  805.                     playerStats[1] = changeHPInt;
  806.                    
  807.                     if(playerStats[1] < 0) {
  808.                         playerStats[1] = 0;
  809.                        
  810.                        
  811.                     }
  812.                     if(playerStats[1] > playerStats[2]) {
  813.                         playerStats[1] = playerStats[2];   
  814.                        
  815.                     }
  816.                     mainMenu();
  817.                     changeHP.close();
  818.                    
  819.             }
  820.             if(adminPannelInt == 4) {
  821.                 System.out.println(menuTD);
  822.                 System.out.println("|              Admin Pannel             |");
  823.                 System.out.println(menuTD);
  824.                 System.out.println("| | Enter a value to change your MaxHP  |");
  825.                 System.out.println(menuTD);
  826.                
  827.                 System.out.print("\nSet MaxHP to:  ");
  828.                     Scanner changeMaxHP = new Scanner(System.in);
  829.                     int changeMaxHPInt = changeMaxHP.nextInt();
  830.                
  831.                     playerStats[2] = changeMaxHPInt;
  832.                    
  833.                     if(playerStats[2] < 1) {
  834.                         playerStats[2] = 1;
  835.                         if(playerStats[1] > playerStats[2]) {
  836.                             playerStats[1] = playerStats[2];
  837.                         }
  838.                        
  839.                        
  840.                     }
  841.                     mainMenu();
  842.                     changeMaxHP.close();
  843.            
  844.             }
  845.             if(adminPannelInt == 5) {
  846.                 System.out.println(menuTD);
  847.                 System.out.println("|              Admin Pannel             |");
  848.                 System.out.println(menuTD);
  849.                 System.out.println("| | Enter a value to change your Level  |");
  850.                 System.out.println(menuTD);
  851.                
  852.                 System.out.print("\nSet Level to:  ");
  853.                     Scanner changeLevel = new Scanner(System.in);
  854.                     int changeLevelInt = changeLevel.nextInt();
  855.                    
  856.                     playerStats[3] = changeLevelInt;
  857.                     if(playerStats[3] < 0) {
  858.                         playerStats[3] = 0;
  859.                     }
  860.                     mainMenu();
  861.                     changeLevel.close();
  862.             }
  863.             if(adminPannelInt == 6) {
  864.                
  865.                   System.out.println(menuTD);
  866.                   System.out.println("|              Admin Pannel             |");
  867.                   System.out.println(menuTD);
  868.                   System.out.println("| |Proceed with Caution! Changing system|");
  869.                   System.out.println("| |values might result in major game    |");
  870.                   System.out.println("| |bugs                                 |");
  871.                   System.out.println(menuTD);
  872.                   System.out.println("|1|       Change Shop travel time       |");
  873.                   System.out.println("|2|                                     |");
  874.                   System.out.println("|3|                                     |");
  875.                   System.out.println(menuTD);
  876.                   System.out.println("|0|               Exit                  |");
  877.                   System.out.println(menuTD);
  878.                  
  879.                   System.out.print("\n\nEnter an option:  ");
  880.                     Scanner systemPannel = new Scanner(System.in);
  881.                     int systemPannelInt = systemPannel.nextInt();
  882.                      
  883.                     if(systemPannelInt == 0) {
  884.                       mainMenu();
  885.                       systemPannel.close();
  886.                     }
  887.             } else {
  888.                 adminPannel();
  889.             }
  890.          
  891.       } else {
  892.           System.out.println("**Denied**");
  893.           mainMenu();
  894.           passwordInput.close();
  895.       }
  896.      
  897.   }
  898.  
  899.   public static void main(String[] args) {
  900.     gameStart();
  901.   }
  902. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement