public async Task <float> getAverageScore(string userId) { _repository = new AmIGoodRepository(_clientFactory); SummonerResponse summonerData = await _repository.getSummonerResponse(userId); MatchResponse matchResponse = await _repository.getMatchesResponse(summonerData.accountId); List <MatchDetail> listMatchDetail = new List <MatchDetail>(); if (matchResponse.matches == null) { return(0f); } foreach (MatchResume resume in matchResponse.matches) { try { MatchDetail match = await _repository.getMatchInformation(resume.gameId); listMatchDetail.Add(match); } catch (Exception e) { Console.WriteLine(e); } Thread.Sleep(100); } return(getScoreFromList(summonerData.accountId, listMatchDetail)); }
public IActionResult getOffField(STFilterRequestData _objReqData) { searchcricket sc = new searchcricket(); List <SearchResultFilterData> obj = new List <SearchResultFilterData>(); BoolQuery _objNestedBoolQuery = new BoolQuery(); if (_objReqData != null) { MatchDetail _objMatchDetail = _objReqData.MatchDetail; Moments _objMomentsData = _objReqData.Moments; if (_objMomentsData != null) { if (_objMomentsData.IsBigMoment || _objMomentsData.IsFunnyMoment || _objMomentsData.IsAudioPiece) { QueryContainer _objNestedBoolQueryFor2 = new QueryContainer(); _objNestedBoolQueryFor2 = sc.GetMatchDetailQueryST(_objNestedBoolQueryFor2, _objMatchDetail); _objNestedBoolQueryFor2 = sc.GetS2MomentDetailQueryForST(_objMatchDetail, _objNestedBoolQueryFor2, _objMomentsData); var result = EsClient.Search <SearchResultFilterData>(s => s.Index("cricket").Query(q => _objNestedBoolQueryFor2).Size(10000)); foreach (var hit in result.Hits) { obj.Add(new SearchResultFilterData { Description = hit.Source.Description.ToString(), MarkIn = hit.Source.MarkIn.ToString(), MarkOut = hit.Source.MarkOut.ToString(), ShotType = hit.Source.MarkOut.ToString(), DeliveryType = hit.Source.DeliveryType.ToString() }); } } } } return(Ok(new { results = obj })); }
void dataDownloader() { var api = RiotSharp.RiotApi.GetInstance("82d252ad-f7a4-4a28-8c3a-0f679dcf2ea5"); if (matchIDsDownloading.Count > 0) { MatchDetail Y = null; try { Y = api.GetMatch(RiotSharp.Region.kr, matchIDsDownloading[0], includeTimeline: true); } catch (RiotSharp.RiotSharpException e) { } //TODO:save match detail as json //TODO:transport match detail to SQL Console.WriteLine("Excellent! New match: " + Y.MatchId); for (int i = 0; i < 10; i++) { long tempID = Y.ParticipantIdentities[i].Player.SummonerId; if (!summonerIDsDownloading.Contains(tempID)) { summonerIDsDownloading.Add(tempID); } } matchIDsDownloaded.Add(matchIDsDownloading[0]); matchIDsDownloading.RemoveAt(0); } else if (summonerIDsDownloading.Count > 0) { DateTime startTime = DateTime.Today.AddDays(-60); MatchList Z = api.GetMatchList(RiotSharp.Region.kr, summonerId: summonerIDsDownloading[0], rankedQueues: a, beginTime: startTime); Console.WriteLine("Excellent! New summoner: " + summonerIDsDownloading[0]); if (Z != null && Z.Matches != null && Z.Matches.Count > 0) { for (int i = 0; i < Z.Matches.Count; i++) { long tempMatchID = Z.Matches[i].MatchID; if (!matchIDsDownloading.Contains(tempMatchID) && !matchIDsDownloaded.Contains(tempMatchID)) { matchIDsDownloading.Add(tempMatchID); } } } summonerIDsDownloaded.Add(summonerIDsDownloading[0]); summonerIDsDownloading.RemoveAt(0); } else { Console.WriteLine("Panic!No match or summoner!"); return; } }
public static BuildSet GetMatchBuild(MatchDetail match, Participant participant) { if (PotentialUpgrades == null) { InitializePotentialUpgrades(); } var set = new BuildSet() { HasMatchData = true }; set.TimeSince = GetTimeSince(match.MatchCreation); var timeline = match.Timeline; var allPurchasedItems = getAllPurchasedItems(timeline, participant.ParticipantId); set.InitialPurchase = getStartingItems(timeline, participant.ParticipantId); set.FinalBuild = getFinalBuild(participant); set.RushItem = getRushItem(allPurchasedItems.ToList(), set.InitialPurchase.Items.ToList()); var allConsumables = getConsumables(allPurchasedItems.ToList()); if (allConsumables.Count > 0) { set.Consumables = (getPurchaseSet("Consumables", allConsumables, includePrice: false)); } set.FullBuild = set.FinalBuild.Items.Count == 7 && !(set.FinalBuild.Items.Any(x => PotentialUpgrades.ContainsKey(x.Id.ToString()))); set.Id = match.MatchId; set.MatchDataFetched = true; return(set); }
public override dynamic getFinalResult(QueryContainer _objNestedQuery, MatchDetail _objMatchDetail, ElasticClient EsClient, string sportid = "1") { string input = Convert.ToInt32(Convert.ToBoolean(_objMatchDetail.IsAsset)).ToString(); QueryContainer query = new TermQuery { Field = "isAsset", Value = input }; _objNestedQuery &= query; dynamic result; List <FilteredEntityData> lstsearchresults = new List <FilteredEntityData>(); var resultsMultiSelectData = EsClient.Search <MatchDetailMultiSelectResulttData>(s => s.Index("crickets").Query(q => _objNestedQuery) .Aggregations(a => a.Terms("agg_MultiSelect", t => t.Field(p => p.CompType))) .Size(802407)); var response = resultsMultiSelectData.Aggregations.Terms("agg_MultiSelect"); foreach (var items in response.Buckets) { lstsearchresults.Add(new FilteredEntityData { EntityId = items.Key.ToString(), EntityName = items.Key.ToString() }); } result = lstsearchresults; return(result); }
public MatchDetail GetMatchDetail(long matchId, region region, bool includeTimeline = false, bool useCaching = false) { MatchDetail val = Cache.Get <MatchDetail>(matchId.ToString(), region.ToString(), includeTimeline.ToString()); //cache getting if (val != null) { return(val); } RiotApiCaller <MatchDetail> caller = new RiotApiCaller <MatchDetail>(suffix.matchdetail); caller.AddParam(param.matchId, matchId); caller.AddParam(param.region, region); caller.AddParam(param.includeTimeline, includeTimeline); if (useCaching) { Cache.AddOrUpdate(caller.CreateRequest(new TimeSpan(0, 22, 0))); } else { caller.CreateRequest(); } return(caller.Result.FirstOrDefault()); }
public bool Save(MatchModel matchModel) { Match match = new Match(); match.MatchDate = matchModel.MatchDate; match.MatchName = matchModel.MatchName; match.StartTime = matchModel.StartTime; match.TeamOneId = matchModel.TeamOneId; match.TeamTwoId = matchModel.TeamTwoId; match.Address = matchModel.Address; db.Matches.Add(match); db.SaveChanges(); int matchId = match.Id; foreach (var item in matchModel.MatchDetails) { MatchDetail matchDetails = new MatchDetail(); matchDetails.MatchId = matchId; matchDetails.PlayerId = item.PlayerId; matchDetails.PlayerType = item.PlayerType; matchDetails.Position = item.Position; matchDetails.TeamId = item.TeamId; db.MatchDetails.Add(matchDetails); db.SaveChanges(); } return(true); }
internal static GameDisplay CreateGameDisplay(MatchDetail match) { GameDisplay gameDisplay = new GameDisplay() { SecondsElapsed = Convert.ToInt32(DateTime.Now.Subtract(LastChosen).TotalSeconds) * 1000, MatchInterval = Convert.ToInt32(ConfigurationManager.AppSettings["NewMatchInterval"]), BlueTeam = new List <ParticipantDisplay>(), PurpleTeam = new List <ParticipantDisplay>(), BetType = ChosenQuestion.BetType, BetQuestion = ChosenQuestion.BetQuestion }; foreach (Participant participant in ChosenMatch.Participants.Where(p => p.TeamId == 100)) { gameDisplay.BlueTeam.Add( new ParticipantDisplay() { ParticipantId = participant.ParticipantId, ChampionImage = champs.Data.Values.FirstOrDefault(c => c.Id == participant.ChampionId).Image.Full }); } foreach (Participant participant in ChosenMatch.Participants.Where(p => p.TeamId == 200)) { gameDisplay.PurpleTeam.Add( new ParticipantDisplay() { ParticipantId = participant.ParticipantId, ChampionImage = champs.Data.Values.FirstOrDefault(c => c.Id == participant.ChampionId).Image.Full }); } return(gameDisplay); }
/// <summary> /// Ritorna i dati di un singolo match /// </summary> /// <param name="id">Id del match</param> /// <param name="allEvents">Se true torna tutti gli eventi come se la partita fosse finita</param> /// <returns></returns> public async Task <MatchDetail> GetMatch(int id, bool allEvents) { var now = DateTime.Now; //singolo match con eventi fino al minuto attuale return(await ExecuteCall <MatchDetail, DTO.MatchDetail>( HttpMethod.Get, $"http://localhost:3000/matches/{id}", (dto) => { var det = new MatchDetail() { Id = dto.Id, StartTime = dto.StartTime, Team1 = dto.Team1, Team2 = dto.Team2, ActualMin = Mapper.ActualMin(dto.StartTime, now), Events = dto.Events?. Where(ev => { return allEvents || Mapper.IsPassedEvent(ev.Min, dto.StartTime, now); }). Select(ev => ev.ToEvent()), }; det.Team1Points = det.Events.Where(ev => ev.Team == 1).Sum(ev => ev.Points); det.Team2Points = det.Events.Where(ev => ev.Team == 2).Sum(ev => ev.Points); return det; })); }
public async Task <MatchDetail> UpdateMatch(MatchDetail matchDetail) { var url = Matches_Update_Url; var updatedMatchDetail = await Put <MatchDetail, MatchDetail>(url, matchDetail); return(updatedMatchDetail); }
public List <int> GetCorrectAnswerIds(MatchDetail match) { List <int> correctAnswers = new List <int>(); correctAnswers.Add(match.Participants.FirstOrDefault(p => p.Stats.FirstBloodKill).ParticipantId); return(correctAnswers); }
public void GetMatchDetail() { ApiService.ApiKey = APIKEY;//you must add your project, if you dont use ninject NonStaticApi api = new NonStaticApi(new Api.Cache.ApiCache()); MatchDetail data = api.GetMatchDetail(gameId1, Region, true); Assert.IsNotNull(data); }
public Match(MatchDetail matchDetail) { Id = matchDetail.MatchId; Duration = matchDetail.MatchDuration; Region = matchDetail.Region; Patch = matchDetail.MatchVersion; Queue = matchDetail.QueueType.ToString(); }
public List <int> GetCorrectAnswerIds(MatchDetail match) { List <int> correctAnswers = new List <int>(); correctAnswers.Add(match.Teams.Where(t => t.Winner).FirstOrDefault().TeamId); return(correctAnswers); }
public List <int> GetCorrectAnswerIds(MatchDetail match) { List <Participant> participantsWithMostKills = match.Participants.Where(pmax => pmax.Stats.Kills == match.Participants.Max(p => p.Stats.Kills)) .ToList(); return(participantsWithMostKills.Select(participant => participant.ParticipantId).ToList()); }
public List <int> GetCorrectAnswerIds(MatchDetail match) { List <Participant> participantsWithMostDamage = match.Participants.Where(pmax => pmax.Stats.TotalDamageTaken == match.Participants.Max(p => p.Stats.TotalDamageTaken)) .ToList(); return(participantsWithMostDamage.Select(participant => participant.ParticipantId).ToList()); }
public IEnumerable <MatchDetail> GetMatchDetails(long accountId, int heroId) { var retList = new List <MatchDetail>(); var matches = GetMatchesByAccountAndHero(accountId, heroId).OrderByDescending(m => m.StartTime); foreach (var match in matches) { var matchDetail = new MatchDetail(); var player = match.Players.FirstOrDefault(p => p.AccountId == accountId); if (player == null) { continue; } // RESULTS if ((player.PlayerSlot < 5 && match.RadiantWin) || (player.PlayerSlot > 5 && !match.RadiantWin)) { matchDetail.Results = "Win"; } else if ((player.PlayerSlot < 5 && !match.RadiantWin) || (player.PlayerSlot > 5 && match.RadiantWin)) { matchDetail.Results = "Loss"; } // MODE matchDetail.Mode = Enum.GetName(typeof(GameTypes), match.GameMode) ?? "-"; // KDA matchDetail.KDA = $"{player.Kills}/{player.Deaths}/{player.Assists}"; // DURATION var duration = TimeSpan.FromSeconds(match.Duration); matchDetail.Duration = duration.ToString(@"hh\:mm\:ss"); // ITEMS var items = Items.GetItems(); matchDetail.Items = new List <Item>(); foreach (var item in items) { if (player.Item0 == item.ItemId || player.Item1 == item.ItemId || player.Item2 == item.ItemId || player.Item3 == item.ItemId || player.Item4 == item.ItemId || player.Item5 == item.ItemId) { matchDetail.Items.Add(item); } if (player.Backpack0 == item.ItemId || player.Backpack1 == item.ItemId || player.Backpack2 == item.ItemId) { matchDetail.Items.Add(item); } } // ABILITIES // TODO retList.Add(matchDetail); } return(retList); }
/// <summary> /// Maps the map detail to match detail API dto. /// </summary> /// <returns>The map detail to match detail API dto.</returns> /// <param name="matchDetail">Match detail.</param> public MatchDetailApiDto MapMapDetailToMatchDetailApiDto(MatchDetail matchDetail) { return(new MatchDetailApiDto() { DetailPersonalityApiDto = MapPersonalityReferencialToDetailPersonalityApiDto(matchDetail.PersonalityReferencial), Percent = matchDetail.Percent, Value = matchDetail.Value }); }
static void Main(string[] args) { var apikey = ConfigurationManager.AppSettings["apikey"]; Console.WriteLine("waddup boois"); Console.WriteLine(apikey); var api = RiotApi.GetInstance(apikey, 8, 500); // , 7, 500 GameBase gamebase = GameBase.LoadFromFile("DataFiles/gamebaseEX.xml"); GameBase gamebaseToAdd = GameBase.LoadFromFile("DataFiles/gamebase.xml"); int gamesToAdd = 0; //gamebaseToAdd.games.Count(g => !gamebase.games.Any(p => g.GameId == p.GameId)); int index = 0; Console.WriteLine("Games to Add: " + gamesToAdd); ChampStatBase champStatBase = ChampStatBase.LoadFromFile("DataFiles/ChampStatBase.xml"); // new ChampStatBase();// var timer = new System.Threading.Timer((e) => { gamebase.SaveToFile("DataFiles/gamebaseEX.xml"); champStatBase.SaveToFile("DataFiles/ChampStatBase.xml"); Console.WriteLine("SAVING FILES"); }, null, TimeSpan.Zero, TimeSpan.FromMinutes(1)); foreach (Game game in gamebaseToAdd.games) { if (!gamebase.games.Any(g => g.GameId == game.GameId)) // if not already in de gamebase { MatchDetail apiGame = null; try { apiGame = api.GetMatch(Region.euw, game.GameId); } catch (Exception) { continue; } gamebase.games.Add(new Game(game.GameId, apiGame.MatchCreation, 1, (int)apiGame.MatchDuration.TotalSeconds, apiGame.Region)); foreach (var participant in apiGame.Participants) { champStatBase.champStats.Add(new ChampStat(game.GameId, participant)); } index++; Console.WriteLine("GameId: " + game.GameId + " Game " + index + " out of " + gamesToAdd + " Total Games: " + gamebase.games.Count()); } } Console.WriteLine("All Done! press any key to close."); Console.ReadKey(); }
public IActionResult GetFilteredEntitiesBySport(SearchEntityRequestData _objReqData) { try { EsClient_obj = oLayer.CreateConnection(); int _sportid = 1; string result = string.Empty; string searchtext = string.Empty; searchtext = _objReqData.EntityText.Trim().ToLower(); List <SearchQueryModel> _objLstSearchQuery = new List <SearchQueryModel>(); var responseResult = new List <FilteredEntityForCricket>(); SearchEntityRequestData _objEntityReqData; string jsonData = JsonConvert.SerializeObject(_objReqData); _objEntityReqData = JsonConvert.DeserializeObject <SearchEntityRequestData>(jsonData); //GetMatchDetails obj = new GetMatchDetails(); MatchDetail _objMatchDetail = _objEntityReqData.MatchDetails; _objMatchDetail.SeriesId = _objEntityReqData.EntityTypeId != 5 ? _objMatchDetail.SeriesId : string.Empty; _objMatchDetail.MatchId = _objEntityReqData.EntityTypeId != 9 ? _objMatchDetail.MatchId : string.Empty; if (_objEntityReqData != null) { Dictionary <string, string> _columns = sc.GetColumnForEntity(_objEntityReqData.EntityTypeId); QueryContainer _objNestedQuery = new QueryContainer(); QueryContainer _objNestedQueryRresult = new QueryContainer(); IEnumerable <FilteredEntityForCricket> _objFilteredEntityForCricket = new List <FilteredEntityForCricket>(); // _objNestedQuery = obj.GetMatchDetailQueryST(_objNestedQuery, _objMatchDetail); //_objNestedQuery = obj.GetPlayerDetailQueryForFilteredEntityBySport(_objNestedQuery, _objEntityReqData.playerDetails, _objMatchDetail.SportID);//GetCricketPlayerDetailQuery(_objEntityReqData.playerDetails, _objNestedBoolQuery); if (!string.IsNullOrEmpty(_objMatchDetail.MatchDate)) { //_objNestedQuery= obj.GetEntityBySport(_objNestedQuery, _objMatchDetail, _columns, searchtext); } if (_columns.Count > 0) { List <string> EntityIds = new List <string>(); List <string> EntityNames = new List <string>(); foreach (var col in _columns) { EntityIds.Add(col.Key); EntityNames.Add(col.Value); } if (searchtext != "") { var Result = sc.GetFilteredEntitiesBySportResult(_objNestedQuery, EntityIds.ElementAt(0), EntityNames.ElementAt(0), EsClient_obj, searchtext); responseResult = Result; } } } return(Ok(new { responseText = responseResult })); //return Ok(); } catch (Exception ex) { return(BadRequest()); } }
public IActionResult getDeliveryTypeOnChange(STFilterRequestData _objReqData) { try { //List<QueryContainer> myDynamicMustQuery = new List<QueryContainer>(); //var boolMustQuery = new BoolQuery(); List <ddlValue> obj = new List <ddlValue>(); HttpResponseMessage response = null; EsClient = oLayer.CreateConnection(); List <ResponseResult> value = new List <ResponseResult>(); searchcricket sc = new searchcricket(); QueryContainer _objNestedBoolQuery = new QueryContainer(); if (_objReqData != null) { MatchDetail _objMatchDetail = _objReqData.MatchDetail; dynamic _objS1Data = _objReqData.S1Data; _objNestedBoolQuery = sc.getCricketPlayerDetails(_objMatchDetail, _objNestedBoolQuery); } //QueryContainer q1 = new TermQuery { Field = "isTagged", Value = "1" }; //QueryContainer q2 = new TermQuery { Field = "isAsset", Value = "0" }; //QueryContainer q3 = new TermQuery { Field = "shotTypeId", Value = shotTypeId }; //var q = new QueryContainer(); //q &= q2; //q &= q1; //q &= q3; //myDynamicMustQuery.Add(q1); //myDynamicMustQuery.Add(q2); //myDynamicMustQuery.Add(q3); //boolMustQuery.Must = myDynamicMustQuery; var result = EsClient.Search <SearchCricketData>(a => a.Index("cricket").Size(0).Query(qs => _objNestedBoolQuery) .Aggregations(a1 => a1.Terms("my_terms_agg", t => t.Script(t1 => t1.Source("doc['deliveryType.keyword'].value + '|' + doc['deliveryTypeId.keyword'].value")).Size(802407)) ) ); var agg = result.Aggregations.Terms("my_terms_agg").Buckets; foreach (var items in agg) { obj.Add(new ddlValue { Id = items.Key.ToString().Split("|")[1], Key = items.Key.ToString().Split("|")[0] }); } return(Ok(new { results = obj })); } catch (Exception ex) { return(BadRequest(ex.ToString())); } }
public IActionResult MatchDetail(int id) { var matchDetail = new MatchDetail(); matchDetail.Match = _matchService.Get(id); matchDetail.Events = _matchEventService.GetForMatch(id).OrderBy(e => e.Minute); matchDetail.Goals = _matchGoalService.GetForMatch(id).OrderBy(g => g.Minute); return(View(matchDetail)); }
public IActionResult GetSearchResultsFilterTemp(STFilterRequestData _objReqData) { try { Cricket objCS = new Cricket(); GetMatchDetails objMatchDet = new GetMatchDetails(); EsClient_obj = oLayer.CreateConnection(); ExtendedSearchResultFilterData _objSearchResults = new ExtendedSearchResultFilterData(); ExtendedSearchResultFilterData _objSearchResults2 = new ExtendedSearchResultFilterData(); ExtendedSearchResultFilterData _objResult = new ExtendedSearchResultFilterData(); _objResult.ResultData = new List <SearchResultFilterData>(); _objSearchResults2.ResultData = new List <SearchResultFilterData>(); _objSearchResults.ResultData = new List <SearchResultFilterData>(); _objResult.Master = new MasterDatas(); _objResult.Master.MasterData = new Dictionary <string, object>(); _objSearchResults.Master = new MasterDatas(); _objSearchResults.Master.MasterData = new Dictionary <string, object>(); QueryContainer _objNestedQuery = new QueryContainer(); if (_objReqData != null) { MatchDetail _objMatchDetail = _objReqData.MatchDetail; dynamic _objS1Data = _objReqData.S1Data; MatchSituation _objMatchSituation = _objReqData.MatchSituation; Moments _objMomentsData = _objReqData.Moments; string value = sqObj.GetKeyValueForSport(sc.getType(_objMatchDetail.SportID), "DropdwonKey"); List <string> valueObj = sqObj.GetKeyValueForSportTemp(sc.getType(_objMatchDetail.SportID).ToLower(), "PlayerDetails"); string SportName = sc.getType(_objMatchDetail.SportID); if (_objS1Data != null) { _objNestedQuery = objMatchDet.getDetailsAsPerSport(_objS1Data, _objNestedQuery, _objMatchDetail, _objMatchSituation, valueObj, _objMatchDetail.SportID); _objSearchResults = objCf.searchStoryTeller(_objMatchDetail, _objNestedQuery, _objS1Data, _objResult.Master.MasterData, _objResult.ResultData, value, SportName.ToLower()); } if (_objMomentsData != null) { QueryContainer objMoment = new QueryContainer(); objMoment = objCf.getMomentDetailsQueryST(_objMatchDetail, objMoment, _objMomentsData); _objSearchResults2.ResultData = objCS.returnSportResult(EsClient_obj, objMoment, SportName); } _objResult.ResultData = _objSearchResults.ResultData.Union(_objSearchResults2.ResultData); _objResult.Master = _objSearchResults.Master; if (_objMatchDetail.SportID == 1) { string[] _objReqInnings = _objMatchSituation.Innings.Contains(",") ? _objReqInnings = _objMatchSituation.Innings.Split(',') : _objReqInnings = new string[] { _objMatchSituation.Innings }; var innings = objCS.fetchDropDownForMatch(_objResult.Master.MasterData, _objReqInnings); //_objResult.Master.MasterData.Add("Innings", innings); } } return(Ok(new { responseText = _objResult })); } catch (Exception ex) { return(BadRequest()); } }
public async Task <IActionResult> OnGetAsync(string slug) { Match = await _matchRepository.GetMatchDetail(slug); if (Match == null) { return(NotFound()); } return(Page()); }
public GameState(MatchDetail match) { // TODO: track champion lanes/roles/etc. Teams = match.Teams.ToDictionary( t => t.TeamId, t => new TeamState(t.TeamId, match.Participants.Where(p => p.TeamId == t.TeamId).Select(p => p.ChampionId))); ParticipantMap = match.Participants.ToDictionary( p => p.ParticipantId, p => p.ChampionId); }
//this is where we will add the new event internal static void GenerateNewMatch() { //We've already pulled match info and stored the json on the local drive in the event the api is down. //If you don't have the matches stored on your local drive uncomment the code below and comment the region below it //There is one match hard coded here but you would want to pull your match Id from whereever you're storing them if you wanted more than one match :) /* * Task<RESTResult<MatchDetail>> matchResult = RESTHelpers.RESTRequest<MatchDetail> * ( * "https://na.api.pvp.net/api/lol/na/v2.2/match/1778704162", * "", * NurfUsController.DevKey, * "includeTimeline=true" * ); * * matchResult.Wait(); * * if (matchResult.Result.Success) * { * ChosenMatch = matchResult.Result.ReturnObject; * } * else * { * //Do your error logic here * } */ #region Pull Match from local drive //*************************************************** DirectoryInfo diMatchHistory = new DirectoryInfo(ConfigurationManager.AppSettings["MatchDirectory"]); Random randomGameNum = new Random((int)DateTime.Now.Ticks); int randomFile = randomGameNum.Next(TotalMatchFiles); string matchContent = File.ReadAllText(FileNames[randomFile]); JavaScriptSerializer jss = new JavaScriptSerializer(); ChosenMatch = jss.Deserialize <MatchDetail>(matchContent); //*************************************************** #endregion Pull Match from local drive LastChosen = DateTime.Now; ChosenQuestion = questions[new Random().Next(questions.Count)]; CurrentCorrectAnswers = ChosenQuestion.GetCorrectAnswerIds(ChosenMatch); #if DEBUG Debug.WriteLine(string.Join(",", CurrentCorrectAnswers)); #endif PlayerBets.Clear(); }
public QueryContainer getMomentDetailsQueryST(MatchDetail _ObjMatchDetails, QueryContainer _objNestedQuery, Moments _objMomentsData) { if (_objMomentsData != null) { if (!string.IsNullOrEmpty(_objMomentsData.Entities) || _objMomentsData.IsBigMoment || _objMomentsData.IsFunnyMoment || _objMomentsData.IsAudioPiece) { //_objNestedQuery = matchDetails.GetMatchDetailQueryST(_objNestedQuery, _ObjMatchDetails); _objNestedQuery = GetS2MomentDetailQueryForST(_ObjMatchDetails, _objNestedQuery, _objMomentsData); } } return(_objNestedQuery); }
public QueryContainer GetFilteredEntitiesBySport(MatchDetail _objReqData, QueryContainer _objNestedQuery, string sCase, int sDate, Dictionary <string, string> _columns, string searchText, string Edate = "") { dynamic Result = null; string input = Convert.ToInt32(Convert.ToBoolean(_objReqData.IsAsset)).ToString(); List <string> EntityId = new List <string>(); List <string> EntityName = new List <string>(); foreach (var col in _columns) { EntityId.Add(col.Key); EntityName.Add(col.Value); } var terms = searchText.Trim().Replace("-", " ").Split(' ').Where(x => !string.IsNullOrEmpty(x)).Select(x => x.Trim() + "*"); searchText = string.Join(" ", terms).ToLower(); if (searchText != "") { QueryContainer query = new QueryContainer(); if (EntityName.ElementAt(0) != "CompType" && EntityName.ElementAt(0) != "MatchStage") { for (int i = 0; i < _columns.Count; i++) { QueryContainer q2 = new TermQuery { Field = EntityName.ElementAt(i), Value = searchText }; query |= q2; } _objNestedQuery &= query; //Bq.Add(bq, Occur.MUST); } QueryContainer q3 = new TermQuery { Field = "isAsset", Value = searchText }; _objNestedQuery &= q3; if (sCase == "2") { QueryContainer q4 = new TermQuery { Field = "matchDate", Value = sDate }; _objNestedQuery &= q4; } else if (sCase == "3") { QueryContainer q4 = new TermRangeQuery { Field = "matchDate", GreaterThanOrEqualTo = sDate.ToString(), LessThanOrEqualTo = Edate.ToString() }; _objNestedQuery &= q4; } } return(_objNestedQuery); }
private void ModifyHeroStatsBasedOnGame(MatchDetail match, Player player, PlayerHeroViewModel hero) { hero.GamesPlayed += 1; hero.Kills += player.kills; hero.Deaths += player.deaths; hero.Assists += player.assists; hero.GoldPerMinute += player.gold_per_min; hero.XpPerMinute += player.xp_per_min; if (_affiliationHelper.PlayerWins(player, match.radiant_win)) { hero.Wins += 1; } }
public async Task <MatchDetail> UpdateMatch(MatchDetail match) { var entity = await _matchesRepository.GetMatch(match.Id); entity.MatchContactPreferences.First(mc => mc.ProfileId == match.ProfileId).ContactDetailsVisible = match.UserContactDetailsVisible; var updatedEntity = await _matchesRepository.UpsertMatch(entity); var updatedMatch = MatchDetailMapper.ToContract(match.ProfileId, updatedEntity); return(updatedMatch); }