Esempio n. 1
0
 private void InitializeMatchRating(SoccerPlayer p)
 {
     if (p.CurrentSkill >= 70)
     {
         p.MatchRating = Convert.ToDouble(rnd.Next(750, 900)) / 100;
     }
     else if (p.CurrentSkill >= 50)
     {
         p.MatchRating = Convert.ToDouble(rnd.Next(600, 750)) / 100;
     }
     else if (p.CurrentSkill >= 40)
     {
         p.MatchRating = Convert.ToDouble(rnd.Next(500, 650)) / 100;
     }
     else if (p.CurrentSkill >= 30)
     {
         p.MatchRating = Convert.ToDouble(rnd.Next(400, 550)) / 100;
     }
     else if (p.CurrentSkill >= 20)
     {
         p.MatchRating = Convert.ToDouble(rnd.Next(300, 450)) / 100;
     }
     else
     {
         p.MatchRating = Convert.ToDouble(rnd.Next(200, 350)) / 100;
     }
 }
Esempio n. 2
0
        private void UpdateMatchRating(SoccerPlayer p)
        {
            double change = Convert.ToDouble(rnd.Next(-50, 51)) / 1000;

            p.MatchRating *= (1 + change);
            if (p.MatchRating > 10)
            {
                p.MatchRating = 10.0;
            }
        }
Esempio n. 3
0
        private void CalculateKeeperOfTheYearScore(SoccerPlayer p)
        {
            double score = 0;

            score = (p.CurrentSkill * 2) + (p.Team.Wins * 7) + (p.Popularity) + (2 - (p.GAA * 100)) + (p.CleanSheets * 5) + (p.Saves) + p.SavePercentage;
            if (p.DepthChart != 1)
            {
                score = score / 2;
            }
            p.PlayerOfYearScore = score;
        }
Esempio n. 4
0
        private void DetermineShotsFaced(SoccerPlayer p)
        {
            if (p.DepthChart == 1)
            {
                p.GamesPlayed++;
                int shotsFaced = rnd.Next(2, 7);
                p.ShotsFaced += shotsFaced;

                DetermineSaves(p, shotsFaced);
            }
        }
 private void DisplaySoccerStats(SoccerPlayer player)
 {
     if (player.Position == Position.GK)
     {
         lblStats.Text = DisplayKeeperStats(player);
     }
     else
     {
         lblStats.Text = DisplayNonKeeperStats(player);
     }
 }
Esempio n. 6
0
 public void CreateDraftEntrants()
 {
     for (int i = 0; i < numberOfEntrants; i++)
     {
         SoccerPlayer b = new SoccerPlayer(rnd, league.IdCount, Sports.Soccer, rnd.Next(16, 22), DeterminePosition());
         b.PlayerType = PlayerType.DraftEntrant;
         b.League     = league;
         league.DraftEntrants.Add(b);
     }
     ModifyDraftClass(league.DraftEntrants);
     ModifyDraftClassPopularityAndPGP(league.DraftEntrants);
 }
Esempio n. 7
0
        private void CalculatePlayerOfTheYearScore(SoccerPlayer p)
        {
            int    goalModifier   = 4;
            int    assistModifier = 1;
            double score          = 0;

            if (p.Position == Position.F)
            {
                goalModifier = 7;
            }
            if (p.Position == Position.MID)
            {
                assistModifier = 5;
            }

            score = (p.CurrentSkill * 2) + (p.Team.Points * 2) + (p.Popularity * 2) + (p.MatchRating * 10) + (p.Goals * goalModifier) + (p.Assists * assistModifier);
            p.PlayerOfYearScore = score;
        }
Esempio n. 8
0
        private void DetermineSaves(SoccerPlayer p, int shotsFaced)
        {
            int gkSaveRoll   = 0;
            int goalsAllowed = 0;
            int diceRoll     = 0;

            if (p.CurrentSkill >= 65)
            {
                gkSaveRoll = 5;
            }
            else if (p.CurrentSkill >= 50)
            {
                gkSaveRoll = 6;
            }
            else if (p.CurrentSkill >= 35)
            {
                gkSaveRoll = 7;
            }
            else
            {
                gkSaveRoll = 8;
            }

            for (int i = 0; i < shotsFaced; i++)
            {
                diceRoll = DiceRoll();
                if (diceRoll <= gkSaveRoll)
                {
                    goalsAllowed++;
                }
            }
            if (goalsAllowed > 4)
            {
                goalsAllowed = 4;
            }
            p.GoalsAllowed += goalsAllowed;
            p.Saves        += shotsFaced - goalsAllowed;
            if (goalsAllowed == 0)
            {
                p.CleanSheets++;
            }
            CalculateGAA(p);
            CalculateSavePercentage(p);
        }
Esempio n. 9
0
        private void DetermineAssists(SoccerPlayer p)
        {
            bool assist   = false;
            int  diceRoll = DiceRoll();

            if (p.Position == Position.F || p.Position == Position.D)
            {
                if (p.DepthChart == 1 || p.DepthChart == 2)
                {
                    if (p.CurrentSkill >= 65)
                    {
                        if (diceRoll <= 4)
                        {
                            assist = true;
                        }
                    }
                    else if (p.CurrentSkill >= 45)
                    {
                        if (diceRoll <= 3)
                        {
                            assist = true;
                        }
                    }
                    else
                    {
                        if (diceRoll == 2)
                        {
                            assist = true;
                        }
                    }
                }
                else
                {
                    if (p.CurrentSkill >= 55)
                    {
                        if (diceRoll <= 3)
                        {
                            assist = true;
                        }
                    }
                    else
                    {
                        if (diceRoll == 2)
                        {
                            assist = true;
                        }
                    }
                }
            }
            else if (p.Position == Position.MID)
            {
                if (p.DepthChart == 1 || p.DepthChart == 2)
                {
                    if (p.CurrentSkill >= 65)
                    {
                        if (diceRoll <= 6)
                        {
                            assist = true;
                        }
                    }
                    else if (p.CurrentSkill >= 45)
                    {
                        if (diceRoll <= 4)
                        {
                            assist = true;
                        }
                    }
                    else
                    {
                        if (diceRoll <= 3)
                        {
                            assist = true;
                        }
                    }
                }
                else
                {
                    if (p.CurrentSkill >= 55)
                    {
                        if (diceRoll <= 3)
                        {
                            assist = true;
                        }
                    }
                    else
                    {
                        if (diceRoll == 2)
                        {
                            assist = true;
                        }
                    }
                }
            }
            if (assist)
            {
                p.Assists++;
            }
        }
Esempio n. 10
0
        private void DetermineGoals(SoccerPlayer p, int shotsTaken)
        {
            int goalsScored = 0;
            int diceRoll    = 0;

            for (int i = 0; i < shotsTaken; i++)
            {
                diceRoll = DiceRoll();
                if (p.Position == Position.F)
                {
                    if (p.CurrentSkill >= 65 && diceRoll <= 6)
                    {
                        goalsScored++;
                    }
                    else if (p.CurrentSkill >= 50 && diceRoll <= 5)
                    {
                        goalsScored++;
                    }
                    else if (p.CurrentSkill >= 35 && diceRoll <= 4)
                    {
                        goalsScored++;
                    }
                    else if (p.CurrentSkill < 35 && diceRoll <= 3)
                    {
                        goalsScored++;
                    }
                }
                else if (p.Position == Position.MID)
                {
                    if (p.CurrentSkill >= 65 && diceRoll <= 5)
                    {
                        goalsScored++;
                    }
                    else if (p.CurrentSkill >= 50 && diceRoll <= 4)
                    {
                        goalsScored++;
                    }
                    else if (p.CurrentSkill >= 35 && diceRoll <= 3)
                    {
                        goalsScored++;
                    }
                    else if (p.CurrentSkill < 35 && diceRoll <= 2)
                    {
                        goalsScored++;
                    }
                }
                else if (p.Position == Position.D)
                {
                    if (p.CurrentSkill >= 65 && diceRoll <= 4)
                    {
                        goalsScored++;
                    }
                    else if (p.CurrentSkill >= 50 && diceRoll <= 3)
                    {
                        goalsScored++;
                    }
                    else if (p.CurrentSkill < 50 && diceRoll == 2)
                    {
                        goalsScored++;
                    }
                }
            }
            p.Goals += goalsScored;
        }
Esempio n. 11
0
        private void DetermineShotsTaken(SoccerPlayer p)
        {
            int shotsTaken = 0;
            int diceRoll   = DiceRoll();
            int diceRoll2  = DiceRoll();

            if (p.Position == Position.F)
            {
                if (p.DepthChart == 1 || p.DepthChart == 2)
                {
                    if (p.CurrentSkill >= 65)
                    {
                        if (diceRoll <= 3)
                        {
                            shotsTaken = 3;
                        }
                        else if (diceRoll == 12)
                        {
                            shotsTaken = 1;
                        }
                        else
                        {
                            shotsTaken = 2;
                        }
                    }
                    else if (p.CurrentSkill >= 45)
                    {
                        if (diceRoll <= 3)
                        {
                            shotsTaken = 2;
                        }
                        else if (diceRoll == 12)
                        {
                            shotsTaken = 0;
                        }
                        else
                        {
                            shotsTaken = 1;
                        }
                    }
                    else
                    {
                        if (diceRoll == 2)
                        {
                            shotsTaken = 2;
                        }
                        if (diceRoll >= 11)
                        {
                            shotsTaken = 0;
                        }
                        else
                        {
                            shotsTaken = 1;
                        }
                    }
                }
                else
                {
                    if (p.CurrentSkill >= 55)
                    {
                        if (diceRoll <= 3)
                        {
                            shotsTaken = 2;
                        }
                        else if (diceRoll >= 10)
                        {
                            shotsTaken = 0;
                        }
                        else
                        {
                            shotsTaken = 1;
                        }
                    }
                    else
                    {
                        if (diceRoll <= 4)
                        {
                            shotsTaken = 1;
                        }
                        else
                        {
                            shotsTaken = 0;
                        }
                    }
                }
            }
            else if (p.Position == Position.MID)
            {
                if (p.DepthChart == 1 || p.DepthChart == 2)
                {
                    if (p.CurrentSkill >= 65)
                    {
                        if (diceRoll <= 3)
                        {
                            shotsTaken = 2;
                        }
                        else if (diceRoll >= 11)
                        {
                            shotsTaken = 0;
                        }
                        else
                        {
                            shotsTaken = 1;
                        }
                    }
                    else if (p.CurrentSkill >= 45)
                    {
                        if (diceRoll == 2)
                        {
                            shotsTaken = 2;
                        }
                        else if (diceRoll == 7)
                        {
                            shotsTaken = 0;
                        }
                        else
                        {
                            shotsTaken = 1;
                        }
                    }
                    else
                    {
                        if (diceRoll == 2)
                        {
                            shotsTaken = 2;
                        }
                        if (diceRoll >= 8)
                        {
                            shotsTaken = 0;
                        }
                        else
                        {
                            shotsTaken = 1;
                        }
                    }
                }
                else
                {
                    if (p.CurrentSkill >= 55)
                    {
                        if (diceRoll == 2)
                        {
                            shotsTaken = 2;
                        }
                        else if (diceRoll >= 6)
                        {
                            shotsTaken = 0;
                        }
                        else
                        {
                            shotsTaken = 1;
                        }
                    }
                    else
                    {
                        if (diceRoll <= 3)
                        {
                            shotsTaken = 1;
                        }
                        else
                        {
                            shotsTaken = 0;
                        }
                    }
                }
            }
            else if (p.Position == Position.D)
            {
                if (p.DepthChart == 1 || p.DepthChart == 2)
                {
                    if (p.CurrentSkill >= 60)
                    {
                        if (diceRoll <= 3)
                        {
                            shotsTaken = 1;
                        }
                        else
                        {
                            shotsTaken = 0;
                        }
                    }
                    else
                    {
                        if (diceRoll == 2)
                        {
                            shotsTaken = 1;
                        }
                        else
                        {
                            shotsTaken = 0;
                        }
                    }
                }
                else
                {
                    diceRoll2 = DiceRoll();
                    if (diceRoll <= 3 && diceRoll2 <= 3)
                    {
                        shotsTaken = 1;
                    }
                    else
                    {
                        shotsTaken = 0;
                    }
                }
            }
            DetermineGoals(p, shotsTaken);
        }
Esempio n. 12
0
 private void CalculateSavePercentage(SoccerPlayer p)
 {
     p.SavePercentage = Convert.ToDouble(p.Saves) / Convert.ToDouble(p.ShotsFaced);
 }
Esempio n. 13
0
 private void CalculateGAA(SoccerPlayer p)
 {
     p.GAA = Convert.ToDouble(p.GoalsAllowed) / Convert.ToDouble(p.GamesPlayed);
 }
Esempio n. 14
0
        private string DisplayNonKeeperStats(SoccerPlayer player)
        {
            string stats = "GOALS: " + player.Goals + Environment.NewLine + "ASSISTS: " + player.Assists + Environment.NewLine + "Rating: " + player.MatchRating.ToString("#.00");

            return(stats);
        }
Esempio n. 15
0
        private string DisplayKeeperStats(SoccerPlayer player)
        {
            string results = "SAVES: " + player.Saves + Environment.NewLine + "SAVE%: " + player.SavePercentage.ToString("P2") + Environment.NewLine + "GA: " + player.GoalsAllowed + Environment.NewLine + "GAA: " + player.GAA.ToString("0.##") + Environment.NewLine + "Clean Sheets: " + player.CleanSheets;

            return(results);
        }
Esempio n. 16
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;
        }