Ejemplo n.º 1
0
        // Serialize and save all league rules to a file (static?)
        public void SaveRules(League lr, string file)
        {
            string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string fileName = dir + @"\" + file;
            
            //creates a backup file that we can revert to
            string backup = Path.ChangeExtension(fileName, ".old");
            if (File.Exists(fileName))
            {
                if (File.Exists(backup))
                    File.Delete(backup);

                File.Move(fileName, backup);
            }

            lr.UpdateWeeks();
            //serializes the list of teams
            using (FileStream fstream = new FileStream(fileName, FileMode.Create))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(League));
                serializer.Serialize(fstream, lr);
                fstream.Flush();
                fstream.Close();
            }
        }
Ejemplo n.º 2
0
 public LeagueDataParser(String fname)
 {
     if (File.Exists(fname))
     {
         storedRules = LoadRules(fname);
         initialized = true;
     }
     else
     {
         storedRules = new League();
         initialized = false;
     }
 }
Ejemplo n.º 3
0
        public Leaderboard()
        {
            TeamDataParser  teamParser   = new TeamDataParser();
            List <Team>     teamList     = teamParser.GetTeams();
            List <Employee> employeeList = new List <Employee>();

            ldp              = new LeagueDataParser("leaguerules.xml");
            displayedTeams   = new List <TeamsData>();
            displayedPlayers = new List <PlayersData>();
            game             = ldp.StoredRules;
            Trace.WriteLine("Playoff weeks: " + game.PlayoffWeeks + " Season weeks: " + game.SeasonWeeks);
            foreach (Team t in teamList)
            {
                employeeList.AddRange(t.Members);
            }

            employeeList.Sort();



            InitializeComponent();
            DataGridTextColumn tCol1 = new DataGridTextColumn();
            DataGridTextColumn tCol2 = new DataGridTextColumn();
            DataGridTextColumn tCol3 = new DataGridTextColumn();
            DataGridTextColumn tCol4 = new DataGridTextColumn();

            teamsDataGrid.Columns.Add(tCol1);
            teamsDataGrid.Columns.Add(tCol2);
            teamsDataGrid.Columns.Add(tCol3);
            teamsDataGrid.Columns.Add(tCol4);
            tCol1.Binding = new Binding("teamRank");
            tCol2.Binding = new Binding("teamName");
            tCol3.Binding = new Binding("teamScore");
            tCol4.Binding = new Binding("teamProgress");
            tCol1.Header  = "Rank";
            tCol2.Header  = "Team Name";
            tCol3.Header  = "Score";
            tCol4.Header  = "Progress";

            DataGridTextColumn pCol1 = new DataGridTextColumn();
            DataGridTextColumn pCol2 = new DataGridTextColumn();
            DataGridTextColumn pCol3 = new DataGridTextColumn();
            DataGridTextColumn pCol4 = new DataGridTextColumn();

            playersDataGrid.Columns.Add(pCol1);
            playersDataGrid.Columns.Add(pCol2);
            playersDataGrid.Columns.Add(pCol3);
            playersDataGrid.Columns.Add(pCol4);
            pCol1.Binding = new Binding("playerRank");
            pCol2.Binding = new Binding("playerName");
            pCol3.Binding = new Binding("playerScore");
            pCol4.Binding = new Binding("playerProgress");
            pCol1.Header  = "Rank";
            pCol2.Header  = "Player Name";
            pCol3.Header  = "Score";
            pCol4.Header  = "Progress";

            for (int j = 0; j < teamList.Count; j++)
            {
                if (teamList[j].TeamName != "Free Agents")
                {
                    teamList[j].SubCheck(weeks);
                    teamsDataGrid.Items.Add(
                        new TeamsData
                    {
                        teamRank     = j,
                        teamName     = teamList[j].TeamName,
                        teamScore    = teamList[j].GetTotalForWeek(weeks),
                        teamProgress = "+" + teamList[j].GetPointsGainedForWeek(weeks),
                        hostTeam     = teamList[j]
                    });
                    displayedTeams.Add(
                        new TeamsData
                    {
                        teamRank     = j + 1,
                        teamName     = teamList[j].TeamName,
                        teamScore    = teamList[j].GetTotalForWeek(weeks),
                        teamProgress = "+" + teamList[j].GetPointsGainedForWeek(weeks),
                        hostTeam     = teamList[j]
                    });
                }
            }
            teamsDataGrid.Items.Remove(teamsDataGrid.Items[0]);

            for (int k = 0; k < employeeList.Count; k++)
            {
                playersDataGrid.Items.Add(
                    new PlayersData {
                    playerRank     = (k + 1),
                    playerName     = employeeList[k].GetName(),
                    playerScore    = employeeList[k].GetPoints(),
                    playerProgress = "+" + employeeList[k].GetScoreOfWeek(weeks),
                    hostEmp        = employeeList[k]
                });
                displayedPlayers.Add(
                    new PlayersData
                {
                    playerRank     = (k + 1),
                    playerName     = employeeList[k].GetName(),
                    playerScore    = employeeList[k].GetPoints(),
                    playerProgress = "+" + employeeList[k].GetScoreOfWeek(weeks),
                    hostEmp        = employeeList[k]
                });
            }
            playersDataGrid.Items.Remove(playersDataGrid.Items[0]);

            vL1.Add(new KeyValuePair <string, int>("Week 1", 0));
            vL2.Add(new KeyValuePair <string, int>("Week 1", 0));
            vL3.Add(new KeyValuePair <string, int>("Week 1", 0));
            vL4.Add(new KeyValuePair <string, int>("Week 1", 0));
            vL5.Add(new KeyValuePair <string, int>("Week 1", 0));
            vL6.Add(new KeyValuePair <string, int>("Week 1", 0));
            vL7.Add(new KeyValuePair <string, int>("Week 1", 0));
            vL8.Add(new KeyValuePair <string, int>("Week 1", 0));
            vL9.Add(new KeyValuePair <string, int>("Week 1", 0));
            vL10.Add(new KeyValuePair <string, int>("Week 1", 0));
        }
