Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.04 KB | None | 0 0
  1. public static void Plant()
  2. {
  3. int ItemID = -1;
  4. String Command = "";
  5. while(ItemID < 0)
  6. {
  7. while(ItemID == -1)
  8. {
  9. System.out.print("Item ID to plant: ");
  10. Command = input.nextLine();
  11. if(Command.equals(".cancel"))
  12. {
  13. return;
  14.  
  15.  
  16. }
  17. try
  18. {
  19. if(Command.equals(".cancel"))
  20. {
  21. return;
  22. }
  23. ItemID = Integer.parseInt(Command);
  24. } catch (NumberFormatException e)
  25. {
  26.  
  27. }
  28. }
  29. if(ItemID < 0)
  30. {
  31. System.out.println("Invalid Item ID.");
  32. }
  33. if(inventory.Items[ItemID] == 0)
  34. {
  35. System.out.println("You don't have this item.");
  36. ItemID = -1;
  37. }
  38. }
  39. inventory.Items[ItemID] -= 1;
  40. int x[] = new int[16];
  41. int Counter = 0;
  42. System.out.println("List of Empty Plots: ");
  43. for(int i = 0; i < mainGame.NoOfPlots; i++)
  44. {
  45. if(mainGame.Plot[i] == 0)
  46. {
  47. System.out.println("Plot[" + i + "]");
  48. x[Counter] = i;
  49. Counter++;
  50. }
  51. }
  52. int Selection = 0; int LoopBreak = 0;
  53. while(LoopBreak == 0)
  54. {
  55. System.out.println("Which plot would you like to plant " + shop.ItemName[ItemID] + " in: ");
  56. Selection = Integer.parseInt(input.nextLine());
  57. for(int i = 0 ; i < mainGame.NoOfPlots; i++)
  58. {
  59. if(x[i] == Selection)
  60. {
  61. LoopBreak++;
  62. } else {
  63. System.out.println("Invalid plot selection.");
  64. }
  65. }
  66. }
  67. switch (ItemID){
  68. //Wheat Seed
  69. case(0):
  70. mainGame.Seed[Selection] = " w ";
  71. mainGame.daysToRipe[Selection] = 4;
  72. break;
  73. case(1):
  74. mainGame.Seed[Selection] = " p ";
  75. mainGame.daysToRipe[Selection] = 7;
  76. break;
  77. case(2):
  78. mainGame.Seed[Selection] = " c ";
  79. mainGame.daysToRipe[Selection] = 12;
  80. break;
  81. case(3):
  82. mainGame.Seed[Selection] = " l ";
  83. mainGame.daysToRipe[Selection] = 16;
  84. break;
  85. case(4):
  86. mainGame.Seed[Selection] = "|p|";
  87. mainGame.daysToRipe[Selection] = 28;
  88. break;
  89. case(5):
  90. mainGame.Seed[Selection] = "|w|";
  91. mainGame.daysToRipe[Selection] = 36;
  92. break;
  93. }
  94. mainGame.dateStarted[Selection] = mainGame.NoOfDays;
  95. //Sets plot to be in use
  96. mainGame.Plot[Selection] = 1;
  97. System.out.println("Successfully planted seed!");
  98. }
  99.  
  100. -----------------------------------------------------------------------
  101.  
  102. public static void PlotUpdater()
  103. {
  104. PlotNo = 0;
  105. for(int i = 0; i < NoOfPlots; i++)
  106. {
  107. if(Plot[i] == 0)
  108. {
  109. System.out.println("Plot " + PlotNo);
  110. System.out.println("+-----+");
  111. System.out.println("| |");
  112. System.out.println("+-----+");
  113. PlotNo++;
  114. } else if (Plot[i] == 1)
  115. {
  116. switch(Seed[i])
  117. {
  118. case(" w "):
  119. if(NoOfDays - dateStarted[i] >= 1)
  120. {
  121. Seed[i] = " W ";
  122. }
  123. break;
  124. case(" C "):
  125. case(" P "):
  126. case(" W "):
  127. case(" L "):
  128. case("|W|"):
  129. case("|P|"):
  130. if (daysToRipe[i] <= NoOfDays - dateStarted[i])
  131. {
  132. Seed[i] = " H ";
  133. }
  134. break;
  135. case(" p "):
  136. if(NoOfDays - dateStarted[i] >= 3)
  137. {
  138. Seed[i] = " P ";
  139. }
  140. break;
  141. case(" c "):
  142. if(daysToRipe[i] <= NoOfDays - dateStarted[i])
  143. {
  144. Seed[i] = " C ";
  145. }
  146. break;
  147. case(" l "):
  148. if(daysToRipe[i] <= NoOfDays - dateStarted[i])
  149. {
  150. Seed[i] = " L ";
  151. }
  152. break;
  153. case("|p|"):
  154. if(daysToRipe[i] <= NoOfDays - dateStarted[i])
  155. {
  156. Seed[i] = "|P|";
  157. }
  158. break;
  159. case("|w|"):
  160. if(daysToRipe[i] <= NoOfDays - dateStarted[i])
  161. {
  162. Seed[i] = "|W|";
  163. }
  164. break;
  165. }
  166. }
  167. }
  168. for(int i = 0; i < NoOfPlots; i++)
  169. {
  170. if(Plot[i] == 1)
  171. {
  172. System.out.println("Plot " + PlotNo);
  173. System.out.println("+-----+");
  174. System.out.println("| " + Seed[i] + " |");
  175. System.out.println("+-----+");
  176. PlotNo++;
  177. }
  178. }
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement