public static void CollectInput(Farm farm) { Console.Clear(); Console.WriteLine("1. Composter"); Console.WriteLine("2. Egg Gatherer"); Console.WriteLine("3. Feather Harvester"); Console.WriteLine("4. Meat Processor"); Console.WriteLine("5. Seed Harvester"); Console.WriteLine(); Console.WriteLine("Which equipment do you want to use?"); Console.Write("> "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: Process.ChooseCompostableResource(farm); break; case 2: Process.ChooseEggResource(farm); break; case 3: Process.ChooseFeatherResource(farm); break; case 4: ChooseMeatResource.CollectInput(farm); break; case 5: ChooseSeedResource.CollectInput(farm); break; default: break; } }
public static void CollectInput(Farm farm) { Console.Clear(); List <dynamic> meatProducingFacilities = new List <dynamic>(); farm.GrazingFields.ForEach(field => { meatProducingFacilities.Add(field); }); farm.ChickenHouses.ForEach(field => { meatProducingFacilities.Add(field); }); // List appropriate resource facilities int i = 1; meatProducingFacilities.ForEach(f => { Console.WriteLine($"{i}. {f.GetType().Name}"); i++; }); Console.WriteLine($"{i}. Complete Processing"); int fieldIndex = Prompt.Query("Which facility has the resources to use?") - 1; // If user chose to complete processing if (fieldIndex + 1 == i) { // Output the result of processing the resources farm.MeatProcessor.ProcessResources(); // Remove items from source list ChooseMeatResource.discards.ForEach(d => { var facility = meatProducingFacilities[d.ListIndex]; facility.DiscardResource(d.ItemIndex); }); ChooseMeatResource.discards.Clear(); Console.ReadLine(); } else { var chosenFacility = meatProducingFacilities[fieldIndex]; // List resources in chosen facility i = 1; foreach (var resource in chosenFacility.Resources) { var animal = (IResource)resource; if (!animal.InProcess) { Console.WriteLine($"{i}. {animal.Type}"); } i++; } int resourceIndex = Prompt.Query("Which resource?") - 1; var chosenResource = (IResource)chosenFacility.Resources[resourceIndex]; chosenResource.InProcess = true; farm.MeatProcessor.Resources.Add(chosenResource); ChooseMeatResource.discards.Add(new Discard { ItemIndex = resourceIndex, ListIndex = fieldIndex }); ChooseMeatResource.CollectInput(farm); } }