Esempio n. 1
0
 private static IEnumerable<CustomChampionStats> GetCustomStats(RiotSharp.SummonerEndpoint.Summoner sum)
 {
     try
     {
         return sum.GetStatsRanked().Select(stat => new CustomChampionStats(stat));
     }
     catch (Exception)
     {
         return null;
     }
 }
 public MasteryPage(RiotSharp.SummonerEndpoint.MasteryPage masteryPage)
 {
     InitializeComponent();
     // Loads the values of masteries from JSON file
     _Mastery = LoadJson();
     _images = new Image[] {image4111, image4112, image4113, image4114, image4121, image4122, image4123, image4124, image4131, image4132, image4133, 
                       image4134, image4141, image4142, image4143, image4144, image4151, image4152, image4154, image4162, image4211, image4212,
                       image4213, image4214, image4221, image4222, image4224, image4231, image4232, image4233, image4234, image4241, image4242,
                       image4243, image4244, image4251, image4252, image4253, image4262, image4311, image4312, image4313, image4314, image4322,
                       image4323, image4324, image4331, image4332, image4333, image4334, image4341, image4342, image4343, image4344, image4352,
                       image4353, image4362};
     labelName.Content = masteryPage.Name;
     SetupImages();
     SetupMasteryPage(masteryPage);
     SetupToolTip();
 }
Esempio n. 3
0
        /// <summary>
        /// Consume a match.
        /// </summary>
        public async Task ConsumeMatchDetail(RiotSharp.MatchEndpoint.MatchDetail match)
        {
            long matchId = match.MatchId;
            Console.WriteLine("Processing match " + matchId);

            match.Participants.ForEach(participant =>
            {
                int championId = participant.ChampionId;
                bool isWinner = match.Teams.FirstOrDefault(t => participant.TeamId == t.TeamId).Winner;

                ChampionWinCount.AddOrUpdate(championId,
                    id => { return new ChampionWinData() { Wins = isWinner ? 1 : 0, Matches = 1 }; },
                    (id, winData) => { winData.Increment(isWinner); return winData; }
                );
            });
        }
Esempio n. 4
0
 public RunePage(RiotSharp.SummonerEndpoint.RunePage runePage)
 {
     InitializeComponent();
     Rune = LoadJson();
     images = new Image[]
     {
         imgRune1, imgRune2, imgRune3, imgRune4, imgRune5, imgRune6, imgRune7, imgRune8, imgRune9, imgRune10,
         imgRune11,
         imgRune12, imgRune13, imgRune14, imgRune15, imgRune16, imgRune17, imgRune18, imgRune19, imgRune20,
         imgRune21, imgRune22,
         imgRune23, imgRune24, imgRune25, imgRune26, imgRune27, imgRune28, imgRune29, imgRune30
     };
     //labelName.Content = runePage.Name;
     SetupImages();
     SetupRunePage(runePage);
 }
        public CurrentGamePanel(CurrentGame currentGame, string summonerName, RiotSharp.Region region, List<ChampionStatic> championStatics, Dictionary<long, List<League>> leagues)
        {
            // Set panel properties
            Size = new Size(320, 180);

            // Set team info
            List<long> teamIds = new List<long>();
            List<int> teamNumPlayers = new List<int>();

            foreach (Participant p in currentGame.Participants) {
                // Add new team for the game if it does not exist
                if (!teamIds.Contains(p.TeamId)) {
                    teamIds.Add(p.TeamId);
                    teamNumPlayers.Add(0);
                }

                // Get team index
                int teamIndex = teamIds.IndexOf(p.TeamId);

                // Get champion icon
                string iconLocation = "http://ddragon.leagueoflegends.com/cdn/" +
                                      Program.PatchVersion +
                                      "/img/champion/" +
                                      championStatics[currentGame.Participants.IndexOf(p)].Image.Full;

                // Check if participant is self
                bool isSelf = false;
                if (p.SummonerName.Replace(" ", "").ToLower() == summonerName.Replace(" ", "").ToLower()) {
                    isSelf = true;
                }

                // Get ranked stats
                List<League> rankedStats = new List<League>();
                if (leagues.ContainsKey(p.SummonerId)) {
                    rankedStats = leagues[p.SummonerId];
                }

                // Create player panel
                CurrentGamePlayerPanel playerPanel = new CurrentGamePlayerPanel(p, region, isSelf, iconLocation, rankedStats);
                playerPanel.Location = new Point(155 * teamIndex, 36 * teamNumPlayers[teamIndex]);
                teamNumPlayers[teamIndex]++;

                // Add player panel
                Controls.Add(playerPanel);
            }
        }
Esempio n. 6
0
        public ItemRow(RiotSharp.MatchEndpoint.Event frame_event, PlayerRow player_row, int match_event_counter)
        {
            // Match info
            this.match_version = player_row.match_version;
            this.match_id = player_row.match_id;
            this.queue_type = player_row.queue_type;
            this.region = player_row.region;
            this.summoner_id = player_row.summoner_id;
            this.summoner_name = player_row.summoner_name;

            // General cham/summoner info
            this.champ_id = player_row.champ_id;
            this.part_index = player_row.part_index;
            this.is_winner = player_row.is_winner;

            // Even info
            this.time_ms = frame_event.Timestamp.Duration().TotalMilliseconds;
            this.item_id = frame_event.ItemId;

            // Parse the event type
            if ( frame_event.EventType == RiotSharp.MatchEndpoint.EventType.ItemDestroyed)
            {
                event_type = "destroyed";
            }
            else if ( frame_event.EventType == RiotSharp.MatchEndpoint.EventType.ItemPurchased)
            {
                event_type = "purchased";
            }
            else if ( frame_event.EventType == RiotSharp.MatchEndpoint.EventType.ItemSold )
            {
                event_type = "sold";
            }
            else if ( frame_event.EventType == RiotSharp.MatchEndpoint.EventType.ItemUndo )
            {
                event_type = "undone";
            }
            else
            {
                throw new Exception("[ItemRow] An event type of unexpected type was recieved:" + frame_event.EventType.ToString());
            }

            this.match_event_counter = match_event_counter;
        }
