Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created with IntelliJ IDEA.
- * User: zach
- * Date: 1/20/13
- * Time: 6:27 AM
- * To change this template use File | Settings | File Templates.
- */
- import java.util.Scanner;
- public class Variables {
- private static Scanner input = new Scanner(System.in);
- private static int playerLevel;//capped at 10
- private static int playerHp=85+(15*playerLevel);
- private static int playerFear;//capped at 100
- private static int playerTiredness;//capped at 100
- private static int playerEtl=50+(25*playerLevel);
- private static int playerExp;
- private static boolean playerAlive;
- private static String playerName;
- public Variables(){
- playerLevel=1;
- playerExp=0;
- playerFear=0;
- playerTiredness=0;
- playerAlive=true;
- getName();
- }
- private void getName(){
- String correct;
- System.out.println("Please enter a name!");
- System.out.print("Name: ");
- playerName=input.nextLine();
- System.out.printf("\n%s, correct? ",playerName);
- correct=input.nextLine();
- if(correct.toLowerCase().equals("yes") || correct.toLowerCase().equals("y")){
- System.out.println("Name saved!");
- }else if(correct.toLowerCase().equals("no") || correct.toLowerCase().equals("n")){
- getName();
- }else{
- System.out.printf("Sorry! The input '%s' was not recognized!\n",correct);
- getName();
- }
- }
- public void cheatHeal(){
- playerHp=85+(15*playerLevel);
- playerFear=0;
- playerTiredness=0;
- }
- public void cheatExp(int amount){
- playerExp+=amount;
- calculateLevel(playerExp);
- }
- public void cheatLevel(int amount){
- if(playerLevel >= 10 && amount >= 0){
- System.out.println("You are already max level!");
- }else if(amount > 10){
- System.out.println("You entered a value that was too big, player has been set to max level.");
- playerLevel=10;
- }else{
- if(playerLevel+amount >= 10){
- playerLevel=10;
- }else if(playerLevel+amount <= 0){
- playerLevel=1;
- }else{
- playerLevel+=amount;
- }
- }
- }
- private void calculateLevel(int playerExp){
- if(playerExp >= playerEtl){
- playerExp-=playerEtl;
- if(playerLevel >= 10){
- //player is at level cap
- //do nothing
- }else{
- playerLevel+=1;
- }
- }else{
- //do nothing
- }
- }
- public void checkAlive(){
- if(playerHp >= 1){
- playerAlive=true;
- }else{
- playerAlive=false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement