static void addToPlayerMaps(playerStats player, double wins, double losses) { using (SqlConnection eloCon = new SqlConnection(conStr)) { string queryStr = String.Format("Select * FROM Player_Maps WHERE MapId = '{0}' AND PlayerId = '{1}'", mapChoice.mapName, player.playerName); SqlCommand cmd = new SqlCommand(queryStr, eloCon); eloCon.Open(); using (SqlDataReader oReader = cmd.ExecuteReader()) { if (oReader.HasRows) { while (oReader.Read()) { using (SqlConnection eloCon2 = new SqlConnection(conStr)) { eloCon2.Open(); queryStr = String.Format("UPDATE Player_Maps SET Wins = {0}, Losses = {1} WHERE MapId = '{2}' AND PlayerId = '{3}'", Convert.ToString(Convert.ToDouble(oReader[1]) + wins), Convert.ToString(Convert.ToDouble(oReader[2]) + losses), mapChoice.mapName, player.playerName); SqlCommand cmd2 = new SqlCommand(queryStr, eloCon2); cmd2.ExecuteNonQuery(); } } } else { using (SqlConnection eloCon2 = new SqlConnection(conStr)) { eloCon2.Open(); queryStr = String.Format("INSERT INTO Player_Maps(Wins,Losses,MapId,PlayerId) VALUES ({0},{1},'{2}','{3}')", Convert.ToString(wins), Convert.ToString(losses), mapChoice.mapName, player.playerName); SqlCommand cmd2 = new SqlCommand(queryStr, eloCon2); cmd2.ExecuteNonQuery(); } } } } }
public team() { player1 = new playerStats(); player2 = new playerStats(); player3 = new playerStats(); player4 = new playerStats(); }
static void findMatchesPlayed(playerStats player) { using (SqlConnection eloCon = new SqlConnection(conStr)) { string queryStr = "Select COUNT(idMatchResults) FROM MatchResults WHERE DateOfMatch >= DATEADD(M, -3, GETDATE()) AND" + "(team1player1 = '" + player.playerName + "' OR " + "team1player2 = '" + player.playerName + "' OR " + "team1player3 = '" + player.playerName + "' OR " + "team1player4 = '" + player.playerName + "' OR " + "team2player1 = '" + player.playerName + "' OR " + "team2player2 = '" + player.playerName + "' OR " + "team2player3 = '" + player.playerName + "' OR " + "team2player4 = '" + player.playerName + "')"; SqlCommand cmd = new SqlCommand(queryStr, eloCon); eloCon.Open(); using (SqlDataReader oReader = cmd.ExecuteReader()) { while (oReader.Read()) { player.matchesPlayed = Convert.ToInt32(oReader[0]); } } } }
public team(playerStats player11, playerStats player22, playerStats player33, playerStats player44) { player1 = player11; player2 = player22; player3 = player33; player4 = player44; }
static void applyEloChange(double eloChange, playerStats player) { using (SqlConnection eloCon = new SqlConnection(conStr)) { eloCon.Open(); string queryStr = "UPDATE PlayerStats SET PlayerElo = " + Convert.ToString(Math.Ceiling(Convert.ToDouble(player.playerElo) + eloChange)) + " WHERE PlayerName = '" + player.playerName + "'"; SqlCommand cmd = new SqlCommand(queryStr, eloCon); cmd.ExecuteNonQuery(); } }
static void instansiateStatsArray(playerStats[] instAll) { instAll[0] = new playerStats(); instAll[1] = new playerStats(); instAll[2] = new playerStats(); instAll[3] = new playerStats(); instAll[4] = new playerStats(); instAll[5] = new playerStats(); instAll[6] = new playerStats(); instAll[7] = new playerStats(); }
static void averageEloCalculator() { playerStats[,] pairs = new playerStats[4, 2]; for (int i = 0; i < 8; i++) { bool belowLarger = false; if (i - 1 > 0) { } } }
public matchResults() { mapName = "empty"; team1Player1 = new playerStats(); team1Player2 = new playerStats(); team1Player3 = new playerStats(); team1Player4 = new playerStats(); team2Player1 = new playerStats(); team2Player2 = new playerStats(); team2Player3 = new playerStats(); team2Player4 = new playerStats(); team1Wins = 0; team2Wins = 0; dateOfMatch = new DateTime(); draws = 0; }
public matchResults(string mapname, playerStats t1p1, playerStats t1p2, playerStats t1p3, playerStats t1p4, playerStats t2p1, playerStats t2p2, playerStats t2p3, playerStats t2p4, double team1wins, double team2wins, DateTime dateMatch) { mapName = mapname; team1Player1 = t1p1; team1Player2 = t1p2; team1Player3 = t1p3; team1Player4 = t1p4; team2Player1 = t2p1; team2Player2 = t2p2; team2Player3 = t2p3; team2Player4 = t2p4; team1Wins = team1wins; team2Wins = team2wins; dateOfMatch = dateMatch; draws = 0; }
public matchResults matchResultsNoDT(string mapname, playerStats t1p1, playerStats t1p2, playerStats t1p3, playerStats t1p4, playerStats t2p1, playerStats t2p2, playerStats t2p3, playerStats t2p4, double team1wins, double team2wins) { mapName = mapname; team1Player1 = t1p1; team1Player2 = t1p2; team1Player3 = t1p3; team1Player4 = t1p4; team2Player1 = t2p1; team2Player2 = t2p2; team2Player3 = t2p3; team2Player4 = t2p4; team1Wins = team1wins; team2Wins = team2wins; dateOfMatch = DateTime.Now; draws = 0; return(this); }
static double calculateEloChange(playerStats player, int TeamPerformanceRating, bool team1B) { double eloChange = 0; int dp = TeamPerformanceRating - player.playerElo; double calculatedExpectedScore = calculateExpectedScore(team1, team2); double expectedMapWinsTeam1 = mapChoice.maps * calculatedExpectedScore; double expectedMapWinsTeam2 = mapChoice.maps * (1 - calculatedExpectedScore); if (team1B) { eloChange = dp * player.volatility * expectedScoreForElo(calculatedExpectedScore, true); } else { eloChange = dp * player.volatility * expectedScoreForElo(1 - calculatedExpectedScore, false); } return(eloChange); }
static void grabPlayerStats() { using (SqlConnection eloCon = new SqlConnection(conStr)) { string queryStr = "Select * FROM PlayerStats"; SqlCommand cmd = new SqlCommand(queryStr, eloCon); eloCon.Open(); using (SqlDataReader oReader = cmd.ExecuteReader()) { while (oReader.Read()) { playerStats tempStats = new playerStats(Convert.ToString(oReader[1]), Convert.ToInt32(oReader[2]), 0.0); heldPlayerStats.Add(tempStats); } } } instansiateStatsArray(playersInGame); }
public bool findPlayer(playerStats playerToFind) { bool found = false; if (player1.playerName == playerToFind.playerName) { found = true; } else if (player2.playerName == playerToFind.playerName) { found = true; } else if (player3.playerName == playerToFind.playerName) { found = true; } else if (player4.playerName == playerToFind.playerName) { found = true; } return(found); }
static void calculateAndSetVolatility(playerStats player) { int gamesPlayed = player.matchesPlayed; player.volatility = 1.25 * (1 / (0.2 * Convert.ToDouble(gamesPlayed) + 1)) + 0.3; }