static TournamentUsers GetTournamentPreliminaryWinners(Cxt cxt, int tournamentID, int round, DataTable dtTournamentUsers) { TournamentUsers tuWinners = new TournamentUsers(); TournamentUsers tuLosers = GetTournamentLosers(cxt, tournamentID, round); if (tuLosers.Count > 0) { foreach (DataRow item in dtTournamentUsers.Rows) { TournamentUser tu1 = new TournamentUser(cxt, item); if (!tuLosers.Contains("UserID = " + tu1.UserID)) { tuWinners.Add(tu1); } } } return(tuWinners); }
static TournamentUsers GetTournamentPreliminaryWinners1(Cxt cxt, int tournamentID, int round, DataTable dtTournamentUsers) { TournamentUsers tuWinners = new TournamentUsers(); TournamentMatches tournamentMatches = new TournamentMatches(cxt, GetTournamntPlayers(tournamentID)); TournamentMatches tmW = new TournamentMatches(); TournamentUsers tuW = new TournamentUsers(); TournamentUsers tuL = new TournamentUsers(); int wCounter = 0, bCounter = 0, dCounter = 0; foreach (DataRow item in tournamentMatches.DataTable.Rows) { TournamentMatch tournamentMatch = new TournamentMatch(cxt, item); TournamentUser tournamentUserB = null; TournamentUser tournamentUserW = null; switch (tournamentMatch.GameResultIDE) { case GameResultE.None: break; case GameResultE.InProgress: break; case GameResultE.WhiteWin: bCounter += 1; tournamentUserW = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.WhiteUserID); tournamentUserB = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.BlackUserID); tuW.Add(tournamentUserW); tuL.Add(tournamentUserB); break; case GameResultE.WhiteLose: { wCounter += 1; tournamentUserB = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.BlackUserID); tournamentUserW = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.WhiteUserID); tuW.Add(tournamentUserB); tuL.Add(tournamentUserW); } break; case GameResultE.Draw: dCounter += 1; tmW.Add(tournamentMatch); break; case GameResultE.Absent: break; case GameResultE.NoResult: break; case GameResultE.WhiteBye: wCounter += 1; tournamentUserB = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.BlackUserID); tournamentUserW = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.WhiteUserID); tuW.Add(tournamentUserB); tuL.Add(tournamentUserW); break; case GameResultE.BlackBye: bCounter += 1; tournamentUserW = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.WhiteUserID); tournamentUserB = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.BlackUserID); tuW.Add(tournamentUserW); tuL.Add(tournamentUserB); break; case GameResultE.ForcedWhiteWin: bCounter += 1; tournamentUserW = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.WhiteUserID); tournamentUserB = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.BlackUserID); tuW.Add(tournamentUserW); tuL.Add(tournamentUserB); break; case GameResultE.ForcedWhiteLose: wCounter += 1; tournamentUserB = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.BlackUserID); tournamentUserW = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.WhiteUserID); tuW.Add(tournamentUserB); tuL.Add(tournamentUserW); break; case GameResultE.ForcedDraw: dCounter += 1; tmW.Add(tournamentMatch); break; default: break; } } if (dCounter > 0) { foreach (DataRow item in tmW.DataTable.Rows) { TournamentMatch tournamentMatch = new TournamentMatch(cxt, item); if (tournamentMatch.EloWhiteAfter > tournamentMatch.EloBlackAfter) { TournamentUser tournamentUserW = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.WhiteUserID); TournamentUser tournamentUserB = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.BlackUserID); tuW.Add(tournamentUserW); tuL.Add(tournamentUserB); } else if (tournamentMatch.EloBlackAfter > tournamentMatch.EloWhiteAfter) { TournamentUser tournamentUserB = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.BlackUserID); TournamentUser tournamentUserW = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.WhiteUserID); tuW.Add(tournamentUserB); tuL.Add(tournamentUserW); } else { TournamentUser tournamentUserB = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.BlackUserID); TournamentUser tournamentUserW = TournamentUser.GetTournamentUserById(cxt, tournamentID, tournamentMatch.WhiteUserID); tuW.Add(tournamentUserB); tuW.Add(tournamentUserW); } } } if (tuL.Count > 0) { foreach (DataRow item in dtTournamentUsers.Rows) { TournamentUser tu1 = new TournamentUser(cxt, item); if (!tuL.Contains("UserID = " + tu1.UserID)) { tuWinners.Add(tu1); } } } return(tuWinners); }