Пример #1
0
        private void DetermineShotsFaced(HockeyPlayer p)
        {
            int shotsFaced    = 0;
            int numberOfGames = 0;

            if (p.DepthChart == 1)
            {
                //p.Wins += starterWins;
                numberOfGames = gamesForStarter;
                //p.GamesPlayed += gamesForStarter;
            }
            else
            {
                //p.Wins += backupWins;
                numberOfGames = gamesForBackup;
                //p.GamesPlayed += gamesForBackup;
            }

            if (numberOfGames > 0)
            {
                for (int i = 0; i < numberOfGames; i++)
                {
                    shotsFaced    = rnd.Next(25, 36);
                    p.ShotsFaced += shotsFaced;
                    DetermineShotsSaved(p, shotsFaced);
                }
            }
            //p.GamesPlayed += numberOfGames;
        }
Пример #2
0
        private void CalculatePlayerOfTheYearScore(HockeyPlayer p)
        {
            double score = 0;

            score = p.CurrentSkill * 2 + p.Team.Wins * 3 + p.Popularity * 2 + p.Goals * 3 + p.Assists;
            p.PlayerOfYearScore = score;
        }
Пример #3
0
 private void CalculateGAA(HockeyPlayer p)
 {
     if (p.ShotsFaced > 0)
     {
         p.GAA = Convert.ToDouble(p.GoalsAllowed) / Convert.ToDouble(p.GamesPlayed);
     }
     else
     {
         p.GAA = 99.99;
     }
 }
Пример #4
0
 private void CalculateSavePercentage(HockeyPlayer p)
 {
     if (p.ShotsFaced > 0)
     {
         p.SavePercentage = Convert.ToDouble(p.Saves) / Convert.ToDouble(p.ShotsFaced);
     }
     else
     {
         p.SavePercentage = 0.00;
     }
 }
Пример #5
0
 public void DisplayHockeyStats(HockeyPlayer player)
 {
     if (player.Position == Position.G)
     {
         lblStats.Text = DisplayGoalieStats(player);
     }
     else
     {
         lblStats.Text = DisplaySkaterStats(player);
     }
 }
Пример #6
0
        private void DetermineAssists(HockeyPlayer p)
        {
            int playerDiceRoll   = 0;
            int neededDiceNumber = 0;
            int numberOfRolls    = 0;

            if (p.CurrentSkill >= 70)
            {
                numberOfRolls = 3;
            }
            else if (p.CurrentSkill >= 50)
            {
                numberOfRolls = 2;
            }
            else
            {
                numberOfRolls = 1;
            }

            if (p.CurrentSkill >= 70)
            {
                neededDiceNumber = 6;
            }
            else if (p.CurrentSkill >= 60)
            {
                neededDiceNumber = 7;
            }
            else if (p.CurrentSkill >= 50)
            {
                neededDiceNumber = 8;
            }
            else if (p.CurrentSkill >= 40)
            {
                neededDiceNumber = 9;
            }
            else if (p.CurrentSkill >= 30)
            {
                neededDiceNumber = 10;
            }
            else
            {
                neededDiceNumber = 12;
            }

            for (int i = 0; i < numberOfRolls; i++)
            {
                playerDiceRoll = DiceRoll();
                if (playerDiceRoll >= neededDiceNumber)
                {
                    p.Assists++;
                }
            }
        }
Пример #7
0
 public void CreateDraftEntrants()
 {
     for (int i = 0; i < numberOfEntrants; i++)
     {
         HockeyPlayer b = new HockeyPlayer(rnd, league.IdCount, Sports.Hockey, rnd.Next(18, 25), DeterminePosition());
         b.PlayerType = PlayerType.DraftEntrant;
         b.League     = league;
         league.DraftEntrants.Add(b);
     }
     ModifyDraftClass(league.DraftEntrants);
     ModifyDraftClassPopularityAndPGP(league.DraftEntrants);
 }
Пример #8
0
        private void CalculateGoalieOfTheYearScore(HockeyPlayer p)
        {
            double score = 0;

            score = (p.CurrentSkill * 2) + (p.Team.Wins * 7) + (p.Popularity) + (3 - (p.GAA * 100)) + (p.ShutOuts * 5);
            if (p.GamesPlayed >= 25)
            {
                p.PlayerOfYearScore = score;
            }
            else
            {
                p.PlayerOfYearScore = score / 4;
            }
        }
