Advertisement
daixso

Vuriables

Jan 21st, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.78 KB | None | 0 0
  1. /**
  2.  * Created with IntelliJ IDEA.
  3.  * User: zach
  4.  * Date: 1/20/13
  5.  * Time: 6:27 AM
  6.  * To change this template use File | Settings | File Templates.
  7.  */
  8. import java.util.Scanner;
  9.  
  10. public class Variables {
  11.     private static Scanner input = new Scanner(System.in);
  12.     private static int playerLevel;//capped at 10
  13.     private static int playerHp=85+(15*playerLevel);
  14.     private static int playerFear;//capped at 100
  15.     private static int playerTiredness;//capped at 100
  16.     private static int playerEtl=50+(25*playerLevel);
  17.     private static int playerExp;
  18.     private static boolean playerAlive;
  19.     private static String playerName;
  20.     public Variables(){
  21.         playerLevel=1;
  22.         playerExp=0;
  23.         playerFear=0;
  24.         playerTiredness=0;
  25.         playerAlive=true;
  26.         getName();
  27.     }
  28.     private void getName(){
  29.         String correct;
  30.         System.out.println("Please enter a name!");
  31.         System.out.print("Name: ");
  32.         playerName=input.nextLine();
  33.         System.out.printf("\n%s, correct? ",playerName);
  34.         correct=input.nextLine();
  35.         if(correct.toLowerCase().equals("yes") || correct.toLowerCase().equals("y")){
  36.             System.out.println("Name saved!");
  37.         }else if(correct.toLowerCase().equals("no") || correct.toLowerCase().equals("n")){
  38.             getName();
  39.         }else{
  40.             System.out.printf("Sorry! The input '%s' was not recognized!\n",correct);
  41.             getName();
  42.         }
  43.     }
  44.     public void cheatHeal(){
  45.         playerHp=85+(15*playerLevel);
  46.         playerFear=0;
  47.         playerTiredness=0;
  48.     }
  49.  
  50.     public void cheatExp(int amount){
  51.         playerExp+=amount;
  52.         calculateLevel(playerExp);
  53.     }
  54.  
  55.     public void cheatLevel(int amount){
  56.         if(playerLevel >= 10 && amount >= 0){
  57.             System.out.println("You are already max level!");
  58.         }else if(amount > 10){
  59.             System.out.println("You entered a value that was too big, player has been set to max level.");
  60.             playerLevel=10;
  61.         }else{
  62.             if(playerLevel+amount >= 10){
  63.                 playerLevel=10;
  64.             }else if(playerLevel+amount <= 0){
  65.                 playerLevel=1;
  66.             }else{
  67.                 playerLevel+=amount;
  68.             }
  69.         }
  70.     }
  71.  
  72.     private void calculateLevel(int playerExp){
  73.         if(playerExp >= playerEtl){
  74.             playerExp-=playerEtl;
  75.             if(playerLevel >= 10){
  76.                 //player is at level cap
  77.                 //do nothing
  78.             }else{
  79.                 playerLevel+=1;
  80.             }
  81.         }else{
  82.             //do nothing
  83.         }
  84.     }
  85.  
  86.     public void checkAlive(){
  87.         if(playerHp >= 1){
  88.               playerAlive=true;
  89.         }else{
  90.             playerAlive=false;
  91.         }
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement