public void Calculate1v1Elo() { if (!HasBots) { var losers = SpringBattlePlayers.Where(x => !x.IsSpectator && !x.IsInVictoryTeam).ToList(); var winners = SpringBattlePlayers.Where(x => !x.IsSpectator && x.IsInVictoryTeam).ToList(); if (losers.Count == 1 && winners.Count == 1) { SpringBattlePlayer winner = winners.First(); SpringBattlePlayer loser = losers.First(); Account winnerAcc = winner.Account; Account loserAcc = loser.Account; var winnerElo = winnerAcc.Elo1v1; var loserElo = loserAcc.Elo1v1; var eWin = 1 / (1 + Math.Pow(10, (loserElo - winnerElo) / 400)); var eLose = 1 / (1 + Math.Pow(10, (winnerElo - loserElo) / 400)); var scoreWin = 32 * (1 - eWin); var scoreLose = 32 * (0 - eLose); winnerAcc.Elo1v1 += scoreWin; loserAcc.Elo1v1 += scoreLose; winner.EloChange = (float)scoreWin; loser.EloChange = (float)scoreLose; winnerAcc.XP += WinnerTeamXpChange.Value; loserAcc.XP += LoserTeamXpChange.Value; var sumW = winnerAcc.Elo1v1Weight + loserAcc.Elo1v1Weight; winnerAcc.Elo1v1Weight = Account.AdjustEloWeight(winnerAcc.Elo1v1Weight, sumW, 2); winnerAcc.EloWeight = Account.AdjustEloWeight(winnerAcc.EloWeight, sumW, 2); loserAcc.Elo1v1Weight = Account.AdjustEloWeight(loserAcc.Elo1v1Weight, sumW, 2); loserAcc.EloWeight = Account.AdjustEloWeight(loserAcc.EloWeight, sumW, 2); } } }
public static MvcHtmlString PrintBattle(this HtmlHelper helper, SpringBattlePlayer battlePlayer) { if (battlePlayer == null) return null; return PrintBattle(helper, battlePlayer.SpringBattle, battlePlayer.IsSpectator ? null : (bool?)battlePlayer.IsInVictoryTeam); }