private Dictionary <string, double> ComputeRecent20Stats() { List <RootMatch> matches = this.GetUnrankedMatchType(); if (matches.Count == 0) { return(null); } else { double kills = 0; double damagedealt = 0; double timeSurvived = 0; double averagePlacement = 0; double averageDistanceTraveled = 0; foreach (RootMatch match in matches) { foreach (MatchSingleObject participant in match.included) { if (participant.type == "participant") { ParticipantObject matchplayer = (ParticipantObject)participant; string name = matchplayer.attributes.stats.name; if (name == this.player.Name) { kills += matchplayer.attributes.stats.kills; damagedealt += matchplayer.attributes.stats.damageDealt; timeSurvived += matchplayer.attributes.stats.timeSurvived; averagePlacement += matchplayer.attributes.stats.winPlace; averageDistanceTraveled += matchplayer.attributes.stats.rideDistance + matchplayer.attributes.stats.walkDistance; break; } } } } kills /= matches.Count; damagedealt /= matches.Count; timeSurvived /= 60; timeSurvived /= matches.Count; averagePlacement /= matches.Count; averageDistanceTraveled /= matches.Count; Dictionary <string, double> dict = new Dictionary <string, double>(); dict.Add("kd", kills); dict.Add("adr", damagedealt); dict.Add("time survived", timeSurvived); dict.Add("average placement", averagePlacement); dict.Add("average distance traveled", averageDistanceTraveled); return(dict); } }
public void OnParticipantLeft(Participant participant) { ParticipantObject temp = new ParticipantObject(); temp.ParticipantData = participant; if (participant.Player != null) { temp.Image = participant.Player.image; } mainAction.participantLeft.Value = temp; mainAction.Fsm.Event(mainAction.eventTarget, mainAction.onParticipantLeftEvent); }
public override void OnEnter() { Participant participant = GameServices.RealTime.GetParticipant(participantId.Value); ParticipantObject temp = new ParticipantObject(); temp.ParticipantData = participant; if (participant.Player != null) { temp.Image = participant.Player.image; } participantObject.Value = temp; Finish(); }
private Dictionary <string, GraphPlot> GetDictionary(List <RootMatch> matches, Values.StatType type, string matchType, string playerName) { Dictionary <string, GraphPlot> dict = new Dictionary <string, GraphPlot>(); foreach (RootMatch match in matches) { string currentMatchGameMode = match.data.attributes.gameMode; string currentMatchType = match.data.attributes.matchType; if (currentMatchGameMode == Values.GetEnumString(type).ToLower() && currentMatchType == matchType) { foreach (MatchSingleObject participant in match.included) { if (participant.type == "participant") { ParticipantObject matchPlayer = (ParticipantObject)participant; string matchPlayerName = matchPlayer.attributes.stats.name; if (matchPlayerName == playerName) { string matchDate = match.data.attributes.createdAt; DateTime matchTime = DateTime.Parse(matchDate); string date = matchTime.Year.ToString() + "-" + matchTime.Month.ToString() + "-" + matchTime.Day.ToString(); double damageDealtInMatch = matchPlayer.attributes.stats.damageDealt; if (!dict.ContainsKey(date)) { dict.Add(date, new GraphPlot(damageDealtInMatch, playerName, matchTime)); } else { dict[date].Add(damageDealtInMatch); } break; } } } } } return(dict); }
public bool ShouldReinviteDisconnectedPlayer(Participant participant) { if (mainAction.shouldReinvite.Value) { ParticipantObject temp = new ParticipantObject(); temp.ParticipantData = participant; if (participant.Player != null) { temp.Image = participant.Player.image; } mainAction.playerShouldInvite.Value = temp; mainAction.Fsm.Event(mainAction.eventTarget, mainAction.shouldReinviteDisconnectedPlayerEvent); return(true); } else { mainAction.Fsm.Event(mainAction.eventTarget, mainAction.shouldNotReinviteDisconnectedPlayerEvent); return(false); } }
public override void OnEnter() { ParticipantObject temp = (ParticipantObject)participantObject.Value; Participant participant = temp.ParticipantData; status.Value = participant.Status; displayName.Value = participant.DisplayName;; participantId.Value = participant.ParticipantId; if (participant.Player != null) { image.Value = participant.Player.image; } else { image = null; } isConnectedToRoom = participant.IsConnectedToRoom; Finish(); }
public override void OnEnter() { Participant[] tParticipants = GameServices.RealTime.GetConnectedParticipants().ToArray(); participantCount.Value = tParticipants.Length; participants.Resize(participantCount.Value); for (int i = 0; i < participantCount.Value; i++) { ParticipantObject temp = new ParticipantObject(); temp.ParticipantData = tParticipants[i]; if (tParticipants[i].Player != null) { temp.Image = tParticipants[i].Player.image; } participants.Set(i, temp); } Finish(); }
public List <GraphPlot> GetList() { //DateTime time = DateTime.Parse("2016-07-24T18:47:36Z").ToUniversalTime(); Dictionary <string, GraphPlot> dict = new Dictionary <string, GraphPlot>(); foreach (RootMatch match in this.matches) { string currentMatchGameMode = match.data.attributes.gameMode; string currentMatchType = match.data.attributes.matchType; if (currentMatchGameMode == Values.GetEnumString(this.type).ToLower() && currentMatchType == this.matchType) { foreach (MatchSingleObject participant in match.included) { if (participant.type == "participant") { ParticipantObject matchPlayer = (ParticipantObject)participant; string matchPlayerName = matchPlayer.attributes.stats.name; if (matchPlayerName == this.playerName) { string matchDate = match.data.attributes.createdAt; DateTime matchTime = DateTime.Parse(matchDate); string date = matchTime.Year.ToString() + matchTime.Month.ToString() + matchTime.Day.ToString(); double damageDealtInMatch = matchPlayer.attributes.stats.damageDealt; if (!dict.ContainsKey(date)) { dict.Add(date, new GraphPlot(damageDealtInMatch, this.playerName, matchTime)); } else { dict[date].Add(damageDealtInMatch); } break; } } } } } List <GraphPlot> graphPlots = new List <GraphPlot>(); foreach (KeyValuePair <string, GraphPlot> pair in dict) { graphPlots.Add(pair.Value); } List <GraphPlot> graphPlotsReversed = new List <GraphPlot>(); for (int i = graphPlots.Count - 1; i >= 0; i--) { graphPlotsReversed.Add(graphPlots[i]); } return(graphPlotsReversed); }
private static async Task <double> ComputeRankedFraggerRating(List <RootMatch> matches, string playername) { if (matches.Count == 0) { return(0); } else { double totalKills = 0; double headshotKills = 0; double damageDealt = 0; double timeSurvived = 0; double winPlace = 0; int count = 0; foreach (RootMatch match in matches) { if (count == 20) { break; } if (match.data.attributes.matchType == "competitive") { foreach (MatchSingleObject participant in match.included) { if (participant.type == "participant") { ParticipantObject matchplayer = (ParticipantObject)participant; string name = matchplayer.attributes.stats.name; if (name == playername) { totalKills += matchplayer.attributes.stats.kills; headshotKills += matchplayer.attributes.stats.headshotKills; damageDealt += matchplayer.attributes.stats.damageDealt; timeSurvived += matchplayer.attributes.stats.timeSurvived; if (matchplayer.attributes.stats.winPlace == 1) { winPlace += matchplayer.attributes.stats.winPlace; } count++; break; } } } } } double adr = StatsCalculation.GetAdr(damageDealt, count); double headshotratio = StatsCalculation.GetHeadshotRatioBelowOne(headshotKills, totalKills); double survivedtime = StatsCalculation.GetAverageSurvivedTimeBase10(timeSurvived, count); double winratepercent = StatsCalculation.GetWinRatioBelowOne(winPlace, count); double fraggerRating = Math.Round(StatsCalculation.GetFraggerRating(adr, headshotratio, survivedtime, winratepercent), 0); return(fraggerRating); } }