Esempio n. 1
0
        private static void ShowInfo(string id)
        {
            //===== GENERAL =====//
            General general = General.GetGeneral(id);

            Console.WriteLine("══════════════╡ {0}. {1} ({2}) ╞══════════════", general.Id, general.Name, general.GetTypeMaterial);
            Console.WriteLine("──────────────────────────────────────────────────\n{0}\n──────────────────────────────────────────────────", general.Description);
            Formations.Header("GENERAL");
            Console.WriteLine(" Health: {0}", general.Health);
            Console.WriteLine(" Size: {0}", general.Size);
            Console.WriteLine(" Build Time: {0}", general.BuildTime);
            Console.WriteLine(" Build Cost: {0}", string.Join(", ", general.BuildCosts.Select(sel => sel.ToString())));
            if (general.Weight != null)
            {
                Console.WriteLine(" Weight: {0}", general.Weight);
            }

            //===== POWER =====//
            Power[] powers = general.GetPowers;

            if (powers.Length != 0)
            {
                Power  powerPrev       = new Power();
                string powerUse        = string.Empty;
                string powerGeneration = string.Empty;
                string powerCapacity   = string.Empty;

                foreach (Power power in powers)
                {
                    if (power.PowerUse != null)
                    {
                        if (powerUse == string.Empty)
                        {
                            powerUse = power.PowerUse;
                        }
                        else if (power.PowerUse != powerPrev.PowerUse)
                        {
                            powerUse += " / " + power.PowerUse;
                        }
                    }
                    if (power.PowerGeneration != null)
                    {
                        if (powerGeneration == string.Empty)
                        {
                            powerGeneration = power.PowerGeneration;
                        }
                        else if (power.PowerGeneration != powerPrev.PowerGeneration)
                        {
                            powerGeneration += " / " + power.PowerGeneration;
                        }
                    }
                    if (power.PowerCapacity != null)
                    {
                        if (powerCapacity == string.Empty)
                        {
                            powerCapacity = power.PowerCapacity;
                        }
                        else if (power.PowerCapacity != powerPrev.PowerCapacity)
                        {
                            powerCapacity += " / " + power.PowerCapacity;
                        }
                    }

                    powerPrev = power;
                }

                Formations.Header("POWER");
                if (powerUse != string.Empty)
                {
                    Console.WriteLine(" Power Use: {0} power units/second", powerUse);
                }
                if (powerGeneration != string.Empty)
                {
                    Console.WriteLine(" Power Generation: {0} power units/second", powerGeneration);
                }
                if (powerCapacity != string.Empty)
                {
                    Console.WriteLine(" Power Capacity: {0} power units", powerCapacity);
                }
            }

            //===== INPUT/OUTPUT =====//
            InputOutput[] inputsOutputs = general.GetInputOutputs;

            if (inputsOutputs.Length != 0)
            {
                string input  = string.Empty;
                string output = string.Empty;

                for (int i = 0; i < inputsOutputs.Length; i++)
                {
                    if (inputsOutputs[i].Inputs != null)
                    {
                        if (input == string.Empty)
                        {
                            input = string.Join(", ", inputsOutputs[i].Inputs.Select(sel => sel.ToString()));
                        }
                        else if (inputsOutputs[i].Inputs != inputsOutputs[i - 1].Inputs)
                        {
                            input += " / " + string.Join(", ", inputsOutputs[i].Inputs.Select(sel => sel.ToString()));
                        }
                    }
                    if (inputsOutputs[i].Outputs != null)
                    {
                        if (output == string.Empty)
                        {
                            output = string.Join(", ", inputsOutputs[i].Outputs.Select(sel => sel.ToString()));
                        }
                        else if (inputsOutputs[i].Outputs != inputsOutputs[i - 1].Outputs)
                        {
                            output += " / " + string.Join(", ", inputsOutputs[i].Outputs.Select(sel => sel.ToString()));
                        }
                    }
                }

                Formations.Header("INPUT/OUTPUT");
                if (input != string.Empty)
                {
                    Console.WriteLine(" Input: {0}", input);
                }
                if (output != string.Empty)
                {
                    Console.WriteLine(" Output: {0}", output);
                }
                Console.WriteLine(" Production Time: {0} second", inputsOutputs[0].ProductionTime);
            }
        }