Exemple #1
0
        private int PlayTennisMatch(Player p1, Player p2, Random rnd)
        {
            int          winningPlayer = 0;
            TennisPlayer t1            = (TennisPlayer)p1;
            TennisPlayer t2            = (TennisPlayer)p2;

            int t1SetsWon = 0;
            int t2SetsWon = 0;

            int totalSkill = t1.CurrentSkill + t2.CurrentSkill;

            while (t1SetsWon < 4 && t2SetsWon < 4)
            {
                int luckyNumber = rnd.Next(0, totalSkill);
                if (luckyNumber <= t1.CurrentSkill)
                {
                    t1SetsWon++;
                }
                else
                {
                    t2SetsWon++;
                }
            }
            if (t1SetsWon == 4)
            {
                winningPlayer = 1;
            }
            else if (t2SetsWon == 4)
            {
                winningPlayer = 2;
            }
            return(winningPlayer);
        }
Exemple #2
0
        public int CalculatePlayerTourPoints(TennisPlayer p, World world)
        {
            int tourPoints = 0;

            if (p.TourPointsList.Count > world.ATP.EventList.Count)
            {
                p.TourPointsList.RemoveAt(0);
            }

            foreach (int i in p.TourPointsList)
            {
                tourPoints += i;
            }

            return(tourPoints);
        }