Ejemplo n.º 1
0
        private static void PrintBuildResult(Build build)
        {
            Console.WriteLine($"{build.ComponentToBuild.Recipe.Component.Name} needs {build.ComponentToBuild.NumberOfBuilders} {build.ComponentToBuild.Recipe.MachineType}(s)");
            int color = 1;

            foreach (var inputComponent in build.ComponentToBuild.InputComponents)
            {
                var colorsToUse = colors.First(i => i.Item1 == color);
                Console.BackgroundColor = colorsToUse.Item2;
                Console.ForegroundColor = colorsToUse.Item3;
                PrintBuildComponenet(inputComponent, 1);
                color++;
            }
            var summaryCount = new SummaryCount();

            CalculateSummary(build.ComponentToBuild, summaryCount);

            PrintSummary(summaryCount);
        }
Ejemplo n.º 2
0
        private static void CalculateSummary(BuildComponent buildComponent, SummaryCount counts)
        {
            if (counts.MachineCount.ContainsKey(buildComponent.BuilderMachine.MachineType))
            {
                counts.MachineCount[buildComponent.BuilderMachine.MachineType] += buildComponent.NumberOfBuilders;
            }
            else
            {
                counts.MachineCount.Add(buildComponent.BuilderMachine.MachineType, buildComponent.NumberOfBuilders);
            }



            if (buildComponent.Recipe.Component.IsBasic)
            {
                if (counts.BaseItemCount.ContainsKey(buildComponent.Recipe.Component.Name))
                {
                    counts.BaseItemCount[buildComponent.Recipe.Component.Name] += buildComponent.ProducedPerMinute;
                }
                else
                {
                    counts.BaseItemCount.Add(buildComponent.Recipe.Component.Name, buildComponent.ProducedPerMinute);
                }
            }
            else
            {
                if (counts.ComponentCounts.ContainsKey(buildComponent.Recipe.Component.Name))
                {
                    counts.ComponentCounts[buildComponent.Recipe.Component.Name] += buildComponent.ProducedPerMinute;
                }
                else
                {
                    counts.ComponentCounts.Add(buildComponent.Recipe.Component.Name, buildComponent.ProducedPerMinute);
                }
            }

            foreach (var buildComponentInputComponent in buildComponent.InputComponents)
            {
                CalculateSummary(buildComponentInputComponent, counts);
            }
        }
Ejemplo n.º 3
0
        private static void PrintSummary(SummaryCount counts)
        {
            Console.BackgroundColor = ConsoleColor.Magenta;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("------Machine Counts--------");
            foreach (var machine in counts.MachineCount)
            {
                Console.WriteLine($"{machine.Key} : {machine.Value}");
            }
            Console.WriteLine("------Component Counts--------");
            foreach (var component in counts.ComponentCounts)
            {
                Console.WriteLine($"{component.Key} : {component.Value}");
            }

            Console.WriteLine($"\r\n-----Basic Count-----");
            foreach (var baseItem in counts.BaseItemCount)
            {
                Console.WriteLine($"{baseItem.Key} : {baseItem.Value}");
            }
        }