Advertisement
Tezlaz

RPGtest - For Kainzo

Jul 9th, 2014
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.73 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Rpgtest {
  4.     static int HP = 0;
  5.     static int Potential = 1;
  6.     static int Damage = 0;
  7.     static int Difficulty = 0;
  8.     static int GoldEarned = 0;
  9.     static int MONEY = 0;
  10.     static int TOTALHP = 10;
  11.     static int[] LEVEL = new int[10];
  12.     static int WeaponDamage = 2;
  13.     static int XP = 0;
  14.     static int CURRENTHP = 0;
  15.  
  16.     public static void main(String... Args) {
  17.         LEVEL[0] = 0;
  18.         LEVEL[1] = 5;
  19.         LEVEL[2] = 15;
  20.         LEVEL[3] = 40;
  21.         LEVEL[4] = 75;
  22.         LEVEL[5] = 120;
  23.         LEVEL[6] = 180;
  24.         LEVEL[7] = 280;
  25.         LEVEL[8] = 430;
  26.         LEVEL[9] = 730;
  27.         CURRENTHP = TOTALHP;
  28.         Scanner uIn = new Scanner(System.in);
  29.         System.out.println("====<Welcome to Tez's RPG>====");
  30.         System.out.println("Type 'next' to start your adventure through walls of text!");
  31.         String Q1 = uIn.next().trim().toLowerCase();
  32.         int Lv = 1;
  33.  
  34.         while (Q1.equals("next")) {
  35.             if ((XP >= LEVEL[Lv]) && Lv < 9) {
  36.                 ++Lv;
  37.                 ++WeaponDamage;
  38.                 TOTALHP += 5;
  39.                 CURRENTHP += 1;
  40.             }
  41.             System.out.println("You are currently Level " + (Lv));
  42.             System.out.println("Experience: " + XP + " / " + LEVEL[Lv]);
  43.             System.out.println("Your health is " + CURRENTHP + "/" + TOTALHP);
  44.             System.out.println("Current money: " + MONEY);
  45.             pause();
  46.             System.out.println("Would you like to shop or fight?");
  47.             System.out
  48.                     .println("To shop, type 'shop'\nType anything else to continue.");
  49.             String Q3 = uIn.next().trim().toLowerCase();
  50.             while (Q3.equals("shop")) {
  51.                 System.out.println("What would you like to buy?");
  52.                 pause();
  53.                 System.out.println("1 for full heal -- 30 Coins");
  54.                 pause();
  55.                 System.out
  56.                         .println("2 for increasing weapon damage potential by 1 -- 100 Coins");
  57.                 int Q4 = uIn.nextInt();
  58.                 if (Q4 == 1 && MONEY >= 30) {
  59.                     pause();
  60.                     System.out.println("You replenish your health.");
  61.                     CURRENTHP = TOTALHP;
  62.                     pause();
  63.                     System.out.println("Your health is now " + CURRENTHP);
  64.                     MONEY = MONEY - 30;
  65.                 } else if (Q4 == 2 && MONEY >= 100) {
  66.                     pause();
  67.                     System.out.println("You increase your Weapon Damage by 1.");
  68.                     ++WeaponDamage;
  69.                     MONEY = MONEY - 100;
  70.                 } else {
  71.                     pause();
  72.                     System.out.println("Insufficient Funds");
  73.                 }
  74.                 System.out
  75.                         .println("Would you like to shop more or leave?\n'shop' to continue shopping.\nType anything else to continue.");
  76.                 Q3 = uIn.next().trim().toLowerCase();
  77.             }
  78.             System.out.println("What monster would you like to fight?");
  79.             pause();
  80.             System.out
  81.                     .println("Rat(Level 1 / 5HP)\nGoblin(Level 3 / 10HP)\nBear(Level 10 / 20HP)\nBoss(Level 15 / 50HP)");
  82.             String Q2 = uIn.next().trim().toLowerCase();
  83.  
  84.             if (Q2.equals("rat")) {
  85.                 Difficulty = 2;
  86.                 HP = 5;
  87.                 while ((HP > 0) && (CURRENTHP > 0)) {
  88.                     System.out.println("You have " + CURRENTHP
  89.                             + " health remaining.");
  90.                     pause();
  91.                     pause();
  92.                     System.out.println();
  93.                     System.out
  94.                             .println(Q2 + " has " + HP + " health remaining.");
  95.                     pause();
  96.                     int Damage = (int) (Math.round(Math.random()) + WeaponDamage);
  97.                     System.out.println("You deal " + Damage + " Damage!");
  98.                     HP = (int) (HP - Damage);
  99.                     pause();
  100.                     pause();
  101.                     System.out.println("");
  102.                     int pHealth = (int) (Math.round(Math.random() * 1));
  103.                     System.out.println("You are damaged for " + pHealth
  104.                             + " Damage!");
  105.                     pause();
  106.                     CURRENTHP = CURRENTHP - pHealth;
  107.                     pause();
  108.  
  109.                 }
  110.                 if (CURRENTHP <= 0) {
  111.                     System.out.println("You have died.");
  112.                     System.exit(0);
  113.                 }
  114.                 System.out.println("You have killed the rat!");
  115.                 pause();
  116.                 int GoldEarned = (int) (Math.round(Math.random()
  117.                         * (Potential * Difficulty * 10)));
  118.                 System.out.println("You have earned " + GoldEarned + " Coins.");
  119.                 XP += 5;
  120.                 System.out.println("You've earned 5 XP.");
  121.                 MONEY += GoldEarned;
  122.                 pause();
  123.                 System.out.println("Type 'next' to continue.");
  124.                 Q1 = uIn.next().trim().toLowerCase();
  125.  
  126.             } else if (Q2.equals("goblin")) {
  127.                 Difficulty = 5;
  128.                 HP = 10;
  129.                 while ((HP > 0) && (CURRENTHP > 0)) {
  130.                     System.out.println("You have " + CURRENTHP
  131.                             + " health remaining.");
  132.                     pause();
  133.                     pause();
  134.                     System.out.println();
  135.                     System.out
  136.                             .println(Q2 + " has " + HP + " health remaining.");
  137.                     pause();
  138.                     int Damage = (int) (Math.round(Math.random()) + WeaponDamage);
  139.                     System.out.println("You deal " + Damage + " Damage!");
  140.                     HP = (int) (HP - Damage);
  141.                     pause();
  142.                     pause();
  143.                     System.out.println("");
  144.                     int pHealth = (int) (Math.round(Math.random() * 3));
  145.                     System.out.println("You are damaged for " + pHealth
  146.                             + " Damage!");
  147.                     pause();
  148.                     CURRENTHP = CURRENTHP - pHealth;
  149.                     pause();
  150.  
  151.                 }
  152.                 if (CURRENTHP <= 0) {
  153.                     System.out.println("You have died.");
  154.                     System.exit(0);
  155.                 }
  156.                 System.out.println("You have killed the goblin!");
  157.                 pause();
  158.                 int GoldEarned = (int) (Math.round(Math.random()
  159.                         * (Potential * Difficulty * 10)));
  160.                 System.out.println("You have earned " + GoldEarned + " Coins.");
  161.                 XP += 20;
  162.                 System.out.println("You've earned 20 XP.");
  163.                 MONEY += GoldEarned;
  164.                 pause();
  165.                 System.out.println("Type 'next' to continue.");
  166.                 Q1 = uIn.next().trim().toLowerCase();
  167.  
  168.             } else if (Q2.equals("bear")) {
  169.                 Difficulty = 10;
  170.                 HP = 20;
  171.                 while ((HP > 0) && (CURRENTHP > 0)) {
  172.                     System.out.println("You have " + CURRENTHP
  173.                             + " health remaining.");
  174.                     pause();
  175.                     pause();
  176.                     System.out.println();
  177.                     System.out
  178.                             .println(Q2 + " has " + HP + " health remaining.");
  179.                     pause();
  180.                     int Damage = (int) (Math.round(Math.random()) + WeaponDamage);
  181.                     System.out.println("You deal " + Damage + " Damage!");
  182.                     HP = (int) (HP - Damage);
  183.                     pause();
  184.                     pause();
  185.                     System.out.println("");
  186.                     int pHealth = (int) (Math.round(Math.random() * 5));
  187.                     System.out.println("You are damaged for " + pHealth
  188.                             + " Damage!");
  189.                     pause();
  190.                     CURRENTHP = CURRENTHP - pHealth;
  191.                     pause();
  192.  
  193.                 }
  194.                 if (CURRENTHP <= 0) {
  195.                     System.out.println("You have died.");
  196.                     System.exit(0);
  197.                 }
  198.                 System.out.println("You have killed the bear!");
  199.                 pause();
  200.                 int GoldEarned = (int) (Math.round(Math.random()
  201.                         * (Potential * Difficulty * 10)));
  202.                 System.out.println("You have earned " + GoldEarned + " Coins.");
  203.                 XP += 50;
  204.                 System.out.println("You've earned 50 XP.");
  205.                 MONEY += GoldEarned;
  206.                 pause();
  207.                 System.out.println("Type 'next' to continue.");
  208.                 Q1 = uIn.next().trim().toLowerCase();
  209.  
  210.             } else if (Q2.equals("boss")) {
  211.                 Difficulty = 15;
  212.                 HP = 50;
  213.                 while ((HP > 0) && (CURRENTHP > 0)) {
  214.                     System.out.println("You have " + CURRENTHP
  215.                             + " health remaining.");
  216.                     pause();
  217.                     pause();
  218.                     System.out.println();
  219.                     System.out
  220.                             .println(Q2 + " has " + HP + " health remaining.");
  221.                     pause();
  222.                     int Damage = (int) (Math.round(Math.random()) + WeaponDamage);
  223.                     System.out.println("You deal " + Damage + " Damage!");
  224.                     HP = (int) (HP - Damage);
  225.                     pause();
  226.                     pause();
  227.                     System.out.println("");
  228.                     int pHealth = (int) (Math.round(Math.random() * 10));
  229.                     System.out.println("You are damaged for " + pHealth
  230.                             + " Damage!");
  231.                     pause();
  232.                     CURRENTHP = CURRENTHP - pHealth;
  233.                     pause();
  234.  
  235.                 }
  236.                 if (CURRENTHP <= 0) {
  237.                     System.out.println("You have died.");
  238.                     System.exit(0);
  239.                 }
  240.                 System.out.println("You have killed the boss!");
  241.                 pause();
  242.                 System.out.println("You have beaten the game at Level " + Lv);
  243.                 System.out.println("Final Gold Count: " + MONEY);
  244.                 System.exit(0);
  245.  
  246.             }
  247.         }
  248.         uIn.close();
  249.  
  250.     }
  251.  
  252.     public static void pause() {
  253.         try {
  254.             Thread.sleep(700);
  255.         } catch (InterruptedException e) {
  256.             e.printStackTrace();
  257.         }
  258.     }
  259. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement