Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            //DateTime now = DateTime.Now;
            args = @"simulate -b 5 -n 1 -t rel -i ..\..\..\etc\$$year$$-runs.txt -j ..\..\..\etc\$$year$$-judgments.txt -e mout -p meta=..\..\..\etc\metadata.txt".Replace("$$year$$", args[0]).Split();

            if (args.Length > 0)
            {
                // Check CLI command name
                string          commandName = args[0].ToLower();
                AbstractCommand command     = null;
                switch (commandName)
                {
                case "-h":
                    Allcea.PrintMainUsage(null);
                    Environment.Exit(0);
                    break;

                case "estimate": command = new EstimateCommand(); break;

                case "evaluate": command = new EvaluateCommand(); break;

                case "next": command = new NextCommand(); break;

                case "simulate": command = new SimulateCommand(); break;

                case "features": command = new FeaturesCommand(); break;

                default:
                    Console.Error.WriteLine("'" + commandName + "' is not a valid Allcea command. See '" + Allcea.CLI_NAME_AND_VERSION + " -h'.");
                    Environment.Exit(1);
                    break;
                }
                // Parse CLI options
                Options options = command.Options;
                // help? Cannot wait to parse CLI options because it will throw exception before
                if (options.HasOption("h") && args.Contains("-h"))
                {
                    Allcea.PrintUsage(null, commandName, options, command.OptionsFooter);
                }
                else
                {
                    try {
                        Parser      parser = new BasicParser();
                        CommandLine cmd    = parser.Parse(options, args.Skip(1).ToArray());
                        // If we have extra CLI options the Parse method doesn't throw exception. Handle here
                        if (cmd.Args == null || cmd.Args.Length != 0)
                        {
                            throw new ParseException("Unused option(s): " + string.Join(",", cmd.Args));
                        }
                        // Run command
                        command.CheckOptions(cmd);
                        command.Run();
                    } catch (ParseException pe) {
                        Console.Error.WriteLine((pe.Message.EndsWith(".") ? pe.Message : pe.Message + ".")
                                                + " See '" + Allcea.CLI_NAME_AND_VERSION + " " + commandName + " -h'.");
                        Environment.Exit(1);
                    } catch (Exception ex) {
                        Console.Error.WriteLine(ex.Message);
                        Environment.Exit(1);
                    }
                }
            }
            else
            {
                // No CLI options
                Allcea.PrintMainUsage(null);
                Environment.Exit(1);
            }
            //Console.Error.WriteLine(DateTime.Now.Subtract(now).TotalMilliseconds);
        }
Ejemplo n.º 2
0
        public static string GetPP(
            string osuFilePath,
            int bid,
            int mode,
            string mods,
            double acc,
            int miss,
            int combo,
            int good,
            int meh,
            int score,
            double percentCombo)
        {
            //初始化计算对象数据
            SimulateCommand command = null;

            switch (mode)
            {
            case 0:
                command = new OsuSimulateCommand();
                break;

            case 1:
                command = new TaikoSimulateCommand();
                break;

            case 3:
                command = new ManiaSimulateCommand();
                break;
            }

            //校验传入参数
            if (command == null ||
                bid <= 0 ||
                miss < 0 ||
                combo < 0 ||
                good < 0 ||
                meh < 0 ||
                (acc < 0 && acc > 100) ||
                (score < 0 && score > 1000000 && mode == 3) ||
                (score < 0 && mode != 3) ||
                (percentCombo < 0 && percentCombo > 100))
            {
                return("[]");
            }



            try
            {
                var path = osuFilePath + Path.DirectorySeparatorChar + bid + ".osu";

                FileInfo info = new FileInfo(path);
                if (!info.Exists)
                {
                    string content = client.DownloadString("http://osu.ppy.sh/osu/" + bid);
                    if (!string.IsNullOrWhiteSpace(content))
                    {
                        File.WriteAllText(path, content);
                    }
                }

                //设置osu文件路径
                command.Beatmap = path;


                //设置acc
                command.Accuracy = (acc > 0) ? acc : 100;


                //设置miss
                if (miss > 0)
                {
                    command.Misses = miss;
                }


                //设置combo
                if (percentCombo > 0)
                {
                    command.PercentCombo = percentCombo;
                }
                else if (combo > 0)
                {
                    command.Combo = combo;
                }

                //设置100数量
                if (good > 0)
                {
                    command.Goods = good;
                }

                //设置50数量
                if (meh > 0)
                {
                    command.Mehs = meh;
                }

                //设置游玩模式
                command.Mods = GetMods(mods);

                //Mania的分数处理
                if (command is ManiaSimulateCommand)
                {
                    if (score > 0)
                    {
                        command.Score = score;
                    }
                    else
                    {
                        command.Score = 1000000;
                    }

                    foreach (var item in command.Mods)
                    {
                        if (item.Equals("EZ") || item.Equals("HT") || item.Equals("NF"))
                        {
                            command.Score = (int)(command.Score * 0.5);
                        }
                    }
                }

                //开始计算
                command.Execute();
            }
            catch
            {
            }


            return(command.ToJson());
        }
Ejemplo n.º 3
0
 private void InitializeCommands()
 {
     SimulateCommand = new SimulateCommand(this);
     BindItem(buttonSimulate, SimulateCommand);
 }