Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.14 KB | None | 0 0
  1. //Tony Guillory
  2. import java.io.*;
  3. import java.util.*;
  4. class Game1TG
  5. {
  6. public static void main(String args[])throws IOException
  7. {
  8. String playerName = "", monsterName = "", npcName = "";
  9. String className = "", raceName = "", itemName = "";
  10. int playerLVL = 1, playerEXP = 0, playerClass = 0, playerRace = 0, playerHP = 50, playerDEF = 10;
  11. int playerSTR = 10, playerDEX = 10, playerCON = 10, playerINT = 10;
  12. int modSTR = 0, modDEX = 0, modCON = 0, modINT = 0;
  13. int monsterHP = 0, monsterEXP = 0, monsterDEF = 0, monsterATK = 1;
  14. int monster, chance = 0, choice;
  15. int potion = 1, hipotion = 1, numberPotion = 1, numberHiPotion = 1;
  16. Random roll = new Random();
  17. Scanner input = new Scanner(System.in);
  18.  
  19. System.out.println("What is your character's name?"); // Input Name
  20. playerName = input.next();
  21. System.out.println("\nChoose your race: \n"); // Choose your race
  22. {
  23. int invalidRace = 1;
  24. while(invalidRace == 1)
  25. {
  26. System.out.println("1 Human \n2 Elf\n3 Dwarf");
  27. playerRace = input.nextInt();
  28. switch(playerRace)
  29. {
  30. case 1:
  31. {
  32. raceName = "Human";
  33. playerCON = playerCON + 2;
  34. playerDEF = playerDEF + 5;
  35. invalidRace = invalidRace -1;
  36. System.out.println();
  37. System.out.println("You have chosen Human as your race");
  38. System.out.println();
  39. }
  40. break;
  41. case 2:
  42. {
  43. raceName = "Elf";
  44. playerDEX = playerDEX + 2;
  45. modDEX = modDEX + 1;
  46. playerINT = playerINT + 2;
  47. modINT = modINT + 1;
  48. playerSTR = playerSTR - 2;
  49. modSTR = modSTR -1;
  50. invalidRace = invalidRace - 1;
  51. System.out.println();
  52. System.out.println("You have chosen Elf as your race");
  53. System.out.println();
  54. }
  55. break;
  56. case 3:
  57. {
  58. raceName = "Dwarf";
  59. playerSTR = playerSTR + 2;
  60. modSTR = modSTR + 2;
  61. playerDEX = playerDEX - 2;
  62. modDEX = modDEX - 1;
  63. invalidRace = invalidRace -1;
  64. System.out.println();
  65. System.out.println("You have chosen Dwarf as your race");
  66. System.out.println();
  67. }
  68. break;
  69. default:
  70. {
  71. System.out.println();
  72. System.out.println("That is an invalid selection");
  73. System.out.println();
  74. break;
  75. }
  76. }
  77. }
  78. }
  79.  
  80. System.out.println("\nChoose your class: \n"); // Choose your class
  81.  
  82. {
  83. int invalidClass = 1;
  84. while(invalidClass == 1)
  85. {
  86. System.out.println("1 Fighter \n2 Mage \n3 Archer");
  87. playerClass = input.nextInt();
  88. switch(playerClass)
  89. {
  90. case 1:
  91. {
  92. className = "Fighter";
  93. playerClass = 1;
  94. playerSTR = playerSTR + 8;
  95. modSTR = modSTR + 4;
  96. playerDEX = playerDEX - 2;
  97. modDEX = modDEX - 1;
  98. playerCON = playerCON + 2;
  99. modCON = modCON + 1;
  100. playerINT = playerINT - 4;
  101. modINT = modINT - 2;
  102. playerHP = playerCON * 6;
  103. playerDEF = playerDEF + 7;
  104. invalidClass = invalidClass - 1;
  105. System.out.println();
  106. System.out.println("You have chosen Fighter as your class");
  107. System.out.println();
  108. }
  109. break;
  110. case 2:
  111. {
  112. className = "Mage";
  113. playerClass = 2;
  114. playerSTR = playerSTR - 4;
  115. modSTR = modSTR - 2;
  116. playerDEX = playerDEX + 2;
  117. modDEX = modDEX + 1;
  118. playerCON = playerCON - 2;
  119. modCON = modCON -1;
  120. playerINT = playerINT + 12;
  121. modINT = modINT + 6;
  122. playerHP = playerCON * 4;
  123. playerDEF = playerDEF + 2;
  124. invalidClass = invalidClass - 1;
  125. System.out.println();
  126. System.out.println("You have chosen Mage as your class");
  127. System.out.println();
  128. }
  129. break;
  130. case 3:
  131. {
  132. className = "Archer";
  133. playerClass = 3;
  134. playerSTR = playerSTR + 2;
  135. modSTR = modSTR + 1;
  136. playerDEX = playerDEX + 8;
  137. modDEX = modDEX + 4;
  138. playerCON = playerCON - 2;
  139. modCON = modCON - 1;
  140. playerINT = playerINT - 4;
  141. modINT = modINT - 2;
  142. playerHP = playerCON * 5;
  143. playerDEF = playerDEF + 5;
  144. invalidClass = invalidClass - 1;
  145. System.out.println();
  146. System.out.println("You have chosen Archer as your class");
  147. System.out.println();
  148. }
  149. break;
  150. default:
  151. {
  152. System.out.println();
  153. System.out.println("That is an invalid selection");
  154. System.out.println();
  155. }
  156. break;
  157. }
  158. }
  159. }
  160. int randomEnc = 0;
  161. while(randomEnc == 1)
  162. {
  163. {
  164. monster = roll.nextInt(1000)+1; // setup phase
  165. if (monster <= 25)
  166. {
  167. monsterHP = 25;
  168. monsterName = "Rat";
  169. monsterATK = 3;
  170. monsterDEF = 5;
  171. monsterEXP = 50;
  172. }
  173. else if (monster > 25 && monster <= 50)
  174. {
  175. monsterHP = 35;
  176. monsterName = "Goblin";
  177. monsterATK = 4;
  178. monsterDEF = 7;
  179. monsterEXP = 100;
  180. }
  181. else if (monster > 50 && monster <= 75)
  182. {
  183. monsterHP = 45;
  184. monsterName = "Troll";
  185. monsterATK = 6;
  186. monsterDEF = 9;
  187. monsterEXP = 150;
  188. }
  189. else if (monster > 75 && monster <= 100)
  190. {
  191. monsterHP = 55;
  192. monsterName = "Ogre";
  193. monsterATK = 7;
  194. monsterDEF = 11;
  195. monsterEXP = 200;
  196. }
  197. else if (monster > 100)
  198. {
  199. // no battle
  200. randomEnc = randomEnc - 1;
  201. break;
  202. }
  203. if (randomEnc == 1)
  204. {
  205. System.out.println(playerName + " is attacked by a " + monsterName);
  206. }
  207. System.out.println("\nMake your move: \n");
  208. while(monsterHP > 0 && playerHP > 0 ) //Battle phase
  209. {
  210. if(playerClass == 1)
  211. {
  212. System.out.println("1 Slash \n2 Thrust \n3 Bash");
  213. }
  214. else if(playerClass == 2)
  215. {
  216. System.out.println("1 Fire \n2 Ice \n3 Lightning");
  217. }
  218. else if(playerClass == 3)
  219. {
  220. System.out.println("1 Long Shot \n2 Dagger \n3 Pot Shot");
  221. }
  222. choice = input.nextInt();
  223. switch(choice)
  224. {
  225. case 1:
  226. if(playerClass == 1)
  227. {
  228. chance = roll.nextInt(100)+modSTR;
  229. }
  230. else if(playerClass == 2)
  231. {
  232. chance = roll.nextInt(100)+modINT;
  233. }
  234. else if(playerClass == 3)
  235. {
  236. chance = roll.nextInt(100)+modDEX;
  237. }
  238. if(chance >= 30)
  239. {
  240. System.out.println(" \nYou hit the " + monsterName + " for 4hp");
  241. monsterHP = monsterHP - 4;
  242. }
  243. else if(chance < 30)
  244. {
  245. System.out.println(" \nYou miss the " + monsterName);
  246. }
  247. break;
  248. case 2:
  249. if(playerClass == 1)
  250. {
  251. chance = roll.nextInt(100)+modSTR;
  252. }
  253. else if(playerClass == 2)
  254. {
  255. chance = roll.nextInt(100)+modINT;
  256. }
  257. else if(playerClass == 3)
  258. {
  259. chance = roll.nextInt(100)+modDEX;
  260. }
  261. if(chance >= 45)
  262. {
  263. System.out.println(" \nYou hit the " + monsterName + " for 5hp");
  264. monsterHP = monsterHP - 5;
  265. }
  266. else if( chance < 45)
  267. {
  268. System.out.println(" \nYou miss the " + monsterName);
  269. }
  270. break;
  271. case 3:
  272. if(playerClass == 1)
  273. {
  274. chance = roll.nextInt(100)+modSTR;
  275. }
  276. else if(playerClass == 2)
  277. {
  278. chance = roll.nextInt(100)+modINT;
  279. }
  280. else if(playerClass == 3)
  281. {
  282. chance = roll.nextInt(100)+modDEX;
  283. }
  284. if(chance >= 75)
  285. {
  286. System.out.println(" \nYou hit the " + monsterName + " for 6hp");
  287. monsterHP = monsterHP - 10;
  288. }
  289. else if(chance < 75)
  290. {
  291. System.out.println(" \nYou miss the " + monsterName);
  292. }
  293. break;
  294. default:
  295. System.out.println(" \nWhile wondering why nothing happened the " + monsterName + " attacks you");
  296. playerHP = playerHP - 5;
  297. break;
  298. }
  299. if(playerHP > 0)
  300. {
  301. chance = roll.nextInt(100)+1;
  302. if(chance >= 45)
  303. {
  304. System.out.println("\n" + monsterName + " hits " + playerName + " for " + monsterATK + " hp");
  305. playerHP = playerHP - monsterATK;
  306. }
  307. else if(chance < 45)
  308. {
  309. System.out.println("\n" + monsterName + " misses " + playerName);
  310. }
  311. {
  312. System.out.println("\n" + playerName + " has " + playerHP + "hp left");
  313. System.out.println(" \n" + monsterName + " has " + monsterHP + "hp left");
  314. System.out.println();
  315. }
  316. if(playerHP <= 0 & monsterHP > 0)
  317. {
  318. System.out.println("\nThe " + monsterName + " has defeated " + playerName);
  319. randomEnc = randomEnc - 1;
  320. }
  321. else if(playerHP > 0 & monsterHP <= 0)
  322. {
  323. System.out.println("\nthe " + monsterName + " is defeated");
  324. playerEXP = playerEXP + monsterEXP;
  325. System.out.println( playerName + " gains " + monsterEXP + "Exp");
  326. randomEnc = randomEnc - 1;
  327. System.out.println();
  328. }
  329. else if(playerHP < 0 & monsterHP < 0)
  330. {
  331. System.out.println("\n" + playerName + " and the" + monsterName + " fall from mortal injuries");
  332. randomEnc = randomEnc - 1;
  333. }
  334. }
  335. }
  336. }
  337. if(playerEXP >= 500)
  338. {
  339. System.out.println(playerName + " has gained a level ");
  340. playerLVL = playerLVL + 1;
  341. playerEXP = playerEXP - playerEXP;
  342. playerSTR = playerSTR + 5;
  343. modSTR = modSTR + 1;
  344. playerDEX = playerDEX + 5;
  345. modDEX = modDEX + 1;
  346. playerCON = playerCON + 5;
  347. modCON = modCON +1;
  348. playerINT = playerINT + 5;
  349. modINT = modINT + 1;
  350. playerHP = playerHP + 50;
  351. playerDEF = playerDEF + 2;
  352. System.out.println(playerName +" is level " + playerLVL);
  353. System.out.println("Str = " + playerSTR + " DEX = " + playerDEX + " Con = " + playerCON + " Int = " + playerINT + " HP = " + playerHP + " Def = " + playerDEF);
  354. }
  355. if (playerHP <= 0)
  356. {
  357. System.out.println();
  358. System.out.println("Game Over");
  359. }
  360. }
  361. }
  362. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement