コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }