Example #1
0
        static void Play(string replayPath)
        {
            while (true)
            {
                var process = ClientProcessFinder.Find();
                if (process == null)
                {
                    break;
                }

                Console.WriteLine("The client has been already running. Please close it first.");
                Console.WriteLine("クライアントプロセスが既に起動しています。先に終了してください。");
                Thread.Sleep(2000);
                continue;
            }

            var(replayArgs, error) = ReplayArgsParser.Parse(File.ReadAllText(ReplayArgsPath));
            switch (error)
            {
            case ReplayArgsParserError.LackOfArguments:
            {
                Console.WriteLine("Replay arguments doesn't have enough length.");
                Console.WriteLine("リプレイの引数の数が足りませんでした。");
                Finish();
                break;
            }

            case ReplayArgsParserError.FirstArgumentIsNotExe:
            {
                Console.WriteLine("First argument should be a path to the client exe but isn't.");
                Console.WriteLine("リプレイの最初の引数はクライアントへのパスでないといけません。");
                Finish();
                break;
            }

            case ReplayArgsParserError.SecondArgumentIsNotRofl:
            {
                Console.WriteLine("Second argument should be a path to a rofl file but isn't.");
                Console.WriteLine("リプレイの2つ目の引数はリプレイファイル(rofl)へのパスでないといけません。");
                Finish();
                break;
            }

            case ReplayArgsParserError.None:
            {
                replayArgs.ReplayFile = new FileInfo(replayPath);
                ReplayPlayer.Play(replayArgs);
                break;
            }
            }
        }
Example #2
0
        static ReplayArgs FetchReplayArgs()
        {
            while (true)
            {
                var process = ClientProcessFinder.Find();
                if (process == null || process.HasExited)
                {
                    Console.WriteLine("Couldn't find the client. Please play some replay using the official client.");
                    Console.WriteLine("クライアントプロセスを見つけられませんでした。クライアントでリプレイを再生してください。");
                    Thread.Sleep(2000);
                    continue;
                }

                var(replayArgs, fetcherError, parserError) = ReplayArgsFetcher.Fetch(process);
                switch (fetcherError)
                {
                case ReplayArgsFetcherError.CouldNotGetCommandLineArguments:
                {
                    Console.WriteLine("Couldn't fetch replay arguments from the client.");
                    Console.WriteLine("クライアントから引数を取得出来ませんでした。");
                    Thread.Sleep(2000);
                    continue;
                }
                }

                switch (parserError)
                {
                case ReplayArgsParserError.LackOfArguments:
                {
                    Console.WriteLine("Replay arguments doesn't have enough length.");
                    Console.WriteLine("リプレイの引数の数が足りませんでした。");
                    Console.WriteLine("Please play some replay using the official client.");
                    Console.WriteLine("クライアントでリプレイを再生してください。");
                    Thread.Sleep(2000);
                    continue;
                }

                case ReplayArgsParserError.FirstArgumentIsNotExe:
                {
                    Console.WriteLine("First argument should be a path to the client exe but isn't.");
                    Console.WriteLine("リプレイの最初の引数はクライアントへのパスでないといけません。");
                    Console.WriteLine("Please play some replay using the official client.");
                    Console.WriteLine("クライアントでリプレイを再生してください。");
                    Thread.Sleep(2000);
                    continue;
                }

                case ReplayArgsParserError.SecondArgumentIsNotRofl:
                {
                    Console.WriteLine("Second argument should be a path to a rofl file but isn't.");
                    Console.WriteLine("リプレイの2つ目の引数はリプレイファイル(rofl)へのパスでないといけません。");
                    Console.WriteLine("Please play some replay using the official client.");
                    Console.WriteLine("クライアントでリプレイを再生してください。");
                    Thread.Sleep(2000);
                    continue;
                }
                }

                return(replayArgs);
            }
        }