Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class PJ_Battle{
- /****************************************Variables****************************************/
- //Base Variables
- public static Scanner scan = new Scanner(System.in);
- public static Random rand = new Random();
- public static int pokemonNum = 4;
- public static int moveNum = 2;
- public static int n = 0;
- //Title
- public static String TITLE = "Pokemon Java Battle System";
- //User Stats
- public static int cLVL = 5;
- public static int hp = 1;
- public static int cAtk;
- public static int cDef;
- public static int exp = 0;
- //Enemy Stats
- public static int elvl;
- public static int enemy;
- public static int eHP = 1;
- public static int eAtk;
- public static int eDef;
- //Other Stuff
- public static String pokemonChoice;
- public static int pChoice;
- public static int mChoice;
- public static int dmg;
- public static int gain;
- public final static String wS = " ";
- //Arrays
- public static String[][] pokemon = new String[pokemonNum][4];
- public static String[][] moves = new String[pokemonNum][moveNum];
- public static int[] lvl = new int[100];
- public static String[] statements = new String[100];
- /****************************************Load Game****************************************/
- public static void main(String[] args) {
- /****************************************Data****************************************/
- //Levels
- lvl[n++] = 0;
- lvl[n++] = 0;
- lvl[n++] = 0;
- lvl[n++] = 0;
- lvl[n++] = 50;
- lvl[n++] = 150;
- lvl[n++] = 250;
- //Pokemon
- /*Template:
- pokemon[INDEX][0] = "Name";
- pokemon[INDEX][1] = "Heath";
- pokemon[INDEX][2] = "Attack";
- pokemon[INDEX][3] = "Defense";
- */
- //Pikachu
- pokemon[0][0] = "Pikachu";
- pokemon[0][1] = "19";
- pokemon[0][2] = "10";
- pokemon[0][3] = "7";
- //Charmander
- pokemon[1][0] = "Charmander";
- pokemon[1][1] = "20";
- pokemon[1][2] = "11";
- pokemon[1][3] = "5";
- //Squirtle
- pokemon[2][0] = "Squirtle";
- pokemon[2][1] = "18";
- pokemon[2][2] = "8";
- pokemon[2][3] = "8";
- //Bulbasuar
- pokemon[3][0] = "Bulbasuar";
- pokemon[3][1] = "22";
- pokemon[3][2] = "7";
- pokemon[3][3] = "9";
- //Moves
- moves[0][0] = "Tackle";
- moves[0][1] = "Growl";
- moves[1][0] = "Scratch";
- moves[1][1] = "Growl";
- moves[2][0] = "Tackle";
- moves[2][1] = "Tail Whip";
- moves[3][0] = "Tackle";
- moves[3][1] = "Growl";
- /****************************************Begin Game****************************************/
- System.out.println("Welcome to " + TITLE);
- System.out.println("Available Pokemon:");
- for(int x=0;x<pokemon.length;x++){
- System.out.println(x+1 + ") " + pokemon[x][0]);
- }
- System.out.print("Choose a pokemon: ");
- //Prompt for pokemon choice.
- pChoice = scan.nextInt() - 1;
- pokemonChoice = pokemon[0][pChoice];
- //Print chosen pokemon.
- System.out.println("\nYou chose " + pokemonChoice + ".\n");
- //Begin Gameplay
- while(true){
- battle();
- }
- }
- /****************************************Battle****************************************/
- public static void battle(){
- enemy = rand.nextInt(pokemonNum);
- hp = Integer.parseInt(pokemon[pChoice][1]) + (cLVL-4 * 2);
- cAtk = Integer.parseInt(pokemon[pChoice][2]) + (cLVL-4 * 2);
- cDef = Integer.parseInt(pokemon[pChoice][3]) + (cLVL-4 * 2);
- eHP = Integer.parseInt(pokemon[enemy][1]) + (cLVL-4 * 2);
- eAtk = Integer.parseInt(pokemon[enemy][2]) + (cLVL-4 * 2);
- eDef = Integer.parseInt(pokemon[enemy][2]) + (cLVL-4 * 2);
- initPrintStats(enemy);
- }
- /****************************************Attack****************************************/
- public static void attack(int enemy){
- System.out.print("Choose A Move: ");
- mChoice = scan.nextInt();
- attackCalc(mChoice, enemy);
- }
- public static void attackCalc(int move, int enemy){
- //Calculate Damage - You.
- boolean miss = rand.nextInt(100)<15?true:false;
- boolean evade = rand.nextInt(100)<10?true:false;
- if(miss==false && evade==false){
- dmg = ((((2*cLVL/5+2)*cAtk*cAtk/eDef)/ 50) + 2)*rand.nextInt(5);;
- if(dmg<=0) dmg = 4;
- eHP = eHP - dmg<0?0:eHP-dmg;
- //Print Outcome
- System.out.println("\nYou attack the foe's " + pokemon[enemy][0] + " for " + dmg + " damage.");
- System.out.println();
- printStats(enemy);
- }
- else if(miss==true){
- System.out.println("\nYour attack missed.");
- System.out.println();
- printStats(enemy);
- }
- else{
- System.out.println("\nThe foe evaded your attack.");
- System.out.println();
- printStats(enemy);
- }
- }
- public static void eCalc(int enemy){
- boolean miss = rand.nextInt(100)<15?true:false;
- boolean evade = rand.nextInt(100)<10?true:false;
- if(miss==false && evade==false){
- dmg = ((((2*cLVL/5+2)*eAtk*eAtk/cDef)/ 50) + 2)*rand.nextInt(5);;
- if(dmg<=0) dmg = 4;
- hp = hp - dmg<0?0:hp-dmg;
- //Print Outcome
- System.out.println("\nThe foe's " + pokemon[enemy][0] + " attacks you for " + dmg + " damage.");
- System.out.println();
- printStats(enemy);
- }
- else if(miss==true){
- System.out.println("\nYour attack missed.");
- System.out.println();
- printStats(enemy);
- }
- else{
- System.out.println("\nThe foe evaded your attack.");
- System.out.println();
- printStats(enemy);
- }
- }
- /****************************************Stats****************************************/
- public static void initPrintStats(int enemy){
- //User Pokemon
- System.out.print("Pokemon: " + pokemonChoice);
- System.out.print(wS + "HP: " + hp);
- System.out.print(wS + "Level: " + cLVL);
- System.out.print(wS + "Experience: " + exp + "/" + lvl[cLVL-1]);
- System.out.println("\nMoves:");
- for(int x=0;x<moves[pChoice].length;x++){
- System.out.println(x + 1 + ") " + moves[pChoice][x]);
- }
- System.out.println();
- //Enemy Pokemon
- //Calculate Level
- boolean lvlR = rand.nextInt(100)>50?true:false;
- //Print enemy stats
- System.out.print("Opponent: " + pokemon[enemy][0]);
- if(lvlR==true){
- eHP -= rand.nextInt(5);
- System.out.print(wS + "HP: " + eHP);
- elvl = cLVL - rand.nextInt(3);
- System.out.print(wS + "Level:" + elvl);
- eAtk += rand.nextInt(elvl);
- eDef += rand.nextInt(elvl);
- }
- else{
- eHP += rand.nextInt(5);
- System.out.print(wS + "HP: " + eHP);
- elvl = cLVL + rand.nextInt(3);
- System.out.print(wS + "Level:" + elvl);
- eAtk -= rand.nextInt(elvl);
- eDef -= rand.nextInt(elvl);
- }
- System.out.println();
- attack(enemy);
- }
- public static void printStats(int enemy){
- //User Pokemon
- System.out.print("Pokemon: " + pokemonChoice);
- System.out.print(wS + "HP: " + hp);
- System.out.print(wS + "Level: " + cLVL);
- System.out.println(wS + "Experience: " + exp + "/" + lvl[cLVL-1]);
- System.out.println("Moves:");
- for(int x=0;x<moves[pChoice].length;x++){
- System.out.println(x + 1 + ") " + moves[pChoice][x]);
- }
- System.out.println();
- //Enemy Pokemon
- //Print enemy stats
- System.out.print("Oponent: " + pokemon[enemy][0]);
- System.out.print(wS + "HP: " + eHP);
- System.out.print(wS + "Level:" + elvl);
- if(eHP<=0){
- System.out.println("\n\nFoe " + pokemon[enemy][0] + " fainted.\n");
- exp(enemy);
- System.out.println(pokemonChoice + " gained " + gain + " experience.\n");
- scan.nextLine();
- battle();
- }
- else{
- System.out.println();
- attack(enemy);
- }
- }
- /****************************************Levels and EXP****************************************/
- public static void exp(int enemy){
- gain = cLVL*rand.nextInt(elvl) + ((Integer.parseInt(pokemon[enemy][2]) + Integer.parseInt(pokemon[enemy][2])/2));
- if(gain<=0)gain = Integer.parseInt(pokemon[enemy][2]);
- exp+=gain;
- }
- public static void level(int leftOver){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement