/// <summary> /// Track purchases for this champion. /// </summary> public void Process(ChampionMatchItemPurchases matchPurchases) { // Create or get the purchase set for this match PurchaseSetKey key = new PurchaseSetKey(matchPurchases); PurchaseSet set = PurchaseSets.GetOrAdd(key, k => new PurchaseSet(k)); set.Process(matchPurchases); }
/// <summary> /// Processes purchases to build out information needed to generate an item set. /// </summary> public void Process(ChampionMatchItemPurchases matchPurchases) { // Eliminate undo events (and corresponding purchase events) var purchases = EliminateUndos(matchPurchases.ItemPurchases); if (purchases == null) { return; } // Process purchases to determine "builds into" information for each purchase AddBuildsIntoInformation(purchases); // Track how many times items were purchased TrackPurchaseCounts(purchases); // Use to test that build tree information is correctly generated /////// //Action<ItemPurchaseInformation> writePurchase = null; //writePurchase = new Action<ItemPurchaseInformation>(p => //{ // if (p.EventType != EventType.ItemPurchased) // return; // if (p.BuiltFrom.Count != 0) // Console.Write(" => "); // if (p.IsRecipeComponent) // Console.ForegroundColor = ConsoleColor.DarkMagenta; // else if (p.IsDestroyed) // Console.ForegroundColor = ConsoleColor.Red; // else if (p.IsSold) // Console.ForegroundColor = ConsoleColor.Blue; // Console.Write(p.Item.Name); // Console.ResetColor(); // if (p.IsRecipeComponent) // writePurchase(p.BuildsInto); // else // Console.WriteLine(); //}); //purchases.ForEach(p => writePurchase(p)); /////// // Eliminate sales and destroys (we can get them if needed by following links) var filteredPurchases = purchases.Where(purchase => purchase.EventType == EventType.ItemPurchased).ToList(); // Track purchases TrackPurchases(filteredPurchases); // Increment match processed count Interlocked.Increment(ref MatchCount); }
public PurchaseSetKey(ChampionMatchItemPurchases matchPurchases) { ChampionId = matchPurchases.ChampionId; Lane = matchPurchases.Lane; HasSmite = matchPurchases.HasSmite; // Convert all "Bot" to "Bottom" if (Lane == RiotSharp.MatchEndpoint.Lane.Bot) { Lane = RiotSharp.MatchEndpoint.Lane.Bottom; } }