예제 #1
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;
        }
예제 #2
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;
        }
예제 #3
0
 public void DisplayHockeyStats(HockeyPlayer player)
 {
     if (player.Position == Position.G)
     {
         mainForm.lblScoutedStats.Text = DisplayGoalieStats(player);
     }
     else
     {
         mainForm.lblScoutedStats.Text = DisplaySkaterStats(player);
     }
 }
예제 #4
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;
     }
 }
예제 #5
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;
     }
 }
예제 #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 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();
        }
예제 #11
0
        public string DisplaySkaterStats(HockeyPlayer player)
        {
            string results = "GOALS: " + player.Goals + Environment.NewLine + "ASSISTS: " + player.Assists + Environment.NewLine + "POINTS: " + player.Points;

            return(results);
        }
예제 #12
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);
        }
예제 #13
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;
        }
예제 #14
0
 private void CalculatePoints(HockeyPlayer p)
 {
     p.Points = p.Goals + p.Assists;
 }
예제 #15
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++;
                }
            }
        }
        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;
        }