Ejemplo n.º 4
0
 public LeagueDataParser()
 {
     storedRules = new League();
     initialized = false;
 }
Ejemplo n.º 5
0
 public LeagueDataParser()
 {
     storedRules = new League();
     initialized = false;
 }
Ejemplo n.º 6
0
        public Leaderboard()
        {
            
			TeamDataParser teamParser = new TeamDataParser();
			List<Team> teamList = teamParser.GetTeams();
			List<Employee> employeeList = new List<Employee>();
            ldp = new LeagueDataParser("leaguerules.xml");
            displayedTeams = new List<TeamsData>();
            displayedPlayers = new List<PlayersData>();
            game = ldp.StoredRules;
            Trace.WriteLine("Playoff weeks: " + game.PlayoffWeeks + " Season weeks: " + game.SeasonWeeks);
			foreach(Team t in teamList)
			{
				employeeList.AddRange(t.Members);
			}
			
			employeeList.Sort();

            

            InitializeComponent();
            DataGridTextColumn tCol1 = new DataGridTextColumn();
            DataGridTextColumn tCol2 = new DataGridTextColumn();
            DataGridTextColumn tCol3 = new DataGridTextColumn();
			DataGridTextColumn tCol4 = new DataGridTextColumn();
            teamsDataGrid.Columns.Add(tCol1);
            teamsDataGrid.Columns.Add(tCol2);
            teamsDataGrid.Columns.Add(tCol3);
			teamsDataGrid.Columns.Add(tCol4);
            tCol1.Binding = new Binding("teamRank");
            tCol2.Binding = new Binding("teamName");
            tCol3.Binding = new Binding("teamScore");
			tCol4.Binding = new Binding("teamProgress");
            tCol1.Header = "Rank";
            tCol2.Header = "Team Name";
            tCol3.Header = "Score";
			tCol4.Header = "Progress";
			
			DataGridTextColumn pCol1 = new DataGridTextColumn();
			DataGridTextColumn pCol2 = new DataGridTextColumn();
			DataGridTextColumn pCol3 = new DataGridTextColumn();
			DataGridTextColumn pCol4 = new DataGridTextColumn();
			playersDataGrid.Columns.Add(pCol1);
			playersDataGrid.Columns.Add(pCol2);
			playersDataGrid.Columns.Add(pCol3);
			playersDataGrid.Columns.Add(pCol4);
			pCol1.Binding = new Binding("playerRank");
			pCol2.Binding = new Binding("playerName");
			pCol3.Binding = new Binding("playerScore");
			pCol4.Binding = new Binding("playerProgress");
			pCol1.Header = "Rank";
			pCol2.Header = "Player Name";
			pCol3.Header = "Score";
			pCol4.Header = "Progress";
			
			for(int j = 0; j<teamList.Count; j++)
			{
                if (teamList[j].TeamName != "Free Agents")
                {
                    teamList[j].SubCheck(weeks);
                    teamsDataGrid.Items.Add(
                        new TeamsData
                        {
                            teamRank = j,
                            teamName = teamList[j].TeamName,
                            teamScore = teamList[j].GetTotalForWeek(weeks),
                            teamProgress = "+" + teamList[j].GetPointsGainedForWeek(weeks),
                            hostTeam = teamList[j]
                        });
                    displayedTeams.Add(
                        new TeamsData
                        {
                            teamRank = j + 1,
                            teamName = teamList[j].TeamName,
                            teamScore = teamList[j].GetTotalForWeek(weeks),
                            teamProgress = "+" + teamList[j].GetPointsGainedForWeek(weeks),
                            hostTeam = teamList[j]
                        });
                }
			}
            teamsDataGrid.Items.Remove(teamsDataGrid.Items[0]);

			for(int k = 0; k<employeeList.Count; k++)
			{
				playersDataGrid.Items.Add(
                    new PlayersData{
                        playerRank = (k+1), 
                        playerName = employeeList[k].GetName(), 
                        playerScore = employeeList[k].GetPoints(), 
                        playerProgress = "+"+employeeList[k].GetScoreOfWeek(weeks),
                        hostEmp = employeeList[k]});
                displayedPlayers.Add(
                        new PlayersData
                        {
                            playerRank = (k + 1),
                            playerName = employeeList[k].GetName(),
                            playerScore = employeeList[k].GetPoints(),
                            playerProgress = "+" + employeeList[k].GetScoreOfWeek(weeks),
                            hostEmp = employeeList[k]
                        });
			}
            playersDataGrid.Items.Remove(playersDataGrid.Items[0]);

            vL1.Add(new KeyValuePair<string, int>("Week 1", 0));
            vL2.Add(new KeyValuePair<string, int>("Week 1", 0));
            vL3.Add(new KeyValuePair<string, int>("Week 1", 0));
            vL4.Add(new KeyValuePair<string, int>("Week 1", 0));
            vL5.Add(new KeyValuePair<string, int>("Week 1", 0));
            vL6.Add(new KeyValuePair<string, int>("Week 1", 0));
            vL7.Add(new KeyValuePair<string, int>("Week 1", 0));
            vL8.Add(new KeyValuePair<string, int>("Week 1", 0));
            vL9.Add(new KeyValuePair<string, int>("Week 1", 0));
            vL10.Add(new KeyValuePair<string, int>("Week 1", 0));
        
        }
Ejemplo n.º 7
0
        public LeagueRules()
        {
            LeagueDataParser ldp  = new LeagueDataParser("leaguerules.xml");
            League           game = ldp.StoredRules;

            InitializeComponent();

            String teamR   = "error reading rules";
            String seasonR = "seriously, there's a problem";

            String mm;

            if (game.MutualMatching)
            {
                mm = "Yes";
            }
            else
            {
                mm = "No";
            }

            //team size, extras, x teams player is on, mutual match
            teamR = "Team Size: " + game.MembersPerTeam +
                    "\nExtras on team: " + game.ExtrasPerTeam +
                    "\nMutual Matching: " + mm +
                    "\nPlayer Recurrence: " + game.SimultaneousTeams;

            String gd;

            if (game.GameNight == 0)
            {
                gd = "Thursday";
            }
            else if (game.GameNight == 1)
            {
                gd = "Sunday";
            }
            else
            {
                gd = "Monday";
            }

            String tsb;

            if (game.TeamSuperbowl)
            {
                tsb = "Yes";
            }
            else
            {
                tsb = "No";
            }

            //game night, playoff size, bowl project, season duration, break duration
            //Season End needs work, -does start date mean first game that night or not?
            seasonR = "Game Night: " + gd +
                      "\nDraft Day: " + game.DraftTime.Date.ToString("d") +
                      "\nSeason Start: " + game.SeasonStart.Date.ToString("d") +
                      "\nSeason End: " + game.SeasonStart.AddDays((game.SeasonWeeks - 1) * 7).Date.ToString("d") +
                      "\nTeams in Playoffs: " + game.PlayoffTeams +
                      "\nPlayoff Start: " + game.PlayoffStart.Date.ToString("d") +
                      "\nSuperbowl Project: " + tsb;

            teamRules.Text   = teamR;
            seasonRules.Text = seasonR;

            //IMPLEMENT CALENDAR STUFF
            //draft day, season play, game days, playoffs, playoff break

            calendar.SelectedDates.Add(game.SeasonStart);
            for (int i = 1; i < game.SeasonWeeks; i++)
            {
                calendar.SelectedDates.Add(game.SeasonStart.AddDays(i * 7));
            }
            for (int i = 0; i < game.PlayoffWeeks; i++)
            {
                calendar.SelectedDates.Add(game.PlayoffStart.AddDays(i * 7));
            }
        }