예제 #1
0
        private async Task AddRunes()
        {
            var runeTreeDtos = this.riotSharpService.ReturnRunesData().ToArray();

            foreach (var runeTreeDto in runeTreeDtos)
            {
                var runeTree = new RunePath
                {
                    Name     = runeTreeDto.Name,
                    ImageUrl = runeTreeDto.ImageUrl,
                    Id       = runeTreeDto.Id,
                };

                foreach (var runeDto in runeTreeDto.RuneDtos)
                {
                    var rune = new Rune
                    {
                        Name             = runeDto.Name,
                        LongDescription  = runeDto.LongDescription,
                        ShortDescription = runeDto.ShortDescription,
                        ImageUrl         = runeDto.ImageUrl,
                        IsKeystone       = runeDto.IsKeystone,
                        RunePathId       = runeTree.Id,
                        Row   = runeDto.Row,
                        Count = runeDto.Count,
                    };

                    runeTree.Runes.Add(rune);
                }

                await this.runePathsRepository.AddAsync(runeTree);
            }

            await this.runePathsRepository.SaveChangesAsync();
        }
예제 #2
0
        private static List <RunePath> GetRunePaths()
        {
            var pathBuilder = new UrlPathBuilder();

            using (var client = new WebClient())
            {
                try
                {
                    var runesJson = client.DownloadString(pathBuilder.GetRunesReforgedUrl());
                    var runePaths = JsonConvert.DeserializeObject <List <RunePath> >(runesJson);

                    foreach (var path in runePaths)
                    {
                        path.Icon = pathBuilder.GetRuneIcon(path.Icon);
                        foreach (var slot in path.Slots)
                        {
                            foreach (var rune in slot.Runes)
                            {
                                rune.Icon = pathBuilder.GetRuneIcon(rune.Icon);
                            }
                        }
                    }

                    //Deliberately adding a custom runepath for rune fragments, since they are not provided by DDragon
                    var runepath = new RunePath()
                    {
                        Name = "Rune Stats"
                    };
                    var slot1 = new Slot();
                    slot1.Runes.Add(new Rune {
                        Id = 5008, Name = "Offense", LongDesc = "Adaptive Force +9", ShortDesc = "Adaptive Force +9", Icon = "../DataAccess/RiotGamesApi/Images/Misc/fragment_dmg.png"
                    });                                                                                                                                                                                           // damage fragment
                    slot1.Runes.Add(new Rune {
                        Id = 5005, Name = "Offense", LongDesc = "+10% Attack Speed", ShortDesc = "+10% Attack Speed", Icon = "../DataAccess/RiotGamesApi/Images/Misc/fragment_aspeed.png"
                    });                                                                                                                                                                                              // attack speed fragment
                    slot1.Runes.Add(new Rune {
                        Id = 5007, Name = "Offense", LongDesc = "+1-10% CDR (based on level)", ShortDesc = "+1-10% CDR (based on level)", Icon = "../DataAccess/RiotGamesApi/Images/Misc/fragment_cdr.png"
                    });                                                                                                                                                                                                               // cdr fragment
                    var slot2 = new Slot();
                    slot2.Runes.Add(new Rune {
                        Id = 5008, Name = "Flex", LongDesc = "Adaptive Force +9", ShortDesc = "Adaptive Force +9", Icon = "../DataAccess/RiotGamesApi/Images/Misc/fragment_dmg.png"
                    });                                                                                                                                                                                        // damage fragment
                    slot2.Runes.Add(new Rune {
                        Id = 5002, Name = "Flex", LongDesc = "+6 Armor", ShortDesc = "+6 Armor", Icon = "../DataAccess/RiotGamesApi/Images/Misc/fragment_armor.png"
                    });                                                                                                                                                                        // armor fragment
                    slot2.Runes.Add(new Rune {
                        Id = 5003, Name = "Flex", LongDesc = "+8 Magic Resist", ShortDesc = "+8 Magic Resist", Icon = "../DataAccess/RiotGamesApi/Images/Misc/fragment_mr.png"
                    });                                                                                                                                                                                   // magic resist fragment
                    var slot3 = new Slot();
                    slot3.Runes.Add(new Rune {
                        Id = 5001, Name = "Defense", LongDesc = "+15-90 Health (Based on level)", ShortDesc = "+15-90 Health (Based on level)", Icon = "../DataAccess/RiotGamesApi/Images/Misc/fragment_hp.png"
                    });                                                                                                                                                                                                                    // hp fragment
                    slot3.Runes.Add(new Rune {
                        Id = 5002, Name = "Defense", LongDesc = "+6 Armor", ShortDesc = "+6 Armor", Icon = "../DataAccess/RiotGamesApi/Images/Misc/fragment_armor.png"
                    });                                                                                                                                                                           // armor fragment
                    slot3.Runes.Add(new Rune {
                        Id = 5003, Name = "Defense", LongDesc = "+8 Magic Resist", ShortDesc = "+8 Magic Resist", Icon = "../DataAccess/RiotGamesApi/Images/Misc/fragment_mr.png"
                    });                                                                                                                                                                                      // magic resist fragment

                    runepath.Slots.Add(slot1);
                    runepath.Slots.Add(slot2);
                    runepath.Slots.Add(slot3);

                    runePaths.Add(runepath);

                    return(runePaths);
                }
                catch (Exception) { return(new List <RunePath>()); }
            }
        }