Guest User

Untitled

a guest
May 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. class dandd {
  4. public static class Person {
  5. String name;
  6. int hp;
  7. int ac;
  8. int init;
  9. String weapon;
  10. int attk;
  11. int Dmg;
  12.  
  13. public static int Rollhp (int HD,int lvl) {
  14. int hit = 0;
  15. for (int count = 1; count <= lvl; count++) {
  16. hit = hit + new Random() .nextInt(HD) +1;
  17. }
  18. return hit;
  19. }
  20. }
  21. public static Person Build() { //Constructor to build a new Person object.
  22. Person Guard = new Person();
  23. Guard.name = "Guard";
  24. Guard.hp = Person.Rollhp(8,3) + 3;
  25. Guard.ac = 16;
  26. Guard.init = 10;
  27. Guard.weapon = "Longsword (1d8+3)";
  28. Guard.attk = 5;
  29.  
  30. return Guard;
  31.  
  32. }
  33.  
  34. public static void Display (Person Combatants[],int numComb) {
  35. for (int i = 0; i < numComb; i++) {
  36. System.out.println((i+1)+":");
  37. System.out.println("Name: "+Combatants[i].name);
  38. System.out.println("HP: "+Combatants[i].hp);
  39. System.out.println("AC: "+Combatants[i].ac);
  40. System.out.println("Weapon: "+Combatants[i].weapon);
  41. System.out.println("Attack: +"+Combatants[i].attk);
  42. System.out.println();
  43. }
  44. }
  45.  
  46. public static Person[] Damage (Person Combatants[]) { //Damages the Player.
  47.  
  48. //Scanner keyboard = new Scanner(System.in);
  49. //System.out.print("Which?");
  50. //int choice = keyboard.nextInt();
  51. //System.out.println();
  52. //System.out.print("Enter Damage:");
  53. int damage = 10;//keyboard.nextInt();
  54. int choice = 2;//choice-1;
  55. Combatants[choice].hp = Combatants[choice].hp - damage;
  56.  
  57. return Combatants;
  58. }
  59.  
  60. /*public Dead () { //Removes the combatant from combat.
  61.  
  62. */
  63.  
  64. public static void main (String args[]) {
  65. Person Combatants[];
  66. Combatants = new Person[10];
  67. int numComb = 0;
  68.  
  69. Combatants[numComb] = Build();
  70. numComb++;
  71. Combatants[numComb] = Build();
  72. numComb++;
  73. Combatants[numComb] = Build();
  74. numComb++;
  75. Display(Combatants, numComb);//Here's where the program stops.
  76.  
  77. Combatants = Damage(Combatants);
  78. Display(Combatants, numComb);
  79. }
  80. }
Add Comment
Please, Sign In to add comment