protected void addTeam(Team team) { if (team.getTeamsTotalSalary() < mSalaryCap - mSalaryThreshold || team.getTeamsTotalSalary() > mSalaryCap || isDuplicate(team)) { return; } if (mTeamList.Count < 30) { mTeamList.Add(team); return; } Team lowestTeam = mTeamList[0]; foreach (Team x in mTeamList) { if (lowestTeam.getTeamsTotalPoints() > x.getTeamsTotalPoints()) { lowestTeam = x; continue; } } mTeamList.Remove(lowestTeam); mTeamList.Add(team); }
public Team(Team team) { mTeamRoster = new List<Player>(); foreach (Player player in team.mTeamRoster) { mTeamRoster.Add(player); } }
public void generateTeams() { foreach (Player g1 in mGolfer1) { Team team = new Team(); team.addPlayer(g1); foreach (Player g2 in mGolfer2) { if (g2.Equals(g1)) { continue; } team.addPlayer(g2); foreach (Player g3 in mGolfer3) { if (g3.Equals(g1) || g3.Equals(g2)) { continue; } team.addPlayer(g3); foreach (Player g4 in mGolfer4) { if (g4.Equals(g1) || g4.Equals(g2) || g4.Equals(g3)) { continue; } team.addPlayer(g4); foreach (Player g5 in mGolfer5) { if (g5.Equals(g1) || g5.Equals(g2) || g5.Equals(g3) || g5.Equals(g4)) { continue; } team.addPlayer(g5); foreach (Player g6 in mGolfer6) { if (g6.Equals(g1) || g6.Equals(g2) || g6.Equals(g3) || g6.Equals(g4) || g6.Equals(g5)) { continue; } team.addPlayer(g6); addTeam(new Team(team)); team.removePlayer(g6); } team.removePlayer(g5); } team.removePlayer(g4); } team.removePlayer(g3); } team.removePlayer(g2); } team.removePlayer(g1); } }
public void generateTeams() { foreach (Player g in mFixedGoalie) { Team team = new Team(); team.addPlayer(g); foreach (Player c1 in mFixedCenter1) { team.addPlayer(c1); foreach (Player c2 in mFixedCenter2) { if (c2.Equals(c1)) { continue; } team.addPlayer(c2); foreach (Player w1 in mFixedWinger1) { team.addPlayer(w1); foreach (Player w2 in mFixedWinger2) { if (w2.Equals(w1)) { continue; } team.addPlayer(w2); foreach (Player w3 in mFixedWinger3) { if (w3.Equals(w1) || w3.Equals(w2)) { continue; } team.addPlayer(w3); foreach (Player d1 in mFixedDefense1) { team.addPlayer(d1); foreach (Player d2 in mFixedDefense2) { if (d2.Equals(d1)) { continue; } team.addPlayer(d2); foreach (Player util in mFixedUtility) { if (util.Equals(c1) || util.Equals(c2) || util.Equals(w1) || util.Equals(w2) || util.Equals(w3) || util.Equals(d1) || util.Equals(d2)) { continue; } team.addPlayer(util); addTeam(new Team(team)); team.removePlayer(util); } team.removePlayer(d2); } team.removePlayer(d1); } team.removePlayer(w3); } team.removePlayer(w2); } team.removePlayer(w1); } team.removePlayer(c2); } team.removePlayer(c1); } } }
private bool isDuplicate(Team addedTeam) { foreach (Team team in mTeamList) { if (team.Equals(addedTeam)) { return true; } } return false; }
public void generateTopCollegeBasketballTeams(MainForm.ProgressBarIncrement inc) { int i = 0; int x = 0; foreach (Player f1 in mForwardList) { Team team = new Team(); team.addPlayer(f1); foreach (Player f2 in mForwardList) { if (f1.Equals(f2)) { continue; } team.addPlayer(f2); foreach (Player f3 in mForwardList) { if (f3.Equals(f2) || f3.Equals(f1)) { continue; } team.addPlayer(f3); foreach (Player g1 in mGuardList) { team.addPlayer(g1); foreach (Player g2 in mGuardList) { if (g2.Equals(g1)) { continue; } team.addPlayer(g2); foreach (Player g3 in mGuardList) { if (g3.Equals(g1) || g3.Equals(g2)) { continue; } team.addPlayer(g3); foreach (Player u1 in mUtilList) { if (u1.Equals(g1) || u1.Equals(g2) || u1.Equals(g3) || u1.Equals(f1) || u1.Equals(f2) || u1.Equals(f3)) { continue; } team.addPlayer(u1); foreach (Player u2 in mUtilList) { if (u2.Equals(u1) || u2.Equals(g1) || u2.Equals(g2) || u2.Equals(g3) || u2.Equals(f1) || u2.Equals(f2) || u2.Equals(f3)) { continue; } i++; //should eventually refactor this, pull this out from all of the Generators, have it as a protected method in GenerateTeams abstract class, and have that abstract class upon receiving // the "progress bar inc" variable set that progress bar for future use, would remove this ugly chunk of code from all calculators, lots less duplicated code. if (i == 10000000) { i = 0; x++; if (x > 3) { x = 0; } inc.Invoke(x); } team.addPlayer(u2); addTeam(new Team(team)); team.removePlayer(u2); } team.removePlayer(u1); } team.removePlayer(g3); } team.removePlayer(g2); } team.removePlayer(g1); } team.removePlayer(f3); } team.removePlayer(f2); } } updateProgressEvent(); }
public void generateTopNFLTeams(MainForm.ProgressBarIncrement inc) { int i = 0; int x = 0; foreach (Player qb in mQBList) { Team team = new Team(); team.addPlayer(qb); foreach (Player rb1 in mRBList) { team.addPlayer(rb1); foreach (Player rb2 in mRBList) { if (rb2.Equals(rb1)) { continue; } team.addPlayer(rb2); foreach (Player wr1 in mWRList) { team.addPlayer(wr1); foreach (Player wr2 in mWRList) { if (wr2.Equals(wr1)) { continue; } team.addPlayer(wr2); foreach (Player wr3 in mWRList) { if (wr3.Equals(wr1) || wr3.Equals(wr2)) { continue; } team.addPlayer(wr3); foreach (Player te in mTEList) { team.addPlayer(te); foreach (Player dst in mDSTList) { team.addPlayer(dst); foreach (Player flex in mFlexList) { if (flex.Equals(te) || flex.Equals(wr1) || flex.Equals(wr2) || flex.Equals(wr3) || flex.Equals(rb1) || flex.Equals(rb2)) { continue; } i++; if (i == 10000000) { i = 0; x++; if (x > 3) { x = 0; } inc.Invoke(x); } team.addPlayer(flex); addTeam(new Team(team)); team.removePlayer(flex); } team.removePlayer(dst); } team.removePlayer(te); } team.removePlayer(wr3); } team.removePlayer(wr2); } team.removePlayer(wr1); } team.removePlayer(rb2); } team.removePlayer(rb1); } } updateProgressEvent(); }
private void generateTeams() { foreach(Player f1 in fixedForward1) { Team team = new Team(); team.addPlayer(f1); foreach(Player f2 in fixedForward2) { if (f2.Equals(f1)) { continue; } team.addPlayer(f2); foreach(Player f3 in fixedForward3) { if (f3.Equals(f2) || f3.Equals(f1)) { continue; } team.addPlayer(f3); foreach(Player g1 in fixedGuard1) { team.addPlayer(g1); foreach(Player g2 in fixedGuard2) { if (g2.Equals(g1)) { continue; } team.addPlayer(g2); foreach(Player g3 in fixedGuard3) { if (g3.Equals(g1) || g3.Equals(g2)) { continue; } team.addPlayer(g3); foreach(Player u1 in mUtilList) { if (u1.Equals(g1) || u1.Equals(g2) || u1.Equals(g3) || u1.Equals(f1) || u1.Equals(f2) || u1.Equals(f3)) { continue; } team.addPlayer(u1); foreach(Player u2 in mUtilList) { if (u2.Equals(u1) || u2.Equals(g1) || u2.Equals(g2) || u2.Equals(g3) || u2.Equals(f1) || u2.Equals(f2) || u2.Equals(f3)) { continue; } team.addPlayer(u2); addTeam(new Team(team)); team.removePlayer(u2); } team.removePlayer(u1); } team.removePlayer(g3); } team.removePlayer(g2); } team.removePlayer(g1); } team.removePlayer(f3); } team.removePlayer(f2); } team.removePlayer(f1); } }