Example #1
0
        public List <IntPair> GetItemCountByAttribute(string attrName)
        {
            AutoDictionary <int, int> counter = new AutoDictionary <int, int>();

            for (int i = 0; i < BagCount; i++)
            {
                HItemConfig itemConfig = ConfigData.GetHItemConfig(Items[i].Type);
                if (itemConfig != null && itemConfig.Attributes != null && Array.IndexOf(itemConfig.Attributes, attrName) >= 0)
                {
                    counter[itemConfig.Id] += Items[i].Value;
                }
            }
            List <IntPair> datas = new List <IntPair>();

            foreach (int itemId in counter.Keys())
            {
                IntPair pairData = new IntPair
                {
                    Type  = itemId,
                    Value = counter[itemId]
                };
                datas.Add(pairData);
            }
            return(datas);
        }
 /// <summary>
 /// 建立新增的「組態記錄」。
 /// </summary>
 public ConfigurationRecord(string name)
 {
     BaseData = new AutoDictionary();
     PreviousData = null; //新格式的話,保持此資料是 Null。
     Namespace = name;
     EditAction = 1;//新增
 }
Example #3
0
 public ExplorerEntry(
     IEnumerable <KeyValuePair <string, ExplorerEntry> > files
     )
 {
     EntryType    = folder;
     ChildEntries = new AutoDictionary <string, ExplorerEntry>(files);
 }
Example #4
0
        long RunProblem(int cycles)
        {
            ParseResult parseResult = ParseInput();

            IDictionary <string, long> polymer = new AutoDictionary <string, long>();

            for (int i = 0; i < parseResult.Template.Length - 1; i++)
            {
                string pair = string.Concat(parseResult.Template.Skip(i).Take(2));
                polymer[pair]++;
            }

            for (int i = 0; i < cycles; i++)
            {
                polymer = ApplyRules(polymer, parseResult.Rules);
            }

            long[] counts = new long[256];

            foreach (string pair in polymer.Keys)
            {
                counts[pair[0]] += polymer[pair];
                counts[pair[1]] += polymer[pair];
            }

            counts[parseResult.Template[0]]++;
            counts[parseResult.Template[parseResult.Template.Length - 1]]++;

            long min = counts.Where(c => c > 0).Min() / 2;
            long max = counts.Where(c => c > 0).Max() / 2;

            return(max - min);
        }
Example #5
0
        public void CanAddToAutoDictionary()
        {
            AutoDictionary <string, bool> tested = new AutoDictionary <string, bool>();

            tested.Add("hello", true);
            Assert.AreEqual(true, tested["hello"]);
        }
Example #6
0
        public void CanAddKeyValuePairToAutoDictionary()
        {
            AutoDictionary <string, bool> tested = new AutoDictionary <string, bool>();

            tested.Add(new KeyValuePair <string, bool>("hello", true));
            Assert.AreEqual(true, tested["hello"]);
        }
Example #7
0
        private static void generateOneForAll(string prefix, IEnumerable<Match1FA> matches, List<string> champions)
        {
            // All the match IDs
            writeAllLines($"{prefix}-match-ids.txt", matches.Select(m => m.MatchId).Order());

            // All possible matchup stats
            {
                var grps = newDict(new { ch1 = "", ch2 = "" }, new List<Match1FA>(), _ => new List<Match1FA>());
                foreach (var m in matches)
                    grps[new { ch1 = m.Champion1, ch2 = m.Champion2 }].Add(m);
                var empty = new List<Match1FA>();
                var statsMatchupsAll = champions.SelectMany(ch1 => champions.Select(ch2 => new { ch1, ch2 })).Where(key => key.ch1.CompareTo(key.ch2) <= 0).Select(key =>
                {
                    if (!grps.ContainsKey(key))
                        return new { Champion1 = key.ch1, Champion2 = key.ch2, Count = 0, WinRate = 0.5, Lower95 = 0.0, Upper95 = 1.0, Lower67 = 0.0, Upper67 = 1.0 };
                    var n = grps[key].Count;
                    if (key.ch1 == key.ch2)
                        return new { Champion1 = key.ch1, Champion2 = key.ch2, Count = n, WinRate = 0.5, Lower95 = 0.5, Upper95 = 0.5, Lower67 = 0.5, Upper67 = 0.5 };
                    var p = winrate(grps[key], key.ch1);
                    var conf95 = Utils.WilsonConfidenceInterval(p, n, 1.96);
                    var conf67 = Utils.WilsonConfidenceInterval(p, n, 0.97);
                    return new { Champion1 = key.ch1, Champion2 = key.ch2, Count = n, WinRate = p, Lower95 = conf95.lower, Upper95 = conf95.upper, Lower67 = conf67.lower, Upper67 = conf67.upper };
                }).ToList();
                statsMatchupsAll = statsMatchupsAll.Concat(statsMatchupsAll
                        .Where(m => m.Champion1 != m.Champion2)
                        .Select(m => new { Champion1 = m.Champion2, Champion2 = m.Champion1, m.Count, WinRate = 1 - m.WinRate, Lower95 = 1 - m.Upper95, Upper95 = 1 - m.Lower95, Lower67 = 1 - m.Upper67, Upper67 = 1 - m.Lower67 })
                    ).OrderBy(m => m.Champion1).ThenBy(m => m.Champion2).ToList();
                writeAllLines($"{prefix}-matchupsall.csv", statsMatchupsAll.Select(l => $"{l.Champion1},{l.Champion2},{l.Count},{l.WinRate},{l.Lower95},{l.Upper95},{l.Lower67},{l.Upper67}"));
            }

            // Champion stats at champ select stage (unknown enemy)
            {
                var grps = new AutoDictionary<string, List<Match1FA>>(_ => new List<Match1FA>());
                foreach (var m in matches)
                {
                    grps[m.Champion1].Add(m);
                    if (m.Champion1 != m.Champion2)
                        grps[m.Champion2].Add(m);
                }
                var statsChampSelect = champions.Select(champion =>
                {
                    var n = grps[champion].Count;
                    var p = winrate(grps[champion], champion);
                    var conf95 = Utils.WilsonConfidenceInterval(p, n, 1.96);
                    // Bans
                    var remaining = grps[champion]; // bans calculation is destructive as we won't need the original list anyway
                    var bans = new string[5];
                    var banWR = new double[5];
                    for (int i = 0; i < 5; i++)
                    {
                        var banResult = champions.Where(ban => ban != champion).Select(ban => new { ban, wr = winrate(matches1FAWithout(remaining, ban), champion) }).MaxElement(x => x.wr);
                        bans[i] = banResult.ban;
                        banWR[i] = banResult.wr;
                        remaining = matches1FAWithout(remaining, bans[i]).ToList();
                    }
                    return new { champion, Count = n, WinRate = p, Lower95 = conf95.lower, Upper95 = conf95.upper, bans, banWR };
                }).OrderBy(r => r.champion).ToList();
                writeAllLines($"{prefix}-champselect.csv", statsChampSelect.Select(l => $"{l.champion},{l.Count},{l.WinRate},{l.Lower95},{l.Upper95},{l.bans[0]},{l.banWR[0]},{l.bans[1]},{l.banWR[1]},{l.bans[2]},{l.banWR[2]},{l.bans[3]},{l.banWR[3]},{l.bans[4]},{l.banWR[4]}"));
            }
        }
Example #8
0
        public void CanTryGetValueFromAutoDictionaryWhenNoEntryExists()
        {
            AutoDictionary <string, bool> tested = new AutoDictionary <string, bool>();

            Assert.AreEqual(true, tested.TryGetValue("Hello", out bool outvalue));
            Assert.AreEqual(false, outvalue);
        }
        /// <summary>
        /// 從XML載入設定
        /// </summary>
        /// <param name="data"></param>
        public void Load(XmlElement data)
        {
            XmlHelper helper = new XmlHelper(data);

            StudentID = data.GetAttribute("RefStudentID");
            ADDate = helper.GetDateString("ADDate");
            ADNumber = helper.GetString("ADNumber");
            Birthdate = helper.GetDateString("Birthdate");
            Comment = helper.GetString("Comment");
            Gender = helper.GetString("Gender");
            GradeYear = helper.GetString("GradeYear");
            ID = helper.GetString("@ID");
            IDNumber = helper.GetString("IDNumber");
            LastADDate = helper.GetDateString("LastADDate");
            LastADNumber = helper.GetString("LastADNumber");
            StudentName = helper.GetString("Name");
            StudentNumber = helper.GetString("StudentNumber");
            UpdateCode = helper.GetString("UpdateCode");
            UpdateDate = helper.GetDateString("UpdateDate");
            UpdateDescription = helper.GetString("UpdateDescription");
            Department = helper.GetString("Department");
            SchoolYear = K12.Data.Int.ParseAllowNull(helper.GetString("SchoolYear"));
            Semester = K12.Data.Int.ParseAllowNull(helper.GetString("Semester"));
            
            Attributes = new AutoDictionary(data.SelectSingleNode("ContextInfo/ContextInfo") as XmlElement, false);
        }
Example #10
0
        public void AutoDictionary_Get_WithNoDefaultValueOrLambdaAndNoExistingKey_GetsExpectedValue()
        {
            var dic = new AutoDictionary <int, int>();

            Assert.That(dic[0], Is.EqualTo(default(int)));
            Assert.That(dic[1], Is.EqualTo(default(int)));
            Assert.That(dic[2], Is.EqualTo(default(int)));
        }
Example #11
0
        public void CanTryGetValueFromAutoDictionary()
        {
            AutoDictionary <string, bool> tested = new AutoDictionary <string, bool>();

            tested["Hello"] = true;
            Assert.AreEqual(true, tested.TryGetValue("Hello", out bool outvalue));
            Assert.AreEqual(true, outvalue);
        }
Example #12
0
        public void AutoDictionary_Get_WithDefaultLambdaAndNoExistingKey_GetsExpectedValue()
        {
            Func <int, int[]> f = i => new[] { i, 42 };
            var dic             = new AutoDictionary <int, int[]>(f);

            Assert.That(dic[0], Is.EquivalentTo(f(0)));
            Assert.That(dic[1], Is.EquivalentTo(f(1)));
            Assert.That(dic[2], Is.EquivalentTo(f(2)));
        }
Example #13
0
        public void AutoDictionary_Get_WithDefaultValueAndNoExistingKey_GetsExpectedValue()
        {
            int def = 42;
            var dic = new AutoDictionary <int, int>(def);

            Assert.That(dic[0], Is.EqualTo(42));
            Assert.That(dic[1], Is.EqualTo(42));
            Assert.That(dic[2], Is.EqualTo(42));
        }
Example #14
0
        public void CanRemoveFromAutoDictionary()
        {
            AutoDictionary <string, bool> tested = new AutoDictionary <string, bool>();

            tested["Hello"] = true;
            Assert.AreEqual(true, tested["Hello"]);
            tested.Remove("Hello");
            Assert.AreEqual(false, tested["Hello"]);
        }
Example #15
0
        public static AutoDictionary <Direction, T> MakeDictionary <T>(T up, T right, T down, T left)
        {
            var result = new AutoDictionary <Direction, T>();

            result[Direction.Up]    = up;
            result[Direction.Right] = right;
            result[Direction.Down]  = down;
            result[Direction.Left]  = left;
            return(result);
        }
Example #16
0
        private Dictionary <string, HashSet <string> > LoadGraph()
        {
            AutoDictionary <string, HashSet <string> > graph = new AutoDictionary <string, HashSet <string> >();

            foreach (string[] entry in File.ReadAllLines("Day12Input.txt").Select(s => s.Split('-')))
            {
                graph[entry[0]].Add(entry[1]);
                graph[entry[1]].Add(entry[0]);
            }

            return(graph.Dictionary);
        }
        private AutoDictionary basedata(string TableName, string Name, string Value, string Text)
        {
            string[] strlist = new string[4];
            strlist[0] = TableName;
            strlist[1] = Name;
            strlist[2] = Value;
            strlist[3] = Text;
            AutoDictionary ad = new AutoDictionary();

            ad.AutoDictionaryList(strlist);
            return(ad);
        }
Example #18
0
        public void AutoDictionary_Set_WithNoDefaultValueOrLambda_SetsExpectedValue()
        {
            var dic = new AutoDictionary <int, int>()
            {
                [0] = 100,
                [1] = 17,
                [2] = 12
            };

            Assert.That(dic[0], Is.EqualTo(100));
            Assert.That(dic[1], Is.EqualTo(17));
            Assert.That(dic[2], Is.EqualTo(12));
        }
Example #19
0
        private AutoDictionary basedataForChild(string TableName, string Name, string Value, string Text, string keyValue)
        {
            string[] strlist = new string[5];
            strlist[0] = TableName;
            strlist[1] = Name;
            strlist[2] = Value;
            strlist[3] = Text;
            strlist[4] = keyValue;
            AutoDictionary ad = new AutoDictionary();

            ad.AutoDictionaryChiledList(strlist);//这里需要传递5个参数过去,keyvalue就是该表的主键ID
            return(ad);
        }
Example #20
0
        public void AutoDictionary_Set_WithDefaultValue_SetsExpectedValue()
        {
            int def = 42;
            var dic = new AutoDictionary <int, int>(def)
            {
                [0] = 100,
                [1] = 17,
                [2] = 12
            };

            Assert.That(dic[0], Is.EqualTo(100));
            Assert.That(dic[1], Is.EqualTo(17));
            Assert.That(dic[2], Is.EqualTo(12));
        }
        /// <summary>
        /// 建立可更新的「組態記錄」。
        /// </summary>
        /// <param name="data">組態的  Xml 資料。</param>
        public ConfigurationRecord(string name, XmlElement data)
        {
            if (data == null)
                throw new ArgumentException("組態的 Xml 資料不可以是 Null。");

            Namespace = name;
            EditAction = 2;//修改
            BaseData = null; //舊的格式的話,保持此資料是 Null。

            if (data.LocalName != RootName)
                PreviousData = data.CloneNode(true) as XmlElement;
            else
                BaseData = new AutoDictionary(data.SelectNodes(RecordName), "Name", false);
        }
Example #22
0
        public void AutoDictionary_Set_WithDefaultLambda_SetsExpectedValue()
        {
            Func <int, int[]> f = i => new[] { i, 42 };
            var dic             = new AutoDictionary <int, int[]>(f)
            {
                [0] = new int[0],
                [1] = new[] { 1, 2, 3, 4, 5 },
                [2] = new[] { 100 }
            };

            Assert.That(dic[0], Is.EquivalentTo(new int[0]));
            Assert.That(dic[1], Is.EquivalentTo(new[] { 1, 2, 3, 4, 5 }));
            Assert.That(dic[2], Is.EquivalentTo(new[] { 100 }));
        }
Example #23
0
        public void CanClearAutoDictionary()
        {
            AutoDictionary <string, bool> tested = new AutoDictionary <string, bool>()
            {
                { "hello", true },
                { "world", true }
            };

            tested.Clear();
            Assert.AreEqual(0, tested.Count);
            Assert.AreEqual(false, tested["hello"]);
            Assert.AreEqual(false, tested.ContainsKey("hello"));
            Assert.AreEqual(false, tested["world"]);
        }
Example #24
0
        private static void MergePreVer(string outputPath, string searchPath, bool mergeJsons)
        {
            var mergers = new AutoDictionary <Region, RegionMergerPreVer>(region => new RegionMergerPreVer {
                Region = region
            });

            foreach (var f in new PathManager(searchPath).GetFiles())
            {
                var match       = Regex.Match(f.Name, @"^(?<region>[A-Z]+)-matches-(?<queueId>\d+)\.losjs$");
                var existing    = Regex.Match(f.Name, @"^(?<region>[A-Z]+)-match-id-existing\.losmid$");
                var nonexistent = Regex.Match(f.Name, @"^(?<region>[A-Z]+)-match-id-nonexistent\.losmid$");

                if (match.Success && mergeJsons)
                {
                    mergers[EnumStrong.Parse <Region>(match.Groups["region"].Value)].MatchFiles.Add((int.Parse(match.Groups["queueId"].Value), f));
                }
                else if (existing.Success)
                {
                    mergers[EnumStrong.Parse <Region>(existing.Groups["region"].Value)].ExistingIdsFiles.Add(f);
                }
                else if (nonexistent.Success)
                {
                    mergers[EnumStrong.Parse <Region>(nonexistent.Groups["region"].Value)].NonexistentIdsFiles.Add(f);
                }
            }

            foreach (var merger in mergers.Values)
            {
                Console.WriteLine($"===== MERGING {merger.Region} ========");
                merger.Merge(outputPath);
                Console.WriteLine();
                Console.WriteLine();
                if (mergeJsons)
                {
                    File.WriteAllLines(Path.Combine(outputPath, $"{merger.Region}-redownload.txt"), merger.RedownloadIds.Select(id => id.ToString()));
                }
            }

            Console.WriteLine($"TOTAL non-existent: {mergers.Values.Sum(m => m.NonexistentCount):#,0}");
            if (mergeJsons)
            {
                Console.WriteLine($"TOTAL re-download: {mergers.Values.Sum(m => m.RedownloadIds.Count):#,0}");
                Console.WriteLine($"TOTAL have: {mergers.Values.Sum(m => m.HaveCounts.Values.Sum()):#,0}");
                Console.WriteLine($"TOTAL have one-for-all: {mergers.Values.Sum(m => m.HaveCounts[1020]):#,0}");
            }
            else
            {
                Console.WriteLine($"TOTAL existing: {mergers.Values.Sum(m => m.RedownloadIds.Count):#,0}");
            }
        }
Example #25
0
        public void CalculateSmallestMultiple()
        {
            var    autod  = new AutoDictionary <double>();
            double result = 1;

            // for the sequence from 1-to-Input, get prime factors for each and store new ones (or higher powers)
            // Then get all factors and multiply them

            // Back then I didn't know IEnumerable.Range o.o
            NumericSources.YieldSequenceFromTo(1, Input).ForEach(x => autod.RegisterIfNew(x.GetPrimeFactors()));
            autod.Dictionary.ForEach(x => result *= Math.Pow(x.Key, x.Value));

            this.SmallestMultiple = result;
        }
Example #26
0
        public void ConstructAutoDictionaryFromNormalDictionary()
        {
            Dictionary <string, bool> input = new Dictionary <string, bool>()
            {
                { "hello", true },
                { "world", false }
            };

            AutoDictionary <string, bool> tested = new AutoDictionary <string, bool>(input);

            Assert.AreEqual(true, tested["hello"]);
            Assert.AreEqual(false, tested["world"]);
            Assert.AreEqual(2, tested.Count);
        }
Example #27
0
        private IDictionary <string, long> ApplyRules(IDictionary <string, long> polymer, Dictionary <string, string> rules)
        {
            AutoDictionary <string, long> newPolymer = new AutoDictionary <string, long>();

            foreach (string pair in polymer.Keys)
            {
                long   count  = polymer[pair];
                string insert = rules[pair];

                newPolymer[string.Concat(pair[0], insert)] += count;
                newPolymer[string.Concat(insert, pair[1])] += count;
            }

            return(newPolymer);
        }
Example #28
0
        public void AutoDictionaryKeysAndValuesCollectionsAreCorrect()
        {
            AutoDictionary <string, bool> tested = new AutoDictionary <string, bool>()
            {
                { "hello", true },
                { "world", false }
            };

            Assert.AreEqual(2, tested.Keys.Count);
            Assert.AreEqual(2, tested.Values.Count);
            Assert.AreEqual("hello", tested.Keys.First());
            Assert.AreEqual("world", tested.Keys.Skip(1).First());
            Assert.AreEqual(true, tested.Values.First());
            Assert.AreEqual(false, tested.Values.Skip(1).First());
        }
