private void InitializeAverage(BaseballPlayer p)
 {
     if (p.CurrentSkill >= 70)
     {
         p.Average = Convert.ToDouble(rnd.Next(325, 376)) / 1000;
     }
     else if (p.CurrentSkill >= 50)
     {
         p.Average = Convert.ToDouble(rnd.Next(290, 325)) / 1000;
     }
     else if (p.CurrentSkill >= 40)
     {
         p.Average = Convert.ToDouble(rnd.Next(265, 290)) / 1000;
     }
     else if (p.CurrentSkill >= 30)
     {
         p.Average = Convert.ToDouble(rnd.Next(240, 265)) / 1000;
     }
     else if (p.CurrentSkill >= 20)
     {
         p.Average = Convert.ToDouble(rnd.Next(195, 240)) / 1000;
     }
     else
     {
         p.Average = Convert.ToDouble(rnd.Next(180, 195)) / 1000;
     }
 }
        private void DetermineSaves(BaseballPlayer p)
        {
            int chances = 0;

            if (p.Team.TitleConteder > 70)
            {
                chances = 5;
            }
            else if (p.Team.TitleConteder > 60)
            {
                chances = 4;
            }
            else if (p.Team.TitleConteder > 50)
            {
                chances = 3;
            }
            else
            {
                chances = 2;
            }

            for (int i = 0; i < chances; i++)
            {
                int numberOnDice = DiceRoll();
                if (numberOnDice > 7)
                {
                    p.Saves++;
                }
            }
        }
 private void InitializeERA(BaseballPlayer p)
 {
     if (p.CurrentSkill >= 70)
     {
         p.ERA = Convert.ToDouble(rnd.Next(100, 275)) / 100;
     }
     else if (p.CurrentSkill >= 50)
     {
         p.ERA = Convert.ToDouble(rnd.Next(275, 350)) / 100;
     }
     else if (p.CurrentSkill >= 40)
     {
         p.ERA = Convert.ToDouble(rnd.Next(325, 400)) / 100;
     }
     else if (p.CurrentSkill >= 30)
     {
         p.ERA = Convert.ToDouble(rnd.Next(375, 450)) / 100;
     }
     else if (p.CurrentSkill >= 20)
     {
         p.ERA = Convert.ToDouble(rnd.Next(450, 700)) / 100;
     }
     else
     {
         p.ERA = Convert.ToDouble(rnd.Next(550, 800)) / 100;
     }
 }
Beispiel #4
0
 public void DisplayBaseballStats(BaseballPlayer player)
 {
     if (player.Position == Position.SP || player.Position == Position.RP)
     {
         mainForm.lblScoutedStats.Text = DisplayPitchingStats(player);
     }
     else
     {
         mainForm.lblScoutedStats.Text = DisplayHittingStats(player);
     }
 }
Beispiel #5
0
 public void CreateDraftEntrants()
 {
     for (int i = 0; i < numberOfEntrants; i++)
     {
         BaseballPlayer b = new BaseballPlayer(rnd, league.IdCount, Sports.Baseball, rnd.Next(18, 22), DeterminePosition());
         b.PlayerType = PlayerType.DraftEntrant;
         b.League     = league;
         league.DraftEntrants.Add(b);
     }
     ModifyDraftClass(league.DraftEntrants);
     ModifyDraftClassPopularityAndPGP(league.DraftEntrants);
 }
        private void DetermineHomeRuns(BaseballPlayer p, int RBI)
        {
            int hrRolls = 0;

            if (RBI == 1)
            {
                hrRolls = 1;
            }
            else if (RBI <= 3)
            {
                hrRolls = 2;
            }
            else if (RBI <= 4)
            {
                hrRolls = 3;
            }
            else
            {
                hrRolls = 4;
            }
            for (int i = 0; i < hrRolls; i++)
            {
                int numberOnDice = DiceRoll();
                int playerNumber = 0;

                if (p.CurrentSkill >= 70)
                {
                    playerNumber = 7;
                }
                else if (p.CurrentSkill >= 50)
                {
                    playerNumber = 8;
                }
                else if (p.CurrentSkill >= 40)
                {
                    playerNumber = 10;
                }
                else if (p.CurrentSkill >= 30)
                {
                    playerNumber = 11;
                }
                else if (p.CurrentSkill >= 20)
                {
                    playerNumber = 12;
                }

                if (numberOnDice >= playerNumber)
                {
                    p.HomeRuns++;
                }
            }
        }
        private void CalculateCyYoungScore(BaseballPlayer p)
        {
            int winMultiplier = 1;

            if (p.Position == Position.SP)
            {
                winMultiplier = 10;
            }
            else
            {
                winMultiplier = 3;
            }
            p.CyYoungScore = ((5.00 - p.ERA) * 100) + (p.Wins * winMultiplier) + (p.Saves * 3) + p.Team.Wins + p.Popularity;
        }
        private void DetermineStarterWinsAndLosses(BaseballPlayer p)
        {
            int  rolls         = 0;
            bool didPitcherWin = false;

            if (p.CurrentSkill >= 70)
            {
                rolls = 5;
            }
            else if (p.CurrentSkill >= 50)
            {
                rolls = 4;
            }
            else if (p.CurrentSkill >= 40)
            {
                rolls = 3;
            }
            else if (p.CurrentSkill >= 30)
            {
                rolls = 2;
            }
            else if (p.CurrentSkill >= 20)
            {
                rolls = 1;
            }

            for (int i = 0; i < rolls; i++)
            {
                int numberOnDice = DiceRoll();
                if (numberOnDice > 8)
                {
                    didPitcherWin = true;
                }
                if (didPitcherWin)
                {
                    break;
                }
            }

            if (didPitcherWin)
            {
                p.Wins++;
            }
            else
            {
                p.Losses++;
            }
        }
        private void DetermineRBIs(BaseballPlayer p)
        {
            int RBI   = 0;
            int rolls = 0;

            if (p.CurrentSkill >= 70)
            {
                rolls = 5;
            }
            else if (p.CurrentSkill >= 50)
            {
                rolls = 4;
            }
            else if (p.CurrentSkill >= 40)
            {
                rolls = 3;
            }
            else if (p.CurrentSkill >= 30)
            {
                rolls = 2;
            }
            else if (p.CurrentSkill >= 20)
            {
                rolls = 1;
            }

            for (int i = 0; i < rolls; i++)
            {
                int numberOnDice = DiceRoll();
                if (numberOnDice >= 5)
                {
                    RBI++;
                }
            }

            p.RBI += RBI;
            if (RBI > 0)
            {
                DetermineHomeRuns(p, RBI);
            }
        }
        private void DetermineReliefWinsAndLosses(BaseballPlayer p)
        {
            bool decisionThisWeek = false;
            int  diceRoll         = DiceRoll();

            if (diceRoll % 2 == 0)
            {
                decisionThisWeek = true;
            }
            if (decisionThisWeek)
            {
                int random = rnd.Next(1, 101);
                if (random <= (p.CurrentSkill + p.Team.TitleConteder) / 2)
                {
                    p.Wins++;
                }
                else
                {
                    p.Losses++;
                }
            }
        }
        public void DisplaySelectedPlayerInfo(Player player)
        {
            League selectedLeague = world.Leagues[mainForm.cbLeagueList.SelectedIndex];
            Team   selectedTeam   = selectedLeague.TeamList[mainForm.cbTeamList.SelectedIndex];
            Player selectedPlayer = player;

            mainForm.lblDepthChart.Text = "Spot on Depth Chart: " + selectedPlayer.DepthChart.ToString();
            if (selectedPlayer.IsStarter)
            {
                mainForm.lblStarter.Text = "Starter: yes";
            }
            else
            {
                mainForm.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[mainForm.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[mainForm.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[mainForm.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[mainForm.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[mainForm.cbTeamRoster.SelectedIndex]);
            }

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

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

            mainForm.lblPopularity.Text      = "Popularity: " + selectedPlayer.PopularityString;
            mainForm.lblGreed.Text           = "Greed: " + selectedPlayer.Greed.ToString();
            mainForm.lblLifestyle.Text       = "Lifestyle: " + selectedPlayer.Lifestyle.ToString();
            mainForm.lblLoyalty.Text         = "Loyalty: " + selectedPlayer.Loyalty.ToString();
            mainForm.lblPlayForTitle.Text    = "Play for Title: " + selectedPlayer.PlayForTitleContender.ToString();
            mainForm.lblTeamHappiness.Text   = "Team Happiness: " + selectedPlayer.TeamHappinessString;
            mainForm.lblAgencyHappiness.Text = "Agency Happiness: " + selectedPlayer.AgencyHappinessString;
        }
 private void CalculateMVPScore(BaseballPlayer p)
 {
     p.MVPScore = (p.Average * 100) + p.HomeRuns + p.RBI + p.Team.Wins + p.Popularity;
 }
Beispiel #13
0
        public string DisplayHittingStats(BaseballPlayer player)
        {
            string stats = "AVG: " + player.Average.ToString(".###") + Environment.NewLine + "HRS: " + player.HomeRuns + Environment.NewLine + "RBI: " + player.RBI;

            return(stats);
        }
Beispiel #14
0
        public string DisplayPitchingStats(BaseballPlayer player)
        {
            string stats = "ERA: " + player.ERA.ToString("0.##") + Environment.NewLine + "WINS: " + player.Wins + Environment.NewLine + "LOSSES: " + player.Losses + Environment.NewLine + "SAVES: " + player.Saves;

            return(stats);
        }
        private void UpdateERA(BaseballPlayer p)
        {
            double change = Convert.ToDouble(rnd.Next(-50, 51)) / 1000;

            p.ERA *= (1 + change);
        }
Beispiel #16
0
        public void DisplayScoutedPlayerInfo(Player player)
        {
            Player selectedPlayer = player;

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

            if (selectedPlayer.Sport == Sports.Basketball)
            {
                DisplayBasketballStats((BasketballPlayer)selectedPlayer);
            }
            else if (selectedPlayer.Sport == Sports.Football)
            {
                DisplayFootballStats((FootballPlayer)selectedPlayer);
            }
            else if (selectedPlayer.Sport == Sports.Baseball)
            {
                DisplayBaseballStats((BaseballPlayer)selectedPlayer);
            }
            else if (selectedPlayer.Sport == Sports.Hockey)
            {
                DisplayHockeyStats((HockeyPlayer)selectedPlayer);
            }
            else if (selectedPlayer.Sport == Sports.Soccer)
            {
                DisplaySoccerStats((SoccerPlayer)selectedPlayer);
            }

            if (selectedPlayer.Sport == Sports.Baseball)
            {
                BaseballPlayer baseballPlayer = (BaseballPlayer)selectedPlayer;
                mainForm.lblScoutedPosition.Text = "Position: " + baseballPlayer.Position.ToString();
            }
            else if (selectedPlayer.Sport == Sports.Basketball)
            {
                BasketballPlayer basketballPlayer = (BasketballPlayer)selectedPlayer;
                mainForm.lblScoutedPosition.Text = "Position: " + basketballPlayer.Position.ToString();
            }
            else if (selectedPlayer.Sport == Sports.Football)
            {
                FootballPlayer footballPlayer = (FootballPlayer)selectedPlayer;
                mainForm.lblScoutedPosition.Text = "Position: " + footballPlayer.Position.ToString();
            }
            else if (selectedPlayer.Sport == Sports.Hockey)
            {
                HockeyPlayer hockeyPlayer = (HockeyPlayer)selectedPlayer;
                mainForm.lblScoutedPosition.Text = "Position: " + hockeyPlayer.Position.ToString();
            }
            else if (selectedPlayer.Sport == Sports.Soccer)
            {
                SoccerPlayer soccerPlayer = (SoccerPlayer)selectedPlayer;
                mainForm.lblScoutedPosition.Text = "Position: " + soccerPlayer.Position.ToString();
            }
            mainForm.lblScoutedAge.Text = "Age: " + selectedPlayer.Age.ToString();

            if (selectedPlayer.Contract != null)
            {
                mainForm.lblScoutedYearlySalary.Text = "Yearly Salary: " + selectedPlayer.Contract.YearlySalary.ToString("C0");
                mainForm.lblScoutedYearsLeft.Text    = "Years Left: " + selectedPlayer.Contract.Years.ToString();
                mainForm.lblScoutedAgentPaid.Text    = "Agent Paid: " + selectedPlayer.Contract.AgentPaySchedule.ToString();
                mainForm.lblScoutedAgentPercent.Text = "Agent Percentage: " + selectedPlayer.Contract.AgentPercentage.ToString() + "%";
            }
            else
            {
                mainForm.lblScoutedYearlySalary.Text = "Yearly Salary: n/a";
                mainForm.lblScoutedYearsLeft.Text    = "Years Left: n/a";
                mainForm.lblScoutedAgentPaid.Text    = "Agent Paid: n/a";
                mainForm.lblScoutedAgentPercent.Text = "Agent Percentage: n/a";
            }

            mainForm.lblScoutedPopularity.Text      = "Popularity: " + selectedPlayer.PopularityString;
            mainForm.lblScoutedTeamHappiness.Text   = "Team Happiness: " + selectedPlayer.TeamHappinessString;
            mainForm.lblScoutedAgencyHappiness.Text = "Agency Happiness: " + selectedPlayer.AgencyHappinessString;
        }
        private void ScoreJob(FreelanceJob job)
        {
            double baselineScore = job.BaselineJobScore;
            double jobScore      = 10;
            bool   jobDoneInTime;
            string results;
            double penaltyPercentage = 0;

            BasketballPlayer basketballPlayer = null;
            BaseballPlayer   baseballPlayer   = null;
            HockeyPlayer     hockeyPlayer     = null;
            FootballPlayer   footballPlayer   = null;
            SoccerPlayer     soccerPlayer     = null;

            Console.WriteLine("Agency Days To Complete Job: " + world.MyAgency.DaysAttemptingJob.ToString());

            if (world.MyAgency.DaysAttemptingJob <= job.DaysToComplete)
            {
                jobDoneInTime = true;
            }
            else
            {
                jobDoneInTime = false;
            }

            if (!jobDoneInTime)
            {
                penaltyPercentage = (Convert.ToDouble(world.MyAgency.DaysAttemptingJob) - Convert.ToDouble(job.DaysToComplete)) / Convert.ToDouble(job.DaysToComplete);
                Console.WriteLine("Original Job Score: " + jobScore.ToString());
            }

            if (job.JobType == JobType.education)
            {
                jobScore = 10;
            }
            else if (job.JobType == JobType.negotiating)
            {
                GetClientSignedFunctions getClientSignedFunctions = new GetClientSignedFunctions(world.mainForm, world);
                League        league;
                List <Agency> agencyList = new List <Agency>();
                Sports        sport      = world.MyAgency.Licenses[world.rnd.Next(0, world.MyAgency.Licenses.Count)];
                job.Sport = sport;
                foreach (Agency a in world.Agencies)
                {
                    if (a != world.MyAgency)
                    {
                        agencyList.Add(a);
                    }
                }

                if (job.Sport == Sports.Soccer)
                {
                    agencyList          = agencyList.OrderByDescending(o => o.SoccerControl).ToList();
                    league              = world.MLS;
                    soccerPlayer        = new SoccerPlayer(world.rnd, league.IdCount, job.Sport, world.rnd.Next(21, 26), AssignRandomPosition(job.Sport));
                    soccerPlayer.League = league;
                    getClientSignedFunctions.AttemptToGetPlayerSigned(soccerPlayer, league, agencyList[0]);
                    getClientSignedFunctions.BeginNegotiations("money");
                    jobScore = soccerPlayer.TeamHappiness;
                }
                else if (job.Sport == Sports.Hockey)
                {
                    agencyList          = agencyList.OrderByDescending(o => o.HockeyControl).ToList();
                    league              = world.NHL;
                    hockeyPlayer        = new HockeyPlayer(world.rnd, league.IdCount, job.Sport, world.rnd.Next(21, 26), AssignRandomPosition(job.Sport));
                    hockeyPlayer.League = league;
                    getClientSignedFunctions.AttemptToGetPlayerSigned(hockeyPlayer, league, agencyList[0]);
                    getClientSignedFunctions.BeginNegotiations("money");
                    jobScore = hockeyPlayer.TeamHappiness;
                }
                else if (job.Sport == Sports.Baseball)
                {
                    agencyList            = agencyList.OrderByDescending(o => o.BaseballControl).ToList();
                    league                = world.MLB;
                    baseballPlayer        = new BaseballPlayer(world.rnd, league.IdCount, job.Sport, world.rnd.Next(21, 26), AssignRandomPosition(job.Sport));
                    baseballPlayer.League = league;
                    getClientSignedFunctions.AttemptToGetPlayerSigned(baseballPlayer, league, agencyList[0]);
                    getClientSignedFunctions.BeginNegotiations("money");
                    jobScore = baseballPlayer.TeamHappiness;
                }
                else if (job.Sport == Sports.Basketball)
                {
                    agencyList              = agencyList.OrderByDescending(o => o.BasketballControl).ToList();
                    league                  = world.NBA;
                    basketballPlayer        = new BasketballPlayer(world.rnd, league.IdCount, job.Sport, world.rnd.Next(21, 26), AssignRandomPosition(job.Sport));
                    basketballPlayer.League = league;
                    getClientSignedFunctions.AttemptToGetPlayerSigned(basketballPlayer, league, agencyList[0]);
                    getClientSignedFunctions.BeginNegotiations("money");
                    jobScore = basketballPlayer.TeamHappiness;
                }
                else //if (job.Sport == Sports.Football)
                {
                    agencyList            = agencyList.OrderByDescending(o => o.FootballControl).ToList();
                    league                = world.NFL;
                    footballPlayer        = new FootballPlayer(world.rnd, league.IdCount, job.Sport, world.rnd.Next(21, 26), AssignRandomPosition(job.Sport));
                    footballPlayer.League = league;
                    getClientSignedFunctions.AttemptToGetPlayerSigned(footballPlayer, league, agencyList[0]);
                    getClientSignedFunctions.BeginNegotiations("money");
                    jobScore = footballPlayer.TeamHappiness;
                }

                jobScore = jobScore / 10;

                /*Player createdPlayer = new Player(world.rnd, league.IdCount, job.Sport, world.rnd.Next(21, 26));
                 * createdPlayer.Position = AssignRandomPosition(job.Sport);
                 * createdPlayer.League = league;
                 * getClientSignedFunctions.AttemptToGetPlayerSigned(createdPlayer, league, agencyList[0]);
                 * getClientSignedFunctions.BeginNegotiations("money");
                 * jobScore = createdPlayer.TeamHappiness;*/


                //if (jobDoneInTime) jobScore = rnd.Next(6, 11);
                //else jobScore = rnd.Next(1, 6);
            }
            else if (job.JobType == JobType.scouting)
            {
            }



            jobScore = jobScore * (1 - penaltyPercentage);

            Console.WriteLine("penaltyPercentage = " + penaltyPercentage);

            results = "Baseline Score Needed: " + baselineScore.ToString() + Environment.NewLine
                      + "Agency's Job Score: " + jobScore.ToString() + Environment.NewLine;

            if (jobScore >= baselineScore)
            {
                results = results + "SUCCESS!";
                AwardCompanyPayouts(job);
            }
            else
            {
                results = results + "JOB FAILED!";
                // knock agency reputation?
                world.MyAgency.Manager.AddPower(-1);
                world.MyAgency.Manager.UpdateManagerUI(world.mainForm);
            }
            MessageBox.Show(results);
            world.MyAgency.FreelanceJobsAvailable.Remove(job);
            AllEmployeesNotWorking();
            DisplayAvailableJobs();
        }