Esempio n. 7
0
        public PlayerRow(string match_version, long match_id, string region, string queue_type, RiotSharp.MatchEndpoint.Participant participant, RiotSharp.MatchEndpoint.ParticipantIdentity ident)
        {
            // Match info
            this.match_version = match_version;
            this.match_id = match_id;
            this.queue_type = queue_type;
            this.region = region;
            if (ident.Player != null)
            {
                this.summoner_id = ident.Player.SummonerId;
                this.summoner_name = ident.Player.SummonerName;
            }

            // Get participant and participant identity for this player
            RiotSharp.MatchEndpoint.ParticipantStats stat  = participant.Stats;

            // General cham/summoner info
            this.champ_id = participant.ChampionId;
            this.part_index = participant.ParticipantId;
            this.is_winner = stat.Winner;

            // Battle stats
            this.magic_damage_dealt = stat.MagicDamageDealt;
            this.magic_damage_dealt_champs = stat.MagicDamageDealtToChampions;
            this.damage_dealt = stat.TotalDamageDealt;
            this.damage_dealt_champs = stat.TotalDamageDealtToChampions;
            this.healing_done = stat.TotalHeal;

            // Farming stats
            this.minions_killed = stat.MinionsKilled;
            this.gold_earned = stat.GoldEarned;

            // KDA stats
            this.kills = stat.Kills;
            this.deaths = stat.Deaths;
            this.assists = stat.Assists;
        }
        public MatchWrapper(RiotSharp.MatchEndpoint.MatchDetail match, string region)
        {
            this.match_id = match.MatchId;
            this.queue_type = match.QueueType.ToString();
            this.region = region;
            this.version = match.MatchVersion.Substring(0, 4);

            var participants = match.Participants;
            var idents = match.ParticipantIdentities;
            var timeline = match.Timeline;

            for (int i = 0; i < 10; i++)
            {
                PlayerRow r = new PlayerRow(version, this.match_id, this.region, this.queue_type, participants[i], idents[i]);
                player_rows.Add(i,r);
            }

            // Init item counters
            const int DEST = 0;
            const int BUY = 1;
            const int SELL = 2;
            const int UNDO = 4;
            Dictionary<int, Dictionary<int, int>> counters_by_part = new Dictionary<int, Dictionary<int, int>>();
            for (int i=0; i<10; i++)
            {
                Dictionary<int, int> counters = new Dictionary<int, int>();
                counters.Add(DEST, 0);
                counters.Add(BUY, 0);
                counters.Add(SELL, 0);
                counters.Add(UNDO, 0);

                counters_by_part.Add(i, counters);
            }

            if (timeline == null)
            {
                throw new Exception("Timeline was not recieved for match ID: " + match.MatchId.ToString());
            }
            else if (timeline.Frames != null)
            {
                foreach (var frame in timeline.Frames)
                {
                    // There are no events at some frames - frame 0 for example.
                    if (frame.Events != null)
                    {
                        foreach (var frame_event in frame.Events)
                        {
                            int operation_index = -1;
                            // If it's one of the events we want to log
                            if (frame_event.EventType == RiotSharp.MatchEndpoint.EventType.ItemDestroyed)
                                operation_index = DEST;
                            else if (frame_event.EventType == RiotSharp.MatchEndpoint.EventType.ItemPurchased)
                                operation_index = BUY;
                            else if (frame_event.EventType == RiotSharp.MatchEndpoint.EventType.ItemSold)
                                operation_index = SELL;
                            else if (frame_event.EventType == RiotSharp.MatchEndpoint.EventType.ItemUndo)
                                operation_index = UNDO;
                            else
                                continue; // Not an item event

                            if (frame_event.EventType == RiotSharp.MatchEndpoint.EventType.ItemDestroyed && frame_event.ParticipantId == 0)
                                continue;

                            int item_id = frame_event.ItemId;

                            int hp_pot = 2003;
                            int mana_pot = 2004;
                            int rej_bisc = 2009;
                            int rej_bisc_2 = 2010;
                            int ward = 2044;
                            int vision_ward = 2043;

                            // Don't proccess these
                            if (item_id == hp_pot || item_id == mana_pot || item_id == rej_bisc || item_id == rej_bisc_2 || item_id == ward || item_id == vision_ward)
                                continue;

                            // Get the dictionary list or create a new one
                            List<ItemRow> dictionary_list;
                            int index = frame_event.ParticipantId - 1;
                            var counter_by_operations = counters_by_part[index];
                            int current_num = counter_by_operations[operation_index];
                            counter_by_operations[operation_index]++;

                            if (item_rows_per_player.ContainsKey(index))
                            {
                                dictionary_list = item_rows_per_player[index];
                            }
                            else
                            {
                                dictionary_list = new List<ItemRow>();
                                item_rows_per_player.Add(index, dictionary_list);
                            }

                            // Generate the item row
                            var player_row = player_rows[index];
                            ItemRow item_row = new ItemRow(frame_event, player_row, current_num);

                            // Add the event to the dictionary
                            dictionary_list.Add(item_row);
                        }
                    }
                }
            }
            else
            {
                throw new Exception("Timeline frames were null for match ID: " + match.MatchId.ToString());
            }
        }
Esempio n. 9
0
        private Region ConvertRegion(RiotSharp.Region region)
        {
            Guard.NotInvalidEnum(region, nameof(region));

            return this._regionMapping.First(f => f.Value == region).Key;
        }
Esempio n. 10
0
 public void SetupRunePage(RiotSharp.SummonerEndpoint.RunePage runePage)
 {
     foreach (var runeSlot in runePage.Slots)
     {
         if (runeSlot == null)
         {
             return;
         }
         switch (runeSlot.RuneSlotId)
         {
             case 1:
                 imgRune1.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune1.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 2:
                 imgRune2.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune2.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 3:
                 imgRune3.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune3.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 4:
                 imgRune4.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune4.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 5:
                 imgRune5.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune5.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 6:
                 imgRune6.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune6.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 7:
                 imgRune7.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune7.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 8:
                 imgRune8.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune8.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 9:
                 imgRune9.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune9.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 10:
                 imgRune10.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune10.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 11:
                 imgRune11.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune11.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 12:
                 imgRune12.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune12.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 13:
                 imgRune13.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune13.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 14:
                 imgRune14.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune14.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 15:
                 imgRune15.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune15.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 16:
                 imgRune16.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune16.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 17:
                 imgRune17.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune17.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 18:
                 imgRune18.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune18.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 19:
                 imgRune19.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune19.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 20:
                 imgRune20.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune20.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 21:
                 imgRune21.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune21.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 22:
                 imgRune22.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune22.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 23:
                 imgRune23.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune23.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 24:
                 imgRune24.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune24.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 25:
                 imgRune25.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune25.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 26:
                 imgRune26.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune26.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 27:
                 imgRune27.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune27.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 28:
                 imgRune28.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune28.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 29:
                 imgRune29.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune29.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
             case 30:
                 imgRune30.Source = new BitmapImage(new Uri("http://ddragon.leagueoflegends.com/cdn/5.2.1/img/rune/" + Rune.Data[runeSlot.RuneId].Image.Full));
                 imgRune30.ToolTip = Rune.Data[runeSlot.RuneId].Name + "\n" +
                                    Rune.Data[runeSlot.RuneId].Description;
                 break;
         }
     }
 }
Esempio n. 11
0
        public async Task attempt_to_parse(RiotSharp.Region region, long match_id, int attempt = 0)
        {
            var match = await api.GetMatchAsync(region, match_id, true);

            if (match == null && attempt < 10)
            {
                //Console.WriteLine("Match {0} from {1} has failed {2} times!", match_id, region.ToString(), attempt);
                attempt++;
                await Task.Delay(3000);
                await attempt_to_parse(region, match_id, attempt);
                return;
            }
            else if (match == null)
            {
                Console.WriteLine("Failed to get match id {0} 10 times!", match_id);
                return;
            }

            MatchWrapper wrapper = new MatchWrapper(match, region.ToString());
            send_player_info(wrapper.player_rows);
            send_item_events(wrapper.item_rows_per_player);

            match_counter.UpButton();
        }
 public void SetupMasteryPage(RiotSharp.SummonerEndpoint.MasteryPage masteryPage)
 {
     int offensive = 0;
     int defensive = 0;
     int utility = 0;
    
     if (masteryPage.Masteries != null)
     {
         foreach (var mastery in masteryPage.Masteries)
         {
             switch (mastery.Id)
             {
                 // Offensive Tree
                 case 4111:
                     image4111.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4112:
                     image4112.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4113:
                     image4113.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4114:
                     image4114.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4121:
                     image4121.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4122:
                     image4122.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4123:
                     image4123.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4124:
                     image4124.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4131:
                     image4131.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4132:
                     image4132.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4133:
                     image4133.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4134:
                     image4134.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4141:
                     image4141.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4142:
                     image4142.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4143:
                     image4143.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4144:
                     image4144.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4151:
                     image4151.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4152:
                     image4152.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4154:
                     image4154.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 case 4162:
                     image4162.Opacity = 100;
                     offensive += mastery.Rank;
                     break;
                 // End of Offence
                 // Start of Defense
                 case 4211:
                     image4211.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4212:
                     image4212.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4213:
                     image4213.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4214:
                     image4214.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4221:
                     image4221.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4222:
                     image4222.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4224:
                     image4224.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4231:
                     image4231.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4232:
                     image4232.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4233:
                     image4233.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4234:
                     image4234.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4241:
                     image4241.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4242:
                     image4242.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4243:
                     image4243.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4244:
                     image4244.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4251:
                     image4251.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4252:
                     image4252.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4253:
                     image4253.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                 case 4262:
                     image4262.Opacity = 100;
                     defensive += mastery.Rank;
                     break;
                     // Start utility
                 case 4311:
                     image4311.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4312:
                     image4312.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4313:
                     image4313.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4314:
                     image4314.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4322:
                     image4322.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4323:
                     image4323.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4324:
                     image4324.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4331:
                     image4331.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4332:
                     image4332.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4333:
                     image4333.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4334:
                     image4334.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4341:
                     image4341.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4342:
                     image4342.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4343:
                     image4343.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4344:
                     image4344.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4352:
                     image4352.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4353:
                     image4353.Opacity = 100;
                     utility += mastery.Rank;
                     break;
                 case 4362:
                     image4362.Opacity = 100;
                     utility += mastery.Rank;
                     break;
             }
         }
     }
     labelOffensive.Content = "Offense: " + offensive;
     labelDefense.Content = "Defense: " + defensive;
     labelUtility.Content = "Utility: " + utility;
 }
        public CurrentGamePlayerPanel(Participant p, RiotSharp.Region region, bool isSelf, string iconLocation, List<League> leagues) {
            // Set variables
            Player = p;

            // Set panel properties
            Size = new Size(150, 32);
            Cursor = Cursors.Hand;

            // Create image
            PictureBox iconBox = new PictureBox();
            iconBox.InitialImage = null;
            iconBox.ErrorImage = null;
            iconBox.SizeMode = PictureBoxSizeMode.StretchImage;
            iconBox.ImageLocation = iconLocation;
            iconBox.Size = new Size(32, 32);
            iconBox.Location = new Point(0, 0);

            // Create labels
            Label nameLabel = new Label();
            nameLabel.BackColor = Color.White;
            nameLabel.Size = new Size(118, 16);
            nameLabel.Location = new Point(32, 0);

            Label rankLabel = new Label();
            rankLabel.BackColor = Color.LightGray;
            rankLabel.Size = new Size(118, 16);
            rankLabel.Location = new Point(32, 16);

            Label playedWithLabel = new Label();
            playedWithLabel.BackColor = PLAYED_WITH_BACK_COLOR;
            playedWithLabel.Size = new Size(26, 16);
            playedWithLabel.Location = new Point(98, 16);
            playedWithLabel.TextAlign = ContentAlignment.MiddleCenter;

            Label playedAgainstLabel = new Label();
            playedAgainstLabel.BackColor = PLAYED_AGAINST_BACK_COLOR;
            playedAgainstLabel.Size = new Size(26, 16);
            playedAgainstLabel.Location = new Point(124, 16);
            playedAgainstLabel.TextAlign = ContentAlignment.MiddleCenter;

            // Set name text
            nameLabel.Text = p.SummonerName;

            // Set rank text
            bool rankFound = false;
            foreach (League l in leagues) {
                if (l.Queue == RiotSharp.Queue.RankedSolo5x5) {
                    String rankedTier = l.Tier.ToString();
                    String rankedDivision = l.Entries[0].Division;
                    rankLabel.Text = String.Format("{0} {1}", rankedTier, rankedDivision);
                    rankFound = true;
                    break;
                }
            }
            if (!rankFound) {
                rankLabel.Text = "Unranked";
            }

            // Set win/loss text if not self
            if (!isSelf) {
                // Get num times you've played with the player (minus 1 to exclude current game)
                int numGames = Program.DatabaseManager.FindNumResults(DatabaseManager.PLAYERS_TABLE, p.SummonerId.ToString()) - 1;
                playedWithLabel.Text = numGames.ToString();
                playedAgainstLabel.Text = "0";

                Controls.Add(playedWithLabel);
                Controls.Add(playedAgainstLabel);
            }

            // Add other controls
            Controls.Add(iconBox);
            Controls.Add(nameLabel);
            Controls.Add(rankLabel);

            // Add on click
            iconBox.Click += new EventHandler(Panel_Click);
            nameLabel.Click += new EventHandler(Panel_Click);
            rankLabel.Click += new EventHandler(Panel_Click);
            playedWithLabel.Click += new EventHandler(Panel_Click);
            playedAgainstLabel.Click += new EventHandler(Panel_Click);
        }
Esempio n. 14
0
        private BannedChampion ConvertBannedChampion(RiotSharp.CurrentGameEndpoint.BannedChampion bannedChampion, Region region)
        {
            Guard.NotNull(bannedChampion, nameof(bannedChampion));
            Guard.NotInvalidEnum(region, nameof(region));

            return new BannedChampion
            {
                ChampionId = bannedChampion.ChampionId,
                ChampionName = this.GetChampionList(region).Champions.FirstOrDefault(f => f.Value.Id == bannedChampion.ChampionId).Value?.Name,
                PickTurn = bannedChampion.PickTurn
            };
        }
Esempio n. 15
0
        private CurrentGame ConvertCurrentGame(RiotSharp.CurrentGameEndpoint.CurrentGame currentGame, Region region)
        {
            Guard.NotNull(currentGame, nameof(currentGame));
            Guard.NotInvalidEnum(region, nameof(region));

            return new CurrentGame
            {
                GameId = currentGame.GameId,
                GameQueueType = this.ConvertGameQueueType(currentGame.GameQueueType),
                GameType = this.ConvertGameType(currentGame.GameType),
                GameStartTime = currentGame.GameStartTime,
                BlueTeam = new Team
                {
                    Participants = currentGame.Participants
                        .Where(f => f.TeamId == 100)
                        .Select(f => this.ConvertParticipant(f, region))
                        .ToList(),
                    BannedChampions = currentGame.BannedChampions
                        .Where(f => f.TeamId == 100)
                        .Select(f => this.ConvertBannedChampion(f, region))
                        .ToList()
                },
                PurpleTeam = new Team
                {
                    Participants = currentGame.Participants
                        .Where(f => f.TeamId == 200)
                        .Select(f => this.ConvertParticipant(f, region))
                        .ToList(),
                    BannedChampions = currentGame.BannedChampions
                        .Where(f => f.TeamId == 200)
                        .Select(f => this.ConvertBannedChampion(f, region))
                        .ToList()
                },
                GameMode = this.ConvertGameMode(currentGame.GameMode),
                MapType = this.ConvertMapType(currentGame.MapType),
                Region = region
            };
        }
Esempio n. 16
0
 private Role ConvertRole(RiotSharp.MatchEndpoint.Role role)
 {
     return this._roleMapping[role];
 }
Esempio n. 17
0
 private Lane ConvertLane(RiotSharp.MatchEndpoint.Lane lane)
 {
     return this._laneMapping[lane];
 }
Esempio n. 18
0
        private Participant ConvertParticipant(RiotSharp.CurrentGameEndpoint.Participant participant, Region region)
        {
            Guard.NotNull(participant, nameof(participant));
            Guard.NotInvalidEnum(region, nameof(region));

            return new Participant
            {
                IsBot = participant.Bot,
                SummonerId = participant.SummonerId,
                ProfileIconId = (int)participant.ProfileIconId,
                SummonerName = participant.SummonerName,
                ChampionId = participant.ChampionId,
                ChampionName = this.GetChampionList(region).Champions.FirstOrDefault(f => f.Value.Id == participant.ChampionId).Value?.Name,
                SummonerSpell1Id = participant.SummonuerSpell1,
                SummonerSpell1Name = this.GetSummonerSpells(region).SummonerSpells.FirstOrDefault(f => f.Value.Id == participant.SummonuerSpell1).Value?.Name,
                SummonerSpell2Id = participant.SummonerSpell2,
                SummonerSpell2Name = this.GetSummonerSpells(region).SummonerSpells.FirstOrDefault(f => f.Value.Id == participant.SummonerSpell2).Value?.Name,
            };
        }
Esempio n. 19
0
        private GameQueueType ConvertGameQueueType(RiotSharp.CurrentGameEndpoint.Converters.GameQueueType gameQueueType)
        {
            Guard.NotInvalidEnum(gameQueueType, nameof(gameQueueType));

            return this._gameQueueTypeMapping.First(f => f.Value == gameQueueType).Key;
        }
Esempio n. 20
0
        private GameType ConvertGameType(RiotSharp.GameType gameType)
        {
            Guard.NotInvalidEnum(gameType, nameof(gameType));

            return this._gameTypeMapping.First(f => f.Value == gameType).Key;
        }
Esempio n. 21
0
        private MapType ConvertMapType(RiotSharp.MapType mapType)
        {
            Guard.NotInvalidEnum(mapType, nameof(mapType));

            return this._mapTypeMapping.First(f => f.Value == mapType).Key;
        }
Esempio n. 22
0
        private Summoner ConvertSummoner(RiotSharp.SummonerEndpoint.Summoner summoner)
        {
            Guard.NotNull(summoner, nameof(summoner));

            return new Summoner
            {
                RiotSummonerId = summoner.Id,
                Name = summoner.Name,
                Region = this.ConvertRegion(summoner.Region),
                Level = (int)summoner.Level,
                ProfileIconId = summoner.ProfileIconId,
            };
        }