Example #29
0
        public static Widget FileBar(
            AutoDictionary <string, AutoDictionary <string, DropDownEntry> > entries
            )
        {
            var file_bar = new Widget {
                Height = 40f
            };

            file_bar.VisualSettings.ChangeColorOnMouseOver = false;
            file_bar.VisualSettings.VisualRole             = VisualRoleType.header_widget;
            file_bar.FitToContentArea = true;

            //file_bar.Behaviors.Add(new ShadingBehavior() { UseWidgetOutlineColor = true });
            file_bar.Behaviors.Add(new SpacedListFormat()
            {
                ListSpacing = 0f
            });

            foreach (var entry in entries)
            {
                var w_entry = Button(entry.Key, new RectangleF(0, 0, 50, 40));
                w_entry.Behaviors.Get <DrawText>().SideSpacing = 25f;
                w_entry.VisualSettings.DrawOutline             = false;
                w_entry.VisualSettings.DrawBackground          = false;

                var dropdown = DropDown(entry.Value);

                w_entry.Behaviors.Add(
                    new TriggerWidgetAction(
                        nameof(Widget.OnClick),
                        new AddMainWidget(
                            dropdown,
                            new SideOfParent {
                    ParentSide = Direction2D.down,
                    ParentUp   = 1
                }
                            )
                        )
                    );

                file_bar.Add(w_entry);
            }

            return(file_bar);
        }
Example #30
0
        public static void GenerateRecentItemStats(string dataPath, string itemStatsFile, double includeLastDays)
        {
            Console.WriteLine($"Loading basic match infos...");
            var cutoff = DateTime.UtcNow - TimeSpan.FromDays(includeLastDays);
            var counts = new AutoDictionary <string, string, int, int>();

            foreach (var match in DataStore.ReadMatchesByBasicInfo(mi => mi.GameCreationDate >= cutoff && (mi.QueueId == 420 || mi.QueueId == 400 || mi.QueueId == 430)))
            {
                foreach (var plr in match.json["participants"].GetList())
                {
                    var lane     = plr["timeline"]["lane"].GetString();
                    var role     = plr["timeline"]["role"].GetString();
                    var lanerole =
                        lane == "MIDDLE" && role == "SOLO" ? "mid" :
                        lane == "TOP" && role == "SOLO" ? "top" :
                        lane == "JUNGLE" && role == "NONE" ? "jungle" :
                        lane == "BOTTOM" && role == "DUO_CARRY" ? "adc" :
                        lane == "BOTTOM" && role == "DUO_SUPPORT" ? "sup" : null;
                    if (lanerole == null)
                    {
                        continue;
                    }
                    var champ = LeagueStaticData.Champions[plr["championId"].GetInt()].Name;
                    counts[champ][lanerole][plr["stats"]["item0"].GetInt()]++;
                    counts[champ][lanerole][plr["stats"]["item1"].GetInt()]++;
                    counts[champ][lanerole][plr["stats"]["item2"].GetInt()]++;
                    counts[champ][lanerole][plr["stats"]["item3"].GetInt()]++;
                    counts[champ][lanerole][plr["stats"]["item4"].GetInt()]++;
                    counts[champ][lanerole][plr["stats"]["item5"].GetInt()]++;
                    counts[champ][lanerole][-999]++; // number of games
                }
            }

            File.Delete(itemStatsFile);
            foreach (var champ in counts.Keys)
            {
                foreach (var lanerole in counts[champ].Keys)
                {
                    foreach (var item in counts[champ][lanerole].Keys)
                    {
                        File.AppendAllText(itemStatsFile, $"{champ},{lanerole},{item},{counts[champ][lanerole][item]}\r\n");
                    }
                }
            }
        }
Example #31
0
 private void InitCells(int tile)
 {
     Cells = new MemMapPoint[ColumnCount,RowCount];
     tiles = new AutoDictionary<int, int>();
     for (int i = 0; i < ColumnCount; i++)
     {
         for (int j = 0; j < RowCount; j++)
         {
             int tarTile = bMap.Cells[i, j];
             if (tarTile == 0)
             {
                 tarTile = tile == 0 ? TileConfig.Indexer.DefaultTile : tile;
             }
             Cells[i, j] = new MemMapPoint(i, i*CardSize, j*CardSize, ColumnCount, tarTile);
             tiles[tarTile == TileConfig.Indexer.DefaultTile ? 0 : tarTile]++;
         }
     }
 }
Example #32
0
 private void InitCells(int tile)
 {
     Cells = new MemMapPoint[ColumnCount, RowCount];
     tiles = new AutoDictionary <int, int>();
     for (int i = 0; i < ColumnCount; i++)
     {
         for (int j = 0; j < RowCount; j++)
         {
             int tarTile = bMap.Cells[i, j];
             if (tarTile == 0)
             {
                 tarTile = tile == 0 ? TileConfig.Indexer.DefaultTile : tile;
             }
             Cells[i, j] = new MemMapPoint(i, i * CardSize, j * CardSize, ColumnCount, tarTile);
             tiles[tarTile == TileConfig.Indexer.DefaultTile ? 0 : tarTile]++;
         }
     }
 }
        public static void EstimateActivePlayers_Extract()
        {
            var seenMatches = new AutoDictionary <Region, HashSet <long> >(_ => new HashSet <long>());

            foreach (var f in DataStore.LosMatchJsons.SelectMany(kvpR => kvpR.Value.SelectMany(kvpV => kvpV.Value.Select(kvpQ => (region: kvpR.Key, version: kvpV.Key, queueId: kvpQ.Key, file: kvpQ.Value)))))
            {
                if (f.queueId == 0)
                {
                    continue;
                }
                Console.WriteLine($"Processing {f.file.FileName} ...");
                var count = new CountThread(10000);
                File.WriteAllLines($"ActivePlayersExtract-{f.region}-{f.version}-{f.queueId}.csv",
                                   f.file.ReadItems()
                                   .PassthroughCount(count.Count)
                                   .Where(js => seenMatches[f.region].Add(js["gameId"].GetLong()) && js.ContainsKey("participantIdentities") && js["participantIdentities"].Count > 0)
                                   .Select(js => $"{js["gameId"].GetLong()},{js["gameCreation"].GetLong()},{js["gameDuration"].GetLong()},{js["participantIdentities"].GetList().Select(p => p["player"]["accountId"].GetLong()).JoinString(",")}"));
                count.Stop();
            }
        }
        public void SetUriPattern(string value)
        {
            uriPattern = value;
            if (Parameters == null && uriPattern != null)
            {
                string[] pathParts = Path.Split('?');

                // parse UriPattern
                // UriPattern will be like:
                // "/rest/{version}/driver/{driverId}"
                string[] tokens = uriPattern.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                string[] values = pathParts[0].Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

                if (tokens.Length != values.Length)
                {
                    throw new InvalidOperationException("An error has occurred during validation of the URI Pattern");
                }

                Parameters = new AutoDictionary <string, string>();

                for (int i = 0; i < tokens.Length; i++)
                {
                    string token = tokens[i];
                    if (token.StartsWith("{") && token.EndsWith("}"))
                    {
                        string key = token.Trim('{', '}');
                        Parameters.Add(key, Uri.UnescapeDataString(values[i]));
                    }
                }

                // parse Get params
                if (pathParts.Length > 1)
                {
                    string paramsString = pathParts[1];
                    ParseParameters(paramsString);
                }
            }
        }
 /// <summary>
 /// 新增學生異動記錄建構式,參數為新增記錄的必填欄位
 /// </summary>
 /// <param name="StudentID">所屬學生編號</param>
 /// <param name="UpdateDate">異動日期</param>
 public UpdateRecordRecord(string StudentID,string UpdateDate)
 {
     this.StudentID = StudentID;
     this.UpdateDate = UpdateDate;
     Attributes = new AutoDictionary();
 }
Example #36
0
 public List<IntPair> GetItemCountBySubtype(int type)
 {
     AutoDictionary<int, int> counter = new AutoDictionary<int, int>();
     for (int i = 0; i < BagCount; i++)
     {
         HItemConfig itemConfig = ConfigData.GetHItemConfig(Items[i].Type);
         if (itemConfig != null && itemConfig.SubType == type)
         {
             counter[itemConfig.Id] += Items[i].Value;
         }
     }
     List<IntPair> datas = new List<IntPair>();
     foreach (int itemId in counter.Keys())
     {
         IntPair pairData = new IntPair();
         pairData.Type = itemId;
         pairData.Value = counter[itemId];
         datas.Add(pairData);
     }
     return datas;
 }
 /// <summary>
 /// 無參數建構式
 /// </summary>
 public UpdateRecordRecord()
 {
     Attributes = new AutoDictionary();
 }