예제 #1
0
        static void Main(string[] args)
        {
            if (args.Length < 4 || args.Length > 12)
            {
                CliHelp.Show();
                return;
            }

            var argsParser             = new CommandLineArgumentsParser();
            var characterGenerationDto = argsParser.Parse(args);

            if (characterGenerationDto == null)
            {
                CliHelp.Show();
                return;
            }

            if (String.IsNullOrEmpty(characterGenerationDto.Name))
            {
                characterGenerationDto.Name = NameGenerator.Get().ToName();
            }

            var character = Generate(characterGenerationDto);

            Console.WriteLine(character.ToString());
            Console.ReadKey();
        }
        public CharacterGenerationDto Parse(string[] args)
        {
            try
            {
                var result = new CharacterGenerationDto();

                int i = 0;
                while (i < args.Length)
                {
                    switch (args[i].ToLower())
                    {
                    case "-n":
                    case "--name":
                        result.Name = args[++i].ToLower();
                        break;

                    case "-c":
                    case "--caste":
                        result.Caste = args[++i].ToLower();
                        break;

                    case "-l":
                    case "--level":
                        result.Level = args[++i].ToLower();
                        break;

                    case "-sc":
                    case "--secondary-caste":
                        result.SecondaryCaste = args[++i].ToLower();
                        break;

                    case "-sl":
                    case "--secondary-level":
                        result.SecondaryLevel = args[++i].ToLower();
                        break;

                    case "-r":
                    case "--race":
                        result.Race = args[++i].ToLower();
                        break;
                    }

                    i++;
                }
                return(result);
            }
            catch (Exception)
            {
                CliHelp.Show();
                return(null);
            }
        }