Advertisement
Guest User

java 10

a guest
Dec 3rd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 29.28 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 + "    Gold: " + playerStats[0] +"  HP: " + playerStats[1] + "/" + playerStats[2]);
  253.     System.out.println("|                    Level: " + playerStats[3] + " (" + playerLevels[0] + "/" + currentXpProgress + " EXP)");
  254.     System.out.println(menuTD);
  255.     System.out.println("|                Tavern                 |");
  256.     System.out.println(menuTD);
  257.     System.out.println("|1|           Shop (" + df.format(gameValuesDb[0]) + "sec)       ");
  258.     System.out.println("|2|            Inventory                |");
  259.     System.out.println("|3|            Statistics               |");
  260.     System.out.println(menuTD);
  261.     System.out.print("\n\nEnter an option:  ");
  262.    
  263.    
  264.     Scanner menu = new Scanner(System.in);
  265.     int menuInput;
  266.     menuInput = menu.nextInt();
  267.    
  268.     if(menuInput == 1) {
  269.       System.out.flush();
  270.       shopWalk();
  271.      
  272.     }
  273.    
  274.     if(menuInput == 2) {
  275.         inventory();
  276.     }
  277.  
  278.     if(menuInput == 3) {
  279.         statistics();
  280.     }
  281.    
  282.     if(menuInput == 0) {
  283.         adminPannel();
  284.     }
  285.  
  286.  
  287.   }
  288.  
  289.   public static void shopWalk() {
  290.     if(playerItems[2] == 1) {
  291.         travelId = "Bike";
  292.     }
  293.    
  294.     DecimalFormat df = new DecimalFormat("#.#");
  295.    
  296.     System.out.println("\n");
  297.     System.out.println(menuTD);
  298.     System.out.println("|                  Shop                 |");
  299.     System.out.println(menuTD);
  300.     System.out.println("| You are currently walking to the shop |");
  301.     System.out.println("|            Duration: " + df.format(gameValuesDb[0]) + "sec          ");
  302.     System.out.println(menuTD);
  303.    
  304.     if(playerItems[0] == 0){
  305.       gameValues[0] += 1;
  306.       double i;
  307.       try {
  308.         for(i = gameValuesDb[0]; i > -1; i--){
  309.           System.out.print((int)i + "•");
  310.           System.out.flush();
  311.           Thread.sleep(1000);
  312.      
  313.             if(i <= 1){
  314.                 if(playerItems[2] == 1) {
  315.                     gameValues[2] = gameValues[2] - 1;
  316.                 }
  317.               shop();
  318.             }
  319.         }
  320.       } catch(Exception e) {  }
  321.     }
  322.    
  323.     if(playerItems[0] > 0){
  324.       System.out.println("| Tokens left: " + playerItems[0] + "                        |");
  325.       System.out.println("| You are traveling by: " + travelId);
  326.       System.out.println(menuTD);
  327.       System.out.println("Do you want to use your Quick Travel Token?");
  328.       System.out.print("[Y/N]    ");
  329.      
  330.       Scanner scan = new Scanner(System.in);
  331.       String input = scan.nextLine();
  332.      
  333.       String temp = "Y";
  334.       if(input.equals(temp)){
  335.         gameValues[0] += 1;
  336.         changeToken();
  337.         scan.close();
  338.        
  339.       } else {
  340.         gameValues[0] += 1;
  341.        
  342.         double i;
  343.         try {
  344.         for(i = gameValuesDb[0]; i > -1; i--){
  345.           System.out.print((int)i + "•");
  346.           System.out.flush();
  347.           Thread.sleep(1000);
  348.      
  349.             if(i <= 0.99){
  350.                 if(playerItems[2] == 1) {
  351.                     gameValues[2] = gameValues[2] - 1;
  352.                 }
  353.                 shop();
  354.                 scan.close();
  355.                
  356.             }
  357.            
  358.         }
  359.       } catch(Exception e) {  }
  360.        
  361.       }
  362.      
  363.     }
  364.   }
  365.  
  366.   public static void changeToken() {
  367.      playerItems[0] -= 1;
  368.      shop();
  369.   }
  370.  
  371.   public static void shop() {
  372.    
  373.     System.out.println("\n\n" + menuTD);
  374.     System.out.println("|                  Shop                 |");
  375.     System.out.println(menuTD);
  376.     System.out.println("| Gold:  " + playerStats[0] + "                            ");
  377.     System.out.println("| Level: " + playerStats[3] + "                              |");
  378.     System.out.println(menuTD);
  379.     System.out.println("|             Purchase Items            |");
  380.     System.out.println(menuVoid);
  381.     System.out.println("|1|         Health Potion [25G]         |");
  382.     System.out.println(menuTD);
  383.     System.out.println("|            Purchase Vehicles          |");
  384.     System.out.println(menuVoid);
  385.     System.out.println("|2|             Bike [300G]             |");
  386.     System.out.println("|3|             Motorcycle              |");
  387.     System.out.println("|4|             Small Plane             |");
  388.     System.out.println(menuTD);
  389.     System.out.println("|0|                Exit                 |");
  390.     System.out.println(menuTD);
  391.    
  392.     System.out.print("\n\nEnter an option:  ");
  393.     Scanner shopInput = new Scanner(System.in);
  394.     int shopInputInt = shopInput.nextInt();
  395.    
  396.     if(shopInputInt == 1) {
  397.       System.out.println(menuTD);
  398.       System.out.println("|           Shop (Health Potion)        |");
  399.       System.out.println(menuTD);
  400.       System.out.println("| Health regeneration: 10HP             |");
  401.       System.out.println("| Durability: 1                         |");
  402.       System.out.println(menuTD);
  403.       System.out.println("|0|                Exit                 |");
  404.       System.out.println(menuTD);
  405.  
  406.       System.out.print("Enter the amount of potions you want to buy: ");
  407.      
  408.       Scanner potion = new Scanner(System.in);
  409.       int potionAmount = potion.nextInt();
  410.       if(potionAmount == 0) {
  411.           shop();
  412.           potion.close();
  413.       }
  414.       int priceFinal = potionAmount * 25;
  415.      
  416.       if(priceFinal <= playerStats[0]) {
  417.         playerStats[0] = playerStats[0] - priceFinal;
  418.         playerItems[1] += potionAmount;
  419.         System.out.println("ok");
  420.         shop();
  421.       }
  422.       if(priceFinal > playerStats[0]) {
  423.         System.err.println("Come back later when you have more gold!");
  424.         shop();
  425.       }
  426.    
  427.         shopInput.close();
  428.     }
  429.     if(shopInputInt == 2) {
  430.       System.out.println(menuTD);
  431.       System.out.println("|               Shop (Bike)             |");
  432.       System.out.println(menuTD);
  433.       System.out.println("| Requirements:                         |");
  434.       System.out.println("| Level: 5                              |");
  435.       System.out.println("| Cost:  300 Gold                       |");
  436.       System.out.println(menuTD);
  437.       System.out.println("| Speed: 1.5                            |");
  438.       System.out.println("| Durability: 20                        |");
  439.       System.out.println(menuTD);
  440.       System.out.println("|1|              Purchase               |");
  441.       System.out.println("|0|                Exit                 |");
  442.       System.out.println(menuTD);
  443.      
  444.       Scanner shopBike = new Scanner(System.in);
  445.       int bikePurchase = shopBike.nextInt();
  446.       if(bikePurchase == 0) {
  447.           shop();
  448.           shopBike.close();
  449.       }
  450.       if(bikePurchase == 1) {
  451.           if(playerStats[0] < 300) {
  452.               System.err.println("Come back later when you have more gold!");
  453.               shop();
  454.           }
  455.           if(playerStats[0] >= 300) {
  456.               playerStats[0] = playerStats[0] - 300;
  457.               playerItems[2] = 1;
  458.               gameValues[2] = 1;
  459.               switchB = 0;
  460.              
  461.                
  462.               shop();
  463.              
  464.           }
  465.       }
  466.     }
  467.     else {
  468.      
  469.       mainMenu();
  470.      
  471.     }
  472.   }
  473.  
  474.   public static void inventory() {
  475.       String equip = "";
  476.       if(itemStatus[0] == 0) {
  477.           equip = "[not equipped]";
  478.       } else {
  479.           equip = "[equipped]";
  480.       }
  481.       String bike = "";
  482.       if(playerItems[2] == 0) {
  483.           bike = "no                           ";
  484.       }
  485.       if(playerItems[2] == 1 && itemStatus[0] == 0) {
  486.           bike = "yes (" + gameValues[2] + "/20)" + equip + "     ";
  487.       }
  488.       if(playerItems[2] == 1 && itemStatus[0] == 1) {
  489.           bike = "yes (" + gameValues[2] + "/20)" + equip + "         ";
  490.       }
  491.       System.out.println("\n" + menuTD);
  492.       System.out.println("|               Inventory               |");
  493.       System.out.println(menuTD);
  494.       System.out.println("| |  Items:                             |");
  495.       System.out.println("|1|  Tokens: " + playerItems[0] + "                          |");
  496.       System.out.println("|2|  Health Potions: " + playerItems[1] + "                  |");
  497.       System.out.println(menuTD);
  498.       System.out.println("| |  Vehicles:                          |");
  499.       System.out.println("|3|  Bike: " + bike + "|");
  500.       System.out.println(menuTD);
  501.       System.out.println("| |  Lootcrates:                        |");
  502.       System.out.println("|4|  Founder's Crate: " + playerItems[3] + "                 |");
  503.       System.out.println(menuTD);
  504.       System.out.println("|0|               Exit                  |");
  505.       System.out.println(menuTD);
  506.      
  507.       System.out.print("\n\nEnter an option:  ");
  508.       Scanner inventoryInput = new Scanner(System.in);
  509.         int inventoryInputInt = inventoryInput.nextInt();
  510.        
  511.        
  512.         if(inventoryInputInt == 3) {
  513.             if(playerItems[2] == 1 && gameValues[2] > 0) {
  514.                 gameValuesDb[0] = gameValuesDb[0] / 1.5;
  515.                 if(itemStatus[0] == 0) {
  516.                     itemStatus[0] = 1;
  517.                 } else {
  518.                     itemStatus[0] = 0;
  519.                 }
  520.                
  521.             }
  522.             inventory();
  523.         }
  524.         if(inventoryInputInt == 4) {
  525.             System.out.println("\n" + menuTD);
  526.             System.out.println("|           Inventory (Tokens)          |");
  527.             System.out.println(menuTD);
  528.             System.out.println("| |      Founder's Crate left: " + playerItems[3] + "        |");
  529.             System.out.println("| |                                     |");
  530.             System.out.println("| |The Founder's Crate, one of the very |");
  531.             System.out.println("| |first starter rewards to be found.   |");
  532.             System.out.println(menuTD);
  533.             System.out.println("| |Durability: 1        Craftable: false|");
  534.             System.out.println(menuTD);
  535.             System.out.println("|1|            Open Crate               |");
  536.             System.out.println("|0|               Exit                  |");
  537.             System.out.println(menuTD);
  538.            
  539.             System.out.print("\n\nEnter an option:  ");
  540.             int inventoryInputDescription4Int = inventoryInput.nextInt();
  541.            
  542.             if(inventoryInputDescription4Int == 0) {
  543.                 inventory();
  544.                 inventoryInput.close();
  545.             }
  546.             if(inventoryInputDescription4Int == 1) {
  547.                
  548.                 if(playerItems[3] == 0) {
  549.                     System.err.println("You don't own this many Founder's Crates!");
  550.                     inventory();
  551.                 }
  552.                 if(playerItems[3] >= 1) {
  553.                     playerItems[3] = playerItems[3] - 1;
  554.                    
  555.                     Random rand = new Random();
  556.                     int random = rand.nextInt(3);
  557.                    
  558.                     if(random == 0) {
  559.                         System.out.println("You recieved nothing");
  560.                         inventory();
  561.                     }
  562.                     if(random == 1) {
  563.                         Random randHealth = new Random();
  564.                         int randomHealth = randHealth.nextInt(3) + 1;
  565.                         playerItems[1] = playerItems[1] + randomHealth;
  566.                         if(randomHealth == 1) {
  567.                             System.out.println("\nYou recieved " + randomHealth + " health Potion");
  568.                             inventory();
  569.                         }
  570.                         if(randomHealth > 1) {
  571.                             System.out.println("\nYou recieved " + randomHealth + " health Potions");
  572.                             inventory();
  573.                         }
  574.                     }
  575.                     if(random > 1) {
  576.                         Random randHealth2 = new Random();
  577.                         int randomHealth2 = randHealth2.nextInt(3) + 1;
  578.                         playerItems[1] = playerItems[1] + randomHealth2;
  579.                        
  580.                         Random randToken = new Random();
  581.                         int randomToken = randToken.nextInt(2) + 1;
  582.                         playerItems[0] = playerItems[0] + randomToken;
  583.                        
  584.                         if(randomHealth2 == 1 && randomToken > 1) {
  585.                             System.out.println("\nYou recieved " + randomHealth2 + " health Potion and " + randomToken + " Tokens");
  586.                             inventory();
  587.                         }
  588.                         if(randomHealth2 == 1 && randomToken == 1) {
  589.                             System.out.println("\nYou recieved " + randomHealth2 + " health Potion and " + randomToken + " Token");
  590.                             inventory();
  591.                         }
  592.                         if(randomHealth2 > 1 && randomToken > 1) {
  593.                             System.out.println("\nYou recieved " + randomHealth2 + " health Potions and " + randomToken + " Tokens");
  594.                             inventory();
  595.                         }
  596.                         if(randomHealth2 > 1 && randomToken == 1) {
  597.                             System.out.println("\nYou recieved " + randomHealth2 + " health Potions and " + randomToken + " Token");
  598.                             inventory();
  599.                         }
  600.                        
  601.                     }
  602.                    
  603.                 }
  604.             }
  605.            
  606.         }
  607.         if(inventoryInputInt == 1) {
  608.             System.out.println("\n" + menuTD);
  609.             System.out.println("|           Inventory (Tokens)          |");
  610.             System.out.println(menuTD);
  611.             System.out.println("| |Tokens enable fast travel to the     |");
  612.             System.out.println("| |shop.                                |");
  613.             System.out.println(menuTD);
  614.             System.out.println("| |Durability: 1        Craftable: false|");
  615.             System.out.println(menuTD);
  616.             System.out.println("|0|               Exit                  |");
  617.             System.out.println(menuTD);
  618.  
  619.            
  620.             System.out.print("\n\nEnter an option:  ");
  621.            
  622.             int inventoryInputDescription1Int = inventoryInput.nextInt();
  623.             if(inventoryInputDescription1Int == 0) {
  624.                 inventory();
  625.                 inventoryInput.close();
  626.             }
  627.             inventoryInput.close();
  628.         }
  629.         if(inventoryInputInt == 2) {
  630.           System.out.println("\n" + menuTD);
  631.           System.out.println("|       Inventory (Health Potion)       |");
  632.           System.out.println(menuTD);
  633.           System.out.println("| |Health regeneration: 10HP            |");
  634.           System.out.println("| |Health potions left: " + playerItems[1] +"               |");
  635.           System.out.println(menuVoid);
  636.           System.out.println("| |Durability: 1         Craftable: true|");
  637.           System.out.println(menuTD);
  638.           System.out.println("|1|           Use Potions               |");
  639.           System.out.println("|0|               Exit                  |");
  640.           System.out.println(menuTD);
  641.          
  642.          
  643.           System.out.print("\n\nEnter an option:  ");
  644.             int inventoryInputDescription2Int = inventoryInput.nextInt();
  645.             if(inventoryInputDescription2Int == 0) {
  646.                 inventory();
  647.                 inventoryInput.close();
  648.             }
  649.             if(inventoryInputDescription2Int == 1) {
  650.                 System.out.print("Enter how many Health Potions you want to use: ");
  651.          
  652.                 Scanner potionInput = new Scanner(System.in);
  653.                 int potionAmount = potionInput.nextInt();
  654.          
  655.                 if(potionAmount > playerItems[1]) {
  656.                     System.err.println("You don't own this many Health Potions!");
  657.                     inventory();
  658.                 }
  659.                 if(potionAmount <= playerItems[1]) {
  660.                     playerItems[1] = playerItems[1] - potionAmount;
  661.                    
  662.                     if(playerStats[1] < 100) {
  663.                         playerStats[1] += (10 * potionAmount);
  664.                         inventory();
  665.                     }
  666.                     if(playerStats[1] == 100) {
  667.                         System.err.println("\nYour HP is already full!");
  668.                         playerItems[1] = playerItems[1] + potionAmount;
  669.                         inventory();
  670.                     }
  671.                     if(playerStats[1] > playerStats[2]) {
  672.                         playerStats[1] = playerStats[2];
  673.                         inventory();
  674.                     }
  675.                     if(playerStats[1] <= playerStats[2]) {
  676.                         inventory();
  677.                     }
  678.                 }
  679.             }
  680.         }
  681.         else {
  682.          
  683.           mainMenu();
  684.          
  685.         }
  686.   }
  687.  
  688.  
  689.  
  690.  
  691.   public static void statistics() {
  692.       long elapsedTime = System.currentTimeMillis() - startTime;
  693.       long elapsedSeconds = elapsedTime / 1000;
  694.       long secondsDisplay = elapsedSeconds % 60;      
  695.       long elapsedMinutes = elapsedSeconds / 60;
  696.  
  697.       String str = secondsDisplay < 10 ? "0" + secondsDisplay : "" + secondsDisplay;
  698.      
  699.       System.out.println("\n" + menuTD);
  700.       System.out.println("|               Statistics              |");
  701.       System.out.println(menuTD);
  702.       System.out.println("|Playtime:  " + elapsedMinutes + ":" + str + " Minutes                |");
  703.       System.out.println(menuVoid);
  704.       System.out.println("|Times travelled to the shop:  " + gameValues[0] + "        |");
  705.       System.out.println(menuTD);
  706.       System.out.println("|0|               Exit                  |");
  707.       System.out.println(menuTD);
  708.      
  709.       System.out.print("\n\nEnter an option:  ");
  710.         Scanner statisticsInput = new Scanner(System.in);
  711.         int statisticsInputInt = statisticsInput.nextInt();
  712.        
  713.         if(statisticsInputInt == 0) {
  714.             mainMenu();
  715.             statisticsInput.close();
  716.         }
  717.   }
  718.  
  719.   private static void adminPannel() {
  720.       adminAccess = "betterberich";
  721.       System.out.print("\n\nPassword:  ");
  722.       Scanner passwordInput = new Scanner(System.in);
  723.       String password = passwordInput.nextLine();
  724.      
  725.       if(password.equals(adminAccess)) {
  726.          
  727.           System.out.println(menuTD);
  728.           System.out.println("|              Admin Pannel             |");
  729.           System.out.println(menuTD);
  730.           System.out.println("|1|              Add Gold               |");
  731.           System.out.println("|2|               Add XP                |");
  732.           System.out.println("|3|              Change HP              |");
  733.           System.out.println("|4|            Change MaxHP             |");
  734.           System.out.println("|5|            Change Level             |");
  735.           System.out.println("|6|            System Value             |");
  736.           System.out.println(menuTD);
  737.           System.out.println("|0|               Exit                  |");
  738.           System.out.println(menuTD);
  739.          
  740.           System.out.print("\n\nEnter an option:  ");
  741.             Scanner adminPannel = new Scanner(System.in);
  742.             int adminPannelInt = adminPannel.nextInt();
  743.              
  744.             if(adminPannelInt == 0) {
  745.               mainMenu();
  746.               adminPannel.close();
  747.               passwordInput.close();
  748.             }
  749.             if(adminPannelInt == 1) {
  750.                 System.out.println(menuTD);
  751.                 System.out.println("|              Admin Pannel             |");
  752.                 System.out.println(menuTD);
  753.                 System.out.println("| | Enter a value to add Gold           |");
  754.                 System.out.println(menuTD);
  755.                
  756.                 System.out.print("\nGold to add:  ");
  757.                     Scanner goldAdd = new Scanner(System.in);
  758.                     int goldAddInt = goldAdd.nextInt();
  759.                    
  760.                     playerStats[0] += goldAddInt;
  761.                    
  762.                     if(playerStats[0] < 0) {
  763.                         playerStats[0] = 0;
  764.                        
  765.                     }
  766.                     mainMenu();
  767.                     goldAdd.close();
  768.                
  769.             }
  770.             if(adminPannelInt == 2) {
  771.                 System.out.println(menuTD);
  772.                 System.out.println("|              Admin Pannel             |");
  773.                 System.out.println(menuTD);
  774.                 System.out.println("| | Enter a value to add to your XP     |");
  775.                 System.out.println(menuTD);
  776.                 System.out.print("\nChange XP to:  ");
  777.                     Scanner changeXP = new Scanner(System.in);
  778.                     int changeXPInt = changeXP.nextInt();
  779.                    
  780.                     playerLevels[0] += changeXPInt;
  781.                     if(playerLevels[0] < 0) {
  782.                         playerLevels[0] = 0;
  783.                        
  784.                        
  785.                     }
  786.                     mainMenu();
  787.                     changeXP.close();
  788.  
  789.             }
  790.            
  791.             if(adminPannelInt == 3) {
  792.                 System.out.println(menuTD);
  793.                 System.out.println("|              Admin Pannel             |");
  794.                 System.out.println(menuTD);
  795.                 System.out.println("| | Enter a value to change your HP     |");
  796.                 System.out.println(menuTD);
  797.                
  798.                 System.out.print("\nSet HP to:  ");
  799.                     Scanner changeHP = new Scanner(System.in);
  800.                     int changeHPInt = changeHP.nextInt();
  801.                
  802.                     playerStats[1] = changeHPInt;
  803.                    
  804.                     if(playerStats[1] < 0) {
  805.                         playerStats[1] = 0;
  806.                        
  807.                        
  808.                     }
  809.                     if(playerStats[1] > playerStats[2]) {
  810.                         playerStats[1] = playerStats[2];   
  811.                        
  812.                     }
  813.                     mainMenu();
  814.                     changeHP.close();
  815.                    
  816.             }
  817.             if(adminPannelInt == 4) {
  818.                 System.out.println(menuTD);
  819.                 System.out.println("|              Admin Pannel             |");
  820.                 System.out.println(menuTD);
  821.                 System.out.println("| | Enter a value to change your MaxHP  |");
  822.                 System.out.println(menuTD);
  823.                
  824.                 System.out.print("\nSet MaxHP to:  ");
  825.                     Scanner changeMaxHP = new Scanner(System.in);
  826.                     int changeMaxHPInt = changeMaxHP.nextInt();
  827.                
  828.                     playerStats[2] = changeMaxHPInt;
  829.                    
  830.                     if(playerStats[2] < 1) {
  831.                         playerStats[2] = 1;
  832.                         if(playerStats[1] > playerStats[2]) {
  833.                             playerStats[1] = playerStats[2];
  834.                         }
  835.                        
  836.                        
  837.                     }
  838.                     mainMenu();
  839.                     changeMaxHP.close();
  840.            
  841.             }
  842.             if(adminPannelInt == 5) {
  843.                 System.out.println(menuTD);
  844.                 System.out.println("|              Admin Pannel             |");
  845.                 System.out.println(menuTD);
  846.                 System.out.println("| | Enter a value to change your Level  |");
  847.                 System.out.println(menuTD);
  848.                
  849.                 System.out.print("\nSet Level to:  ");
  850.                     Scanner changeLevel = new Scanner(System.in);
  851.                     int changeLevelInt = changeLevel.nextInt();
  852.                    
  853.                     playerStats[3] = changeLevelInt;
  854.                     if(playerStats[3] < 0) {
  855.                         playerStats[3] = 0;
  856.                     }
  857.                     mainMenu();
  858.                     changeLevel.close();
  859.             }
  860.             if(adminPannelInt == 6) {
  861.                 System.out.println(menuTD);
  862.                   System.out.println("|              Admin Pannel             |");
  863.                   System.out.println(menuTD);
  864.                   System.out.println("| |Proceed with Caution! Changing system|");
  865.                   System.out.println("| |values might result in major game    |");
  866.                   System.out.println("| |bugs                                 |");
  867.                   System.out.println(menuTD);
  868.                   System.out.println("|1|       Change Shop travel time       |");
  869.                   System.out.println("|2|                                     |");
  870.                   System.out.println("|3|                                     |");
  871.                   System.out.println(menuTD);
  872.                   System.out.println("|0|               Exit                  |");
  873.                   System.out.println(menuTD);
  874.                  
  875.                   System.out.print("\n\nEnter an option:  ");
  876.                     Scanner systemPannel = new Scanner(System.in);
  877.                     int systemPannelInt = systemPannel.nextInt();
  878.                      
  879.                     if(systemPannelInt == 0) {
  880.                       mainMenu();
  881.                       systemPannel.close();
  882.                     }
  883.             }
  884.          
  885.       } else {
  886.           System.out.println("**Denied**");
  887.           mainMenu();
  888.           passwordInput.close();
  889.       }
  890.      
  891.   }
  892.  
  893.   public static void main(String[] args) {
  894.     gameStart();
  895.   }
  896. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement