yumi1996

Java Help: Stat extensions

Aug 5th, 2013
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.84 KB | None | 0 0
  1. //Hello. This code will be used to create a textbased RPG that will feature images further down the line (likely in //Beta) but I am having issues with the checkLevel method located in Player.class. It doesn't show the revised //versions of the variables each stat inherits, but the original versions the stat.class defines. Please help me //with solving this problem as I was hoping to write a similar method to create dynamic shop economy. Please mind I //haven't even created an alpha stage and much of my code is incomplete and choppy. if you have found this paste via //the public paste bar, please post any possible solutions on Reddit here: http://www.reddit.com/r/javahelp/comments/1js6qr/methods_involving_revised_inherited_variables_in/
  2.  
  3. PS: I am aware my variables are often named conventionally incorrect.
  4.  
  5.  
  6. public class Player {
  7.  
  8.     public static int Level = 1;
  9.    
  10.     public static double experience = 0;
  11.    
  12.     public static double totalXP = 50;
  13.    
  14.     public static double gold = 100;
  15.    
  16.     static Scanner Keyboard_in = new Scanner(System.in);
  17.  
  18.     static String PlayerName = " ";
  19.    
  20.     static String Gender = " ";
  21.    
  22.     public static double PlayerHP = 20;
  23.    
  24.     public int PlayerEnergy = 50;
  25.    
  26.     public static int location1 = 1;
  27.     public static int location2 = 1;
  28.    
  29.     //Start of effect values
  30.     public static Boolean PoisonACT = false;
  31.     public static Boolean BleedACT = false;
  32.     public static Boolean SapACT = false;
  33.     public static Boolean ArmorBreakACT = false;
  34.     public static Boolean WeaknessACT = false;
  35.     public static Boolean RageACT = false;
  36.     public static Boolean SparkleACT = false;
  37.     public static Boolean RangedACT = false;
  38.     public static Boolean CastingACT = false;
  39.      //end of effect values.
  40.    
  41.    
  42.     //Start of combat chunk
  43.     public static double rawincomingDMG = 0;
  44.     public static double rawoutboundDMG = 0;
  45.     public static int incomingDMG = (int) Math.round(rawincomingDMG);
  46.     public static int outboundDMG = (int) Math.round(rawoutboundDMG);
  47.     //end of combat chunk
  48.    
  49.    
  50.     //parses for the users location using 2 variables
  51.     public static void parseLocation() throws IOException {
  52.        
  53.         if (location1 == 1) {
  54.            
  55.             if (location2 == 1) {
  56.                 //moves to alley
  57.                 TheAlley1.Room1();
  58.                
  59.             }//end of location2 if statement
  60.            
  61.             if (location2 == 2) {
  62.                 //moves to the street
  63.                
  64.                
  65.             }//end of location2 if statement
  66.            
  67.             if (location2 == 3) {
  68.                 //moves to tavern
  69.                
  70.                
  71.             }//end of location2 if statement
  72.            
  73.         }//end of location1 if statement
  74.        
  75.     }
  76.    
  77.    
  78.     public static void checkLevel() {
  79.        
  80.         System.out.println("You are level: " + Level);
  81.         System.out.println("You have " + experience + " experience out of " + totalXP + " total experience");
  82.         System.out.println(stat.Attack.Name + " Level: " + stat.Attack.Level + ": Experience: " + stat.Attack.Experience + "/" + stat.Attack.totalXP);
  83.         System.out.println(stat.Archery.Name +" Level: " + stat.Archery.Level +": Experience: " + stat.Archery.Experience + "/" + stat.Archery.totalXP);
  84.         System.out.println(stat.Agility.Name +" Level: " + stat.Agility.Level + ": Experience: " + stat.Agility.Experience + "/" + stat.Agility.totalXP);
  85.        
  86.     }//end of checkLevel method
  87.    
  88.    
  89.     //Checks for Level up. If requirements are met, you level up
  90.     public static void PlayerLvlup() {
  91.        
  92.         if(experience >=   totalXP) {
  93.              Level++;
  94.              totalXP = totalXP * 1.3;
  95.              experience = 0;
  96.              
  97.         }//end of if statement
  98.        
  99.     }//end of StatLvlup method
  100.    
  101.    
  102.    
  103.    
  104.     //Choose your gender and Name
  105.     public static void initPlayer() {
  106.         //choose name
  107.         System.out.println("What is your name?");
  108.         PlayerName = Keyboard_in.nextLine();
  109.         // choose gender
  110.         System.out.println("Enter your gender. Male/Female");
  111.         @SuppressWarnings("unused")
  112.         String choice = Keyboard_in.nextLine();
  113.            switch("choice") {
  114.             case "Male":
  115.            case "male":
  116.                  Gender = "male";
  117.                   break;
  118.             case "Female":
  119.             case "female":
  120.                    Gender = "Female";
  121.                     break;
  122.             case "both":
  123.             case "Both":
  124.                   Gender = "Both";
  125.            }// end of switch statement.
  126.  
  127.         } // end of initPlayer()
  128.  
  129. }//end of Player class
  130.  
  131. //start of Stat class. Variables in question are defined here. (Name, Level, Experience, totalXP)
  132. public class Stat {
  133.  
  134.     public static String Name = " ";
  135.     public static int Level = 0;
  136.     public static double Experience = 0;
  137.     public static double totalXP = 0;
  138.    
  139.     //Sets Name
  140.     public static void setName(String NameIn) {
  141.         Name = NameIn;
  142.     }
  143.     //Sets Level
  144.     public static void setLevel(int LevelIn) {
  145.         Level = LevelIn;
  146.     }
  147.     //Sets Experience
  148.     public static void setExperience(double ExperienceIn) {
  149.         Experience = ExperienceIn;
  150.     }
  151.     //Sets totalXP
  152.     public static void settotalXP(double totalXPIn) {
  153.         totalXP = totalXPIn;
  154.     }
  155.    
  156.    
  157.     //Sets up Attributes
  158.     public static void setall() {
  159.         setName("Herp");
  160.         setLevel(1);
  161.         setExperience(0);
  162.         settotalXP(0);
  163.        
  164.        
  165.     }
  166.    
  167.    
  168.    
  169.     //Displays a Stat's Attributes
  170.     public static void DisplayLevel() {
  171.        
  172.         System.out.println(Name);
  173.         System.out.println("Level: " + Level);
  174.         System.out.println(Experience + " out of " + totalXP + " total experience.");
  175.        
  176.     }//End of method
  177.    
  178.     public static void Levelup() {
  179.        
  180.         if(Experience >= totalXP) {
  181.            
  182.             Level++;
  183.             totalXP = totalXP * 1.3;
  184.             Experience = 0;
  185.            
  186.         }//end of if statement
  187.        
  188.     }//end of Levelup method
  189.    
  190. }//end of Stat.class
  191.  
  192.  
  193.  
  194. //Start of Agility.class. All other stat extensions look the same as far as revised variables go.
  195. public class Agility extends Stat{
  196.  
  197.     {//Revisionary Block
  198.         Name = "Agility";
  199.         Level = 1;
  200.         Experience = 0;
  201.         totalXP = 125;
  202.     }
  203.    
  204.    
  205.    
  206.     public static int runnappDodge(int Dodge) {
  207.         Random generator = new Random(10);
  208.        
  209.        
  210.         Dodge = generator.nextInt(10);
  211.         if (Dodge == 0) {
  212.            
  213.             Player.incomingDMG = 0;
  214.            
  215.          }//end of if statement
  216.         return Dodge;
  217.  
  218.            
  219.         }
  220.    
  221.    
  222.        
  223.     }
Add Comment
Please, Sign In to add comment