public ParticipantStat GetParticipantStat(Match match, MatchParticipant participant, int participantNum, int id) { ParticipantStat stats = new ParticipantStat(); // StatID needs to be pulled stats.Winner = match.Participants[participantNum].Stats.Winner.ToString(); //Oops stats.Kills = (int)match.Participants[participantNum].Stats.Kills; // This is a long? stats.Assists = (int)match.Participants[participantNum].Stats.Assists; // Why are all of these longs... stats.GoldSpent = (int)match.Participants[participantNum].Stats.GoldSpent; stats.GoldEarned = (int)match.Participants[participantNum].Stats.GoldEarned; stats.TotalDamageTaken = (int)match.Participants[participantNum].Stats.TotalDamageTaken; stats.TotalDamageDealtToChampions = (int)match.Participants[participantNum].Stats.TotalDamageDealtToChampions; stats.TotalDamageDealt = (int)match.Participants[participantNum].Stats.TotalDamageDealt; stats.PhysicalDamageTaken = (int)match.Participants[participantNum].Stats.PhysicalDamageTaken; stats.PhysicalDamageDealtToChampions = (int)match.Participants[participantNum].Stats.PhysicalDamageDealtToChampions; stats.PhysicalDamageDealt = (int)match.Participants[participantNum].Stats.PhysicalDamageDealt; stats.MagicDamageTaken = (int)match.Participants[participantNum].Stats.MagicDamageTaken; stats.MagicDamageDealtToChampions = (int)match.Participants[participantNum].Stats.MagicDamageDealtToChampions; stats.MagicDamageDealt = (int)match.Participants[participantNum].Stats.MagicDamageDealt; stats.TrueDamageTaken = (int)match.Participants[participantNum].Stats.TrueDamageTaken; stats.TrueDamageDealtToChampions = (int)match.Participants[participantNum].Stats.TrueDamageDealtToChampions; stats.TrueDamageDealt = (int)match.Participants[participantNum].Stats.TrueDamageDealt; stats.TotalUnitsHealed = (int)match.Participants[participantNum].Stats.TotalUnitsHealed; stats.TotalHeal = (int)match.Participants[participantNum].Stats.TotalHeal; stats.TotalTimeCrowdControlDealt = (int)match.Participants[participantNum].Stats.TotalTimeCrowdControlDealt; stats.WardsPlaced = (int)match.Participants[participantNum].Stats.WardsPlaced; stats.WardsKilled = (int)match.Participants[participantNum].Stats.WardsKilled; stats.VisionWardsBoughtInGame = (int)match.Participants[participantNum].Stats.VisionWardsBoughtInGame; stats.VisionScore = (int)match.Participants[participantNum].Stats.VisionScore; stats.SightWardsBoughtInGame = (int)match.Participants[participantNum].Stats.SightWardsBoughtInGame; stats.TowerKills = (int)match.Participants[participantNum].Stats.TowerKills; stats.InhibitorKills = (int)match.Participants[participantNum].Stats.InhibitorKills; stats.FirstTowerKill = match.Participants[participantNum].Stats.FirstTowerKill; stats.FirstTowerAssist = match.Participants[participantNum].Stats.FirstTowerAssist; stats.FirstInhibitorKill = match.Participants[participantNum].Stats.FirstInhibitorKill; stats.FirstInhibitorAssist = match.Participants[participantNum].Stats.FirstInhibitorAssist; stats.FirstBloodKill = match.Participants[participantNum].Stats.FirstBloodKill; stats.FirstBloodAssist = match.Participants[participantNum].Stats.FirstBloodAssist; stats.DoubleKills = (int)match.Participants[participantNum].Stats.DoubleKills; stats.TripleKills = (int)match.Participants[participantNum].Stats.TripleKills; stats.QuadraKills = (int)match.Participants[participantNum].Stats.QuadraKills; stats.PentaKills = (int)match.Participants[participantNum].Stats.PentaKills; stats.UnrealKills = (int)match.Participants[participantNum].Stats.UnrealKills; stats.KillingSprees = (int)match.Participants[participantNum].Stats.KillingSprees; stats.LargestKillingSpree = (int)match.Participants[participantNum].Stats.LargestKillingSpree; stats.LargestCriticalStrike = (int)match.Participants[participantNum].Stats.LargestCriticalStrike; stats.NeutralMinionsKilledEnemyJungle = (int)match.Participants[participantNum].Stats.NeutralMinionsKilledEnemyJungle; stats.NeutralMinionsKilledJungle = (int)match.Participants[participantNum].Stats.NeutralMinionsKilledJungle; stats.TotalMinionsKilled = (int)match.Participants[participantNum].Stats.TotalMinionsKilled; stats.ParticipantID = id; stats.Deaths = match.Participants[participantNum].Stats.Deaths; stats.ChampionLevel = match.Participants[participantNum].Stats.ChampLevel; // TODO: // The stat io stats.StatID = statIO.InsertParticipantStat(stats); return(stats); }
public MatchSeriesParticipant Convert(MatchParticipant source, MatchSeriesParticipant destination, ResolutionContext context) { if (source == null) { return(null); } var participant = new MatchSeriesParticipant(); participant.Id = source.Id; return(participant); }
public void AddMatch(MatchAdd matchToAdd, Match newMatch, MatchParticipant MP1, MatchParticipant MP2) { appDBContent.Matches.Add(newMatch); appDBContent.SaveChanges(); appDBContent.MatchParticipant.Add(new MatchParticipant { player = Convert.ToString(matchToAdd.win), matchID = Convert.ToInt32(newMatch.Id), result = 1 }); appDBContent.MatchParticipant.Add(new MatchParticipant { player = Convert.ToString(matchToAdd.lose), matchID = Convert.ToInt32(newMatch.Id), result = 0 }); appDBContent.SaveChanges(); }
public IActionResult MAPost(MatchAdd matchToAdd) { if (matchToAdd.win == matchToAdd.lose || matchToAdd.win == null || matchToAdd.lose == null) { ViewBag.PostResultText = "Матч не добавлен! Участники заданы неверно."; ViewBag.PostResult = "0"; return(View()); } int PONewRating = 0; int PTNewRating = 0; if (matchToAdd.time == new DateTime(1, 1, 1, 0, 0, 0)) { matchToAdd.time = DateTime.Now; } Match newMatch = new Match { Time = matchToAdd.time, Comment = matchToAdd.comment + "" }; MatchParticipant ParticipantOne = new MatchParticipant { player = Convert.ToString(matchToAdd.win), matchID = Convert.ToInt32(newMatch.Id), result = 1 }; MatchParticipant ParticipantTwo = new MatchParticipant { player = Convert.ToString(matchToAdd.lose), matchID = Convert.ToInt32(newMatch.Id), result = 0 }; PONewRating = _allPlayers.GetPlayerByAlias(matchToAdd.win).Rating; PTNewRating = _allPlayers.GetPlayerByAlias(matchToAdd.lose).Rating; ELO.CalculateELO(ref PONewRating, ref PTNewRating, 1); ELO.CalculateELO(ref PTNewRating, ref PONewRating, 0); //POne.Rating = PONewRating; //PTwo.Rating = PONewRating; _allPlayers.UpdateRating(PONewRating, matchToAdd.win); _allPlayers.UpdateRating(PTNewRating, matchToAdd.lose); PONewRating = 0; PTNewRating = 0; _AddMatch.AddMatch(matchToAdd, newMatch, ParticipantOne, ParticipantTwo); //ViewBag.AP = _allPlayers.AllPlayers PlayersListViewModel PListed = new PlayersListViewModel(); PListed.GetAllPlayers = _allPlayers.AllPlayers; ViewBag.PostResultText = "Матч добавлен!"; ViewBag.PostResult = "1"; return(View()); }
public async Task <IActionResult> AddMatch([FromBody] NewMatchBindingModel model) { if (model == null || !ModelState.IsValid) { return(BadRequest()); } var newMatch = new Match() { CreatedDate = DateTime.Now, Participants = new List <MatchParticipant>() }; var isDraw = model.Participants.Select(m => m.Score).Distinct().Count() == 1; var winnerId = 0; if (!isDraw) { var winner = model.Participants.FirstOrDefault(m => m.Score == model.Participants.Max(p => p.Score)); if (winner != null) { winnerId = winner.Id; } } foreach (var matchParticipant in model.Participants) { var newParticipant = new MatchParticipant() { Match = newMatch, MatchResult = isDraw ? MatchResultConstants.Draw : (winnerId == matchParticipant.Id ? MatchResultConstants.Win : MatchResultConstants.Loss), ParticipantId = matchParticipant.Id, Score = matchParticipant.Score }; newMatch.Participants.Add(newParticipant); } await _foosballService.AddMatch(newMatch); return(Ok()); }
public List <MatchParticipant> GetMatchParticipants(Match match) { //MatchParticipantManager mpManager = new MatchParticipantManager(); List <MatchParticipant> participants = new List <MatchParticipant>(); int numParticipants = match.Participants.Count; //foreach (Participant participant in match.Participants) for (int x = 0; x < 10; x++) { MatchParticipant newParticipant = new MatchParticipant(); newParticipant.ParticipantID = match.Participants[x].ParticipantId; newParticipant.MatchID = match.GameId; newParticipant.SummonerID = match.ParticipantIdentities[x].Player.SummonerId; //Getting summoner ID from participantindent newParticipant.ChampionID = match.Participants[x].ChampionId; newParticipant.TeamID = match.Participants[x].TeamId; newParticipant.Spell1ID = match.Participants[x].Spell1Id; newParticipant.Spell2ID = match.Participants[x].Spell2Id; // If summoner not in DB, insert if (!summonerIO.SummonerExists(newParticipant.SummonerID)) { Summoner summoner = new Summoner() { SummonerID = match.ParticipantIdentities[x].Player.SummonerId, SummonerName = match.ParticipantIdentities[x].Player.SummonerName, AccountID = match.ParticipantIdentities[x].Player.AccountId, ProfileIconID = match.ParticipantIdentities[x].Player.ProfileIcon }; summonerIO.InsertSummoner(summoner); } // Insert the participant into the DB matchParticipantIO.InsertMatchParticipant(newParticipant); int participantID = matchParticipantIO.GetParticipantIDBySummonerID(newParticipant.SummonerID, newParticipant.MatchID); // Insert the stats in the DB and retrieve them ParticipantStat stats = statManager.GetParticipantStat(match, newParticipant, x, participantID); } return(participants); }
public async Task <List <MatchParticipant> > GetMatchWinner(int matchId) { var result = new MatchParticipant(); var userMatches = await this.userMatchRepo.GetUserMatchesByMatchId(matchId); if (!userMatches.Any(x => x.NumberInput.HasValue)) { return(Enumerable.Empty <MatchParticipant>().ToList()); } var winner = userMatches.Where(x => x.NumberInput == userMatches.Max(x => x.NumberInput)); var winnerList = from um in winner join u in await userRepo.GetAllUsers() on um.UserId equals u.Id select new MatchParticipant { UserId = u.Id, MatchId = um.MatchId, NumberInput = um.NumberInput, UserName = u.UserName }; return(winnerList.ToList()); }