コード例 #1
0
        public static State GenerateState(int counter, int stateId, StatesContainer importedObjects)
        {
            if (importedObjects.ImportedDefaults != null)
            {
                ExtractAndUpdateDefaultsToImport(importedObjects.ImportedDefaults);
            }

            int    manpower  = MainClass.GetRandomNumber(_manpowerMinValue, _manpowerMaxValue);
            string TAG       = GetTAG(importedObjects.ImportedTAGs);
            string secondTAG = GetTAG(importedObjects.ImportedTAGs);

            History history = new History();

            history.Owner          = "owner = " + TAG;
            history.VictoryPoints1 = MainClass.GetRandomNumber(0, _vp1MaxValue);
            history.VictoryPoints2 = MainClass.GetRandomNumber(0, _vp2MaxValue);
            history.Core           = "add_core_of = " + TAG;
            if (TAG != secondTAG && importedObjects.TwoCores)
            {
                history.Core2 = "add_core_of = " + secondTAG;
            }
            history.Buildings = PopulateBuildings();

            return(new State {
                StateId = GetStateId(counter, stateId),
                StateName = GetStateName(importedObjects.ImportedNames),
                Manpower = manpower,
                StateCategory = GetStateCategory(manpower),
                BuildingMaxLevelFactor = (double)(MainClass.GetRandomNumber(0, 100) / 100),                  //get as number between 0 and 1
                Resources = PopulateResources(),
                History = history
            });
        }
コード例 #2
0
        public static void StatesMain()
        {
            Console.WriteLine("Input number of states requiring generation:");
            var input = Console.ReadLine();
            int stateNumber;

            Int32.TryParse(input, out stateNumber);

            Console.WriteLine("Start from 1? (y/n):");
            input = Console.ReadLine();
            bool startat1 = MainClass.ValidateYesNoInput(input);
            int  stateId  = 0;

            if (!startat1)
            {
                Console.WriteLine("Enter start value:");
                input = Console.ReadLine();
                Int32.TryParse(input, out stateId);
            }

            StatesContainer container     = new StatesContainer();
            List <string>   importStrings = new List <string> {
                "State Name", "TAG", "Province ID", "New Generation Defaults"
            };

            foreach (var importString in importStrings)
            {
                Console.WriteLine("Import {0} list from local folder? (y/n)", importString);
                input = Console.ReadLine();
                bool import = MainClass.ValidateYesNoInput(input);

                if (import)
                {
                    bool   correctFile = false;
                    string filename    = "foo";
                    while (!correctFile)
                    {
                        Console.WriteLine("Please input filename (CasE-SenSiTiVe) (including extension)");
                        var search = Console.ReadLine();
                        filename = FileManagement.GetImportFile(search);
                        Console.WriteLine("Is the file: {0} ? (y/n)", filename);
                        input       = Console.ReadLine();
                        correctFile = MainClass.ValidateYesNoInput(input);
                    }

                    if (correctFile)
                    {
                        switch (importString)
                        {
                        case "State Name":
                            container.ImportedNames = FileManagement.ImportText(filename);
                            break;

                        case "TAG":
                            container.ImportedTAGs = FileManagement.ImportText(filename);
                            break;

                        case "Province ID":
                            container.ImportedProvinces = FileManagement.ImportText(filename);
                            break;

                        case "New Generation Defaults":
                            container.ImportedDefaults = FileManagement.ImportText(filename);
                            break;
                        }
                    }
                }
            }

            Console.WriteLine("Do you want to generate multiple core owners for one state (y/n)");
            Console.WriteLine("WARNING: second tag is randomly assigned from the list imported - advised you import a limited selection of TAGs if you do this.");
            Console.WriteLine("If you didn't import a TAG list, or the random assignment of TAG is the same twice, you'll only get one row, no matter what you pick here.");
            input = Console.ReadLine();
            container.TwoCores = MainClass.ValidateYesNoInput(input);

            int counter = 0;

            while (counter < stateNumber)
            {
                Console.WriteLine("Generating states...");
                State newState = StateGeneration.GenerateState(counter, stateId, container);
                Console.WriteLine("State: {0} generated", newState.StateName);
                Console.WriteLine("Saving output to local folder.");
                FileManagement.SaveStatetoTextFile(newState, container.ImportedProvinces);
                if (stateId != 0)
                {
                    stateId++;
                }
                counter++;
            }
            Console.WriteLine("Generation of {0} states, complete", counter);
            Console.WriteLine("Press Any Key to Kill.");
            Console.ReadKey();
        }
コード例 #3
0
 public Menu()
 {
     States = new StatesContainer();
 }