Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //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/
- PS: I am aware my variables are often named conventionally incorrect.
- public class Player {
- public static int Level = 1;
- public static double experience = 0;
- public static double totalXP = 50;
- public static double gold = 100;
- static Scanner Keyboard_in = new Scanner(System.in);
- static String PlayerName = " ";
- static String Gender = " ";
- public static double PlayerHP = 20;
- public int PlayerEnergy = 50;
- public static int location1 = 1;
- public static int location2 = 1;
- //Start of effect values
- public static Boolean PoisonACT = false;
- public static Boolean BleedACT = false;
- public static Boolean SapACT = false;
- public static Boolean ArmorBreakACT = false;
- public static Boolean WeaknessACT = false;
- public static Boolean RageACT = false;
- public static Boolean SparkleACT = false;
- public static Boolean RangedACT = false;
- public static Boolean CastingACT = false;
- //end of effect values.
- //Start of combat chunk
- public static double rawincomingDMG = 0;
- public static double rawoutboundDMG = 0;
- public static int incomingDMG = (int) Math.round(rawincomingDMG);
- public static int outboundDMG = (int) Math.round(rawoutboundDMG);
- //end of combat chunk
- //parses for the users location using 2 variables
- public static void parseLocation() throws IOException {
- if (location1 == 1) {
- if (location2 == 1) {
- //moves to alley
- TheAlley1.Room1();
- }//end of location2 if statement
- if (location2 == 2) {
- //moves to the street
- }//end of location2 if statement
- if (location2 == 3) {
- //moves to tavern
- }//end of location2 if statement
- }//end of location1 if statement
- }
- public static void checkLevel() {
- System.out.println("You are level: " + Level);
- System.out.println("You have " + experience + " experience out of " + totalXP + " total experience");
- System.out.println(stat.Attack.Name + " Level: " + stat.Attack.Level + ": Experience: " + stat.Attack.Experience + "/" + stat.Attack.totalXP);
- System.out.println(stat.Archery.Name +" Level: " + stat.Archery.Level +": Experience: " + stat.Archery.Experience + "/" + stat.Archery.totalXP);
- System.out.println(stat.Agility.Name +" Level: " + stat.Agility.Level + ": Experience: " + stat.Agility.Experience + "/" + stat.Agility.totalXP);
- }//end of checkLevel method
- //Checks for Level up. If requirements are met, you level up
- public static void PlayerLvlup() {
- if(experience >= totalXP) {
- Level++;
- totalXP = totalXP * 1.3;
- experience = 0;
- }//end of if statement
- }//end of StatLvlup method
- //Choose your gender and Name
- public static void initPlayer() {
- //choose name
- System.out.println("What is your name?");
- PlayerName = Keyboard_in.nextLine();
- // choose gender
- System.out.println("Enter your gender. Male/Female");
- @SuppressWarnings("unused")
- String choice = Keyboard_in.nextLine();
- switch("choice") {
- case "Male":
- case "male":
- Gender = "male";
- break;
- case "Female":
- case "female":
- Gender = "Female";
- break;
- case "both":
- case "Both":
- Gender = "Both";
- }// end of switch statement.
- } // end of initPlayer()
- }//end of Player class
- //start of Stat class. Variables in question are defined here. (Name, Level, Experience, totalXP)
- public class Stat {
- public static String Name = " ";
- public static int Level = 0;
- public static double Experience = 0;
- public static double totalXP = 0;
- //Sets Name
- public static void setName(String NameIn) {
- Name = NameIn;
- }
- //Sets Level
- public static void setLevel(int LevelIn) {
- Level = LevelIn;
- }
- //Sets Experience
- public static void setExperience(double ExperienceIn) {
- Experience = ExperienceIn;
- }
- //Sets totalXP
- public static void settotalXP(double totalXPIn) {
- totalXP = totalXPIn;
- }
- //Sets up Attributes
- public static void setall() {
- setName("Herp");
- setLevel(1);
- setExperience(0);
- settotalXP(0);
- }
- //Displays a Stat's Attributes
- public static void DisplayLevel() {
- System.out.println(Name);
- System.out.println("Level: " + Level);
- System.out.println(Experience + " out of " + totalXP + " total experience.");
- }//End of method
- public static void Levelup() {
- if(Experience >= totalXP) {
- Level++;
- totalXP = totalXP * 1.3;
- Experience = 0;
- }//end of if statement
- }//end of Levelup method
- }//end of Stat.class
- //Start of Agility.class. All other stat extensions look the same as far as revised variables go.
- public class Agility extends Stat{
- {//Revisionary Block
- Name = "Agility";
- Level = 1;
- Experience = 0;
- totalXP = 125;
- }
- public static int runnappDodge(int Dodge) {
- Random generator = new Random(10);
- Dodge = generator.nextInt(10);
- if (Dodge == 0) {
- Player.incomingDMG = 0;
- }//end of if statement
- return Dodge;
- }
- }
Add Comment
Please, Sign In to add comment