Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void Plant()
- {
- int ItemID = -1;
- String Command = "";
- while(ItemID < 0)
- {
- while(ItemID == -1)
- {
- System.out.print("Item ID to plant: ");
- Command = input.nextLine();
- if(Command.equals(".cancel"))
- {
- return;
- }
- try
- {
- if(Command.equals(".cancel"))
- {
- return;
- }
- ItemID = Integer.parseInt(Command);
- } catch (NumberFormatException e)
- {
- }
- }
- if(ItemID < 0)
- {
- System.out.println("Invalid Item ID.");
- }
- if(inventory.Items[ItemID] == 0)
- {
- System.out.println("You don't have this item.");
- ItemID = -1;
- }
- }
- inventory.Items[ItemID] -= 1;
- int x[] = new int[16];
- int Counter = 0;
- System.out.println("List of Empty Plots: ");
- for(int i = 0; i < mainGame.NoOfPlots; i++)
- {
- if(mainGame.Plot[i] == 0)
- {
- System.out.println("Plot[" + i + "]");
- x[Counter] = i;
- Counter++;
- }
- }
- int Selection = 0; int LoopBreak = 0;
- while(LoopBreak == 0)
- {
- System.out.println("Which plot would you like to plant " + shop.ItemName[ItemID] + " in: ");
- Selection = Integer.parseInt(input.nextLine());
- for(int i = 0 ; i < mainGame.NoOfPlots; i++)
- {
- if(x[i] == Selection)
- {
- LoopBreak++;
- } else {
- System.out.println("Invalid plot selection.");
- }
- }
- }
- switch (ItemID){
- //Wheat Seed
- case(0):
- mainGame.Seed[Selection] = " w ";
- mainGame.daysToRipe[Selection] = 4;
- break;
- case(1):
- mainGame.Seed[Selection] = " p ";
- mainGame.daysToRipe[Selection] = 7;
- break;
- case(2):
- mainGame.Seed[Selection] = " c ";
- mainGame.daysToRipe[Selection] = 12;
- break;
- case(3):
- mainGame.Seed[Selection] = " l ";
- mainGame.daysToRipe[Selection] = 16;
- break;
- case(4):
- mainGame.Seed[Selection] = "|p|";
- mainGame.daysToRipe[Selection] = 28;
- break;
- case(5):
- mainGame.Seed[Selection] = "|w|";
- mainGame.daysToRipe[Selection] = 36;
- break;
- }
- mainGame.dateStarted[Selection] = mainGame.NoOfDays;
- //Sets plot to be in use
- mainGame.Plot[Selection] = 1;
- System.out.println("Successfully planted seed!");
- }
- -----------------------------------------------------------------------
- public static void PlotUpdater()
- {
- PlotNo = 0;
- for(int i = 0; i < NoOfPlots; i++)
- {
- if(Plot[i] == 0)
- {
- System.out.println("Plot " + PlotNo);
- System.out.println("+-----+");
- System.out.println("| |");
- System.out.println("+-----+");
- PlotNo++;
- } else if (Plot[i] == 1)
- {
- switch(Seed[i])
- {
- case(" w "):
- if(NoOfDays - dateStarted[i] >= 1)
- {
- Seed[i] = " W ";
- }
- break;
- case(" C "):
- case(" P "):
- case(" W "):
- case(" L "):
- case("|W|"):
- case("|P|"):
- if (daysToRipe[i] <= NoOfDays - dateStarted[i])
- {
- Seed[i] = " H ";
- }
- break;
- case(" p "):
- if(NoOfDays - dateStarted[i] >= 3)
- {
- Seed[i] = " P ";
- }
- break;
- case(" c "):
- if(daysToRipe[i] <= NoOfDays - dateStarted[i])
- {
- Seed[i] = " C ";
- }
- break;
- case(" l "):
- if(daysToRipe[i] <= NoOfDays - dateStarted[i])
- {
- Seed[i] = " L ";
- }
- break;
- case("|p|"):
- if(daysToRipe[i] <= NoOfDays - dateStarted[i])
- {
- Seed[i] = "|P|";
- }
- break;
- case("|w|"):
- if(daysToRipe[i] <= NoOfDays - dateStarted[i])
- {
- Seed[i] = "|W|";
- }
- break;
- }
- }
- }
- for(int i = 0; i < NoOfPlots; i++)
- {
- if(Plot[i] == 1)
- {
- System.out.println("Plot " + PlotNo);
- System.out.println("+-----+");
- System.out.println("| " + Seed[i] + " |");
- System.out.println("+-----+");
- PlotNo++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement