Guest User

Untitled

a guest
Feb 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.31 KB | None | 0 0
  1. // weapon class
  2.  
  3. package javaapplication4;
  4.  
  5. public class Weapon {
  6.  
  7.         public static void main(String[] args) {
  8.         String[] weapon = new String[10];
  9.         weapon[0] = "";
  10.         weapon[1] = "";
  11.         weapon[2] = "";
  12.         weapon[3] = "";
  13.         weapon[4] = "";
  14.         weapon[5] = "";
  15.         weapon[6] = "";
  16.     }
  17.  
  18. }
  19.  
  20.  
  21.  
  22. //Main Method
  23.  
  24. package javaapplication4;
  25.  
  26. import java.util.*;
  27.  
  28. public class JavaApplication4 {
  29.  
  30.     public static String a = "a";
  31.     public static String b = "b";
  32.     public static String c = "c";
  33.  
  34.     public static void main(String[] args) {
  35.         int Playerattack = 10;
  36.         int Playerdefense = 10;
  37.         int Playerlifepoints = 100;
  38.         int Goblinattack = 6 - (Playerdefense / 5);
  39.         int Goblindefense = 5;
  40.         int Goblinlifepoints = 40;
  41.         int Defendgoblin = Goblinattack - Playerdefense + 10;
  42.         int Defenddamage = Playerattack / 5;
  43.         int spec = 5;
  44.         int coins = 0;
  45.         Scanner Inputin = new Scanner(System.in);
  46.         Weapon[] weapons = new Weapon[5];
  47.         weapons[0] = new Weapon("Sword", 5);
  48.  
  49.         System.out.println("Hello warrior what is your name?");
  50.         String name = Inputin.nextLine();
  51.         System.out.println("Welcome, " + name);
  52.         System.out.println("You currently have " + Playerattack + " " + "attack, " + Playerdefense + " " + "defense, and " + Playerlifepoints + " " + "lifepoints ");
  53.         System.out.println("You currently have " + spec + " special points" + " avaliable, what would you like to spend them on?");
  54.         System.out.println("Press a for +1 attack, b for +1 defense or c for +10 Lifepoints");
  55.  
  56.         for (int sp = spec; spec > 0; spec--) {   // Adding stats
  57.             String plusstats = Inputin.nextLine();
  58.             if (plusstats.equals(a)) {
  59.                 Playerattack++;
  60.                 System.out.println("Your attack is now " + Playerattack);
  61.             }
  62.             if (plusstats.equals(b)) {
  63.                 Playerdefense++;
  64.                 System.out.println("Your defense is now " + Playerdefense);
  65.  
  66.             }
  67.             if (plusstats.equals(c)) {
  68.                 Playerlifepoints = Playerlifepoints + 10;
  69.                 System.out.println("Your life points are now " + Playerlifepoints);
  70.             }
  71.             if (plusstats.equals("admin")) {
  72.                 Playerlifepoints = Playerlifepoints + 1000;
  73.                 Playerattack = Playerattack + 1000;
  74.                 Playerdefense = Playerdefense + 1000;
  75.                 System.out.println("Hello, Admin");
  76.             }
  77.  
  78.         }
  79.         System.out.println("You now have " + Playerattack + " " + "attack, " + Playerdefense + " " + "defense, and " + Playerlifepoints + " " + "lifepoints ");
  80.         System.out.println("A Goblin aproaches, you are forced to fight");
  81.         System.out.println("Goblin, attack " + Goblinattack + " defense " + Goblindefense + " lifepoints " + Goblinlifepoints + " Vs. " + name + ", attack " + Playerattack + " defense " + Playerdefense + " lifepoints " + Playerlifepoints);
  82.         System.out.println("Press a to attack, b to defend.");
  83.         for (int GoblinHp = Goblinlifepoints; Goblinlifepoints > 1;) {
  84.             String attackgoblin = Inputin.nextLine();
  85.             if (attackgoblin.equals(a)) {
  86.                 Goblinlifepoints = Goblinlifepoints - Playerattack;
  87.                 Playerlifepoints = Playerlifepoints - Goblinattack;
  88.                 System.out.println("You attack the Goblin and deal " + Playerattack + " damage");
  89.                 System.out.println("You are attacked by the goblin and are dealt " + Goblinattack + " damage");
  90.                 System.out.println("You now have " + Playerlifepoints + " health");
  91.                 System.out.println("The Goblin now has " + Goblinlifepoints + " health");
  92.             }
  93.             if (attackgoblin.equals(b)) {
  94.                 Goblinlifepoints = Goblinlifepoints - Defenddamage;
  95.                 Playerlifepoints = Playerlifepoints - Defendgoblin;
  96.                 System.out.println("You defend from the Goblin and deal " + Defenddamage + " damage");
  97.                 System.out.println("You are attacked by the goblin and are dealt " + Defendgoblin + " damage");
  98.                 System.out.println("You now have " + Playerlifepoints + " health");
  99.                 System.out.println("The Goblin now has " + Goblinlifepoints + " health");
  100.             }
  101.         }
  102.         System.out.println("Congrats you have defeated the Goblin!");
  103.         System.out.println("You now have " + Playerlifepoints + " health");
  104.         coins = coins + 130;
  105.         System.out.println("You found " + coins + " Gold coins!");
  106.         String rdrop = pickRand.get(drops);
  107.         System.out.println("You found Item" + rdrop);
  108.         System.out.println("Would you like to equip it? a, Yes b, No");
  109.         for (int eq = 1; eq > 0; eq--) {
  110.             String equip = Inputin.nextLine();
  111.             if (equip.equals(a)) {
  112.                 System.out.println("You equip the item; your Stats are now " + Playerattack + " attack " + Playerdefense + " defense and " + Playerlifepoints + " life points");
  113.             }
  114.             if (equip.equals(b)) {
  115.                 System.out.println("You Discard the Item");
  116.             }
  117.  
  118.         }
  119.  
  120.  
  121.         System.out.println("You have beaten the game..... for now.");
  122.     }
  123. }
Add Comment
Please, Sign In to add comment