Пример #1
0
        public static CommandResult Run(CommandArguments args)
        {
            if (args.Arguments.Length == 0)
            {
                return new CommandResult
                       {
                           Type   = CommandResultType.MESSAGE,
                           Result = $"Usuage: !with [Mods] (Mods) (Mods)... or !with reset to reset."
                       }
            }
            ;
            Mod[] mods = null;


            BanchoUserHistory history = HistoryCache.Get(args.Username);

            if (history == null)
            {
                HistoryCache.Init(args.Username);
            }
            history = HistoryCache.Get(args.Username);


            if (args.Arguments[0] == "reset")
            {
                history.RecentMod = new Mod[] { };
                return(new CommandResult
                {
                    Type = CommandResultType.MESSAGE,
                    Result = $"Reseted mods."
                });
            }
            try
            {
                mods = Common.GetMods(args.Arguments, new OsuRuleset()).ToArray();
            }
            catch (Exception ex)
            {
                return(new CommandResult
                {
                    Type = CommandResultType.MESSAGE,
                    Result = ex.Message
                });
            }
            history.RecentMod = mods;
            StringBuilder sb = new StringBuilder();

            foreach (Mod mod in mods)
            {
                sb.Append(mod.Acronym);
            }


            OsuCalculator calc = new OsuCalculator(history.RecentBeatmapId);

            calc.Mod = mods;
            CalculateMessage msg = new CalculateMessage(calc);
            CommandResult    rs  = new CommandResult
            {
                Type   = CommandResultType.MESSAGE,
                Result = msg.ToString().Split("\n")[1]
            };

            return(rs);
        }
    }
Пример #2
0
        public static CommandResult Run(CommandArguments args)
        {
            if (args.Arguments.Length == 0)
            {
                return new CommandResult
                       {
                           Type   = CommandResultType.MESSAGE,
                           Result = $"Usuage: !acc [Accuracy] (Miss) (Max Combo)"
                       }
            }
            ;
            double acc       = -1;
            int    miss      = 0;
            int    max_combo = -1;

            try
            {
                var accraw = double.Parse(args.Arguments[0]);

                acc       = accraw > 1 ? accraw : accraw / 100;
                miss      = args.Arguments.Length > 1 ? int.Parse(args.Arguments[1]) : 0;
                max_combo = args.Arguments.Length > 2 ? int.Parse(args.Arguments[2]) : -1;
            }
            catch
            {
                return(new CommandResult
                {
                    Type = CommandResultType.MESSAGE,
                    Result = $"Wrong Argument. (Not a number.)"
                });
            }
            BanchoUserHistory history = HistoryCache.Get(args.Username);

            if (history.RecentBeatmapId == 0)
            {
                return(new CommandResult
                {
                    Type = CommandResultType.MESSAGE,
                    Result = $"Oops! we dont have history! plase /np and do it again!"
                });
            }
            OsuCalculator calc = new OsuCalculator(history.RecentBeatmapId);

            if (history.RecentMod.Length > 0)
            {
                calc.Mod = history.RecentMod;
            }
            calc.Misses = miss;
            CalculateMessage msg = new CalculateMessage(calc);

            msg.Acc = acc;
            if (max_combo != -1)
            {
                calc.Combo = max_combo;
            }
            CommandResult rs = new CommandResult()
            {
                Type   = CommandResultType.MESSAGE,
                Result = msg.ToString()
            };


            return(rs);
        }
    }