示例#1
0
        private static void TestCalculate()
        {
            WorldParser        world       = new WorldParser(@"Jsons\World.json");
            LoginResultParser  loginResult = new LoginResultParser(@"Jsons\LoginResult.json", false);
            LocalizationParser dict        = new LocalizationParser(@"Jsons\Runes.json");
            DropRateCalculator calc        = new DropRateCalculator();
            var result = calc.Calculate(loginResult.pChests, world, dict);

            List <dynamic> output = new List <dynamic>();

            foreach (var r in result)
            {
                var     key         = r.Key.Split('|');
                int     chestNumber = int.Parse(key[0]);
                string  type        = key[1];
                string  name        = key[2];
                var     value       = r.Value;
                dynamic e           = new ExpandoObject();
                e.ChestNumber = chestNumber;
                e.Name        = name;
                e.Type        = type;
                e.Expectation = value.ExpectationInAll;
                e.Chance      = value.ChanceInAll;
                e.Stars       = value.Stars;
                output.Add(e);
            }
            var arr  = output.Select(e => $"{e.ChestNumber},{e.Name},{e.Type},{e.Chance},{e.Expectation},{e.Stars}").ToArray();
            var text = string.Join(Environment.NewLine, arr);

            text = "ChestNumber,Name,Type,Chance,Expectation,Stars" + Environment.NewLine + text;
            File.WriteAllText(@"c:\temp\output.csv", text);
        }
示例#2
0
        private void Load()
        {
            try
            {
                var body = GetLoginBody("QqZ5d1kWkz1D", "GQWLAycpxwFo");
                if (_worldFilePath == null)
                {
                    _worldFilePath = HttpContext.Current.Server.MapPath(@"~\Jsons\World.json");
                }
                if (_runeFilePath == null)
                {
                    _runeFilePath = HttpContext.Current.Server.MapPath(@"~\Jsons\Runes.json");
                }
                WorldParser world = new WorldParser(_worldFilePath);

                LoginResultParser  loginResult = new LoginResultParser(body, true);
                LocalizationParser dict        = new LocalizationParser(_runeFilePath);
                DropRateCalculator calc        = new DropRateCalculator();
                var            result          = calc.Calculate(loginResult.pChests, world, dict);
                List <dynamic> output          = new List <dynamic>();
                foreach (var r in result)
                {
                    var     key         = r.Key.Split('|');
                    int     chestNumber = int.Parse(key[0]);
                    string  type        = key[1];
                    string  name        = key[2];
                    var     value       = r.Value;
                    dynamic e           = new ExpandoObject();
                    e.ChestNumber = chestNumber;
                    e.Chest       = Enum.GetName(typeof(ChestType), chestNumber);
                    e.Name        = name;
                    e.Type        = type;
                    e.Expectation = value.ExpectationInAll;
                    e.Chance      = value.ChanceInAll;
                    e.Stars       = value.Stars;
                    output.Add(e);
                }
                CalculationResult = output;
                LastUpdated       = DateTime.Now;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                CalculationResult = null;
            }
        }