Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Rpgtest {
- static int HP = 0;
- static int Potential = 1;
- static int Damage = 0;
- static int Difficulty = 0;
- static int GoldEarned = 0;
- static int MONEY = 0;
- static int TOTALHP = 10;
- static int[] LEVEL = new int[10];
- static int WeaponDamage = 2;
- static int XP = 0;
- static int CURRENTHP = 0;
- public static void main(String... Args) {
- LEVEL[0] = 0;
- LEVEL[1] = 5;
- LEVEL[2] = 15;
- LEVEL[3] = 40;
- LEVEL[4] = 75;
- LEVEL[5] = 120;
- LEVEL[6] = 180;
- LEVEL[7] = 280;
- LEVEL[8] = 430;
- LEVEL[9] = 730;
- CURRENTHP = TOTALHP;
- Scanner uIn = new Scanner(System.in);
- System.out.println("====<Welcome to Tez's RPG>====");
- System.out.println("Type 'next' to start your adventure through walls of text!");
- String Q1 = uIn.next().trim().toLowerCase();
- int Lv = 1;
- while (Q1.equals("next")) {
- if ((XP >= LEVEL[Lv]) && Lv < 9) {
- ++Lv;
- ++WeaponDamage;
- TOTALHP += 5;
- CURRENTHP += 1;
- }
- System.out.println("You are currently Level " + (Lv));
- System.out.println("Experience: " + XP + " / " + LEVEL[Lv]);
- System.out.println("Your health is " + CURRENTHP + "/" + TOTALHP);
- System.out.println("Current money: " + MONEY);
- pause();
- System.out.println("Would you like to shop or fight?");
- System.out
- .println("To shop, type 'shop'\nType anything else to continue.");
- String Q3 = uIn.next().trim().toLowerCase();
- while (Q3.equals("shop")) {
- System.out.println("What would you like to buy?");
- pause();
- System.out.println("1 for full heal -- 30 Coins");
- pause();
- System.out
- .println("2 for increasing weapon damage potential by 1 -- 100 Coins");
- int Q4 = uIn.nextInt();
- if (Q4 == 1 && MONEY >= 30) {
- pause();
- System.out.println("You replenish your health.");
- CURRENTHP = TOTALHP;
- pause();
- System.out.println("Your health is now " + CURRENTHP);
- MONEY = MONEY - 30;
- } else if (Q4 == 2 && MONEY >= 100) {
- pause();
- System.out.println("You increase your Weapon Damage by 1.");
- ++WeaponDamage;
- MONEY = MONEY - 100;
- } else {
- pause();
- System.out.println("Insufficient Funds");
- }
- System.out
- .println("Would you like to shop more or leave?\n'shop' to continue shopping.\nType anything else to continue.");
- Q3 = uIn.next().trim().toLowerCase();
- }
- System.out.println("What monster would you like to fight?");
- pause();
- System.out
- .println("Rat(Level 1 / 5HP)\nGoblin(Level 3 / 10HP)\nBear(Level 10 / 20HP)\nBoss(Level 15 / 50HP)");
- String Q2 = uIn.next().trim().toLowerCase();
- if (Q2.equals("rat")) {
- Difficulty = 2;
- HP = 5;
- while ((HP > 0) && (CURRENTHP > 0)) {
- System.out.println("You have " + CURRENTHP
- + " health remaining.");
- pause();
- pause();
- System.out.println();
- System.out
- .println(Q2 + " has " + HP + " health remaining.");
- pause();
- int Damage = (int) (Math.round(Math.random()) + WeaponDamage);
- System.out.println("You deal " + Damage + " Damage!");
- HP = (int) (HP - Damage);
- pause();
- pause();
- System.out.println("");
- int pHealth = (int) (Math.round(Math.random() * 1));
- System.out.println("You are damaged for " + pHealth
- + " Damage!");
- pause();
- CURRENTHP = CURRENTHP - pHealth;
- pause();
- }
- if (CURRENTHP <= 0) {
- System.out.println("You have died.");
- System.exit(0);
- }
- System.out.println("You have killed the rat!");
- pause();
- int GoldEarned = (int) (Math.round(Math.random()
- * (Potential * Difficulty * 10)));
- System.out.println("You have earned " + GoldEarned + " Coins.");
- XP += 5;
- System.out.println("You've earned 5 XP.");
- MONEY += GoldEarned;
- pause();
- System.out.println("Type 'next' to continue.");
- Q1 = uIn.next().trim().toLowerCase();
- } else if (Q2.equals("goblin")) {
- Difficulty = 5;
- HP = 10;
- while ((HP > 0) && (CURRENTHP > 0)) {
- System.out.println("You have " + CURRENTHP
- + " health remaining.");
- pause();
- pause();
- System.out.println();
- System.out
- .println(Q2 + " has " + HP + " health remaining.");
- pause();
- int Damage = (int) (Math.round(Math.random()) + WeaponDamage);
- System.out.println("You deal " + Damage + " Damage!");
- HP = (int) (HP - Damage);
- pause();
- pause();
- System.out.println("");
- int pHealth = (int) (Math.round(Math.random() * 3));
- System.out.println("You are damaged for " + pHealth
- + " Damage!");
- pause();
- CURRENTHP = CURRENTHP - pHealth;
- pause();
- }
- if (CURRENTHP <= 0) {
- System.out.println("You have died.");
- System.exit(0);
- }
- System.out.println("You have killed the goblin!");
- pause();
- int GoldEarned = (int) (Math.round(Math.random()
- * (Potential * Difficulty * 10)));
- System.out.println("You have earned " + GoldEarned + " Coins.");
- XP += 20;
- System.out.println("You've earned 20 XP.");
- MONEY += GoldEarned;
- pause();
- System.out.println("Type 'next' to continue.");
- Q1 = uIn.next().trim().toLowerCase();
- } else if (Q2.equals("bear")) {
- Difficulty = 10;
- HP = 20;
- while ((HP > 0) && (CURRENTHP > 0)) {
- System.out.println("You have " + CURRENTHP
- + " health remaining.");
- pause();
- pause();
- System.out.println();
- System.out
- .println(Q2 + " has " + HP + " health remaining.");
- pause();
- int Damage = (int) (Math.round(Math.random()) + WeaponDamage);
- System.out.println("You deal " + Damage + " Damage!");
- HP = (int) (HP - Damage);
- pause();
- pause();
- System.out.println("");
- int pHealth = (int) (Math.round(Math.random() * 5));
- System.out.println("You are damaged for " + pHealth
- + " Damage!");
- pause();
- CURRENTHP = CURRENTHP - pHealth;
- pause();
- }
- if (CURRENTHP <= 0) {
- System.out.println("You have died.");
- System.exit(0);
- }
- System.out.println("You have killed the bear!");
- pause();
- int GoldEarned = (int) (Math.round(Math.random()
- * (Potential * Difficulty * 10)));
- System.out.println("You have earned " + GoldEarned + " Coins.");
- XP += 50;
- System.out.println("You've earned 50 XP.");
- MONEY += GoldEarned;
- pause();
- System.out.println("Type 'next' to continue.");
- Q1 = uIn.next().trim().toLowerCase();
- } else if (Q2.equals("boss")) {
- Difficulty = 15;
- HP = 50;
- while ((HP > 0) && (CURRENTHP > 0)) {
- System.out.println("You have " + CURRENTHP
- + " health remaining.");
- pause();
- pause();
- System.out.println();
- System.out
- .println(Q2 + " has " + HP + " health remaining.");
- pause();
- int Damage = (int) (Math.round(Math.random()) + WeaponDamage);
- System.out.println("You deal " + Damage + " Damage!");
- HP = (int) (HP - Damage);
- pause();
- pause();
- System.out.println("");
- int pHealth = (int) (Math.round(Math.random() * 10));
- System.out.println("You are damaged for " + pHealth
- + " Damage!");
- pause();
- CURRENTHP = CURRENTHP - pHealth;
- pause();
- }
- if (CURRENTHP <= 0) {
- System.out.println("You have died.");
- System.exit(0);
- }
- System.out.println("You have killed the boss!");
- pause();
- System.out.println("You have beaten the game at Level " + Lv);
- System.out.println("Final Gold Count: " + MONEY);
- System.exit(0);
- }
- }
- uIn.close();
- }
- public static void pause() {
- try {
- Thread.sleep(700);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement