Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. package roomgame;
  2. import java.util.Scanner;
  3. public class RoomGame
  4. {
  5. private static String[][][] Room = new String[5][5][2];
  6. private static int Row = 0;
  7. private static int Column = 0;
  8. private static int Depth = 0;
  9. private static int HP = 100;
  10. private static int Damage = 20;
  11. private static int RandoNumber = 0;
  12. private static int min = 1;
  13. private static int max = 2;
  14. private static int range = 0;
  15. private static int TheRandomNumberDamage = 0;
  16. private static int Gold = 0;
  17. private static int minGold = 1;
  18. private static int maxGold = 100;
  19. private static int rangeGold = 0;
  20. private static int RandomGold = 0;
  21.  
  22.  
  23. public static void main(String[] args)
  24. {
  25. System.out.println("This is a program that makes you play a maze game");
  26. RoomGame bob = new RoomGame();
  27. bob.One();
  28. }
  29.  
  30. private void One()
  31. {
  32. System.out.println("The controls are to move North, East, South, West");
  33. Assigning();
  34. System.out.println("You may lose HP or encounter gold in this maze, beware");
  35. System.out.println("Your HP is " + HP);
  36. System.out.println("Your Gold is " + Gold);
  37. Calculating();
  38. }
  39. private void Assigning()
  40. {
  41.  
  42. range = (max-min)+1;
  43. rangeGold = (maxGold - minGold) + 1;
  44.  
  45. Room[0][0][0] = "You are in dark room. You see a light ahead"; //room 0
  46. Room[0][0][1] = "You can move North";
  47.  
  48. Room[1][0][0] = "It's so bright with candles. It's blinding me"; //room 1
  49. Room[1][0][1] = "You can move North or East";
  50.  
  51. Room[2][0][0] = "There is a strange smell. Perhaps a forest is nearby?"; //room 2
  52. Room[2][0][1] = "You can move East or South";
  53.  
  54. Room[2][1][0] = "The room has trees in it. They're prickly"; //room 3
  55. Room[2][1][1] = "You can move West, South, or East";
  56.  
  57. Room[1][1][0] = "The room is very purple. How Strange"; //room 5
  58. Room[1][1][1] = "You can move West, North, or East";
  59.  
  60. Room[1][2][0] = "The room is orange. How strange"; //room 6
  61. Room[1][2][1] = "You can move West, North, or East";
  62.  
  63. Room[2][2][0] = "The room is white. How strange"; //room 7
  64. Room[2][2][1] = "You can move North, West, South, or East";
  65.  
  66. Room[2][3][0] = "The room is pink. How strange"; //room 8
  67. Room[2][3][1] = "You can move West";
  68.  
  69. Room[3][2][0] = "You've reached the final room. Congratulations!"; //room 4
  70. Room[3][2][1] = "You can move back south, if you wish";
  71.  
  72. }
  73.  
  74. private void Calculating()
  75. {
  76. Scanner AnnieBot = new Scanner(System.in);
  77. String Response = "";
  78.  
  79. while(Row != 3 && Column != 2) //while not reached final room
  80. {
  81. System.out.println(Room[Row][Column][Depth]);
  82. System.out.println(Room[Row][Column][Depth+1]);
  83.  
  84. Response = AnnieBot.nextLine();
  85.  
  86. if((Response.equals("North") || Response.equals("East") || Response.equals("South") || Response.equals("West"))) //if it's a proper input
  87. {
  88. if(Response.equals("North"))
  89. {
  90. Row++;
  91. System.out.println("You are now in room " + Row + "," + Column + "," + Depth);
  92. }
  93. if(Response.equals("East"))
  94. {
  95. Column++;
  96. System.out.println("You are now in room " + Row + "," + Column + "," + Depth);
  97. }
  98. if(Response.equals("South"))
  99. {
  100. Row--;
  101. System.out.println("You are now in room " + Row + "," + Column + "," + Depth);
  102. }
  103. if(Response.equals("West"))
  104. {
  105. Column--;
  106. System.out.println("You are now in room " + Row + "," + Column + "," + Depth);
  107. }
  108. // beginner ifs or
  109. if ((Row == 4 || Column == 3 || Row < 0 || Column < 0) || ((Row == 0 && Column == 1 || Row == 0 && Column == 2 || Row == 1 && Column == 3 || Row == 2 && Column == 4) || Row == 3 && Column == 0 || Row == 3 && Column == 1 || Row == 3 && Column == 3))
  110. {
  111. System.out.println("Not valid input. Try again");
  112. Calculating();
  113. }
  114. TheRandomNumberDamage = ((int)(Math.random()*range)+min);
  115. if(TheRandomNumberDamage == 0)
  116. {
  117. HP+=Damage;
  118. System.out.println("Ouch! You took 20 damage points, you are now at " + 100 + " HP");
  119. }
  120. TheRandomNumberDamage = ((int)(Math.random()*range)+min);
  121. if(TheRandomNumberDamage == 1)
  122. {
  123. RandomGold = ((int)(Math.random()*rangeGold)+minGold);
  124. Gold += RandomGold;
  125. System.out.println("You've gained " + RandomGold + " gold and you now have " + Gold);
  126. }
  127. }
  128. else
  129. {
  130. System.out.println("Not valid input. Try again");
  131. Calculating();
  132. }
  133.  
  134.  
  135. } //end while
  136.  
  137.  
  138. }//end main
  139.  
  140. } //end class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement