Exemplo n.º 1
0
        private static void Main()
        {
            Console.SetWindowSize(120, 40);
            Console.SetBufferSize(120, 1000);

            var match = new MatchBuilder {
                Games = 10
            };

            match.Teams.Add(
                RobotBuilder.FromFile(@"C:\Program Files (x86)\Robot Battle\fire.prg"),
                RobotBuilder.FromFile(@"C:\Program Files (x86)\Robot Battle\fire.prg"),
                RobotBuilder.FromFile(@"C:\Program Files (x86)\Robot Battle\fire.prg")
                );
            match.Teams.Add(
                RobotBuilder.FromFile(@"C:\Program Files (x86)\Robot Battle\fire.prg"),
                RobotBuilder.FromFile(@"C:\Program Files (x86)\Robot Battle\fire.prg")
                );
            using (var writer = XmlWriter.Create(Console.Out, new XmlWriterSettings {
                Indent = true
            })) {
                match.ToXml().WriteTo(writer);
            }
            Console.WriteLine();
            var runner = new MatchRunner(match);
            var result = runner.Run();

            using (var writer = XmlWriter.Create(Console.Out, new XmlWriterSettings {
                Indent = true
            })) {
                result.ToXml().WriteTo(writer);
            }
            Console.ReadKey();
        }
        private static void Main(string[] args)
        {
            var options = new Options();

            if (!Parser.Default.ParseArguments(args, options))
            {
                return;
            }

            if (options.ShowRules)
            {
                var rules = Match.GetInstance().GetRules();

                using (var file = new StreamWriter("rules.md"))
                {
                    file.WriteLine(rules);
                }

                Console.WriteLine("Saved these rules in rules.md:");
                Console.WriteLine(rules);
                return;
            }

            try
            {
                var match  = Match.GetInstance();
                var runner = new MatchRunner(
                    match,
                    options.PlayerOneBotFolder,
                    options.PlayerTwoBotFolder,
                    new SpaceInvadersRenderer(),
                    options.Quiet,
                    options.Scrolling,
                    options.Log
                    );
                runner.Run();
            }
            catch (FileNotFoundException ex)
            {
                Debug.WriteLine("File not found...");
                Console.WriteLine("File not found...");

                Debug.WriteLine(ex.Message);
                Console.WriteLine(ex.Message);

                Debug.WriteLine(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Something went wrong...");
                Console.WriteLine("Something went wrong...");

                Debug.WriteLine(ex.Message);
                Console.WriteLine(ex.Message);

                Debug.WriteLine(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
            }
        }