Advertisement
Guest User

Untitled

a guest
May 15th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.04 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4. public class Omega{
  5.  
  6.  
  7. public static void main(String[] args){
  8.  
  9. Random rand = new Random();
  10. Scanner input = new Scanner(System.in);
  11.  
  12. int playerHealth = 100;
  13. int playerMana = 100;
  14. int omegaHealth = 200;
  15.  
  16. boolean gameRunning = true;
  17. boolean bossFightRunning = false;
  18. boolean inventoryRunning = false;
  19. boolean shopRunning = false;
  20. int mainMenuChoice;
  21. int bossMenuChoice;
  22. int swordDamage;
  23. int lunarDamage = 0;
  24. int omegaDamage;
  25.  
  26. int healthPotions = 5;
  27. int manaPotions = 0;
  28. int ranarrSeeds = 0;
  29. int bones = 0;
  30. int staff = 0;
  31. int pet = 0;
  32. int lucky;
  33.  
  34. int dropNumber;
  35.  
  36. int killCount = 0;
  37. int deathCount = 0;
  38. int swordAttacksUsed = 0;
  39. int lunarAttacksUsed = 0;
  40. int manaPotionsUsed = 0;
  41. int healthPotionsUsed = 0;
  42.  
  43. String userName;
  44. String password;
  45.  
  46. System.out.println("Please type in your username: ");
  47. userName = input.nextLine();
  48. System.out.println("Please type in your password: ");
  49. password = input.nextLine();
  50.  
  51. if(checkInfo(userName, password)){
  52. System.out.println("\nWelcome to Omega simulator!\n");
  53. while(gameRunning){
  54. mainMenu();
  55. mainMenuChoice = input.nextInt();
  56. switch(mainMenuChoice){
  57. case 1:
  58. backStory();
  59. bossFightRunning = true;
  60. while(bossFightRunning){
  61.  
  62. if(playerHealth <= 0){
  63. System.out.println("Oh dear, you've died!");
  64. System.out.println("The water Nymphs nearby have risen you back to full health");
  65. System.out.println("but you better watch yourself next time\n");
  66. playerHealth = 100;
  67. omegaHealth = 200;
  68. deathCount++;
  69. bossFightRunning = false;
  70. break;
  71. }
  72.  
  73. if(omegaHealth <= 0){
  74.  
  75. bones++;
  76. System.out.println("Wow you've managed to slay the Omega!");
  77. System.out.println("His remains are in the form of werewolf bones...");
  78. omegaHealth = 200;
  79. killCount++;
  80.  
  81. lucky = dropDrop();
  82. if(lucky == 0){
  83. System.out.println("The Omega didn't drop anything!");
  84. }else if(lucky == 1){
  85. System.out.println("You feel funny as if something is following you...");
  86. pet++;
  87. }else if(lucky == 2){
  88. System.out.println("The Omega dropped a Staff of the Moon!");
  89. staff++;
  90. }else if(lucky == 3){
  91. System.out.println("The Omega dropped three mana potions!");
  92. manaPotions+=3;
  93. }else if(lucky == 4){
  94. System.out.println("The Omega dropped a ranarr seed!");
  95. ranarrSeeds++;
  96. }else if(lucky == 5){
  97. System.out.println("The Omega dropped three health potions!");
  98. healthPotions+=3;
  99. }else if(lucky == 6){
  100. System.out.println("The Omega dropped one mana potion!");
  101. manaPotions++;
  102. }else if(lucky == 7){
  103. System.out.println("The Omega dropped two health potions!");
  104. healthPotions+=2;
  105. }
  106.  
  107.  
  108. bossFightRunning = false;
  109. break;
  110. }
  111.  
  112. System.out.println();
  113. System.out.println("What do you want to do?");
  114. bossMenu();
  115. bossMenuChoice = input.nextInt();
  116.  
  117. switch(bossMenuChoice){
  118. case 1:
  119. swordDamage = rand.nextInt(60);
  120. System.out.println("You swing your sword at Omega and hit him for " + swordDamage + " damage!" );
  121. omegaHealth -= swordDamage;
  122. System.out.println("Omega now has " + omegaHealth + " hitpoints.");
  123. omegaDamage = rand.nextInt(50);
  124. System.out.println("He claws you down for " + omegaDamage + " damage.");
  125. playerHealth -= omegaDamage;
  126. System.out.println("You now have " + playerHealth + " hitpoints.\n");
  127. System.out.println("You now have " + playerMana + " mana left");
  128. swordAttacksUsed++;
  129. break;
  130. case 2:
  131. if(staff == 0){
  132. System.out.println("You do not have the staff of the moon.");
  133. }else if(playerMana <25){
  134. System.out.println("You do not have enough mana to cast lunar seplls.");
  135. }else{
  136.  
  137. lunarDamage = rand.nextInt(150);
  138. while(lunarDamage<80){
  139. lunarDamage = rand.nextInt(150);
  140. }
  141.  
  142. playerMana-= 25;
  143. System.out.println("You cast a lunar spell at Omega and hit him for " + lunarDamage + " damage!" );
  144. omegaHealth -= lunarDamage;
  145. System.out.println("Omega now has " + omegaHealth + " hitpoints.");
  146. omegaDamage = rand.nextInt(50);
  147. System.out.println("He claws you down for " + omegaDamage + " damage.");
  148. playerHealth -= omegaDamage;
  149. System.out.println("You now have " + playerHealth + " hitpoints.");
  150. System.out.println("You now have " + playerMana + " mana left");
  151. lunarAttacksUsed++;
  152.  
  153. }
  154. break;
  155. case 3:
  156. if(healthPotions <= 0){
  157. System.out.println("You don't have any health potions!\n");
  158. break;
  159. }else if(playerHealth >= 100){
  160. System.out.println("You already have max health!");
  161. }else if(playerHealth >= 51 && playerHealth <100){
  162. int healthDifference = 100 - playerHealth;
  163. System.out.println("You drink a health potion and restore" + healthDifference + "healthpoints.");
  164. playerHealth+= healthDifference;
  165. healthPotions--;
  166. healthPotionsUsed++;
  167. System.out.println("Your health is now " + playerHealth + " healthpoints");
  168. System.out.println("You now have " + healthPotions + " left.");
  169. }else{
  170. System.out.println("You drink a health potion and restore 50 healthpoints.");
  171. playerHealth+= 50;
  172. healthPotions--;
  173. healthPotionsUsed++;
  174. System.out.println("Your health is now " + playerHealth + " heathpoints.");
  175. System.out.println("You now have " + healthPotions + " left.");
  176. }
  177. break;
  178. case 4:
  179. if(manaPotions <= 0){
  180. System.out.println("You don't have any mana potions!\n");
  181. break;
  182. }else if(playerMana >= 100){
  183. System.out.println("You already have max mana!");
  184. }else if(playerMana >=51 && playerMana <100){
  185. int manaDifference = 100-playerMana;
  186. System.out.println("You drink a mana potion and restore" + manaDifference + " mana.");
  187. playerMana+= manaDifference;
  188. manaPotions--;
  189. manaPotionsUsed++;
  190. System.out.println("Your mana is now " + playerMana + " mana.");
  191. System.out.println("You now have " + manaPotions + " left.");
  192. }else{
  193. System.out.println("You drink a mana potion and restore 50 mana.");
  194. playerMana+= 50;
  195. manaPotions--;
  196. manaPotionsUsed++;
  197. System.out.println("Your mana is now " + playerMana + " mana.");
  198. System.out.println("You now have " + manaPotions + " left.");
  199. }
  200. break;
  201. case 5:
  202. System.out.println("You have surrendered\n");
  203. System.out.println("The nearby fairys decided to heal you up!");
  204. omegaHealth = 200;
  205. playerHealth = 100;
  206. bossFightRunning = false;
  207. break;
  208. default:
  209. break;
  210.  
  211. }
  212. }
  213. break;
  214.  
  215. case 2:
  216.  
  217.  
  218. System.out.println("#######Inventory and Statistics########\n");
  219. inventoryList(healthPotions, manaPotions, bones, staff, ranarrSeeds, pet, killCount, deathCount, swordAttacksUsed, lunarAttacksUsed, healthPotionsUsed, manaPotionsUsed);
  220. System.out.println("1. Return to main menu.");
  221. int leaveInventory = input.nextInt();
  222. if(leaveInventory == 1){
  223.  
  224.  
  225.  
  226. break;
  227. }
  228.  
  229. case 3:
  230.  
  231.  
  232. System.out.println("Shop is coming soon!");
  233. System.out.println("1. Return to main menu.");
  234. int leaveShop = input.nextInt();
  235. if(leaveShop == 1){
  236.  
  237.  
  238.  
  239. break;
  240. }
  241.  
  242. case 4:
  243. System.out.println("Good day!");
  244. gameRunning = false;
  245. break;
  246. default:
  247. break;
  248. }
  249. }
  250. }else{
  251. System.out.println("Your log-in information is not correct.");
  252. }
  253. }
  254.  
  255.  
  256. public static void backStory(){
  257. System.out.println("You approach the desolate, silent forest.");
  258. System.out.println("All that you possess is a mighty, lightbringing sword\nand five health potions.");
  259. System.out.println("An enormous werewolf suddenly emerges from the shrubs.");
  260. System.out.println("Rumour has it that killing this giant werewolf can yield");
  261. System.out.println("health potions, mana potions, ranarr seeds, and the staff of the moon");
  262. System.out.println("which can be used to cast magic spells requiring 25.");
  263.  
  264. }
  265.  
  266. public static void mainMenu(){
  267. System.out.println("1. Omega Fight");
  268. System.out.println("2. Inventory and Statistics");
  269. System.out.println("3. Shop");
  270. System.out.println("4. Leave the game!");
  271. }
  272.  
  273. public static void bossMenu(){
  274. System.out.println("1. Attack Omega with your sword.");
  275. System.out.println("2. Attack Omega using lunar spells.");
  276. System.out.println("3. Drink a health potion.");
  277. System.out.println("4. Drink a mana potion.");
  278. System.out.println("5. Surrender the fight.");
  279.  
  280. }
  281.  
  282. public static boolean checkInfo(String u, String p){
  283. if(u.equals("Bricson") && p.equals("gotmilk17")){
  284. return true;
  285. }else{
  286. return false;
  287. }
  288. }
  289.  
  290. public static void inventoryList(int h, int m, int b, int s, int r, int p, int kc, int dc, int sa, int la, int hu, int mu){
  291. System.out.println("Health Potions: " + h);
  292. System.out.println("Mana Potions: " + m);
  293. System.out.println("Werewolf Bones: " + b);
  294. System.out.println("Staff of the Moon: " + s);
  295. System.out.println("ranarr seeds: " + r);
  296. System.out.println("Werewolf Pet: " + p);
  297. System.out.println("");
  298. System.out.println("Killcount: " + kc);
  299. System.out.println("Deathcount: " + dc);
  300. System.out.println("Sword Attacks Used: " + sa);
  301. System.out.println("Lunar Attacks Used: " + la);
  302. System.out.println("Health Potions Used: " + hu);
  303. System.out.println("Mana Potions Used: " + mu);
  304.  
  305. }
  306.  
  307. public static int dropDrop(){
  308. int drop = 0;
  309. Random dropPercent = new Random();
  310. if((dropPercent.nextInt(100)+1) == 1){
  311. drop = 1;
  312. }else if((dropPercent.nextInt(100)+1) <= 20){
  313. drop = 2;
  314. }else if((dropPercent.nextInt(100)+1) <= 30){
  315. drop = 3;
  316. }else if((dropPercent.nextInt(100)+1) <= 35){
  317. drop = 4;
  318. }else if((dropPercent.nextInt(100)+1) <= 50){
  319. drop = 5;
  320. }else if((dropPercent.nextInt(100)+1) <= 65){
  321. drop = 6;
  322. }else if((dropPercent.nextInt(100)+1) <= 75){
  323. drop = 7;
  324. }
  325. return drop;
  326. }
  327.  
  328. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement