public RemotingMessageReceivedEventArgs HandleMessage(object sender, RemotingMessageReceivedEventArgs e) { List <ChampionDTO> champions = new List <ChampionDTO>(); foreach (Champions champ in PoroServer._data.Champions) { var champDTO = new ChampionDTO { Owned = true, ChampionID = champ.id, Active = true, BotEnabled = true, RankedPlayEnabled = true }; champDTO.ChampionSkins = PoroServer._data.ChampionSkins.Where(x => x.championId == champ.id).Select(skins => new ChampionSkinDTO { ChampionID = champ.id, SkinID = skins.id, StillObtainable = true, Owned = true }).ToList(); champions.Add(champDTO); } e.ReturnRequired = true; e.Data = champions; return(e); }
public RemotingMessageReceivedEventArgs HandleMessage(object sender, RemotingMessageReceivedEventArgs e) { ArrayCollection champions = new ArrayCollection(); List <DatabaseManager.DBChampions> ChampionDatas = DatabaseManager.getAllChampions(); foreach (var champ in ChampionDatas) { var champDTO = new ChampionDTO { Owned = true, ChampionID = champ.ID, Active = true, BotEnabled = false, Banned = false, Chromas = "", Description = "", DisplayName = "", ChampionData = null, FreeToPlayReward = true, OwnedByYourTeam = true, OwnedByEnemyTeam = true, DefaultSkin = "", FreeToPlay = true, }; champDTO.ChampionSkins = new ArrayCollection(); List <int> ChampionSkinDatas = DatabaseManager.getAllChampionSkinsForId(champ.ID); foreach (var skin in ChampionSkinDatas) { var champSkinData = new ChampionSkinDTO { ChampionID = champ.ID, SkinID = skin, StillObtainable = true, Owned = true }; champDTO.ChampionSkins.Add(champSkinData); } champions.Add(champDTO); } //champions.Add(new Dictionary<string, int>()); e.ReturnRequired = true; e.Data = champions; return(e); }
public async Task GetMasterySuccess() { using (var httpTest = new HttpTest()) { //Arrange var playerName = "TestingPlayer"; var regionName = "eune"; var championName = "Test"; var championId = 10; var player = new SummonerDTO { Id = Guid.NewGuid().ToString() }; var championDTOs = new ChampionDTO[] { new ChampionDTO { Name = "Test", Id = championId } }; var championMasteryDTO = new ChampionMasteryDTO { ChampionLevel = 1, ChampionPoints = "2000" }; var memoryCache = new MemoryCache(new MemoryCacheOptions()); var mockIConfigration = new Mock <IConfiguration>(); mockIConfigration.Setup(c => c[Constants.RIOT_APIKEY]).Returns("RiotApiKey"); var riotApiService = new RiotApiService(memoryCache, mockIConfigration.Object); httpTest.RespondWithJson(player, 200); httpTest.RespondWithJson(championDTOs, 200); httpTest.RespondWithJson(championMasteryDTO, 200); //Act var result = await riotApiService.GetMastery(playerName, regionName, championName); //Assert httpTest.ShouldHaveCalled($"http://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champion-summary.json") .WithVerb(HttpMethod.Get) .Times(1); httpTest.ShouldHaveCalled($"https://eun1.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/{player.Id}/by-champion/{championId}") .WithQueryParams("api_key") .WithVerb(HttpMethod.Get) .Times(1); Assert.Equal($"Champion level {championMasteryDTO.ChampionLevel} with {championName} ({championMasteryDTO.ChampionPoints ?? "0"} points)", result); } }
private async void AddBotBlueTeam_Click(object sender, RoutedEventArgs e) { Int32 champint = getRandomChampInt(); champions champions = champions.GetChampion(champint); ChampionDTO champDTO = new ChampionDTO(); champDTO.Active = true; champDTO.Banned = false; champDTO.BotEnabled = true; champDTO.ChampionId = champint; champDTO.DisplayName = champions.displayName; List <ChampionSkinDTO> skinlist = new List <ChampionSkinDTO>(); foreach (Dictionary <string, object> Skins in champions.Skins) { ChampionSkinDTO skin = new ChampionSkinDTO(); skin.ChampionId = champint; skin.FreeToPlayReward = false; Int32 SkinInt = Convert.ToInt32(Skins["id"]); skin.SkinId = SkinInt; List <ChampionDTO> champs = new List <ChampionDTO>(Client.PlayerChampions); foreach (ChampionDTO x in champs) { foreach (ChampionSkinDTO myskin in x.ChampionSkins) { if (myskin.Owned) { } } } skin.Owned = true; skinlist.Add(skin); } champDTO.ChampionSkins = skinlist; BotParticipant par = new BotParticipant(); par.BotSkillLevelName = "Basic"; par.BotSkillLevel = 0; par.Champion = champDTO; await Client.PVPNet.SelectBotChampion(champint, par); await Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { })); }
private void UpdateChampCache(object state) { if (_matchListings.Count == 0) { LogManager.LogMessage("No match ID listings to use for match IDs."); return; } if (_selectedMatchListing == null) { LogManager.LogMessage("No match listing selected to use for match IDs."); return; } if (_selectedVersion == null || _selectedVersion == "") { LogManager.LogMessage("No version selected to use for querying champions"); return; } LogProgress("Starting to pull and cache champions."); _champCacheCancelationSource = new CancellationTokenSource(); List <int> championIds = _championManager.LoadIds(_selectedMatchListing.region, _selectedVersion); LogProgress(" - Pulled " + championIds.Count + " champion ids for version " + _selectedVersion); List <ChampionDTO> champions = new List <ChampionDTO>(); foreach (int championId in championIds) { if (_champCacheCancelationSource.Token.IsCancellationRequested) { break; } ChampionDTO thisChamp = _championManager.LoadChampion(_selectedMatchListing.region, _selectedVersion, championId); if (thisChamp != null) { champions.Add(thisChamp); } } _champCacheCancelationSource = null; VersionedChampions = champions; LogProgress("Finished caching champions."); }
/// 4.) public async Task <ChampionDTO[]> GetAvailableChampions() { int Id = Invoke("inventoryService", "getAvailableChampions", new object[] { }); while (!results.ContainsKey(Id)) { await Task.Delay(10); } ChampionDTO[] result = new ChampionDTO[results[Id].GetTO("data").GetArray("body").Length]; for (int i = 0; i < results[Id].GetTO("data").GetArray("body").Length; i++) { result[i] = new ChampionDTO((TypedObject)results[Id].GetTO("data").GetArray("body")[i]); } results.Remove(Id); return(result); }
public async Task GetMasteryNull() { using (var httpTest = new HttpTest()) { //Arrange var playerName = "TestingPlayer"; var regionName = "eune"; var championName = "Unexisting Champion"; var player = new SummonerDTO { Id = Guid.NewGuid().ToString() }; var championDTOs = new ChampionDTO[] { new ChampionDTO { Name = "Test" } }; var memoryCache = new MemoryCache(new MemoryCacheOptions()); var mockIConfigration = new Mock <IConfiguration>(); mockIConfigration.Setup(c => c[Constants.RIOT_APIKEY]).Returns("RiotApiKey"); var riotApiService = new RiotApiService(memoryCache, mockIConfigration.Object); httpTest.RespondWithJson(player, 200); httpTest.RespondWithJson(championDTOs, 200); //Act await Assert.ThrowsAsync <ChampionNotFoundException>(() => riotApiService.GetMastery(playerName, regionName, championName)); //Assert httpTest.ShouldHaveCalled($"http://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champion-summary.json") .WithVerb(HttpMethod.Get) .Times(1); } }
private static async void AddBot(int id, bool blueSide, int difficulty) { Int32 champint = (id == 0 ? GetRandomChampInt() : id); champions champions = champions.GetChampion(champint); var champDTO = new ChampionDTO { Active = true, Banned = false, BotEnabled = true, ChampionId = champint, DisplayName = champions.displayName }; List <ChampionSkinDTO> skinlist = (from Dictionary <string, object> skins in champions.Skins select new ChampionSkinDTO { ChampionId = champint, SkinId = Convert.ToInt32(skins["id"]), SkinIndex = Convert.ToInt32(skins["num"]), StillObtainable = true }).ToList(); champDTO.ChampionSkins = skinlist; var par = new BotParticipant { Champion = champDTO, pickMode = 0, IsGameOwner = false, PickTurn = 0, IsMe = false, Badges = 0, TeamName = null, Team = 0, SummonerName = champions.displayName + " bot" }; if (blueSide) { par.teamId = "100"; par.SummonerInternalName = "bot_" + champions.name + "_100"; } else { par.teamId = "200"; par.SummonerInternalName = "bot_" + champions.name + "_200"; } switch (difficulty) { case 0: par.botSkillLevelName = "Beginner"; par.BotSkillLevel = difficulty; break; case 1: par.botSkillLevelName = "Intermediate"; par.BotSkillLevel = difficulty; break; } await Client.PVPNet.SelectBotChampion(champint, par); }
private static InventoryService.JsChampion ToJsChampion(ChampionDTO champion) { return new InventoryService.JsChampion() { Id = champion.ChampionId, Owned = champion.Owned, Free = champion.FreeToPlay, Skins = Enumerable.ToArray<InventoryService.JsChampionSkin>(Enumerable.Select<ChampionSkinDTO, InventoryService.JsChampionSkin>((IEnumerable<ChampionSkinDTO>) champion.ChampionSkins, (Func<ChampionSkinDTO, InventoryService.JsChampionSkin>) (s => new InventoryService.JsChampionSkin() { Id = (int) s.SkinId, Owned = s.Owned }))) }; }
private static InventoryService.JsChampion ToJsChampion(ChampionDTO champion) { InventoryService.JsChampion jsChampion = new InventoryService.JsChampion() { Id = champion.ChampionId, Owned = champion.Owned, Free = champion.FreeToPlay, Skins = ( from s in champion.ChampionSkins select new InventoryService.JsChampionSkin() { Id = (int)s.SkinId, Owned = s.Owned }).ToArray<InventoryService.JsChampionSkin>() }; return jsChampion; }