Пример #9
0
        private void DetermineShotsSaved(HockeyPlayer p, int shotsFaced)
        {
            int saves        = 0;
            int goalsAllowed = 0;

            for (int i = 0; i < shotsFaced; i++)
            {
                int saveRoll = DiceRoll();
                if (p.CurrentSkill >= 65)
                {
                    if (saveRoll > 3)
                    {
                        saves++;
                    }
                }
                else if (p.CurrentSkill >= 45)
                {
                    if (saveRoll > 4)
                    {
                        saves++;
                    }
                }
                else
                {
                    if (saveRoll > 5)
                    {
                        saves++;
                    }
                }
            }
            p.Saves        += saves;
            goalsAllowed    = shotsFaced - saves;
            p.GoalsAllowed += goalsAllowed;

            if (saves == shotsFaced)
            {
                p.ShutOuts++;
            }
            CalculateSavePercentage(p);
            CalculateGAA(p);
        }
Пример #10
0
 private void CalculatePoints(HockeyPlayer p)
 {
     p.Points = p.Goals + p.Assists;
 }
Пример #11
0
        private void DetermineGoalsScored(HockeyPlayer p)
        {
            int playerDiceRoll   = 0;
            int neededDiceNumber = 0;
            int numberOfRolls    = 0;

            if (p.Position == Position.W || p.Position == Position.C)
            {
                if (p.CurrentSkill >= 70)
                {
                    numberOfRolls = 3;
                }
                else if (p.CurrentSkill >= 50)
                {
                    numberOfRolls = 2;
                }
                else
                {
                    numberOfRolls = 1;
                }
            }
            else
            {
                if (p.CurrentSkill >= 55)
                {
                    numberOfRolls = 2;
                }
                else
                {
                    numberOfRolls = 1;
                }
            }
            if (p.Position == Position.W || p.Position == Position.C)
            {
                if (p.CurrentSkill >= 70)
                {
                    neededDiceNumber = 8;
                }
                else if (p.CurrentSkill >= 60)
                {
                    neededDiceNumber = 9;
                }
                else if (p.CurrentSkill >= 50)
                {
                    neededDiceNumber = 10;
                }
                else if (p.CurrentSkill >= 40)
                {
                    neededDiceNumber = 11;
                }
                else if (p.CurrentSkill >= 30)
                {
                    neededDiceNumber = 11;
                }
                else
                {
                    neededDiceNumber = 12;
                }
            }
            else if (p.Position == Position.D)
            {
                if (p.CurrentSkill >= 70)
                {
                    neededDiceNumber = 9;
                }
                else if (p.CurrentSkill >= 60)
                {
                    neededDiceNumber = 10;
                }
                else if (p.CurrentSkill >= 50)
                {
                    neededDiceNumber = 10;
                }
                else if (p.CurrentSkill >= 40)
                {
                    neededDiceNumber = 11;
                }
                else if (p.CurrentSkill >= 30)
                {
                    neededDiceNumber = 11;
                }
                else
                {
                    neededDiceNumber = 12;
                }
            }

            for (int i = 0; i < numberOfRolls; i++)
            {
                playerDiceRoll = DiceRoll();
                if (playerDiceRoll >= neededDiceNumber)
                {
                    p.Goals++;
                }
            }
        }
Пример #12
0
        public string DisplaySkaterStats(HockeyPlayer player)
        {
            string results = "GOALS: " + player.Goals + Environment.NewLine + "ASSISTS: " + player.Assists + Environment.NewLine + "POINTS: " + player.Points;

            return(results);
        }
Пример #13
0
        public string DisplayGoalieStats(HockeyPlayer player)
        {
            string results = "SAVE%: " + player.SavePercentage.ToString("P2") + Environment.NewLine + "GAA: " + player.GAA.ToString("0.##") + Environment.NewLine + "SHUTOUTS: " + player.ShutOuts;

            return(results);
        }
Пример #14
0
        private void cbTeamRoster_SelectedIndexChanged(object sender, EventArgs e)
        {
            League selectedLeague = World.Leagues[cbLeagues.SelectedIndex];
            Team   selectedTeam   = selectedLeague.TeamList[cbTeamList.SelectedIndex];
            Player selectedPlayer = selectedTeam.Roster[cbTeamRoster.SelectedIndex];

            lblDepthChart.Text = "Spot on Depth Chart: " + selectedPlayer.DepthChart.ToString();
            if (selectedPlayer.IsStarter)
            {
                lblStarter.Text = "Starter: yes";
            }
            else
            {
                lblStarter.Text = "Starter: no";
            }

            if (selectedLeague.Sport == Sports.Basketball)
            {
                List <BasketballPlayer> hoopsRoster = new List <BasketballPlayer>();
                foreach (BasketballPlayer bp in selectedTeam.Roster)
                {
                    hoopsRoster.Add(bp);
                }
                DisplayBasketballStats(hoopsRoster[cbTeamRoster.SelectedIndex]);
            }
            else if (selectedLeague.Sport == Sports.Football)
            {
                List <FootballPlayer> footballRoster = new List <FootballPlayer>();
                foreach (FootballPlayer fp in selectedTeam.Roster)
                {
                    footballRoster.Add(fp);
                }
                DisplayFootballStats(footballRoster[cbTeamRoster.SelectedIndex]);
            }
            else if (selectedLeague.Sport == Sports.Baseball)
            {
                List <BaseballPlayer> baseballRoster = new List <BaseballPlayer>();
                foreach (BaseballPlayer p in selectedTeam.Roster)
                {
                    baseballRoster.Add(p);
                }
                DisplayBaseballStats(baseballRoster[cbTeamRoster.SelectedIndex]);
            }
            else if (selectedLeague.Sport == Sports.Hockey)
            {
                List <HockeyPlayer> hockeyRoster = new List <HockeyPlayer>();
                foreach (HockeyPlayer p in selectedTeam.Roster)
                {
                    hockeyRoster.Add(p);
                }
                DisplayHockeyStats(hockeyRoster[cbTeamRoster.SelectedIndex]);
            }
            else if (selectedLeague.Sport == Sports.Soccer)
            {
                List <SoccerPlayer> soccerRoster = new List <SoccerPlayer>();
                foreach (SoccerPlayer p in selectedTeam.Roster)
                {
                    soccerRoster.Add(p);
                }
                DisplaySoccerStats(soccerRoster[cbTeamRoster.SelectedIndex]);
            }


            if (selectedPlayer.Sport == Sports.Baseball)
            {
                BaseballPlayer baseballPlayer = (BaseballPlayer)selectedPlayer;
                lblPosition.Text = "Position: " + baseballPlayer.Position.ToString();
            }
            else if (selectedPlayer.Sport == Sports.Basketball)
            {
                BasketballPlayer basketballPlayer = (BasketballPlayer)selectedPlayer;
                lblPosition.Text = "Position: " + basketballPlayer.Position.ToString();
            }
            else if (selectedPlayer.Sport == Sports.Football)
            {
                FootballPlayer footballPlayer = (FootballPlayer)selectedPlayer;
                lblPosition.Text = "Position: " + footballPlayer.Position.ToString();
            }
            else if (selectedPlayer.Sport == Sports.Hockey)
            {
                HockeyPlayer hockeyPlayer = (HockeyPlayer)selectedPlayer;
                lblPosition.Text = "Position: " + hockeyPlayer.Position.ToString();
            }
            else if (selectedPlayer.Sport == Sports.Soccer)
            {
                SoccerPlayer soccerPlayer = (SoccerPlayer)selectedPlayer;
                lblPosition.Text = "Position: " + soccerPlayer.Position.ToString();
            }
            lblFullName.Text   = selectedPlayer.FullName;
            lblAge.Text        = "Age: " + selectedPlayer.Age.ToString();
            lblSkillLevel.Text = "Skill Level: " + selectedPlayer.CurrentSkill.ToString() + "/" + selectedPlayer.PotentialSkill.ToString();

            lblYearlySalary.Text = "Yearly Salary: " + selectedPlayer.Contract.YearlySalary.ToString("C0");
            lblYearsLeft.Text    = "Years Left: " + selectedPlayer.Contract.Years.ToString();
            lblAgentPaid.Text    = "Agent Paid: " + selectedPlayer.Contract.AgentPaySchedule.ToString();
            lblAgentPercent.Text = "Agent Percentage: " + selectedPlayer.Contract.AgentPercentage.ToString() + "%";

            lblPopularity.Text      = "Popularity: " + selectedPlayer.PopularityString;
            lblGreed.Text           = "Greed: " + selectedPlayer.Greed.ToString();
            lblLifestyle.Text       = "Lifestyle: " + selectedPlayer.Lifestyle.ToString();
            lblLoyalty.Text         = "Loyalty: " + selectedPlayer.Loyalty.ToString();
            lblPlayForTitle.Text    = "Play for Title: " + selectedPlayer.PlayForTitleContender.ToString();
            lblTeamHappiness.Text   = "Team Happiness: " + selectedPlayer.TeamHappinessString;
            lblAgencyHappiness.Text = "Agency Happiness: " + selectedPlayer.AgencyHappinessString;
        }